public Builder mergeFrom(com.google.spanner.admin.instance.v1.Instance other) { if (other == com.google.spanner.admin.instance.v1.Instance.getDefaultInstance()) return this; if (!other.getName().isEmpty()) { name_ = other.name_; onChanged(); } if (!other.getConfig().isEmpty()) { config_ = other.config_; onChanged(); } if (!other.getDisplayName().isEmpty()) { displayName_ = other.displayName_; onChanged(); } if (other.getNodeCount() != 0) { setNodeCount(other.getNodeCount()); } if (other.state_ != 0) { setStateValue(other.getStateValue()); } internalGetMutableLabels().mergeFrom(other.internalGetLabels()); this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@Test public void updateInstanceMetadata() throws Exception { com.google.spanner.admin.instance.v1.Instance instance = com.google.spanner.admin.instance.v1.Instance.newBuilder() .setName(INSTANCE_NAME) .setConfig(CONFIG_NAME) .setNodeCount(2) .build(); OperationFuture<com.google.spanner.admin.instance.v1.Instance, UpdateInstanceMetadata> rawOperationFuture = OperationFutureUtil.immediateOperationFuture( "updateInstance", getInstanceProto(), UpdateInstanceMetadata.getDefaultInstance()); when(rpc.updateInstance(instance, FieldMask.newBuilder().addPaths("node_count").build())) .thenReturn(rawOperationFuture); InstanceInfo instanceInfo = InstanceInfo.newBuilder(InstanceId.of(INSTANCE_NAME)) .setInstanceConfigId(InstanceConfigId.of(CONFIG_NAME)) .setNodeCount(2) .build(); OperationFuture<Instance, UpdateInstanceMetadata> op = client.updateInstance(instanceInfo, InstanceInfo.InstanceField.NODE_COUNT); assertThat(op.isDone()).isTrue(); assertThat(op.get().getId().getName()).isEqualTo(INSTANCE_NAME); }
@Test @SuppressWarnings("all") public void getInstanceTest() { InstanceName name2 = InstanceName.of("[PROJECT]", "[INSTANCE]"); InstanceConfigName config = InstanceConfigName.of("[PROJECT]", "[INSTANCE_CONFIG]"); String displayName = "displayName1615086568"; int nodeCount = 1539922066; Instance expectedResponse = Instance.newBuilder() .setName(name2.toString()) .setConfig(config.toString()) .setDisplayName(displayName) .setNodeCount(nodeCount) .build(); mockInstanceAdmin.addResponse(expectedResponse); InstanceName name = InstanceName.of("[PROJECT]", "[INSTANCE]"); Instance actualResponse = client.getInstance(name); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockInstanceAdmin.getRequests(); Assert.assertEquals(1, actualRequests.size()); GetInstanceRequest actualRequest = (GetInstanceRequest) actualRequests.get(0); Assert.assertEquals(name, InstanceName.parse(actualRequest.getName())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
public Builder mergeFrom(com.google.spanner.admin.instance.v1.Instance other) { if (other == com.google.spanner.admin.instance.v1.Instance.getDefaultInstance()) return this; if (!other.getName().isEmpty()) { name_ = other.name_; onChanged(); } if (!other.getConfig().isEmpty()) { config_ = other.config_; onChanged(); } if (!other.getDisplayName().isEmpty()) { displayName_ = other.displayName_; onChanged(); } if (other.getNodeCount() != 0) { setNodeCount(other.getNodeCount()); } if (other.state_ != 0) { setStateValue(other.getStateValue()); } internalGetMutableLabels().mergeFrom(other.internalGetLabels()); this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
com.google.spanner.admin.instance.v1.Instance toProto() { com.google.spanner.admin.instance.v1.Instance.Builder builder = com.google.spanner.admin.instance.v1.Instance.newBuilder() .setName(getId().getName()) .setNodeCount(getNodeCount()) .putAllLabels(getLabels()); if (getDisplayName() != null) { builder.setDisplayName(getDisplayName()); } if (getInstanceConfigId() != null) { builder.setConfig(getInstanceConfigId().getName()); } return builder.build(); }
.setConfig(config.toString()) .setDisplayName(displayName) .setNodeCount(nodeCount) .build(); Operation resultOperation =
.setConfig(config.toString()) .setDisplayName(displayName) .setNodeCount(nodeCount) .build(); Operation resultOperation =
com.google.spanner.admin.instance.v1.Instance toProto() { com.google.spanner.admin.instance.v1.Instance.Builder builder = com.google.spanner.admin.instance.v1.Instance.newBuilder() .setName(getId().getName()) .setNodeCount(getNodeCount()) .putAllLabels(getLabels()); if (getDisplayName() != null) { builder.setDisplayName(getDisplayName()); } if (getInstanceConfigId() != null) { builder.setConfig(getInstanceConfigId().getName()); } return builder.build(); }
private com.google.spanner.admin.instance.v1.Instance getInstanceProto() { return com.google.spanner.admin.instance.v1.Instance.newBuilder() .setConfig(CONFIG_NAME) .setName(INSTANCE_NAME) .setNodeCount(1) .build(); }
private com.google.spanner.admin.instance.v1.Instance getAnotherInstanceProto() { return com.google.spanner.admin.instance.v1.Instance.newBuilder() .setConfig(CONFIG_NAME) .setName(INSTANCE_NAME2) .setNodeCount(1) .build(); }