Source:
public void testSimpleCall() throws DolphinRemotingException { ClientConfiguration clientConfiguration = new ClientConfiguration(getDummyURL(), new DummyUiThreadHandler()); clientConfiguration.setConnectionFactory(new HttpURLConnectionFactory() { @Override public HttpURLConnection create(URL url) throws IOException { return new HttpURLConnection(url) { @Override public void disconnect() { } @Override public boolean usingProxy() { return false; } @Override public void connect() throws IOException { } @Override public int getResponseCode() throws IOException { return HttpStatus.HTTP_OK; } @Override public OutputStream getOutputStream() throws IOException { return new ByteArrayOutputStream(); } @Override public InputStream getInputStream() throws IOException { String response = "[{\"pmId\":\"p1\",\"clientSideOnly\":false,\"id\":\"CreatePresentationModel\",\"attributes\":[],\"pmType\":null,\"className\":\"com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand\"}]"; return new ByteArrayInputStream(response.getBytes("UTF-8")); } @Override public String getHeaderField(String name) { if (PlatformConstants.CLIENT_ID_HTTP_HEADER_NAME.equals(name)) { return "TEST-ID"; } return super.getHeaderField(name); } }; } }); HttpClient httpClient = new HttpClientImpl(new Gson(), clientConfiguration.getConnectionFactory()); ClientModelStore clientModelStore = new ClientModelStore(new DefaultModelSynchronizer(new Provider<AbstractClientConnector>() { @Override public AbstractClientConnector get() { return null; } })); DolphinPlatformHttpClientConnector connector = new DolphinPlatformHttpClientConnector(clientConfiguration, clientModelStore, new JsonCodec(), new SimpleExceptionHandler(), httpClient); CreatePresentationModelCommand command = new CreatePresentationModelCommand(); command.setPmId("p1"); Command rawCommand = command; List<Command> result = connector.transmit(Collections.singletonList(rawCommand)); Assert.assertEquals(result.size(), 1); Assert.assertTrue(result.get(0) instanceof CreatePresentationModelCommand); Assert.assertEquals(((CreatePresentationModelCommand) result.get(0)).getPmId(), "p1"); }

Target:
public void testSimpleCall() throws DolphinRemotingException { final ClientConfiguration clientConfiguration = new ClientConfiguration(getDummyURL(), new DummyUiThreadHandler()); clientConfiguration.setConnectionFactory(new HttpURLConnectionFactory() { @Override public HttpURLConnection create(URL url) throws IOException { return new HttpURLConnection(url) { @Override public void disconnect() { } @Override public boolean usingProxy() { return false; } @Override public void connect() throws IOException { } @Override public int getResponseCode() throws IOException { return HttpStatus.HTTP_OK; } @Override public OutputStream getOutputStream() throws IOException { return new ByteArrayOutputStream(); } @Override public InputStream getInputStream() throws IOException { String response = "[{\"pmId\":\"p1\",\"clientSideOnly\":false,\"id\":\"CreatePresentationModel\",\"attributes\":[],\"pmType\":null,\"className\":\"com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand\"}]"; return new ByteArrayInputStream(response.getBytes("UTF-8")); } @Override public String getHeaderField(String name) { if (PlatformConstants.CLIENT_ID_HTTP_HEADER_NAME.equals(name)) { return "TEST-ID"; } return super.getHeaderField(name); } }; } }); final HttpClient httpClient = new HttpClientImpl(new Gson(), clientConfiguration.getConnectionFactory()); final ClientModelStore clientModelStore = new ClientModelStore(new DefaultModelSynchronizer(new Provider<AbstractClientConnector>() { @Override public AbstractClientConnector get() { return null; } })); final DolphinPlatformHttpClientConnector connector = new DolphinPlatformHttpClientConnector(clientConfiguration, clientModelStore, new JsonCodec(), new SimpleExceptionHandler(), httpClient); final CreatePresentationModelCommand command = new CreatePresentationModelCommand(); command.setPmId("p1"); Command rawCommand = command; final List<Command> result = connector.transmit(Collections.singletonList(rawCommand)); Assert.assertEquals(result.size(), 1); Assert.assertTrue(result.get(0) instanceof CreatePresentationModelCommand); Assert.assertEquals(((CreatePresentationModelCommand) result.get(0)).getPmId(), "p1"); }