use of com.google.recaptchaenterprise.v1beta1.DeleteKeyRequest in project java-recaptchaenterprise by googleapis.
the class RecaptchaEnterpriseServiceV1Beta1ClientTest method deleteKeyTest.
@Test
public void deleteKeyTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockRecaptchaEnterpriseServiceV1Beta1.addResponse(expectedResponse);
DeleteKeyRequest request = DeleteKeyRequest.newBuilder().setName(KeyName.of("[PROJECT]", "[KEY]").toString()).build();
client.deleteKey(request);
List<AbstractMessage> actualRequests = mockRecaptchaEnterpriseServiceV1Beta1.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteKeyRequest actualRequest = ((DeleteKeyRequest) actualRequests.get(0));
Assert.assertEquals(request.getName(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.recaptchaenterprise.v1beta1.DeleteKeyRequest in project java-recaptchaenterprise by googleapis.
the class RecaptchaEnterpriseServiceV1Beta1ClientTest method deleteKeyExceptionTest.
@Test
public void deleteKeyExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockRecaptchaEnterpriseServiceV1Beta1.addException(exception);
try {
DeleteKeyRequest request = DeleteKeyRequest.newBuilder().setName(KeyName.of("[PROJECT]", "[KEY]").toString()).build();
client.deleteKey(request);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.recaptchaenterprise.v1beta1.DeleteKeyRequest in project java-recaptchaenterprise by googleapis.
the class DeleteSiteKey method deleteSiteKey.
/**
* Delete the given reCAPTCHA site key present under the project ID.
*
* @param projectID: GCloud Project ID.
* @param recaptchaSiteKey: Specify the site key to be deleted.
*/
public static void deleteSiteKey(String projectID, String recaptchaSiteKey) throws IOException, ExecutionException, InterruptedException, TimeoutException {
// clean up any remaining background resources.
try (RecaptchaEnterpriseServiceClient client = RecaptchaEnterpriseServiceClient.create()) {
// Set the project ID and reCAPTCHA site key.
DeleteKeyRequest deleteKeyRequest = DeleteKeyRequest.newBuilder().setName(KeyName.of(projectID, recaptchaSiteKey).toString()).build();
client.deleteKeyCallable().futureCall(deleteKeyRequest).get(5, TimeUnit.SECONDS);
System.out.println("reCAPTCHA Site key successfully deleted !");
}
}
use of com.google.recaptchaenterprise.v1beta1.DeleteKeyRequest in project java-recaptchaenterprise by googleapis.
the class RecaptchaEnterpriseServiceClientTest method deleteKeyTest.
@Test
public void deleteKeyTest() throws Exception {
Empty expectedResponse = Empty.newBuilder().build();
mockRecaptchaEnterpriseService.addResponse(expectedResponse);
DeleteKeyRequest request = DeleteKeyRequest.newBuilder().setName(KeyName.of("[PROJECT]", "[KEY]").toString()).build();
client.deleteKey(request);
List<AbstractMessage> actualRequests = mockRecaptchaEnterpriseService.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteKeyRequest actualRequest = ((DeleteKeyRequest) actualRequests.get(0));
Assert.assertEquals(request.getName(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.recaptchaenterprise.v1beta1.DeleteKeyRequest in project java-recaptchaenterprise by googleapis.
the class RecaptchaEnterpriseServiceClientTest method deleteKeyExceptionTest.
@Test
public void deleteKeyExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockRecaptchaEnterpriseService.addException(exception);
try {
DeleteKeyRequest request = DeleteKeyRequest.newBuilder().setName(KeyName.of("[PROJECT]", "[KEY]").toString()).build();
client.deleteKey(request);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations