private Scene runTestGetResult(SceneMode scenMode, Scene expectedScene) throws IOException { _sceneReader = EasyMock.createStrictMock(SceneReader.class); SceneConfiguration sceneConfiguration = new SceneConfiguration(ROOT, scenMode, NAME); EasyMock.expect(_sceneReader.readScene(EasyMock.anyString(), EasyMock.anyString())).andReturn(expectedScene); EasyMock.replay(_sceneReader); Scene result = SceneFactory.create(sceneConfiguration, _sceneReader); return result; }
/** * Helper method that will be used for unit test * */ static Scene create(SceneConfiguration sceneConfiguration, SceneReader sceneReader) throws IOException { Scene sceneResult = null; Scene sceneFromLocal = sceneReader.readScene(sceneConfiguration.getSceneRoot(), sceneConfiguration.getSceneName()); if (sceneFromLocal == null) { if (sceneConfiguration.getSceneMode() == SceneMode.PLAYBACK || sceneConfiguration.getSceneMode() == SceneMode.SEQUENTIAL_PLAYBACK) { throw new IllegalStateException(String.format("No Scene is found at %s/%s", sceneConfiguration.getSceneRoot(), sceneConfiguration.getSceneName())); } else { sceneResult = new Scene(sceneConfiguration); } } else { List<RecordedHttpExchange> recordedHttpExchanges = sceneFromLocal.getRecordedHttpExchangeList(); // In sequential record mode, start with an empty scene if (sceneConfiguration.getSceneMode() == SceneMode.SEQUENTIAL_RECORD) { recordedHttpExchanges = new ArrayList<>(); } sceneResult = new Scene(sceneConfiguration.getSceneName(), sceneConfiguration.getSceneMode(), sceneConfiguration.getSceneRoot(), recordedHttpExchanges); } return sceneResult; } }