Search in sources :

Example 71 with Instance

use of com.google.cloud.redis.v1beta1.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)

Example 72 with Instance

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

the class CloudRedisClientTest method listInstancesTest.

@Test
public void listInstancesTest() throws Exception {
    Instance responsesElement = Instance.newBuilder().build();
    ListInstancesResponse expectedResponse = ListInstancesResponse.newBuilder().setNextPageToken("").addAllInstances(Arrays.asList(responsesElement)).build();
    mockCloudRedis.addResponse(expectedResponse);
    LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]");
    ListInstancesPagedResponse pagedListResponse = client.listInstances(parent);
    List<Instance> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getInstancesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockCloudRedis.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListInstancesRequest actualRequest = ((ListInstancesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListInstancesPagedResponse(com.google.cloud.redis.v1beta1.CloudRedisClient.ListInstancesPagedResponse) Test(org.junit.Test)

Example 73 with Instance

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

the class CloudRedisClientTest method listInstancesTest2.

@Test
public void listInstancesTest2() throws Exception {
    Instance responsesElement = Instance.newBuilder().build();
    ListInstancesResponse expectedResponse = ListInstancesResponse.newBuilder().setNextPageToken("").addAllInstances(Arrays.asList(responsesElement)).build();
    mockCloudRedis.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListInstancesPagedResponse pagedListResponse = client.listInstances(parent);
    List<Instance> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getInstancesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockCloudRedis.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListInstancesRequest actualRequest = ((ListInstancesRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListInstancesPagedResponse(com.google.cloud.redis.v1beta1.CloudRedisClient.ListInstancesPagedResponse) Test(org.junit.Test)

Example 74 with Instance

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

the class ITSystemTest method testGetInstance.

@Test
public void testGetInstance() {
    Instance response = client.getInstance(INSTANCE_NAME);
    assertEquals(TIER, response.getTier());
    assertEquals(INSTANCE_NAME.toString(), response.getName());
}
Also used : Instance(com.google.cloud.redis.v1beta1.Instance) Test(org.junit.Test)

Example 75 with Instance

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

the class ITSystemTest method setUp.

@BeforeClass
public static void setUp() throws Exception {
    CloudRedisSettings.Builder cloudRedisSettingsBuilder = CloudRedisSettings.newBuilder();
    cloudRedisSettingsBuilder.getInstanceSettings().setRetrySettings(cloudRedisSettingsBuilder.getInstanceSettings().getRetrySettings().toBuilder().setTotalTimeout(Duration.ofSeconds(900)).build());
    CloudRedisSettings cloudRedisSettings = cloudRedisSettingsBuilder.build();
    client = CloudRedisClient.create(cloudRedisSettings);
    /* Clean up old instances that were not deleted. */
    cleanUpOldInstances();
    /* Creates a Redis instance based on the specified tier and memory size. */
    Instance instance = Instance.newBuilder().setTier(TIER).setMemorySizeGb(1).setAuthorizedNetwork(AUTHORIZED_NETWORK).build();
    client.createInstanceAsync(PARENT, INSTANCE, instance).get();
    LOG.info("redis instance created successfully.");
}
Also used : Instance(com.google.cloud.redis.v1.Instance) CloudRedisSettings(com.google.cloud.redis.v1.CloudRedisSettings) BeforeClass(org.junit.BeforeClass)

Aggregations

Test (org.junit.Test)43 CloudRedisClient (com.google.cloud.redis.v1beta1.CloudRedisClient)42 Instance (com.google.cloud.redis.v1beta1.Instance)34 Instance (com.google.cloud.compute.v1.Instance)25 InstancesClient (com.google.cloud.compute.v1.InstancesClient)19 AbstractMessage (com.google.protobuf.AbstractMessage)17 ByteString (com.google.protobuf.ByteString)17 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 Operation (com.google.longrunning.Operation)10 AttachedDisk (com.google.cloud.compute.v1.AttachedDisk)9 Instance (com.google.cloud.notebooks.v1beta1.Instance)9 Any (com.google.protobuf.Any)8 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)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