/** * here is the place to be used in test case and within this runnable flashback will use this matchRule. * * @param matchRule the match rule, will be loaded into flashback. * @param runnable to call after the match rule loaded. */ protected void withMatchRule(MatchRule matchRule, Runnable runnable) { try { _flashbackRunner.setMatchRule(matchRule); runnable.run(); } finally { _flashbackRunner.setMatchRule(_defaultMatchRule); } }
/** * here is the place to be used in test case and within this callable flashback will use this matchRule. * * @param matchRule the match rule will be loaded info flashback. * @param callable to call after the match rule changed in flashback. * @param <T> return type of the callable. * @return return callable result. * @throws Exception */ protected <T> T withMatchRule(MatchRule matchRule, Callable<T> callable) throws Exception { try { _flashbackRunner.setMatchRule(matchRule); return (T) callable.call(); } finally { _flashbackRunner.setMatchRule(_defaultMatchRule); } }
private void determineDefaultSettings() throws IOException { // if default scenePath hasn't been set, need to figure it out // from either your java default resource folder or home dir. if (_defaultScenePath == null) { _defaultScenePath = HOME_DIR; URL flashbackScene = getClass().getResource(FLASHBACK_SCENE_DIR); if (flashbackScene != null) { _defaultScenePath = flashbackScene.getPath(); } } // if default sceneName is set, it must exist (because by default is PLAYBACK mode) // and we will try to load it. if (_defaultSceneName != null) { SceneConfiguration sceneConfiguration = new SceneConfiguration(_defaultScenePath, _defaultSceneMode, _defaultSceneName); _defaultScene = SceneFactory.create(sceneConfiguration); } // after determined the default Scene&MatchRule for this test class, set them. _flashbackRunner.setScene(_defaultScene); _flashbackRunner.setMatchRule(_defaultMatchRule); }
@Action(name = "changeMatchRule") public void changeMatchRule(@ActionParam("matchRule") String matchRule) { validate(); MatchRule namedMatchRule = NamedMatchRule.fromString(matchRule); if (namedMatchRule == null) { throw new RestLiServiceException(HttpStatus.S_400_BAD_REQUEST, "Unknown match rule" + matchRule); } _flashbackRunner.setMatchRule(namedMatchRule); }