FeignCommandTransporterStrategy implements CommandTransporterStrategy { @Override public Boolean transportCommand(final TransporterCommand command) { try { Response response = this.clientFactory.apply(command.getDestination(), this.client).postCommand(command); return response.status() == HttpStatus.ACCEPTED.value() || response.status() == HttpStatus.CONFLICT.value(); } catch (Exception e) { log.error(e.getMessage(), e); } return false; } FeignCommandTransporterStrategy(final Client client,final KermossProperties kermossProperties,
			final BiFunction<String, Client, FeignCommandTransporterClient> clientFactory); @Override Boolean transportCommand(final TransporterCommand command); @Override Boolean transportPrepareCommand(final TransporterCommand command); static FeignCommandTransporterClient defaultClientFactory(final String target, final Client client);  }
@Test public void transportCommandShouldSendPostRequest() { final TransporterCommand command = new TransporterCommand(); final Response response = Response.builder().status(202).headers(new HashMap<>()).build(); when(clientFactory.apply(any(), any())).thenReturn(client); when(client.postCommand(any())).thenReturn(response); feignCommandTransporterStrategy.transportCommand(command); verify(client).postCommand(command); }
@Test public void transportCommandReturnsTrueWhenPostRequestSucceeds() { final TransporterCommand command = new TransporterCommand(); final Response response = Response.builder().status(202).headers(new HashMap<>()).build(); when(clientFactory.apply(any(), any())).thenReturn(client); when(client.postCommand(any())).thenReturn(response); final Boolean result = feignCommandTransporterStrategy.transportCommand(command); assertTrue(result); }