private void writeHttpExchange(RecordedHttpExchange recordedHttpExchanges) throws IOException { _jsonGenerator.writeStringField(SceneSerializationConstant.SCENE_TAG_UPDATE_TIME, recordedHttpExchanges.getUpdateTime().toGMTString()); _jsonGenerator.writeObjectFieldStart(SceneSerializationConstant.SCENE_TAG_HTTPREQUEST); writeHttpRequest(recordedHttpExchanges.getRecordedHttpRequest()); _jsonGenerator.writeEndObject(); _jsonGenerator.writeObjectFieldStart(SceneSerializationConstant.SCENE_TAG_HTTPRESPONSE); writeHttpResponse(recordedHttpExchanges.getRecordedHttpResponse()); _jsonGenerator.writeEndObject(); }
@Test public void testCreateSceneExistInRecordMode() throws Exception { Scene expectedScene = EasyMock.createStrictMock(Scene.class); List<RecordedHttpExchange> recordedHttpExchanges = new ArrayList<>(); Date now = new Date(); recordedHttpExchanges.add(new RecordedHttpExchange(null, null, now)); EasyMock.expect(expectedScene.getRecordedHttpExchangeList()).andReturn(recordedHttpExchanges); EasyMock.replay(expectedScene); Scene result = runTestGetResult(SceneMode.RECORD, expectedScene); Assert.assertNotNull(result); Assert.assertEquals(result.getName(), NAME); Assert.assertEquals(result.getSceneRoot(), ROOT); Assert.assertFalse(result.isReadable()); Assert.assertEquals(result.getRecordedHttpExchangeList().get(0).getUpdateTime(), now); }
@Test public void testCreateSceneExistInPlaybackMode() throws Exception { Scene expectedScene = EasyMock.createStrictMock(Scene.class); List<RecordedHttpExchange> recordedHttpExchanges = new ArrayList<>(); Date now = new Date(); recordedHttpExchanges.add(new RecordedHttpExchange(null, null, now)); EasyMock.expect(expectedScene.getRecordedHttpExchangeList()).andReturn(recordedHttpExchanges); EasyMock.replay(expectedScene); Scene result = runTestGetResult(SceneMode.PLAYBACK, expectedScene); Assert.assertNotNull(result); Assert.assertEquals(result.getName(), NAME); Assert.assertEquals(result.getSceneRoot(), ROOT); Assert.assertTrue(result.isReadable()); Assert.assertEquals(result.getRecordedHttpExchangeList().get(0).getUpdateTime(), now); }