use of com.google.cloud.securitycenter.v1.OrganizationName in project java-securitycenter by googleapis.
the class SecurityCenterClientTest method listNotificationConfigsTest.
@Test
public void listNotificationConfigsTest() throws Exception {
NotificationConfig responsesElement = NotificationConfig.newBuilder().build();
ListNotificationConfigsResponse expectedResponse = ListNotificationConfigsResponse.newBuilder().setNextPageToken("").addAllNotificationConfigs(Arrays.asList(responsesElement)).build();
mockSecurityCenter.addResponse(expectedResponse);
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
ListNotificationConfigsPagedResponse pagedListResponse = client.listNotificationConfigs(parent);
List<NotificationConfig> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getNotificationConfigsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockSecurityCenter.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListNotificationConfigsRequest actualRequest = ((ListNotificationConfigsRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.securitycenter.v1.OrganizationName in project java-dlp by googleapis.
the class DlpServiceClientTest method createInspectTemplateExceptionTest3.
@Test
public void createInspectTemplateExceptionTest3() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockDlpService.addException(exception);
try {
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
InspectTemplate inspectTemplate = InspectTemplate.newBuilder().build();
client.createInspectTemplate(parent, inspectTemplate);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.cloud.securitycenter.v1.OrganizationName in project java-dlp by googleapis.
the class DlpServiceClientTest method createDeidentifyTemplateTest3.
@Test
public void createDeidentifyTemplateTest3() throws Exception {
DeidentifyTemplate expectedResponse = DeidentifyTemplate.newBuilder().setName(DeidentifyTemplateName.ofOrganizationDeidentifyTemplateName("[ORGANIZATION]", "[DEIDENTIFY_TEMPLATE]").toString()).setDisplayName("displayName1714148973").setDescription("description-1724546052").setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).setDeidentifyConfig(DeidentifyConfig.newBuilder().build()).build();
mockDlpService.addResponse(expectedResponse);
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
DeidentifyTemplate deidentifyTemplate = DeidentifyTemplate.newBuilder().build();
DeidentifyTemplate actualResponse = client.createDeidentifyTemplate(parent, deidentifyTemplate);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateDeidentifyTemplateRequest actualRequest = ((CreateDeidentifyTemplateRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(deidentifyTemplate, actualRequest.getDeidentifyTemplate());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.securitycenter.v1.OrganizationName in project java-dlp by googleapis.
the class DlpServiceClientTest method createInspectTemplateTest3.
@Test
public void createInspectTemplateTest3() throws Exception {
InspectTemplate expectedResponse = InspectTemplate.newBuilder().setName(InspectTemplateName.ofOrganizationInspectTemplateName("[ORGANIZATION]", "[INSPECT_TEMPLATE]").toString()).setDisplayName("displayName1714148973").setDescription("description-1724546052").setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).setInspectConfig(InspectConfig.newBuilder().build()).build();
mockDlpService.addResponse(expectedResponse);
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
InspectTemplate inspectTemplate = InspectTemplate.newBuilder().build();
InspectTemplate actualResponse = client.createInspectTemplate(parent, inspectTemplate);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateInspectTemplateRequest actualRequest = ((CreateInspectTemplateRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(inspectTemplate, actualRequest.getInspectTemplate());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.cloud.securitycenter.v1.OrganizationName in project java-dlp by googleapis.
the class DlpServiceClientTest method createStoredInfoTypeExceptionTest3.
@Test
public void createStoredInfoTypeExceptionTest3() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockDlpService.addException(exception);
try {
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
StoredInfoTypeConfig config = StoredInfoTypeConfig.newBuilder().build();
client.createStoredInfoType(parent, config);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations