use of com.robo4j.socket.http.dto.HttpPathMethodDTO in project robo4j by Robo4J.
the class OutboundHttpSocketChannelHandler method start.
@Override
public void start() {
// FIXME: 1/24/18 (miro) -> client context
final HttpPathMethodDTO pathMethod = new HttpPathMethodDTO(message.getPathMethod().getPath(), message.getPathMethod().getMethod(), message.getCallbacks());
// @formatter:off
final String resultMessage = HttpMessageBuilder.Build().setDenominator(message.getDenominator()).addHeaderElements(message.getHeader()).build(message.getMessage());
// @formatter:on
final ByteBuffer buffer = ChannelBufferUtils.getByteBufferByString(resultMessage);
ChannelUtils.handleWriteChannelAndBuffer("client send message", byteChannel, buffer);
decoratedResponse = getDecoratedResponse(byteChannel, pathMethod);
}
use of com.robo4j.socket.http.dto.HttpPathMethodDTO in project robo4j by Robo4J.
the class ReflectUtilTests method serverAttributesResponse.
@Test
void serverAttributesResponse() {
ResponseAttributeListDTO tmpAttr = new ResponseAttributeListDTO();
tmpAttr.setType("Type");
tmpAttr.setId("ID");
// String roboUnit, HttpMethod method, List<String> callbacks
tmpAttr.addValue(new HttpPathMethodDTO("testUnit", HttpMethod.GET, Collections.singletonList("test")));
String result = ReflectUtils.createJson(tmpAttr);
System.out.println("result:" + result);
}
use of com.robo4j.socket.http.dto.HttpPathMethodDTO in project robo4j by Robo4J.
the class HttpPathUtilTests method parseJsonPathMethod.
@Test
void parseJsonPathMethod() {
List<String> jsonList = Arrays.asList("{\"roboUnit\":\"imageController\", \"method\":\"POST\", \"callbacks\":[\"callbackPOSTController\"]}", "{\"roboUnit\":\"imageController\", \"method\" : \"POST\", \"callbacks\" : [ \"callbackPOSTController\" ]}", "{ \"roboUnit\": \"imageController\", \"method\": \"POST\", \"callbacks\" :[\"callbackPOSTController\"] }");
jsonList.forEach(json -> {
HttpPathMethodDTO pathMethod = JsonUtil.getPathMethodByJson(json);
assertNotNull(pathMethod, json);
assertEquals("imageController", pathMethod.getRoboUnit(), json);
assertEquals(HttpMethod.POST, pathMethod.getMethod(), json);
assertTrue(pathMethod.getCallbacks().contains("callbackPOSTController"), json);
});
}
use of com.robo4j.socket.http.dto.HttpPathMethodDTO in project robo4j by Robo4J.
the class HttpPathUtilTests method parseJsonArrayPathMethodToList.
@Test
void parseJsonArrayPathMethodToList() {
final int observedElement = 2;
final String jsonArray = "[{\"roboUnit\":\"imageController\", \"method\":\"POST\",\"callbacks\":[\"callbackPOSTController\"]}," + "{\"roboUnit\":\"imageController\",\"method\":\"GET\",\"callbacks\":[\"callbackGETController\"]}," + "{\"roboUnit\":\"cameraController\",\"method\":\"POST\",\"callbacks\":[\"callbackPOSTController\"]}," + "{\"roboUnit\":\"cameraController\",\"method\":\"POST\",\"callbacks\":[\"callbackPOSTController\"]}," + "{\"roboUnit\":\"cameraController\",\"method\":\"GET\",\"callbacks\":[\"callbackGETController\"]}," + "{\"roboUnit\":\"emptyController\",\"method\":\"GET\"}]";
HttpPathMethodDTO duplicate = new HttpPathMethodDTO("cameraController", HttpMethod.POST, Collections.singletonList("callbackPOSTController"));
List<HttpPathMethodDTO> result = JsonUtil.toListFromJsonArray(HttpPathMethodDTO.class, jsonArray);
System.out.println("result: " + result);
assertNotNull(result);
assertEquals(6, result.size());
assertEquals("cameraController", result.get(observedElement).getRoboUnit());
assertEquals(HttpMethod.POST, result.get(observedElement).getMethod());
assertTrue(result.get(observedElement).getCallbacks().contains("callbackPOSTController"));
assertTrue(result.contains(duplicate));
}
Aggregations