RunIndexWrapper { public static void cleanUrlFromExecutionData(Url url) { url.setCollectionStats(null); url.getSteps() .forEach(step -> { step.setStepResult(null); if (step.getComparators() != null) { step.getComparators() .forEach(comparator -> comparator.setStepResult(null) ); } }); } RunIndexWrapper(Run<T> objectToRunWrapper); static void cleanUrlFromExecutionData(Url url); Optional<Url> getTestUrl(String testName, final String urlName); Optional<Test> getTest(String testName); Run<T> get(); abstract List<UrlPacket> getUrlPackets(); abstract int countUrls(); @Override String toString();  }
@Test public void cleanUrlFromExecutionData_whenUrlIsRerunning_expectClearedUrl() { Url realUrl = new Url("urlName", "urlUrl", "urlDomain"); realUrl.setCollectionStats(new Statistics(10)); realUrl.addStep(step); Comparator comparator = new Comparator("comparatorType"); comparator.setStepResult(new ComparatorStepResult("comparatorStepResultName", Status.PASSED)); ArrayList<Operation> listOperation = new ArrayList<>(); listOperation.add(new Operation("operationType")); comparator.setFilters(listOperation); Set<Comparator> comparators = new HashSet<>(); comparators.add(comparator); when(step.getComparators()).thenReturn(comparators); cleanUrlFromExecutionData(realUrl); assertEquals(realUrl.getName(), "urlName"); assertEquals(realUrl.getUrl(), "urlUrl"); assertEquals(realUrl.getDomain(), "urlDomain"); assertNull(realUrl.getCollectionStats()); verify(step, times(1)).setStepResult(null); assertNull(comparator.getStepResult()); assertEquals(comparator.getFilters().size(), 1); }
@Test public void cleanUrlFromExecutionData_whenUrlIsClear_expectTheSameUrl() { Url realUrl = new Url("urlName", "urlUrl", "urlDomain"); realUrl.setCollectionStats(null); realUrl.addStep(step); Comparator comparator = new Comparator("comparatorType"); Set<Comparator> comparators = new HashSet<>(); ArrayList<Operation> listOperation = new ArrayList<>(); listOperation.add(new Operation("operationType")); comparator.setFilters(listOperation); comparators.add(comparator); when(step.getComparators()).thenReturn(comparators); cleanUrlFromExecutionData(realUrl); assertEquals(realUrl.getName(), "urlName"); assertEquals(realUrl.getUrl(), "urlUrl"); assertEquals(realUrl.getDomain(), "urlDomain"); assertNull(realUrl.getCollectionStats()); assertEquals(realUrl.getSteps().size(), 1); verify(step, times(1)).setStepResult(null); assertNull(comparator.getStepResult()); assertEquals(comparator.getFilters().size(), 1); }