use of com.google.cloud.compute.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());
}
}
use of com.google.cloud.compute.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()));
}
use of com.google.cloud.compute.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;
}
use of com.google.cloud.compute.v1.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());
}
use of com.google.cloud.compute.v1.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.");
}
Aggregations