SuiteMergeStrategy { public static Suite merge(Suite current, Suite lastVersion) { return merge(current, lastVersion, lastVersion); } private  SuiteMergeStrategy(); static Suite merge(Suite current, Suite lastVersion); static Suite merge(Suite current, Suite lastVersion, Suite pattern);  }
@TestWith({"conversion/pattern.json;conversion/current.json"}) public void merge_checkVersionIncrement(String patternResource, String currentResource) throws Exception { final Suite pattern = readSuite(patternResource); final Suite current = readSuite(currentResource); final Suite merged = SuiteMergeStrategy.merge(current, pattern); assertThat(merged.getVersion(), is(2L)); }
@TestWith({"conversion/pattern.json;conversion/current.json"}) public void merge_checkPatternsRewritten(String patternResource, String currentResource) throws Exception { final Suite pattern = readSuite(patternResource); final Suite current = readSuite(currentResource); final Suite merged = SuiteMergeStrategy.merge(current, pattern); final Test test = merged.getTests().get(0); final Url url = test.getUrls().iterator().next(); final Step desktopScreenStep = url.getSteps().get(2); assertThat(desktopScreenStep.getPattern(), is("56ebbed87346a042e67ef462")); }
@TestWith({"conversion/current.json"}) public void merge_checkVersionSetAtFirstRun(String currentResource) throws Exception { final Suite current = readSuite(currentResource); final Suite merged = SuiteMergeStrategy.merge(current, null); assertThat(merged.getVersion(), is(1L)); }
@TestWith({"conversion/pattern.json;conversion/current.json"}) public void merge_checkNewCollectStepAddedAndOldRemoved(String patternResource, String currentResource) throws Exception { final Suite pattern = readSuite(patternResource); final Suite current = readSuite(currentResource); final Suite merged = SuiteMergeStrategy.merge(current, pattern); final Test test = merged.getTests().get(0); final Url url = test.getUrls().iterator().next(); final List<Step> steps = url.getSteps(); assertThat(steps.size(), is(5)); final Step desktopMobileNewStep = steps.get(4); assertThat(desktopMobileNewStep.getType(), is("screen")); assertNull(desktopMobileNewStep.getPattern()); }