use of com.google.recaptchaenterprise.v1.Key in project java-recaptchaenterprise by googleapis.
the class RecaptchaEnterpriseServiceClientTest method migrateKeyTest.
@Test
public void migrateKeyTest() throws Exception {
Key expectedResponse = Key.newBuilder().setName(KeyName.of("[PROJECT]", "[KEY]").toString()).setDisplayName("displayName1714148973").putAllLabels(new HashMap<String, String>()).setCreateTime(Timestamp.newBuilder().build()).setTestingOptions(TestingOptions.newBuilder().build()).build();
mockRecaptchaEnterpriseService.addResponse(expectedResponse);
MigrateKeyRequest request = MigrateKeyRequest.newBuilder().setName(KeyName.of("[PROJECT]", "[KEY]").toString()).build();
Key actualResponse = client.migrateKey(request);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockRecaptchaEnterpriseService.getRequests();
Assert.assertEquals(1, actualRequests.size());
MigrateKeyRequest actualRequest = ((MigrateKeyRequest) actualRequests.get(0));
Assert.assertEquals(request.getName(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.recaptchaenterprise.v1.Key in project java-recaptchaenterprise by googleapis.
the class RecaptchaEnterpriseServiceClientTest method getMetricsTest2.
@Test
public void getMetricsTest2() throws Exception {
Metrics expectedResponse = Metrics.newBuilder().setName(MetricsName.of("[PROJECT]", "[KEY]").toString()).setStartTime(Timestamp.newBuilder().build()).addAllScoreMetrics(new ArrayList<ScoreMetrics>()).addAllChallengeMetrics(new ArrayList<ChallengeMetrics>()).build();
mockRecaptchaEnterpriseService.addResponse(expectedResponse);
String name = "name3373707";
Metrics actualResponse = client.getMetrics(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockRecaptchaEnterpriseService.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetMetricsRequest actualRequest = ((GetMetricsRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.recaptchaenterprise.v1.Key in project java-recaptchaenterprise by googleapis.
the class RecaptchaEnterpriseServiceClientTest method getMetricsTest.
@Test
public void getMetricsTest() throws Exception {
Metrics expectedResponse = Metrics.newBuilder().setName(MetricsName.of("[PROJECT]", "[KEY]").toString()).setStartTime(Timestamp.newBuilder().build()).addAllScoreMetrics(new ArrayList<ScoreMetrics>()).addAllChallengeMetrics(new ArrayList<ChallengeMetrics>()).build();
mockRecaptchaEnterpriseService.addResponse(expectedResponse);
MetricsName name = MetricsName.of("[PROJECT]", "[KEY]");
Metrics actualResponse = client.getMetrics(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockRecaptchaEnterpriseService.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetMetricsRequest actualRequest = ((GetMetricsRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.recaptchaenterprise.v1.Key in project grpc-gcp-java by GoogleCloudPlatform.
the class DataStoreChecksumClient method simpleLookup.
private static void simpleLookup(DatastoreBlockingStub stub, String projectId) {
PathElement pathElement = PathElement.newBuilder().setKind("Person").setName("weiranf").build();
Key key = Key.newBuilder().addPath(pathElement).build();
LookupRequest lookupRequest = LookupRequest.newBuilder().setProjectId(projectId).addKeys(key).build();
LookupResponse lookupResponse = stub.lookup(lookupRequest);
if (lookupResponse.getFoundCount() > 0) {
System.out.println("ENTITY FOUND:");
Entity entity = lookupResponse.getFound(0).getEntity();
Map<String, Value> map = entity.getPropertiesMap();
for (Map.Entry<String, Value> entry : map.entrySet()) {
System.out.printf("%s => %s\n", entry.getKey(), entry.getValue().getStringValue());
}
} else {
System.out.println("NO ENTITY FOUND!");
}
}
use of com.google.recaptchaenterprise.v1.Key in project beam by apache.
the class DataStoreReadWriteIT method testWriteRead_viaCoreBeamIO.
@Test
public void testWriteRead_viaCoreBeamIO() {
String projectId = options.getProject();
Key ancestor = makeKey(KIND, UUID.randomUUID().toString()).build();
Key itemKey = makeKey(ancestor, KIND, UUID.randomUUID().toString()).setPartitionId(PartitionId.newBuilder().setProjectId(projectId).build()).build();
Row testWriteRow = Row.withSchema(SOURCE_SCHEMA).addValues(itemKey.toByteArray(), "4000").build();
writePipeline.apply(Create.of(testWriteRow).withRowSchema(SOURCE_SCHEMA)).apply(RowToEntity.create("__key__", KIND)).apply(DatastoreIO.v1().write().withProjectId(projectId));
writePipeline.run().waitUntilFinish();
Query.Builder query = Query.newBuilder();
query.addKindBuilder().setName(KIND);
query.setFilter(makeFilter("__key__", Operator.EQUAL, makeValue(itemKey)));
DatastoreV1.Read read = DatastoreIO.v1().read().withProjectId(projectId).withQuery(query.build());
PCollection<Row> rowsRead = readPipeline.apply(read).apply(EntityToRow.create(SOURCE_SCHEMA, "__key__"));
PAssert.that(rowsRead).containsInAnyOrder(testWriteRow);
readPipeline.run().waitUntilFinish();
}
Aggregations