use of com.robo4j.socket.http.dto.HttpPathMethodDTO in project robo4j by Robo4J.
the class HttpPathUtilTests method parseFullPathMethod.
@Test
void parseFullPathMethod() {
List<String> jsonList = Arrays.asList("{\"roboUnit\":\"\", \"method\":\"POST\", \"callbacks\":[\"callbackPOSTController\"]}", "{\"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);
System.out.println("pathMethod: " + pathMethod);
assertNotNull(pathMethod, json);
assertNotNull(pathMethod.getRoboUnit(), json);
assertTrue(pathMethod.getRoboUnit().isEmpty() ? pathMethod.getRoboUnit().equals(StringConstants.EMPTY) : pathMethod.getRoboUnit().equals("imageController"));
});
}
use of com.robo4j.socket.http.dto.HttpPathMethodDTO in project robo4j by Robo4J.
the class HttpServerConfigTests method serverConfigurationWithoutPropertiesDTOTest.
@Test
void serverConfigurationWithoutPropertiesDTOTest() {
String configurationJson = "{\"roboUnit\":\"roboUnit1\",\"method\":\"GET\"}";
HttpPathMethodDTO serverUnitPathDTO = HttpPathUtils.readServerPathDTO(configurationJson);
System.out.println("serverUnitPathDTO: " + serverUnitPathDTO);
assertEquals("roboUnit1", serverUnitPathDTO.getRoboUnit());
assertEquals(HttpMethod.GET, serverUnitPathDTO.getMethod());
assertTrue(serverUnitPathDTO.getCallbacks().isEmpty());
}
use of com.robo4j.socket.http.dto.HttpPathMethodDTO in project robo4j by Robo4J.
the class HttpServerConfigTests method serverConfigurationNullTest.
@Test
void serverConfigurationNullTest() {
Throwable exception = assertThrows(NullPointerException.class, () -> {
HttpPathMethodDTO serverUnitPathDTO = HttpPathUtils.readServerPathDTO(null);
assertNull(serverUnitPathDTO);
});
assertNull(exception.getMessage());
}
use of com.robo4j.socket.http.dto.HttpPathMethodDTO in project robo4j by Robo4J.
the class HttpServerConfigTests method serverConfigurationWithMultiplePathsWithPropertiesTest.
@Test
void serverConfigurationWithMultiplePathsWithPropertiesTest() {
String configurationJson = "[{\"roboUnit\":\"roboUnit1\",\"method\":\"GET\" , \"callbacks\":[\"filter1\",\"filter2\"]}," + "{\"roboUnit\":\"roboUnit2\",\"method\":\"POST\"}, {\"roboUnit\":\"roboUnit3\",\"method\":\"GET\",\"callbacks\":[]}]";
List<HttpPathMethodDTO> expectedPathList = Arrays.asList(new HttpPathMethodDTO("roboUnit1", HttpMethod.GET, Arrays.asList("filter1", "filter2")), new HttpPathMethodDTO("roboUnit2", HttpMethod.POST), new HttpPathMethodDTO("roboUnit3", HttpMethod.GET, Collections.emptyList()));
List<HttpPathMethodDTO> paths = JsonUtil.readPathConfig(HttpPathMethodDTO.class, configurationJson);
System.out.println("paths: " + paths);
assertNotNull(paths);
assertEquals(expectedPathList.size(), paths.size());
assertArrayEquals(expectedPathList.toArray(), paths.toArray());
}
use of com.robo4j.socket.http.dto.HttpPathMethodDTO in project robo4j by Robo4J.
the class HttpServerConfigTests method serverConfigurationWithMultiplePathsWithoutPropertiesTest.
@Test
void serverConfigurationWithMultiplePathsWithoutPropertiesTest() {
String configurationJson = "[{\"roboUnit\":\"roboUnit1\",\"method\":\"GET\"}," + "{\"roboUnit\":\"roboUnit2\",\"method\":\"POST\"}]";
List<HttpPathMethodDTO> expectedPathList = Arrays.asList(new HttpPathMethodDTO("roboUnit1", HttpMethod.GET), new HttpPathMethodDTO("roboUnit2", HttpMethod.POST));
List<HttpPathMethodDTO> paths = JsonUtil.readPathConfig(HttpPathMethodDTO.class, configurationJson);
assertEquals(expectedPathList.size(), paths.size());
assertArrayEquals(expectedPathList.toArray(), paths.toArray());
}
Aggregations