Search in sources :

Example 61 with Instance

use of com.google.cloud.redis.v1.Instance in project java-bigtable by googleapis.

the class BaseBigtableInstanceAdminClientTest method createInstanceExceptionTest.

@Test
public void createInstanceExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockBigtableInstanceAdmin.addException(exception);
    try {
        ProjectName parent = ProjectName.of("[PROJECT]");
        String instanceId = "instanceId902024336";
        Instance instance = Instance.newBuilder().build();
        Map<String, Cluster> clusters = new HashMap<>();
        client.createInstanceAsync(parent, instanceId, instance, clusters).get();
        Assert.fail("No exception raised");
    } catch (ExecutionException e) {
        Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
        InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
        Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) ProjectName(com.google.bigtable.admin.v2.ProjectName) Instance(com.google.bigtable.admin.v2.Instance) HashMap(java.util.HashMap) StatusRuntimeException(io.grpc.StatusRuntimeException) Cluster(com.google.bigtable.admin.v2.Cluster) ByteString(com.google.protobuf.ByteString) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Example 62 with Instance

use of com.google.cloud.redis.v1.Instance in project java-bigtable by googleapis.

the class BaseBigtableInstanceAdminClientTest method partialUpdateInstanceTest.

@Test
public void partialUpdateInstanceTest() throws Exception {
    Instance expectedResponse = Instance.newBuilder().setName(InstanceName.of("[PROJECT]", "[INSTANCE]").toString()).setDisplayName("displayName1714148973").putAllLabels(new HashMap<String, String>()).setCreateTime(Timestamp.newBuilder().build()).build();
    Operation resultOperation = Operation.newBuilder().setName("partialUpdateInstanceTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
    mockBigtableInstanceAdmin.addResponse(resultOperation);
    Instance instance = Instance.newBuilder().build();
    FieldMask updateMask = FieldMask.newBuilder().build();
    Instance actualResponse = client.partialUpdateInstanceAsync(instance, updateMask).get();
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    PartialUpdateInstanceRequest actualRequest = ((PartialUpdateInstanceRequest) actualRequests.get(0));
    Assert.assertEquals(instance, actualRequest.getInstance());
    Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : PartialUpdateInstanceRequest(com.google.bigtable.admin.v2.PartialUpdateInstanceRequest) AbstractMessage(com.google.protobuf.AbstractMessage) Instance(com.google.bigtable.admin.v2.Instance) ByteString(com.google.protobuf.ByteString) Operation(com.google.longrunning.Operation) FieldMask(com.google.protobuf.FieldMask) Test(org.junit.Test)

Example 63 with Instance

use of com.google.cloud.redis.v1.Instance in project java-bigtable by googleapis.

the class BaseBigtableInstanceAdminClientTest method partialUpdateInstanceExceptionTest.

@Test
public void partialUpdateInstanceExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockBigtableInstanceAdmin.addException(exception);
    try {
        Instance instance = Instance.newBuilder().build();
        FieldMask updateMask = FieldMask.newBuilder().build();
        client.partialUpdateInstanceAsync(instance, updateMask).get();
        Assert.fail("No exception raised");
    } catch (ExecutionException e) {
        Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
        InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
        Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) Instance(com.google.bigtable.admin.v2.Instance) StatusRuntimeException(io.grpc.StatusRuntimeException) ExecutionException(java.util.concurrent.ExecutionException) FieldMask(com.google.protobuf.FieldMask) Test(org.junit.Test)

Example 64 with Instance

use of com.google.cloud.redis.v1.Instance in project java-bigtable by googleapis.

the class BaseBigtableInstanceAdminClientTest method getInstanceTest2.

@Test
public void getInstanceTest2() throws Exception {
    Instance expectedResponse = Instance.newBuilder().setName(InstanceName.of("[PROJECT]", "[INSTANCE]").toString()).setDisplayName("displayName1714148973").putAllLabels(new HashMap<String, String>()).setCreateTime(Timestamp.newBuilder().build()).build();
    mockBigtableInstanceAdmin.addResponse(expectedResponse);
    String name = "name3373707";
    Instance actualResponse = client.getInstance(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockBigtableInstanceAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetInstanceRequest actualRequest = ((GetInstanceRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) GetInstanceRequest(com.google.bigtable.admin.v2.GetInstanceRequest) Instance(com.google.bigtable.admin.v2.Instance) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 65 with Instance

use of com.google.cloud.redis.v1.Instance in project omegat by omegat-org.

the class FilterMaster method getDefaultSettingsFromFilter.

/**
 * Create default filter's config.
 *
 * @param filterClassname
 *            filter's classname
 * @return default filter's config
 */
public static Filter getDefaultSettingsFromFilter(final String filterClassname) {
    IFilter f = getFilterInstance(filterClassname);
    if (f == null) {
        return null;
    }
    Filter fc = new Filter();
    fc.setClassName(f.getClass().getName());
    fc.setEnabled(true);
    for (Instance ins : f.getDefaultInstances()) {
        Files ff = new Files();
        ff.setSourceEncoding(ins.getSourceEncoding());
        ff.setSourceFilenameMask(ins.getSourceFilenameMask());
        ff.setTargetEncoding(ins.getTargetEncoding());
        ff.setTargetFilenamePattern(ins.getTargetFilenamePattern());
        fc.getFiles().add(ff);
    }
    return fc;
}
Also used : IFilter(org.omegat.filters2.IFilter) IFilter(org.omegat.filters2.IFilter) Filter(gen.core.filters.Filter) AbstractFilter(org.omegat.filters2.AbstractFilter) Instance(org.omegat.filters2.Instance) Files(gen.core.filters.Files)

Aggregations

Test (org.junit.Test)41 Instance (com.google.cloud.redis.v1beta1.Instance)34 CloudRedisClient (com.google.cloud.redis.v1beta1.CloudRedisClient)30 Instance (com.google.cloud.compute.v1.Instance)25 InstancesClient (com.google.cloud.compute.v1.InstancesClient)19 ByteString (com.google.protobuf.ByteString)17 AbstractMessage (com.google.protobuf.AbstractMessage)15 Operation (com.google.cloud.compute.v1.Operation)13 Instance (com.google.spanner.admin.instance.v1.Instance)11 Instance (com.google.bigtable.admin.v2.Instance)10 InsertInstanceRequest (com.google.cloud.compute.v1.InsertInstanceRequest)10 AttachedDisk (com.google.cloud.compute.v1.AttachedDisk)9 Instance (com.google.cloud.notebooks.v1beta1.Instance)9 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)7 Any (com.google.protobuf.Any)7 FieldMask (com.google.protobuf.FieldMask)7 StatusRuntimeException (io.grpc.StatusRuntimeException)7 ArrayList (java.util.ArrayList)7 NetworkInterface (com.google.cloud.compute.v1.NetworkInterface)6 Operation (com.google.longrunning.Operation)6