ClientClusterManagementService implements ClusterManagementService { @Override public <T extends AbstractConfiguration<R>, R extends RuntimeInfo> ClusterManagementGetResult<T, R> get( T config) { ClusterManagementGetResult<T, R> result = transport.submitMessageForGet(config); assertSuccessful(result); return result; } ClientClusterManagementService(ClusterManagementServiceTransport transport); @Override ClusterManagementRealizationResult create(T config); @Override ClusterManagementRealizationResult delete(
      T config); @Override ClusterManagementRealizationResult update(
      T config); @Override ClusterManagementListResult<T, R> list(
      T config); @Override ClusterManagementGetResult<T, R> get(
      T config); @Override ClusterManagementOperationResult<A, V> start(
      A op); @Override ClusterManagementOperationResult<A, V> get(
      A opType, String opId); @Override CompletableFuture<ClusterManagementOperationResult<A, V>> getFuture(
      A opType, String opId); @Override ClusterManagementListOperationsResult<A, V> list(
      A opType); @Override boolean isConnected(); @Override void close();  }
@Test public void getCallsSubmitMessageAndReturnsResult() { @SuppressWarnings("unchecked") ClusterManagementGetResult<AbstractConfiguration<RuntimeInfo>, RuntimeInfo> successGetResult = mock(ClusterManagementGetResult.class); when(successGetResult.isSuccessful()).thenReturn(true); when(serviceTransport.submitMessageForGet(any())).thenReturn(successGetResult); ClusterManagementGetResult<AbstractConfiguration<RuntimeInfo>, RuntimeInfo> getResult = service.get(configuration); assertThat(getResult).isSameAs(successGetResult); verify(serviceTransport).submitMessageForGet(same(configuration)); }
@Test public void getOperationCallsSubmitMessageAndReturnsResult() { String opId = "opId"; RebalanceOperation opType = new RebalanceOperation(); doReturn(successOperationResult).when(serviceTransport) .submitMessageForGetOperation(same(opType), same(opId)); ClusterManagementOperationResult<RebalanceOperation, RebalanceResult> operationResult = service.get(opType, opId); assertThat(operationResult).isSameAs(successOperationResult); verify(serviceTransport).submitMessageForGetOperation(same(opType), same(opId)); }