Skip to content

Commit 9690fb7

Browse files
committed
addressed PR comments
1 parent ab81bcd commit 9690fb7

File tree

3 files changed

+15
-17
lines changed

3 files changed

+15
-17
lines changed

container-registry/container-analysis/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<parent>
1818
<groupId>com.google.cloud.samples</groupId>
1919
<artifactId>shared-configuration</artifactId>
20-
<version>1.0.9</version>
20+
<version>1.0.10</version>
2121
</parent>
2222

2323
<properties>

container-registry/container-analysis/src/main/java/com/example/containeranalysis/Samples.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018 Google Inc.
2+
* Copyright 2018 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

container-registry/container-analysis/src/test/java/com/example/containeranalysis/SamplesTest.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2018 Google Inc.
2+
* Copyright 2018 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
2020
import static junit.framework.Assert.fail;
2121
import static junit.framework.TestCase.assertEquals;
2222

23+
import com.google.api.gax.rpc.NotFoundException;
2324
import com.google.cloud.devtools.containeranalysis.v1beta1.GrafeasV1Beta1Client;
2425
import com.google.cloud.pubsub.v1.Subscriber;
2526
import com.google.cloud.pubsub.v1.SubscriptionAdminClient;
@@ -74,6 +75,7 @@ public static void tearDownClass() {
7475
subscriptionAdminClient.shutdownNow();
7576
} catch (Exception e) {
7677
// these exceptions aren't relevant to the tests
78+
System.out.println("TearDownClass Error: " + e.toString());
7779
}
7880
}
7981

@@ -92,30 +94,28 @@ public void tearDown() {
9294
Samples.deleteNote(client, noteId, PROJECT_ID);
9395
} catch (Exception e) {
9496
// these exceptions aren't relevant to the tests
97+
System.out.println("TearDown Error: " + e.toString());
9598
}
9699
}
97100

98101
@Test
99102
public void testCreateNote() throws Exception {
100-
101103
// note should have been created as part of set up. verify that it succeeded
102104
Note n = Samples.getNote(client, noteId, PROJECT_ID);
103105

104106
assertEquals(n.getName(), noteObj.getName());
105-
106107
}
107108

108109
@Test
109110
public void testDeleteNote() throws Exception {
110111
Samples.deleteNote(client, noteId, PROJECT_ID);
111112
try {
112113
Samples.getNote(client, noteId, PROJECT_ID);
113-
//above should throw, because note was deleted
114+
// above should throw, because note was deleted
114115
fail("note not deleted");
115-
} catch (Exception e) {
116+
} catch (NotFoundException e) {
116117
// test passes
117118
}
118-
119119
}
120120

121121
@Test
@@ -133,29 +133,27 @@ public void testUpdateNote() throws Exception {
133133

134134
@Test
135135
public void testCreateOccurrence() throws Exception {
136-
137136
Occurrence o = Samples.createOccurrence(client, imageUrl, noteId, PROJECT_ID, PROJECT_ID);
138137
Occurrence retrieved = Samples.getOccurrence(client, o.getName());
139138
assertEquals(o.getName(), retrieved.getName());
140139

141-
//clean up
140+
// clean up
142141
Samples.deleteOccurrence(client, o.getName());
143142
}
144143

145144
@Test
146145
public void testDeleteOccurrence() throws Exception {
147-
148146
Occurrence o = Samples.createOccurrence(client, imageUrl, noteId, PROJECT_ID, PROJECT_ID);
149147
String occName = o.getName();
150148

151149
Samples.deleteOccurrence(client, occName);
152150

153151
try {
154152
Samples.getOccurrence(client, occName);
155-
//getOccurrence should fail, because occurrence was deleted
153+
// getOccurrence should fail, because occurrence was deleted
156154
fail("failed to delete occurrence");
157-
} catch (Exception e) {
158-
//test passes
155+
} catch (NotFoundException e) {
156+
// test passes
159157
}
160158
}
161159

@@ -175,7 +173,7 @@ public void testUpdateOccurrence() throws Exception {
175173
Occurrence got = Samples.getOccurrence(client, o.getName());
176174
assertEquals(typeId, got.getVulnerability().getType());
177175

178-
//clean up
176+
// clean up
179177
Samples.deleteOccurrence(client, o.getName());
180178
}
181179

@@ -193,7 +191,7 @@ public void testOccurrencesForImage() throws Exception {
193191
assertEquals(1, newCount);
194192
assertEquals(0, origCount);
195193

196-
//clean up
194+
// clean up
197195
Samples.deleteOccurrence(client, o.getName());
198196
}
199197

@@ -211,7 +209,7 @@ public void testOccurrencesForNote() throws Exception {
211209
assertEquals(0, origCount);
212210
assertEquals(1, newCount);
213211

214-
//clean up
212+
// clean up
215213
Samples.deleteOccurrence(client, o.getName());
216214
}
217215

0 commit comments

Comments
 (0)