@Test public void testAddingNewSessionWithBadParam() throws Exception { GridStatus status = new GridStatus(); Map<String, String> shouldNotRecord = new HashMap<String, String>(); shouldNotRecord.put("not-session", "123445"); Map actualResultsNotRecordedSession = JsonParserWrapper.toHashMap(status.execute(shouldNotRecord)); assertEquals( formatKey("sessions", new ArrayList()), formatKey("sessions", actualResultsNotRecordedSession.get("sessions"))); Map<String, String> shouldRecord = new HashMap<String, String>(); shouldRecord.put("session", "123456"); ArrayList expectedResults = new ArrayList(); expectedResults.add("123456"); Map actualResultsWithRecordedSession = JsonParserWrapper.toHashMap(status.execute(shouldRecord)); assertEquals( formatKey("sessions", expectedResults), formatKey("sessions", actualResultsWithRecordedSession.get("sessions"))); }
@Test public void testGetEmptyJsonResponse() throws Exception { Map actual = JsonParserWrapper.toHashMap(task.getJsonResponse().getJson()); assertEquals(expectedJsonResponse.keySet(), actual.keySet()); for (Object key : expectedJsonResponse.keySet()) { assertEquals( formatKey(key.toString(), expectedJsonResponse.get(key)), formatKey(key.toString(), actual.get(key))); } }
@Test public void testGetResponseDescription() throws Exception { Map expected = new HashMap(); expected.put( JsonCodec.WebDriver.Grid.HUB_RUNNING, GridStatus.BOOLEAN_IF_HUB_IS_RUNNING_ON_GIVEN_PORT); expected.put( JsonCodec.WebDriver.Grid.NODE_RUNNING, GridStatus.BOOLEAN_IF_NODE_IS_RUNNING_ON_GIVEN_PORT); expected.put( JsonCodec.WebDriver.Grid.HUB_INFO, GridStatus.HASH_OBJECT_DESCRIBING_THE_HUB_PROCESS); expected.put( JsonCodec.WebDriver.Grid.NODE_INFO, GridStatus.HASH_OBJECT_DESCRIBING_THE_NODE_CONFIG_PROCESS); expected.put(JsonCodec.WebDriver.Grid.RECORDED_SESSIONS, GridStatus.LIST_OF_RECORDED_SESSIONS); expected.put( JsonCodec.WebDriver.Grid.NODE_SESSIONS_LIMIT, GridStatus.INTEGER_UPPER_LIMIT_BEFORE_THE_BOX_REBOOTS); expected.put(JsonCodec.ERROR, JsonResponseBuilder.ERROR_RECEIVED_DURING_EXECUTION_OF_COMMAND); expected.put( JsonCodec.OUT, JsonResponseBuilder.ALL_OF_THE_STANDARD_OUT_RECEIVED_FROM_THE_SYSTEM); expected.put(JsonCodec.EXIT_CODE, JsonResponseBuilder.EXIT_CODE_FOR_OPERATION); assertEquals(expected, JsonParserWrapper.toHashMap(task.getResponseDescription())); }