JsErrorsComparator implements ComparatorJob { @Override @SuppressWarnings("unchecked") public ComparatorStepResult compare() throws ProcessingException { final ComparatorStepResult result; LOGGER.info("Starting JS Error Comparison with parameters {}.", comparatorProperties); try { Set<JsErrorLog> jsErrorLogs = getCollectedResult(); for (DataFilterJob<Set<JsErrorLog>> dataFilterJob : dataFilterJobs) { jsErrorLogs = dataFilterJob.modifyData(jsErrorLogs); } LOGGER.info("Successfully ended data modifications using {}.", comparatorProperties); String artifactId = null; if (!jsErrorLogs.isEmpty()) { artifactId = artifactsDAO.saveArtifactInJsonFormat(comparatorProperties, jsErrorLogs); } if (noErrorsOrIgnoredOnly(jsErrorLogs)) { result = new ComparatorStepResult(artifactId, ComparatorStepResult.Status.PASSED); } else { result = new ComparatorStepResult(artifactId, ComparatorStepResult.Status.FAILED); } } catch (Exception e) { throw new ProcessingException("Failed to obtain Js Errors Collection Result!", e); } return result; } JsErrorsComparator(ComparatorProperties comparatorProperties, List<DataFilterJob> dataFilterJobs,
      ArtifactsDAO artifactsDAO); @Override @SuppressWarnings("unchecked") ComparatorStepResult compare(); @Override void setParameters(Map<String, String> params); static final String COMPARATOR_TYPE; static final String COMPARATOR_NAME; }
@Test public void testFailed() throws Exception { comparatorProperties = new ComparatorProperties(TEST_COMPANY, TEST_PROJECT, null, "data-result.json"); tested = new JsErrorsComparator(comparatorProperties, new ArrayList<DataFilterJob>(), artifactDaoMock); result = tested.compare(); assertEqualsToSavedArtifact("expected-result.json"); assertEquals(ComparatorStepResult.Status.FAILED, result.getStatus()); }
@Test public void testSuccess() throws Exception { comparatorProperties = new ComparatorProperties(TEST_COMPANY, TEST_PROJECT, null, "data-empty-result.json"); tested = new JsErrorsComparator(comparatorProperties, new ArrayList<DataFilterJob>(), artifactDaoMock); result = tested.compare(); assertEquals(null, getActual()); assertEquals(ComparatorStepResult.Status.PASSED, result.getStatus()); }