use of com.google.cloud.secretmanager.v1.ProjectName in project java-containeranalysis by googleapis.
the class GrafeasV1Beta1ClientTest method createNoteTest.
@Test
@SuppressWarnings("all")
public void createNoteTest() {
String name = "name3373707";
String shortDescription = "shortDescription-235369287";
String longDescription = "longDescription-1747792199";
Note expectedResponse = Note.newBuilder().setName(name).setShortDescription(shortDescription).setLongDescription(longDescription).build();
mockGrafeasV1Beta1.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
String noteId = "noteId2129224840";
Note note = Note.newBuilder().build();
Note actualResponse = client.createNote(parent, noteId, note);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockGrafeasV1Beta1.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateNoteRequest actualRequest = (CreateNoteRequest) actualRequests.get(0);
Assert.assertEquals(parent, ProjectName.parse(actualRequest.getParent()));
Assert.assertEquals(noteId, actualRequest.getNoteId());
Assert.assertEquals(note, actualRequest.getNote());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.secretmanager.v1.ProjectName in project java-containeranalysis by googleapis.
the class GrafeasV1Beta1ClientTest method createOccurrenceTest.
@Test
@SuppressWarnings("all")
public void createOccurrenceTest() {
String name = "name3373707";
String noteName = "noteName1780787896";
String remediation = "remediation779381797";
Occurrence expectedResponse = Occurrence.newBuilder().setName(name).setNoteName(noteName).setRemediation(remediation).build();
mockGrafeasV1Beta1.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
Occurrence occurrence = Occurrence.newBuilder().build();
Occurrence actualResponse = client.createOccurrence(parent, occurrence);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockGrafeasV1Beta1.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateOccurrenceRequest actualRequest = (CreateOccurrenceRequest) actualRequests.get(0);
Assert.assertEquals(parent, ProjectName.parse(actualRequest.getParent()));
Assert.assertEquals(occurrence, actualRequest.getOccurrence());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.secretmanager.v1.ProjectName in project java-containeranalysis by googleapis.
the class GrafeasV1Beta1ClientTest method batchCreateNotesTest.
@Test
@SuppressWarnings("all")
public void batchCreateNotesTest() {
BatchCreateNotesResponse expectedResponse = BatchCreateNotesResponse.newBuilder().build();
mockGrafeasV1Beta1.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
Map<String, Note> notes = new HashMap<>();
BatchCreateNotesResponse actualResponse = client.batchCreateNotes(parent, notes);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockGrafeasV1Beta1.getRequests();
Assert.assertEquals(1, actualRequests.size());
BatchCreateNotesRequest actualRequest = (BatchCreateNotesRequest) actualRequests.get(0);
Assert.assertEquals(parent, ProjectName.parse(actualRequest.getParent()));
Assert.assertEquals(notes, actualRequest.getNotesMap());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.secretmanager.v1.ProjectName in project java-containeranalysis by googleapis.
the class GrafeasV1Beta1ClientTest method listOccurrencesExceptionTest.
@Test
@SuppressWarnings("all")
public void listOccurrencesExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockGrafeasV1Beta1.addException(exception);
try {
ProjectName parent = ProjectName.of("[PROJECT]");
String filter = "filter-1274492040";
client.listOccurrences(parent, filter);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
}
}
use of com.google.cloud.secretmanager.v1.ProjectName in project java-containeranalysis by googleapis.
the class GrafeasV1Beta1ClientTest method createNoteExceptionTest.
@Test
@SuppressWarnings("all")
public void createNoteExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockGrafeasV1Beta1.addException(exception);
try {
ProjectName parent = ProjectName.of("[PROJECT]");
String noteId = "noteId2129224840";
Note note = Note.newBuilder().build();
client.createNote(parent, noteId, note);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception
}
}
Aggregations