ClientClusterManagementService implements ClusterManagementService { @Override public <T extends AbstractConfiguration<R>, R extends RuntimeInfo> ClusterManagementListResult<T, R> list( T config) { ClusterManagementListResult<T, R> result = transport.submitMessageForList(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 listCallsSubmitMessageAndReturnsResult() { @SuppressWarnings("unchecked") ClusterManagementListResult<AbstractConfiguration<RuntimeInfo>, RuntimeInfo> successListResult = mock(ClusterManagementListResult.class); when(successListResult.isSuccessful()).thenReturn(true); when(serviceTransport.submitMessageForList(any())).thenReturn(successListResult); ClusterManagementListResult<AbstractConfiguration<RuntimeInfo>, RuntimeInfo> listResult = service.list(configuration); assertThat(listResult).isSameAs(successListResult); verify(serviceTransport).submitMessageForList(same(configuration)); }
@Test public void listOperationCallsSubmitMessageAndReturnsResult() { @SuppressWarnings("unchecked") ClusterManagementListOperationsResult<ClusterManagementOperation<OperationResult>, OperationResult> successListOperationsResult = mock(ClusterManagementListOperationsResult.class); when(successListOperationsResult.isSuccessful()).thenReturn(true); doReturn(successListOperationsResult).when(serviceTransport) .submitMessageForListOperation(any()); ClusterManagementListOperationsResult<ClusterManagementOperation<OperationResult>, OperationResult> operationResult = service.list(operation); assertThat(operationResult).isSameAs(successListOperationsResult); verify(serviceTransport).submitMessageForListOperation(same(operation)); }