use of com.google.cloud.secretmanager.v1.ProjectName in project java-webrisk by googleapis.
the class WebRiskServiceClientTest method createSubmissionTest.
@Test
public void createSubmissionTest() throws Exception {
Submission expectedResponse = Submission.newBuilder().setUri("uri116076").build();
mockWebRiskService.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
Submission submission = Submission.newBuilder().build();
Submission actualResponse = client.createSubmission(parent, submission);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockWebRiskService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateSubmissionRequest actualRequest = ((CreateSubmissionRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(submission, actualRequest.getSubmission());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.secretmanager.v1.ProjectName in project java-containeranalysis by googleapis.
the class ContainerAnalysisV1Beta1ClientTest method listScanConfigsExceptionTest.
@Test
@SuppressWarnings("all")
public void listScanConfigsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockContainerAnalysisV1Beta1.addException(exception);
try {
ProjectName parent = ProjectName.of("[PROJECT]");
String filter = "filter-1274492040";
client.listScanConfigs(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 createOccurrenceExceptionTest.
@Test
@SuppressWarnings("all")
public void createOccurrenceExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockGrafeasV1Beta1.addException(exception);
try {
ProjectName parent = ProjectName.of("[PROJECT]");
Occurrence occurrence = Occurrence.newBuilder().build();
client.createOccurrence(parent, occurrence);
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 batchCreateOccurrencesExceptionTest.
@Test
@SuppressWarnings("all")
public void batchCreateOccurrencesExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockGrafeasV1Beta1.addException(exception);
try {
ProjectName parent = ProjectName.of("[PROJECT]");
List<Occurrence> occurrences = new ArrayList<>();
client.batchCreateOccurrences(parent, occurrences);
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 listOccurrencesTest.
@Test
@SuppressWarnings("all")
public void listOccurrencesTest() {
String nextPageToken = "";
Occurrence occurrencesElement = Occurrence.newBuilder().build();
List<Occurrence> occurrences = Arrays.asList(occurrencesElement);
ListOccurrencesResponse expectedResponse = ListOccurrencesResponse.newBuilder().setNextPageToken(nextPageToken).addAllOccurrences(occurrences).build();
mockGrafeasV1Beta1.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
String filter = "filter-1274492040";
ListOccurrencesPagedResponse pagedListResponse = client.listOccurrences(parent, filter);
List<Occurrence> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getOccurrencesList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockGrafeasV1Beta1.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListOccurrencesRequest actualRequest = (ListOccurrencesRequest) actualRequests.get(0);
Assert.assertEquals(parent, ProjectName.parse(actualRequest.getParent()));
Assert.assertEquals(filter, actualRequest.getFilter());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations