@Test(expectedExceptions = IllegalStateException.class, expectedExceptionsMessageRegExp = SceneAccessLayer.NO_MATCHING_RECORDING_FOUND) public void testPlaybackNoMatchRequest() throws IOException { Scene scene = EasyMock.createStrictMock(Scene.class); EasyMock.expect(scene.isReadable()).andReturn(true); EasyMock.expect(scene.isSequential()).andReturn(false); RecordedHttpExchange recordedHttpExchange1 = EasyMock.createStrictMock(RecordedHttpExchange.class); RecordedHttpExchange recordedHttpExchange2 = EasyMock.createStrictMock(RecordedHttpExchange.class); RecordedHttpRequest recordedHttpRequest1 = EasyMock.createStrictMock(RecordedHttpRequest.class); RecordedHttpRequest recordedHttpRequest2 = EasyMock.createStrictMock(RecordedHttpRequest.class); EasyMock.expect(recordedHttpExchange1.getRecordedHttpRequest()).andReturn(recordedHttpRequest1); EasyMock.expect(recordedHttpExchange2.getRecordedHttpRequest()).andReturn(recordedHttpRequest2); RecordedHttpRequest incomingHttpRequest = EasyMock.createStrictMock(RecordedHttpRequest.class); ArrayList<RecordedHttpExchange> recordedHttpExchangeArrayList = new ArrayList<>(); recordedHttpExchangeArrayList.add(recordedHttpExchange1); recordedHttpExchangeArrayList.add(recordedHttpExchange2); EasyMock.expect(scene.getRecordedHttpExchangeList()).andReturn(recordedHttpExchangeArrayList); SceneWriter sceneWriter = EasyMock.createStrictMock(SceneWriter.class); MatchRule matchRule = EasyMock.createStrictMock(MatchRule.class); EasyMock.expect(matchRule.test(incomingHttpRequest, recordedHttpRequest1)).andReturn(false); EasyMock.expect(matchRule.test(incomingHttpRequest, recordedHttpRequest2)).andReturn(false); EasyMock.replay(scene, recordedHttpExchange1, recordedHttpExchange2, matchRule); SceneAccessLayer sceneAccessLayer = new SceneAccessLayer(scene, sceneWriter, matchRule); sceneAccessLayer.playback(incomingHttpRequest); EasyMock.verify(scene, recordedHttpExchange1, recordedHttpExchange2, matchRule); }
public RecordedHttpResponse playback(RecordedHttpRequest request) { if (!_scene.isReadable()) { throw new IllegalStateException(THE_SCENE_IS_NOT_READABLE); } int position = findMatchRequest(request); if (position < 0) { throw new IllegalStateException(NO_MATCHING_RECORDING_FOUND); } if (_scene.isSequential()) { _sequencePosition++; } List<RecordedHttpExchange> recordedHttpExchangeList = _scene.getRecordedHttpExchangeList(); return recordedHttpExchangeList.get(position).getRecordedHttpResponse(); }
SceneAccessLayer { public RecordedHttpResponse playback(RecordedHttpRequest request) { if (!_scene.isReadable()) { throw new IllegalStateException(THE_SCENE_IS_NOT_READABLE); } int position = findMatchRequest(request); if (position < 0) { throw new IllegalStateException(NO_MATCHING_RECORDING_FOUND); } if (_scene.isSequential()) { _sequencePosition++; } List<RecordedHttpExchange> recordedHttpExchangeList = _scene.getRecordedHttpExchangeList(); return recordedHttpExchangeList.get(position).getRecordedHttpResponse(); } }
SceneAccessLayer { public RecordedHttpResponse playback(RecordedHttpRequest request) { if (!_scene.isReadable()) { throw new IllegalStateException(THE_SCENE_IS_NOT_READABLE); } int position = findMatchRequest(request); if (position < 0) { throw new IllegalStateException(NO_MATCHING_RECORDING_FOUND); } if (_scene.isSequential()) { _sequencePosition++; } List<RecordedHttpExchange> recordedHttpExchangeList = _scene.getRecordedHttpExchangeList(); return recordedHttpExchangeList.get(position).getRecordedHttpResponse(); } SceneAccessLayer(Scene scene, SceneWriter sceneWriter, MatchRule matchRule);  SceneAccessLayer(Scene scene, MatchRule matchRule);  SceneAccessLayer(); }
SceneAccessLayer { public RecordedHttpResponse playback(RecordedHttpRequest request) { if (!_scene.isReadable()) { throw new IllegalStateException(THE_SCENE_IS_NOT_READABLE); } int position = findMatchRequest(request); if (position < 0) { throw new IllegalStateException(NO_MATCHING_RECORDING_FOUND); } if (_scene.isSequential()) { _sequencePosition++; } List<RecordedHttpExchange> recordedHttpExchangeList = _scene.getRecordedHttpExchangeList(); return recordedHttpExchangeList.get(position).getRecordedHttpResponse(); } SceneAccessLayer(Scene scene, SceneWriter sceneWriter, MatchRule matchRule);  SceneAccessLayer(Scene scene, MatchRule matchRule);  SceneAccessLayer(); String getSceneName(); void setMatchRule(MatchRule matchRule); void setScene(Scene scene); boolean canPlayback(); boolean hasMatchRequest(RecordedHttpRequest request); RecordedHttpResponse playback(RecordedHttpRequest request); void record(RecordedHttpRequest recordedHttpRequest, RecordedHttpResponse recordedHttpResponse); void flush(); String getMatchFailureDescription(RecordedHttpRequest request); }
SceneAccessLayer { public RecordedHttpResponse playback(RecordedHttpRequest request) { if (!_scene.isReadable()) { throw new IllegalStateException(THE_SCENE_IS_NOT_READABLE); } int position = findMatchRequest(request); if (position < 0) { throw new IllegalStateException(NO_MATCHING_RECORDING_FOUND); } if (_scene.isSequential()) { _sequencePosition++; } List<RecordedHttpExchange> recordedHttpExchangeList = _scene.getRecordedHttpExchangeList(); return recordedHttpExchangeList.get(position).getRecordedHttpResponse(); } SceneAccessLayer(Scene scene, SceneWriter sceneWriter, MatchRule matchRule);  SceneAccessLayer(Scene scene, MatchRule matchRule);  SceneAccessLayer(); String getSceneName(); void setMatchRule(MatchRule matchRule); void setScene(Scene scene); boolean canPlayback(); boolean hasMatchRequest(RecordedHttpRequest request); RecordedHttpResponse playback(RecordedHttpRequest request); void record(RecordedHttpRequest recordedHttpRequest, RecordedHttpResponse recordedHttpResponse); void flush(); String getMatchFailureDescription(RecordedHttpRequest request);  }