use of com.google.privacy.dlp.v2.Error in project ovirt-engine-sdk-java by oVirt.
the class ConnectionBuilder45 method createConnectionSocketFactoryRegistry.
private Registry createConnectionSocketFactoryRegistry() {
String protocol = getProtocol();
Registry registry = null;
// Create SSL/TLS or plain connection:
if (HTTP_PROTOCOL.equals(protocol)) {
ConnectionSocketFactory plainsf = PlainConnectionSocketFactory.getSocketFactory();
registry = RegistryBuilder.<ConnectionSocketFactory>create().register(HTTP_PROTOCOL, plainsf).build();
} else if (HTTPS_PROTOCOL.equals(protocol)) {
try {
LayeredConnectionSocketFactory sslsf = null;
if (this.insecure) {
SSLContext sslcontext = SSLContext.getInstance("TLS");
sslcontext.init(null, new TrustManager[] { noCaTrustManager }, null);
sslsf = new SSLConnectionSocketFactory(sslcontext, NoopHostnameVerifier.INSTANCE);
} else {
SSLContextBuilder sslContextBuilder = SSLContexts.custom();
if (trustStoreFile != null) {
sslContextBuilder.loadTrustMaterial(new File(trustStoreFile), this.trustStorePassword != null ? this.trustStorePassword.toCharArray() : null);
}
SSLContext sslContext = sslContextBuilder.build();
sslsf = new SSLConnectionSocketFactory(sslContext, new DefaultHostnameVerifier());
}
registry = RegistryBuilder.<ConnectionSocketFactory>create().register(HTTPS_PROTOCOL, sslsf).build();
} catch (NoSuchAlgorithmException e) {
throw new Error(NO_TLS_ERROR, e);
} catch (KeyManagementException e) {
throw new Error(BAD_KEY_ERROR, e);
} catch (KeyStoreException e) {
throw new Error(KEY_STORE_ERROR, e);
} catch (FileNotFoundException e) {
throw new Error(KEY_STORE_FILE_NOT_FOUND_ERROR, e);
} catch (CertificateException e) {
throw new Error(CERTIFICATE_ERROR, e);
} catch (IOException e) {
throw new Error(IO_ERROR, e);
}
} else {
throw new Error(BAD_PROTOCOL_ERROR + protocol);
}
return registry;
}
use of com.google.privacy.dlp.v2.Error in project java-dlp by googleapis.
the class DlpServiceClientTest method createDlpJobTest.
@Test
public void createDlpJobTest() throws Exception {
DlpJob expectedResponse = DlpJob.newBuilder().setName(DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]").toString()).setType(DlpJobType.forNumber(0)).setCreateTime(Timestamp.newBuilder().build()).setStartTime(Timestamp.newBuilder().build()).setEndTime(Timestamp.newBuilder().build()).setJobTriggerName("jobTriggerName494333030").addAllErrors(new ArrayList<Error>()).build();
mockDlpService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
InspectJobConfig inspectJob = InspectJobConfig.newBuilder().build();
DlpJob actualResponse = client.createDlpJob(parent, inspectJob);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateDlpJobRequest actualRequest = ((CreateDlpJobRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(inspectJob, actualRequest.getInspectJob());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.privacy.dlp.v2.Error in project java-dlp by googleapis.
the class DlpServiceClientTest method createJobTriggerTest.
@Test
public void createJobTriggerTest() throws Exception {
JobTrigger expectedResponse = JobTrigger.newBuilder().setName(JobTriggerName.ofProjectJobTriggerName("[PROJECT]", "[JOB_TRIGGER]").toString()).setDisplayName("displayName1714148973").setDescription("description-1724546052").addAllTriggers(new ArrayList<JobTrigger.Trigger>()).addAllErrors(new ArrayList<Error>()).setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).setLastRunTime(Timestamp.newBuilder().build()).build();
mockDlpService.addResponse(expectedResponse);
LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
JobTrigger jobTrigger = JobTrigger.newBuilder().build();
JobTrigger actualResponse = client.createJobTrigger(parent, jobTrigger);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateJobTriggerRequest actualRequest = ((CreateJobTriggerRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(jobTrigger, actualRequest.getJobTrigger());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.privacy.dlp.v2.Error in project java-dlp by googleapis.
the class DlpServiceClientTest method getDlpJobTest.
@Test
public void getDlpJobTest() throws Exception {
DlpJob expectedResponse = DlpJob.newBuilder().setName(DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]").toString()).setType(DlpJobType.forNumber(0)).setCreateTime(Timestamp.newBuilder().build()).setStartTime(Timestamp.newBuilder().build()).setEndTime(Timestamp.newBuilder().build()).setJobTriggerName("jobTriggerName494333030").addAllErrors(new ArrayList<Error>()).build();
mockDlpService.addResponse(expectedResponse);
DlpJobName name = DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]");
DlpJob actualResponse = client.getDlpJob(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetDlpJobRequest actualRequest = ((GetDlpJobRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.privacy.dlp.v2.Error in project java-dlp by googleapis.
the class DlpServiceClientTest method getDlpJobTest2.
@Test
public void getDlpJobTest2() throws Exception {
DlpJob expectedResponse = DlpJob.newBuilder().setName(DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]").toString()).setType(DlpJobType.forNumber(0)).setCreateTime(Timestamp.newBuilder().build()).setStartTime(Timestamp.newBuilder().build()).setEndTime(Timestamp.newBuilder().build()).setJobTriggerName("jobTriggerName494333030").addAllErrors(new ArrayList<Error>()).build();
mockDlpService.addResponse(expectedResponse);
String name = "name3373707";
DlpJob actualResponse = client.getDlpJob(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDlpService.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetDlpJobRequest actualRequest = ((GetDlpJobRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations