RestTemplateClusterManagementServiceTransport implements ClusterManagementServiceTransport { @Override public <T extends AbstractConfiguration<?>> ClusterManagementRealizationResult submitMessage( T configMessage, CommandType command) { switch (command) { case CREATE: return create(configMessage, HttpMethod.POST); case CREATE_OR_UPDATE: return create(configMessage, HttpMethod.PUT); case DELETE: return delete(configMessage); } throw new IllegalArgumentException("Unable to process command " + command + ". Perhaps you need to use a different method in ClusterManagementServiceTransport."); } RestTemplateClusterManagementServiceTransport(RestTemplate restTemplate);  RestTemplateClusterManagementServiceTransport(
      ConnectionConfig connectionConfig);  RestTemplateClusterManagementServiceTransport(RestTemplate restTemplate,
      ConnectionConfig connectionConfig); void configureConnection(ConnectionConfig connectionConfig); @Override ClusterManagementRealizationResult submitMessage(
      T configMessage, CommandType command); @Override @SuppressWarnings("unchecked") ClusterManagementGetResult<T, R> submitMessageForGet(
      T config); @Override @SuppressWarnings("unchecked") ClusterManagementListResult<T, R> submitMessageForList(
      T config); @Override @SuppressWarnings("unchecked") ClusterManagementListOperationsResult<A, V> submitMessageForListOperation(
      A opType); @Override @SuppressWarnings("unchecked") ClusterManagementOperationResult<A, V> submitMessageForGetOperation(
      A op, String operationId); @Override @SuppressWarnings("unchecked") ClusterManagementOperationResult<A, V> submitMessageForStart(
      A op); @Override boolean isConnected(); @Override void close();  }
@Test public void submitMessageCallsRestTemplateExchange() { when(links.getList()).thenReturn("/operations"); doReturn(responseEntity).when(restTemplate).exchange(any(String.class), same(HttpMethod.POST), any(HttpEntity.class), same(ClusterManagementRealizationResult.class)); restServiceTransport.submitMessage(configuration, CommandType.CREATE); verify(restTemplate).exchange(eq("/v1/operations"), eq(HttpMethod.POST), any(HttpEntity.class), eq(ClusterManagementRealizationResult.class)); }
@Test public void submitMessageRestCallFails() { when(links.getList()).thenReturn("/operations"); doThrow(new RestClientException("Rest call failed")).when(restTemplate).exchange( any(String.class), same(HttpMethod.POST), any(HttpEntity.class), same(ClusterManagementRealizationResult.class)); Throwable throwable = catchThrowable(() -> restServiceTransport.submitMessage(configuration, CommandType.CREATE)); assertThat(throwable).isInstanceOf(RestClientException.class); assertThat(throwable.getMessage()).isEqualTo("Rest call failed"); }