Search in sources :

Example 6 with GetLocationRequest

use of com.google.cloud.location.GetLocationRequest in project gapic-generator-java by googleapis.

the class KeyManagementServiceClientTest method getLocationTest.

@Test
public void getLocationTest() throws Exception {
    Location expectedResponse = Location.newBuilder().setName("name3373707").setLocationId("locationId1541836720").setDisplayName("displayName1714148973").putAllLabels(new HashMap<String, String>()).setMetadata(Any.newBuilder().build()).build();
    mockLocations.addResponse(expectedResponse);
    GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
    Location actualResponse = client.getLocation(request);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockLocations.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetLocationRequest actualRequest = ((GetLocationRequest) actualRequests.get(0));
    Assert.assertEquals(request.getName(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) GetLocationRequest(com.google.cloud.location.GetLocationRequest) ByteString(com.google.protobuf.ByteString) Location(com.google.cloud.location.Location) Test(org.junit.Test)

Example 7 with GetLocationRequest

use of com.google.cloud.location.GetLocationRequest in project java-datastream by googleapis.

the class DatastreamClientTest method getLocationTest.

@Test
public void getLocationTest() throws Exception {
    Location expectedResponse = Location.newBuilder().setName("name3373707").setLocationId("locationId1541836720").setDisplayName("displayName1714148973").putAllLabels(new HashMap<String, String>()).setMetadata(Any.newBuilder().build()).build();
    mockLocations.addResponse(expectedResponse);
    GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
    Location actualResponse = client.getLocation(request);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockLocations.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetLocationRequest actualRequest = ((GetLocationRequest) actualRequests.get(0));
    Assert.assertEquals(request.getName(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) GetLocationRequest(com.google.cloud.location.GetLocationRequest) Location(com.google.cloud.location.Location) Test(org.junit.Test)

Example 8 with GetLocationRequest

use of com.google.cloud.location.GetLocationRequest in project java-security-private-ca by googleapis.

the class CertificateAuthorityServiceClientTest method getLocationExceptionTest.

@Test
public void getLocationExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockLocations.addException(exception);
    try {
        GetLocationRequest request = GetLocationRequest.newBuilder().setName("name3373707").build();
        client.getLocation(request);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) GetLocationRequest(com.google.cloud.location.GetLocationRequest) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Aggregations

GetLocationRequest (com.google.cloud.location.GetLocationRequest)8 Test (org.junit.Test)6 Location (com.google.cloud.location.Location)5 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)3 AbstractMessage (com.google.protobuf.AbstractMessage)3 StatusRuntimeException (io.grpc.StatusRuntimeException)3 KeyManagementServiceClient (com.google.cloud.kms.v1.KeyManagementServiceClient)2 ByteString (com.google.protobuf.ByteString)2