From b04bcf41497a054a3c9af0fc97cd0500e3103f79 Mon Sep 17 00:00:00 2001 From: plutasnyy Date: Tue, 31 Jul 2018 11:22:54 +0200 Subject: [PATCH 01/17] added lower bound for filterrange --- .../comparators/statuscodes/StatusCodesComparator.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/jobs/src/main/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparator.java b/core/jobs/src/main/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparator.java index 8c89ee55f..f3cab996c 100644 --- a/core/jobs/src/main/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparator.java +++ b/core/jobs/src/main/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparator.java @@ -40,6 +40,8 @@ public class StatusCodesComparator implements ComparatorJob { private static final Logger LOGGER = LoggerFactory.getLogger(StatusCodesComparator.class); + private static final int DEFAULT_FILTER_RANGE_LOWER_BOUND = 400; + private static final int DEFAULT_FILTER_RANGE_UPPER_BOUND = 600; public static final String COMPARATOR_TYPE = "status-codes"; @@ -53,6 +55,7 @@ public class StatusCodesComparator implements ComparatorJob { private static final String PARAM_DELIMITER = ","; private static final String PARAM_SHOW_EXCLUDED = "showExcluded"; + private static final Type RESULT_TYPE = new TypeToken() { }.getType(); @@ -60,7 +63,7 @@ public class StatusCodesComparator implements ComparatorJob { private final ComparatorProperties properties; - private int filterRangeLowerBound; + private int filterRangeLowerBound = DEFAULT_FILTER_RANGE_LOWER_BOUND; private int filterRangeUpperBound = DEFAULT_FILTER_RANGE_UPPER_BOUND; From a02d7b0e0718629bee4adf965081c8feb7f8876a Mon Sep 17 00:00:00 2001 From: plutasnyy Date: Tue, 31 Jul 2018 12:41:10 +0200 Subject: [PATCH 02/17] changed unit tests to be correct with logic or in status code filter --- .../comparators/statuscodes/StatusCodesComparatorTest.java | 6 +++--- .../comparators/statuscodes/StatusCodesFilterTest.java | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparatorTest.java b/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparatorTest.java index 110f12e69..812ec7ab7 100644 --- a/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparatorTest.java +++ b/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparatorTest.java @@ -96,7 +96,7 @@ public void setUp() { @Test public void compareTest() throws ProcessingException { result = tested.compare(); - assertEquals(ComparatorStepResult.Status.FAILED, result.getStatus()); + assertEquals(ComparatorStepResult.Status.PASSED, result.getStatus()); } @Test @@ -105,7 +105,7 @@ public void compareTest_filterRange() throws ProcessingException { when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE); result = tested.compare(); - assertEquals(ComparatorStepResult.Status.FAILED, result.getStatus()); + assertEquals(ComparatorStepResult.Status.PASSED, result.getStatus()); } @Test @@ -115,7 +115,7 @@ public void compareTest_filterCodes() throws ProcessingException { when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_MULTIPLE); result = tested.compare(); - assertEquals(ComparatorStepResult.Status.FAILED, result.getStatus()); + assertEquals(ComparatorStepResult.Status.PASSED, result.getStatus()); } @Test diff --git a/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesFilterTest.java b/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesFilterTest.java index cafc9df97..c4283867e 100644 --- a/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesFilterTest.java +++ b/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesFilterTest.java @@ -93,7 +93,7 @@ public void testFilter_bounds(int lowerBound, int upperBound, int expectedSize) assertThat(result.size(), is(expectedSize)); } - @TestWith({"100;200;201,3", "400;401;499,3", "404,3"}) + @TestWith({"100;200;201,18", "400;401;499,18", "404,18"}) public void testFilter_filterCodes(String filterCodesParam, int expectedSize) { tested = getTested(0, 600, prepareFilterCodes(filterCodesParam)); @@ -102,7 +102,7 @@ public void testFilter_filterCodes(String filterCodesParam, int expectedSize) { assertThat(result.size(), is(expectedSize)); } - @TestWith({"100;200;201,100,200,2", "400;401;499,100,400,1"}) + @TestWith({"100;200;201,100,200,5", "400;401;499,100,400,12"}) public void testFilter_boundsWithfilterCodes(String filterCodesParam, int lowerBound, int upperBound, int expectedSize) { From b1680893354a71d0ac13fa4e24e2974dc6648a46 Mon Sep 17 00:00:00 2001 From: plutasnyy Date: Tue, 31 Jul 2018 12:44:34 +0200 Subject: [PATCH 03/17] changed logical expresion in status codes filter --- .../statuscodes/StatusCodesFilter.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/core/jobs/src/main/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesFilter.java b/core/jobs/src/main/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesFilter.java index 13f40e1d1..2fd255e2f 100644 --- a/core/jobs/src/main/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesFilter.java +++ b/core/jobs/src/main/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesFilter.java @@ -42,19 +42,22 @@ private class StatusCodeFilterPredicate implements Predicate { @Override public boolean apply(StatusCode statusCode) { - if (statusCode.getCode() < lowerBound) { - return false; - } - if (statusCode.getCode() > upperBound) { - return false; - } - if (!filterCodes.isEmpty() && !filterCodes.contains(statusCode.getCode())) { - return false; - } + if (statusCode.getCode() < 0) { return false; } - return true; + if (isCodeInRange(statusCode) || isCodeInFilterCodes(statusCode)) { + return true; + } + return false; + } + + private boolean isCodeInFilterCodes(StatusCode statusCode) { + return !filterCodes.isEmpty() && filterCodes.contains(statusCode.getCode()); + } + + private boolean isCodeInRange(StatusCode statusCode) { + return statusCode.getCode() >= lowerBound && statusCode.getCode() <= upperBound; } } } From 08a70118f7af2135f72ddb4ffc2330d66ef26132 Mon Sep 17 00:00:00 2001 From: plutasnyy Date: Tue, 31 Jul 2018 13:33:39 +0200 Subject: [PATCH 04/17] added in documentation information about status code comparator --- documentation/src/main/wiki/StatusCodesComparator.md | 5 +++-- documentation/src/main/wiki/StatusCodesDataFilters.md | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/documentation/src/main/wiki/StatusCodesComparator.md b/documentation/src/main/wiki/StatusCodesComparator.md index 46f3d788b..26ca6e84e 100644 --- a/documentation/src/main/wiki/StatusCodesComparator.md +++ b/documentation/src/main/wiki/StatusCodesComparator.md @@ -12,9 +12,10 @@ Resource name: status-codes | Parameter | Value | Example | Description | Mandatory | | --------- | ----- | ------- | ----------- | --------- | -| `filterRange` | x,y | 400,500 | Defines range of status codes that should be processed | yes, if `filterCodes` is not present | -| `filterCodes` | x,y,z | 400,401,404 | List of status codes that should be processed | yes, if `filterRange` is not present | +| `filterRange` | x,y (default: `400,600`) | 400,500 | Defines range of status codes that should be processed | no | +| `filterCodes` | x,y,z | 400,401,404 | List of status codes that should be processed | no | | `showExcluded` | boolean (default: `true`) | true | Flag that says if excluded codes (see [[Status Codes Data Filters | StatusCodesDataFilters]]) should be displayed in report. By default set to `true`. | no | +If you provide `filterRange` and `filterCodes`, it will be used as logical sum. It means that `filterRange="400,500"` `filterCodes=501,502` is equivalent to `filterRange="400,502"` but for `filterRange="300,400"` `filterCodes=404` all codes between `401-403` won`t be checked. ##### Example Usage diff --git a/documentation/src/main/wiki/StatusCodesDataFilters.md b/documentation/src/main/wiki/StatusCodesDataFilters.md index 7da38ef58..037f39beb 100644 --- a/documentation/src/main/wiki/StatusCodesDataFilters.md +++ b/documentation/src/main/wiki/StatusCodesDataFilters.md @@ -1,5 +1,7 @@ #### Status Codes Data Filters +Data filters will be apply only for codes contained in the `filterange`. If the `filterRange` isn't provided, default range will be used. + ##### Exclude Filter Exclude Filter removes from reports Status Codes results that match specified parameters. From e34670c87cb1b0c70d47e32ed1966df6a8399373 Mon Sep 17 00:00:00 2001 From: plutasnyy Date: Tue, 31 Jul 2018 13:58:22 +0200 Subject: [PATCH 05/17] changed status-codes suites to work properly with changed logical expresion in status code filter --- .../test-suite/partials/status-codes.xml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/integration-tests/test-suite/partials/status-codes.xml b/integration-tests/test-suite/partials/status-codes.xml index baba9af97..235dd54dd 100644 --- a/integration-tests/test-suite/partials/status-codes.xml +++ b/integration-tests/test-suite/partials/status-codes.xml @@ -32,11 +32,24 @@ - + + + + + + + + + + + + + + @@ -255,7 +268,7 @@ - + @@ -304,7 +317,7 @@ - + From 21a4cae45ca6898621c907a14c7883486f6bb921 Mon Sep 17 00:00:00 2001 From: plutasnyy Date: Wed, 1 Aug 2018 15:54:42 +0200 Subject: [PATCH 06/17] updated changelog and documentation --- CHANGELOG.md | 1 + documentation/src/main/wiki/StatusCodesComparator.md | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 125e4b8a7..94213d1b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to AET will be documented in this file. ## Unreleased **List of changes that are finished but not yet released in any final version.** +- [PR-296](https://github.com/Cognifide/aet/pull/296) The behavior of StatusCodesComparator was changed - [PR-289](https://github.com/Cognifide/aet/pull/289) User now stays on the same tab while navigating between URLs - [PR-271](https://github.com/Cognifide/aet/pull/271) Added possibility to override name parameter from the aet client - [PR-268](https://github.com/Cognifide/aet/pull/268) Bobcat upgrade to version 1.4.0 diff --git a/documentation/src/main/wiki/StatusCodesComparator.md b/documentation/src/main/wiki/StatusCodesComparator.md index 26ca6e84e..203bd3d96 100644 --- a/documentation/src/main/wiki/StatusCodesComparator.md +++ b/documentation/src/main/wiki/StatusCodesComparator.md @@ -15,7 +15,10 @@ Resource name: status-codes | `filterRange` | x,y (default: `400,600`) | 400,500 | Defines range of status codes that should be processed | no | | `filterCodes` | x,y,z | 400,401,404 | List of status codes that should be processed | no | | `showExcluded` | boolean (default: `true`) | true | Flag that says if excluded codes (see [[Status Codes Data Filters | StatusCodesDataFilters]]) should be displayed in report. By default set to `true`. | no | -If you provide `filterRange` and `filterCodes`, it will be used as logical sum. It means that `filterRange="400,500"` `filterCodes=501,502` is equivalent to `filterRange="400,502"` but for `filterRange="300,400"` `filterCodes=404` all codes between `401-403` won`t be checked. + +If you provide both `filterRange` and `filterCodes`, it will be used as logical sum. It means that: + - `` is equivalent to `` + - `` won't check `401-403` codes. ##### Example Usage From 382696c74e266d1d536d8318baf2efe5051e7f7a Mon Sep 17 00:00:00 2001 From: plutasnyy Date: Fri, 3 Aug 2018 13:49:30 +0200 Subject: [PATCH 07/17] updated tests --- .../cognifide/aet/sanity/functional/HomePageTilesTest.java | 4 ++-- .../src/test/resources/features/filtering.feature | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/integration-tests/sanity-functional/src/test/java/com/cognifide/aet/sanity/functional/HomePageTilesTest.java b/integration-tests/sanity-functional/src/test/java/com/cognifide/aet/sanity/functional/HomePageTilesTest.java index 9ef03e614..3d41f365c 100644 --- a/integration-tests/sanity-functional/src/test/java/com/cognifide/aet/sanity/functional/HomePageTilesTest.java +++ b/integration-tests/sanity-functional/src/test/java/com/cognifide/aet/sanity/functional/HomePageTilesTest.java @@ -29,13 +29,13 @@ @Modules(GuiceModule.class) public class HomePageTilesTest { - private static final int TESTS = 113; + private static final int TESTS = 114; private static final int EXPECTED_TESTS_SUCCESS = 66; private static final int EXPECTED_TESTS_WARN = 5; - private static final int EXPECTED_TESTS_FAIL = 42; + private static final int EXPECTED_TESTS_FAIL = 43; @Inject private ReportHomePage page; diff --git a/integration-tests/sanity-functional/src/test/resources/features/filtering.feature b/integration-tests/sanity-functional/src/test/resources/features/filtering.feature index f10a12479..9b4143318 100644 --- a/integration-tests/sanity-functional/src/test/resources/features/filtering.feature +++ b/integration-tests/sanity-functional/src/test/resources/features/filtering.feature @@ -55,8 +55,8 @@ Feature: Tests Results Filtering Scenario: Filtering Tests Results: status-codes Given I have opened sample tests report page When I search for tests containing "status" - Then There are 20 tiles visible - And Statistics text contains "20 ( 8 / 0 / 12 / 0 )" + Then There are 21 tiles visible + And Statistics text contains "21 ( 9 / 0 / 12 / 0 )" Scenario: Filtering Tests Results: w3c-html5 Given I have opened sample tests report page From ae809bc1711a99e09cb26e3979448621dfe8e70b Mon Sep 17 00:00:00 2001 From: Wiiitek Date: Sun, 5 Aug 2018 19:45:06 +0200 Subject: [PATCH 08/17] unit test formatting --- .../StatusCodesComparatorTest.java | 25 ++++--------------- .../statuscodes/StatusCodesFilterTest.java | 2 +- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparatorTest.java b/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparatorTest.java index 812ec7ab7..ad348d91e 100644 --- a/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparatorTest.java +++ b/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparatorTest.java @@ -20,7 +20,6 @@ import com.cognifide.aet.communication.api.metadata.ComparatorStepResult; import com.cognifide.aet.job.api.comparator.ComparatorProperties; -import com.cognifide.aet.job.api.datafilter.DataFilterJob; import com.cognifide.aet.job.api.exceptions.ParametersException; import com.cognifide.aet.job.api.exceptions.ProcessingException; import com.cognifide.aet.job.common.ArtifactDAOMock; @@ -83,9 +82,7 @@ public void setUp() { artifactDaoMock = new ArtifactDAOMock(StatusCodesComparator.class); comparatorProperties = new ComparatorProperties(TEST_COMPANY, TEST_PROJECT, null, "expected-data-200-result.json"); - tested = new StatusCodesComparator(artifactDaoMock, comparatorProperties, - new ArrayList()); - artifactDaoMock = new ArtifactDAOMock(SourceComparator.class); + tested = new StatusCodesComparator(artifactDaoMock, comparatorProperties, new ArrayList<>()); initStatusCodes(); when(dataResult.getStatusCodes()).thenReturn(statusCodes); @@ -202,8 +199,10 @@ public void setParameters_filterCodesMultipleValuesNotANumber() throws Parameter } private void initStatusCodes() { - statusCodes = new StatusCodesBuilder().add(404, 303, 500, 501, 302, 200, 400, 201) - .add(404, "http://www.example.com/image.png").build(); + statusCodes = new StatusCodesBuilder() + .add(404, 303, 500, 501, 302, 200, 400, 201) + .add(404, "http://www.example.com/image.png") + .build(); } private static class StatusCodesBuilder { @@ -216,13 +215,6 @@ private StatusCodesBuilder() { this.codes = Lists.newArrayList(); } - public StatusCodesBuilder add(int code) { - codes.add(new StatusCode(code, DEFAULT_URL)); - return this; - } - - ; - public StatusCodesBuilder add(Integer... httpCodes) { for (Integer httpCode : httpCodes) { codes.add(new StatusCode(httpCode, DEFAULT_URL)); @@ -230,20 +222,13 @@ public StatusCodesBuilder add(Integer... httpCodes) { return this; } - ; - public StatusCodesBuilder add(int code, String url) { codes.add(new StatusCode(code, url)); return this; } - ; - public List build() { return codes; } - - ; - } } diff --git a/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesFilterTest.java b/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesFilterTest.java index c4283867e..21f01eb56 100644 --- a/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesFilterTest.java +++ b/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesFilterTest.java @@ -103,7 +103,7 @@ public void testFilter_filterCodes(String filterCodesParam, int expectedSize) { } @TestWith({"100;200;201,100,200,5", "400;401;499,100,400,12"}) - public void testFilter_boundsWithfilterCodes(String filterCodesParam, int lowerBound, + public void testFilter_boundsWithFilterCodes(String filterCodesParam, int lowerBound, int upperBound, int expectedSize) { tested = getTested(lowerBound, upperBound, prepareFilterCodes(filterCodesParam)); From 640ed481ec97f2193bc46ed1a9a99fec33f45de2 Mon Sep 17 00:00:00 2001 From: plutasnyy Date: Mon, 6 Aug 2018 08:21:01 +0200 Subject: [PATCH 09/17] updated documentation --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 28a14d038..6099d9e07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ All notable changes to AET will be documented in this file. ## Unreleased **List of changes that are finished but not yet released in any final version.** -- [PR-296](https://github.com/Cognifide/aet/pull/296) The behavior of StatusCodesComparator was changed +- [PR-296](https://github.com/Cognifide/aet/pull/296) Status Code Comparator check now range 400-600 by default, parameters validation added - [PR-289](https://github.com/Cognifide/aet/pull/289) User now stays on the same tab while navigating between URLs - [PR-271](https://github.com/Cognifide/aet/pull/271) Added possibility to override name parameter from the aet client - [PR-268](https://github.com/Cognifide/aet/pull/268) Bobcat upgrade to version 1.4.0 From fa611476208488ffb65579ac3361420b2b1f30b8 Mon Sep 17 00:00:00 2001 From: plutasnyy Date: Mon, 6 Aug 2018 08:25:28 +0200 Subject: [PATCH 10/17] removed unused mock --- .../comparators/statuscodes/StatusCodesComparatorTest.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparatorTest.java b/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparatorTest.java index ad348d91e..d8c23b315 100644 --- a/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparatorTest.java +++ b/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparatorTest.java @@ -69,9 +69,6 @@ public class StatusCodesComparatorTest extends AbstractComparatorTest { @Mock private Map params; - @Mock - private StatusCodesCollectorResult dataResult; - @Mock private ComparatorProperties comparatorProperties; @@ -84,7 +81,6 @@ public void setUp() { "expected-data-200-result.json"); tested = new StatusCodesComparator(artifactDaoMock, comparatorProperties, new ArrayList<>()); initStatusCodes(); - when(dataResult.getStatusCodes()).thenReturn(statusCodes); when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(false); when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(false); From ecee6ff180bf044191c93cbeee64272edad4320e Mon Sep 17 00:00:00 2001 From: plutasnyy Date: Mon, 6 Aug 2018 10:19:28 +0200 Subject: [PATCH 11/17] updated tests --- .../StatusCodesComparatorTest.java | 225 ++++++++++++++---- .../a-lot-of-errors-with-exclude-result.json | 58 +++++ .../default-range-399-601-errors-result.json | 27 +++ .../default-range-400-600-errors-result.json | 27 +++ .../not-existing-page-404-result.json | 22 ++ 5 files changed, 311 insertions(+), 48 deletions(-) create mode 100644 core/jobs/src/test/resources/mock/StatusCodesComparator/a-lot-of-errors-with-exclude-result.json create mode 100644 core/jobs/src/test/resources/mock/StatusCodesComparator/default-range-399-601-errors-result.json create mode 100644 core/jobs/src/test/resources/mock/StatusCodesComparator/default-range-400-600-errors-result.json create mode 100644 core/jobs/src/test/resources/mock/StatusCodesComparator/not-existing-page-404-result.json diff --git a/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparatorTest.java b/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparatorTest.java index d8c23b315..8b301d76d 100644 --- a/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparatorTest.java +++ b/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparatorTest.java @@ -19,17 +19,13 @@ import static org.mockito.Mockito.when; import com.cognifide.aet.communication.api.metadata.ComparatorStepResult; +import com.cognifide.aet.communication.api.metadata.ComparatorStepResult.Status; import com.cognifide.aet.job.api.comparator.ComparatorProperties; import com.cognifide.aet.job.api.exceptions.ParametersException; import com.cognifide.aet.job.api.exceptions.ProcessingException; import com.cognifide.aet.job.common.ArtifactDAOMock; -import com.cognifide.aet.job.common.collectors.statuscodes.StatusCode; -import com.cognifide.aet.job.common.collectors.statuscodes.StatusCodesCollectorResult; import com.cognifide.aet.job.common.comparators.AbstractComparatorTest; -import com.cognifide.aet.job.common.comparators.source.SourceComparator; -import com.google.common.collect.Lists; import java.util.ArrayList; -import java.util.List; import java.util.Map; import org.junit.Before; import org.junit.Test; @@ -64,6 +60,12 @@ public class StatusCodesComparatorTest extends AbstractComparatorTest { private static final String FILTER_CODES_MULTIPLE_NAN = "NaN,NaN,NaN,NaN"; + private static final String FILTER_CODES_ONLY_SUCCESS = "200"; + + private static final String FILTER_RANGE_REMOVE_DEFAULT_RANGE = "1,1"; + + private static final String FILTER_CODES_EXCLUDED = "500"; + private StatusCodesComparator tested; @Mock @@ -72,47 +74,185 @@ public class StatusCodesComparatorTest extends AbstractComparatorTest { @Mock private ComparatorProperties comparatorProperties; - private List statusCodes; - @Before public void setUp() { artifactDaoMock = new ArtifactDAOMock(StatusCodesComparator.class); - comparatorProperties = new ComparatorProperties(TEST_COMPANY, TEST_PROJECT, null, - "expected-data-200-result.json"); - tested = new StatusCodesComparator(artifactDaoMock, comparatorProperties, new ArrayList<>()); - initStatusCodes(); - when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(false); when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(false); } @Test - public void compareTest() throws ProcessingException { + public void compareTest_expectPassed() throws ProcessingException { + tested = createNewStatusCodesComparator("expected-data-200-result.json"); + + result = tested.compare(); + assertEquals(ComparatorStepResult.Status.PASSED, result.getStatus()); + } + + @Test + public void compareTest_expectFailed() throws ProcessingException, ParametersException { + tested = createNewStatusCodesComparator("expected-data-200-result.json"); + + when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); + when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_ONLY_SUCCESS); + tested.setParameters(params); + + result = tested.compare(); + assertEquals(ComparatorStepResult.Status.FAILED, result.getStatus()); + } + + @Test + public void compareTest_filterRange_expectPassed() + throws ProcessingException, ParametersException { + tested = createNewStatusCodesComparator("not-existing-page-404-result.json"); + + when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); + when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE_REMOVE_DEFAULT_RANGE); + tested.setParameters(params); + result = tested.compare(); assertEquals(ComparatorStepResult.Status.PASSED, result.getStatus()); } @Test - public void compareTest_filterRange() throws ProcessingException { - // filter only by range + public void compareTest_filterRange_expectFailed() + throws ProcessingException, ParametersException { + tested = createNewStatusCodesComparator("not-existing-page-404-result.json"); + when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE); + tested.setParameters(params); + + result = tested.compare(); + assertEquals(ComparatorStepResult.Status.FAILED, result.getStatus()); + } + + @Test + public void compareTest_filterCodes_expectPassed() + throws ProcessingException, ParametersException { + tested = createNewStatusCodesComparator("not-existing-page-404-result.json"); + + when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); + when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_ONLY_SUCCESS); + when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); + when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE_REMOVE_DEFAULT_RANGE); + tested.setParameters(params); + result = tested.compare(); assertEquals(ComparatorStepResult.Status.PASSED, result.getStatus()); } @Test - public void compareTest_filterCodes() throws ProcessingException { - // filter only by codes + public void compareTest_filterCodes_expectFailed() + throws ProcessingException, ParametersException { + tested = createNewStatusCodesComparator("not-existing-page-404-result.json"); + + when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); + when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_MULTIPLE); + when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); + when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE_REMOVE_DEFAULT_RANGE); + tested.setParameters(params); + + result = tested.compare(); + assertEquals(ComparatorStepResult.Status.FAILED, result.getStatus()); + } + + @Test + public void compareTest_filterCodesMultipleCodes_expectFailed() + throws ProcessingException, ParametersException { + tested = createNewStatusCodesComparator("not-existing-page-404-result.json"); + + when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); + when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_MULTIPLE); + when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); + when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE_REMOVE_DEFAULT_RANGE); + tested.setParameters(params); + + result = tested.compare(); + assertEquals(ComparatorStepResult.Status.FAILED, result.getStatus()); + } + + @Test + public void compareTest_filterCodesAndFilterRange_expectFailed() + throws ParametersException, ProcessingException { + tested = createNewStatusCodesComparator("a-lot-of-errors-with-exclude-result.json"); + + when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); + + when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE); + tested.setParameters(params); + + result = tested.compare(); + assertEquals(ComparatorStepResult.Status.FAILED, result.getStatus()); + when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_MULTIPLE); + when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE_REMOVE_DEFAULT_RANGE); + tested.setParameters(params); + + result = tested.compare(); + assertEquals(ComparatorStepResult.Status.FAILED, result.getStatus()); + + when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_MULTIPLE); + when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE); + tested.setParameters(params); + + result = tested.compare(); + assertEquals(ComparatorStepResult.Status.FAILED, result.getStatus()); + } + + @Test + public void compareTest_filterCodesAndFilterRange_expectPassed() + throws ParametersException, ProcessingException { + tested = createNewStatusCodesComparator("a-lot-of-errors-with-exclude-result.json"); + + when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); + when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); + + when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_SINGLE); + when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE_REMOVE_DEFAULT_RANGE); + tested.setParameters(params); + + result = tested.compare(); + assertEquals(Status.PASSED, result.getStatus()); + } + + @Test + public void compareTest_testExclude_expectPassed() + throws ParametersException, ProcessingException { + tested = createNewStatusCodesComparator("a-lot-of-errors-with-exclude-result.json"); + + when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); + when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_EXCLUDED); + when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); + when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE_REMOVE_DEFAULT_RANGE); + + tested.setParameters(params); + + result = tested.compare(); + assertEquals(ComparatorStepResult.Status.PASSED, result.getStatus()); + } + + @Test + public void compareTest_defaultRange_expectPassed() throws ProcessingException { + tested = createNewStatusCodesComparator("default-range-399-601-errors-result.json"); result = tested.compare(); assertEquals(ComparatorStepResult.Status.PASSED, result.getStatus()); } + @Test + public void compareTest_defaultRange_expectFailed() throws ProcessingException { + tested = createNewStatusCodesComparator("default-range-400-600-errors-result.json"); + + result = tested.compare(); + assertEquals(ComparatorStepResult.Status.FAILED, result.getStatus()); + } + @Test public void setParameters() throws ParametersException { + tested = createNewStatusCodesComparator("expected-data-200-result.json"); + when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE); when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); @@ -124,6 +264,8 @@ public void setParameters() throws ParametersException { @Test public void setParameters_filterRange() throws ParametersException { + tested = createNewStatusCodesComparator("expected-data-200-result.json"); + when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE); @@ -133,6 +275,8 @@ public void setParameters_filterRange() throws ParametersException { @Test(expected = ParametersException.class) public void setParameters_filterRangeInvalid() throws ParametersException { + tested = createNewStatusCodesComparator("expected-data-200-result.json"); + when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE_INVALID); @@ -142,6 +286,8 @@ public void setParameters_filterRangeInvalid() throws ParametersException { @Test(expected = ParametersException.class) public void setParameters_filterRangeNotANumber() throws ParametersException { + tested = createNewStatusCodesComparator("expected-data-200-result.json"); + when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE_NAN); @@ -151,6 +297,8 @@ public void setParameters_filterRangeNotANumber() throws ParametersException { @Test(expected = ParametersException.class) public void setParameters_filterRangeUpperBoundLessThanLowerBound() throws ParametersException { + tested = createNewStatusCodesComparator("expected-data-200-result.json"); + when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE_UPPER_LESS_THAN_LOWER); @@ -160,6 +308,8 @@ public void setParameters_filterRangeUpperBoundLessThanLowerBound() throws Param @Test public void setParameters_filterCodes() throws ParametersException { + tested = createNewStatusCodesComparator("expected-data-200-result.json"); + when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_SINGLE); @@ -169,6 +319,8 @@ public void setParameters_filterCodes() throws ParametersException { @Test public void setParameters_filterCodesMultipleValues() throws ParametersException { + tested = createNewStatusCodesComparator("expected-data-200-result.json"); + when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_MULTIPLE); @@ -178,6 +330,8 @@ public void setParameters_filterCodesMultipleValues() throws ParametersException @Test(expected = ParametersException.class) public void setParameters_filterCodesNotANumber() throws ParametersException { + tested = createNewStatusCodesComparator("expected-data-200-result.json"); + when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_SINGLE_NAN); @@ -187,6 +341,8 @@ public void setParameters_filterCodesNotANumber() throws ParametersException { @Test(expected = ParametersException.class) public void setParameters_filterCodesMultipleValuesNotANumber() throws ParametersException { + tested = createNewStatusCodesComparator("expected-data-200-result.json"); + when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_MULTIPLE_NAN); @@ -194,37 +350,10 @@ public void setParameters_filterCodesMultipleValuesNotANumber() throws Parameter tested.setParameters(params); } - private void initStatusCodes() { - statusCodes = new StatusCodesBuilder() - .add(404, 303, 500, 501, 302, 200, 400, 201) - .add(404, "http://www.example.com/image.png") - .build(); + private StatusCodesComparator createNewStatusCodesComparator(String pathToJson) { + comparatorProperties = new ComparatorProperties(TEST_COMPANY, TEST_PROJECT, null, + pathToJson); + return new StatusCodesComparator(artifactDaoMock, comparatorProperties, new ArrayList<>()); } - private static class StatusCodesBuilder { - - private static final String DEFAULT_URL = "http://www.example.com"; - - private final List codes; - - private StatusCodesBuilder() { - this.codes = Lists.newArrayList(); - } - - public StatusCodesBuilder add(Integer... httpCodes) { - for (Integer httpCode : httpCodes) { - codes.add(new StatusCode(httpCode, DEFAULT_URL)); - } - return this; - } - - public StatusCodesBuilder add(int code, String url) { - codes.add(new StatusCode(code, url)); - return this; - } - - public List build() { - return codes; - } - } } diff --git a/core/jobs/src/test/resources/mock/StatusCodesComparator/a-lot-of-errors-with-exclude-result.json b/core/jobs/src/test/resources/mock/StatusCodesComparator/a-lot-of-errors-with-exclude-result.json new file mode 100644 index 000000000..090fec299 --- /dev/null +++ b/core/jobs/src/test/resources/mock/StatusCodesComparator/a-lot-of-errors-with-exclude-result.json @@ -0,0 +1,58 @@ +{ + "statusCodes": [ + { + "code": 404, + "url": "http://192.168.123.100:9090/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", + "excluded": false + }, + { + "code": 0, + "url": "http://192.168.123.100:9090/favicon.ico", + "excluded": false + }, + { + "code": 303, + "url": "https://www.google.com/", + "excluded": false + }, + { + "code": 500, + "url": "https://www.wikipedia.org/", + "excluded": true + }, + { + "code": 200, + "url": "", + "excluded": false + } + ], + "filteredStatusCodes": [ + { + "code": 404, + "url": "http://192.168.123.100:9090/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", + "excluded": false + }, + { + "code": 0, + "url": "http://192.168.123.100:9090/favicon.ico", + "excluded": false + }, + { + "code": 303, + "url": "https://www.google.com/", + "excluded": false + }, + { + "code": 200, + "url": "www.wikipedia.org", + "excluded": false + } + ], + "excludedStatusCodes": [ + { + "code": 500, + "url": "https://www.wikipedia.org/", + "excluded": true + } + ] +} \ No newline at end of file diff --git a/core/jobs/src/test/resources/mock/StatusCodesComparator/default-range-399-601-errors-result.json b/core/jobs/src/test/resources/mock/StatusCodesComparator/default-range-399-601-errors-result.json new file mode 100644 index 000000000..23cd03815 --- /dev/null +++ b/core/jobs/src/test/resources/mock/StatusCodesComparator/default-range-399-601-errors-result.json @@ -0,0 +1,27 @@ +{ + "statusCodes": [ + { + "code": 399, + "url": "http://192.168.123.100:9090/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", + "excluded": false + }, + { + "code": 601, + "url": "https://www.google.com/", + "excluded": false + } + ], + "filteredStatusCodes": [ + { + "code": 399, + "url": "http://192.168.123.100:9090/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", + "excluded": false + }, + { + "code": 601, + "url": "https://www.google.com/", + "excluded": false + } + ], + "excludedStatusCodes": [] +} \ No newline at end of file diff --git a/core/jobs/src/test/resources/mock/StatusCodesComparator/default-range-400-600-errors-result.json b/core/jobs/src/test/resources/mock/StatusCodesComparator/default-range-400-600-errors-result.json new file mode 100644 index 000000000..76ab8cabc --- /dev/null +++ b/core/jobs/src/test/resources/mock/StatusCodesComparator/default-range-400-600-errors-result.json @@ -0,0 +1,27 @@ +{ + "statusCodes": [ + { + "code": 400, + "url": "http://192.168.123.100:9090/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", + "excluded": false + }, + { + "code": 600, + "url": "https://www.google.com/", + "excluded": false + } + ], + "filteredStatusCodes": [ + { + "code": 400, + "url": "http://192.168.123.100:9090/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", + "excluded": false + }, + { + "code": 600, + "url": "https://www.google.com/", + "excluded": false + } + ], + "excludedStatusCodes": [] +} \ No newline at end of file diff --git a/core/jobs/src/test/resources/mock/StatusCodesComparator/not-existing-page-404-result.json b/core/jobs/src/test/resources/mock/StatusCodesComparator/not-existing-page-404-result.json new file mode 100644 index 000000000..a958dc37a --- /dev/null +++ b/core/jobs/src/test/resources/mock/StatusCodesComparator/not-existing-page-404-result.json @@ -0,0 +1,22 @@ +{ + "statusCodes": [ + { + "code": 404, + "url": "http://192.168.123.100:9090/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", + "excluded": false + }, + { + "code": 0, + "url": "http://192.168.123.100:9090/favicon.ico", + "excluded": false + } + ], + "filteredStatusCodes": [ + { + "code": 404, + "url": "http://192.168.123.100:9090/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", + "excluded": false + } + ], + "excludedStatusCodes": [] +} \ No newline at end of file From 618d9feddec39c466f43ca9ab083885a138919e6 Mon Sep 17 00:00:00 2001 From: plutasnyy Date: Mon, 6 Aug 2018 12:50:37 +0200 Subject: [PATCH 12/17] changed urls --- .../a-lot-of-errors-with-exclude-result.json | 8 ++++---- .../default-range-399-601-errors-result.json | 4 ++-- .../default-range-400-600-errors-result.json | 4 ++-- .../not-existing-page-404-result.json | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/core/jobs/src/test/resources/mock/StatusCodesComparator/a-lot-of-errors-with-exclude-result.json b/core/jobs/src/test/resources/mock/StatusCodesComparator/a-lot-of-errors-with-exclude-result.json index 090fec299..0d97a1fc9 100644 --- a/core/jobs/src/test/resources/mock/StatusCodesComparator/a-lot-of-errors-with-exclude-result.json +++ b/core/jobs/src/test/resources/mock/StatusCodesComparator/a-lot-of-errors-with-exclude-result.json @@ -2,12 +2,12 @@ "statusCodes": [ { "code": 404, - "url": "http://192.168.123.100:9090/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", + "url": "http://aet-vagrant/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", "excluded": false }, { "code": 0, - "url": "http://192.168.123.100:9090/favicon.ico", + "url": "http://aet-vagrant/favicon.ico", "excluded": false }, { @@ -29,12 +29,12 @@ "filteredStatusCodes": [ { "code": 404, - "url": "http://192.168.123.100:9090/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", + "url": "http://aet-vagrant/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", "excluded": false }, { "code": 0, - "url": "http://192.168.123.100:9090/favicon.ico", + "url": "http://aet-vagrant/favicon.ico", "excluded": false }, { diff --git a/core/jobs/src/test/resources/mock/StatusCodesComparator/default-range-399-601-errors-result.json b/core/jobs/src/test/resources/mock/StatusCodesComparator/default-range-399-601-errors-result.json index 23cd03815..2db6c4503 100644 --- a/core/jobs/src/test/resources/mock/StatusCodesComparator/default-range-399-601-errors-result.json +++ b/core/jobs/src/test/resources/mock/StatusCodesComparator/default-range-399-601-errors-result.json @@ -2,7 +2,7 @@ "statusCodes": [ { "code": 399, - "url": "http://192.168.123.100:9090/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", + "url": "http://aet-vagrant/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", "excluded": false }, { @@ -14,7 +14,7 @@ "filteredStatusCodes": [ { "code": 399, - "url": "http://192.168.123.100:9090/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", + "url": "http://aet-vagrant/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", "excluded": false }, { diff --git a/core/jobs/src/test/resources/mock/StatusCodesComparator/default-range-400-600-errors-result.json b/core/jobs/src/test/resources/mock/StatusCodesComparator/default-range-400-600-errors-result.json index 76ab8cabc..a83f721c5 100644 --- a/core/jobs/src/test/resources/mock/StatusCodesComparator/default-range-400-600-errors-result.json +++ b/core/jobs/src/test/resources/mock/StatusCodesComparator/default-range-400-600-errors-result.json @@ -2,7 +2,7 @@ "statusCodes": [ { "code": 400, - "url": "http://192.168.123.100:9090/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", + "url": "http://aet-vagrant/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", "excluded": false }, { @@ -14,7 +14,7 @@ "filteredStatusCodes": [ { "code": 400, - "url": "http://192.168.123.100:9090/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", + "url": "http://aet-vagrant/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", "excluded": false }, { diff --git a/core/jobs/src/test/resources/mock/StatusCodesComparator/not-existing-page-404-result.json b/core/jobs/src/test/resources/mock/StatusCodesComparator/not-existing-page-404-result.json index a958dc37a..da0f287ec 100644 --- a/core/jobs/src/test/resources/mock/StatusCodesComparator/not-existing-page-404-result.json +++ b/core/jobs/src/test/resources/mock/StatusCodesComparator/not-existing-page-404-result.json @@ -2,19 +2,19 @@ "statusCodes": [ { "code": 404, - "url": "http://192.168.123.100:9090/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", + "url": "http://aet-vagrant/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", "excluded": false }, { "code": 0, - "url": "http://192.168.123.100:9090/favicon.ico", + "url": "http://aet-vagrant/favicon.ico", "excluded": false } ], "filteredStatusCodes": [ { "code": 404, - "url": "http://192.168.123.100:9090/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", + "url": "http://aet-vagrant/sample-site/sanity/comparators/statuscodes/noneexistingPage404.jsp", "excluded": false } ], From e45fa42101ead31a791902b647d91b97b6320a24 Mon Sep 17 00:00:00 2001 From: plutasnyy Date: Mon, 6 Aug 2018 12:52:58 +0200 Subject: [PATCH 13/17] fixed typo in documentation --- documentation/src/main/wiki/StatusCodesDataFilters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/src/main/wiki/StatusCodesDataFilters.md b/documentation/src/main/wiki/StatusCodesDataFilters.md index 037f39beb..7da3cde88 100644 --- a/documentation/src/main/wiki/StatusCodesDataFilters.md +++ b/documentation/src/main/wiki/StatusCodesDataFilters.md @@ -1,6 +1,6 @@ #### Status Codes Data Filters -Data filters will be apply only for codes contained in the `filterange`. If the `filterRange` isn't provided, default range will be used. +Data filters will be apply only for codes contained in the `filterRange`. If the `filterRange` isn't provided, default range will be used. ##### Exclude Filter From 55a4c30708dfaf0bf7bf3c8f3c8285c8c4157a8f Mon Sep 17 00:00:00 2001 From: plutasnyy Date: Mon, 6 Aug 2018 12:56:44 +0200 Subject: [PATCH 14/17] updated documentation --- documentation/src/main/wiki/StatusCodesDataFilters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/src/main/wiki/StatusCodesDataFilters.md b/documentation/src/main/wiki/StatusCodesDataFilters.md index 7da3cde88..d4672eeca 100644 --- a/documentation/src/main/wiki/StatusCodesDataFilters.md +++ b/documentation/src/main/wiki/StatusCodesDataFilters.md @@ -1,6 +1,6 @@ #### Status Codes Data Filters -Data filters will be apply only for codes contained in the `filterRange`. If the `filterRange` isn't provided, default range will be used. +Data filters will be apply only for codes contained in logic sum of the `filterRange` and the `filterCodes`. If the `filterRange` isn't provided, default range will be used. ##### Exclude Filter From 79a1fbb7dfa9b0c091aa3117ccc95fdf200fcb1b Mon Sep 17 00:00:00 2001 From: Wiiitek Date: Tue, 7 Aug 2018 09:17:09 +0200 Subject: [PATCH 15/17] more refactoring for unit test --- .../StatusCodesComparatorTest.java | 148 +++++++----------- 1 file changed, 58 insertions(+), 90 deletions(-) diff --git a/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparatorTest.java b/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparatorTest.java index 8b301d76d..8ce1c7236 100644 --- a/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparatorTest.java +++ b/core/jobs/src/test/java/com/cognifide/aet/job/common/comparators/statuscodes/StatusCodesComparatorTest.java @@ -16,6 +16,7 @@ package com.cognifide.aet.job.common.comparators.statuscodes; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; import static org.mockito.Mockito.when; import com.cognifide.aet.communication.api.metadata.ComparatorStepResult; @@ -27,6 +28,8 @@ import com.cognifide.aet.job.common.comparators.AbstractComparatorTest; import java.util.ArrayList; import java.util.Map; + +import com.google.common.collect.ImmutableMap; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -68,17 +71,12 @@ public class StatusCodesComparatorTest extends AbstractComparatorTest { private StatusCodesComparator tested; - @Mock - private Map params; - @Mock private ComparatorProperties comparatorProperties; @Before public void setUp() { artifactDaoMock = new ArtifactDAOMock(StatusCodesComparator.class); - when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(false); - when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(false); } @Test @@ -93,8 +91,8 @@ public void compareTest_expectPassed() throws ProcessingException { public void compareTest_expectFailed() throws ProcessingException, ParametersException { tested = createNewStatusCodesComparator("expected-data-200-result.json"); - when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); - when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_ONLY_SUCCESS); + Map params = ImmutableMap + .of(PARAM_FILTER_CODES, FILTER_CODES_ONLY_SUCCESS); tested.setParameters(params); result = tested.compare(); @@ -106,8 +104,8 @@ public void compareTest_filterRange_expectPassed() throws ProcessingException, ParametersException { tested = createNewStatusCodesComparator("not-existing-page-404-result.json"); - when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); - when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE_REMOVE_DEFAULT_RANGE); + Map params = ImmutableMap + .of(PARAM_FILTER_RANGE, FILTER_RANGE_REMOVE_DEFAULT_RANGE); tested.setParameters(params); result = tested.compare(); @@ -119,8 +117,8 @@ public void compareTest_filterRange_expectFailed() throws ProcessingException, ParametersException { tested = createNewStatusCodesComparator("not-existing-page-404-result.json"); - when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); - when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE); + Map params = ImmutableMap + .of(PARAM_FILTER_RANGE, FILTER_RANGE); tested.setParameters(params); result = tested.compare(); @@ -132,40 +130,23 @@ public void compareTest_filterCodes_expectPassed() throws ProcessingException, ParametersException { tested = createNewStatusCodesComparator("not-existing-page-404-result.json"); - when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); - when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_ONLY_SUCCESS); - when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); - when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE_REMOVE_DEFAULT_RANGE); + Map params = ImmutableMap + .of(PARAM_FILTER_CODES, FILTER_CODES_ONLY_SUCCESS, + PARAM_FILTER_RANGE, FILTER_RANGE_REMOVE_DEFAULT_RANGE); tested.setParameters(params); result = tested.compare(); assertEquals(ComparatorStepResult.Status.PASSED, result.getStatus()); } - @Test - public void compareTest_filterCodes_expectFailed() - throws ProcessingException, ParametersException { - tested = createNewStatusCodesComparator("not-existing-page-404-result.json"); - - when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); - when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_MULTIPLE); - when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); - when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE_REMOVE_DEFAULT_RANGE); - tested.setParameters(params); - - result = tested.compare(); - assertEquals(ComparatorStepResult.Status.FAILED, result.getStatus()); - } - @Test public void compareTest_filterCodesMultipleCodes_expectFailed() throws ProcessingException, ParametersException { tested = createNewStatusCodesComparator("not-existing-page-404-result.json"); - when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); - when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_MULTIPLE); - when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); - when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE_REMOVE_DEFAULT_RANGE); + Map params = ImmutableMap + .of(PARAM_FILTER_CODES, FILTER_CODES_MULTIPLE, + PARAM_FILTER_RANGE, FILTER_RANGE_REMOVE_DEFAULT_RANGE); tested.setParameters(params); result = tested.compare(); @@ -176,25 +157,26 @@ public void compareTest_filterCodesMultipleCodes_expectFailed() public void compareTest_filterCodesAndFilterRange_expectFailed() throws ParametersException, ProcessingException { tested = createNewStatusCodesComparator("a-lot-of-errors-with-exclude-result.json"); + Map params; - when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); - - when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE); + params = ImmutableMap + .of(PARAM_FILTER_CODES, FILTER_RANGE); tested.setParameters(params); result = tested.compare(); assertEquals(ComparatorStepResult.Status.FAILED, result.getStatus()); - when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); - when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_MULTIPLE); - when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE_REMOVE_DEFAULT_RANGE); + params = ImmutableMap + .of(PARAM_FILTER_CODES, FILTER_CODES_MULTIPLE, + PARAM_FILTER_RANGE, FILTER_RANGE_REMOVE_DEFAULT_RANGE); tested.setParameters(params); result = tested.compare(); assertEquals(ComparatorStepResult.Status.FAILED, result.getStatus()); - when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_MULTIPLE); - when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE); + params = ImmutableMap + .of(PARAM_FILTER_CODES, FILTER_CODES_MULTIPLE, + PARAM_FILTER_RANGE, FILTER_RANGE); tested.setParameters(params); result = tested.compare(); @@ -206,11 +188,9 @@ public void compareTest_filterCodesAndFilterRange_expectPassed() throws ParametersException, ProcessingException { tested = createNewStatusCodesComparator("a-lot-of-errors-with-exclude-result.json"); - when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); - when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); - - when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_SINGLE); - when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE_REMOVE_DEFAULT_RANGE); + Map params = ImmutableMap + .of(PARAM_FILTER_CODES, FILTER_CODES_SINGLE, + PARAM_FILTER_RANGE, FILTER_RANGE_REMOVE_DEFAULT_RANGE); tested.setParameters(params); result = tested.compare(); @@ -222,11 +202,9 @@ public void compareTest_testExclude_expectPassed() throws ParametersException, ProcessingException { tested = createNewStatusCodesComparator("a-lot-of-errors-with-exclude-result.json"); - when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); - when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_EXCLUDED); - when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); - when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE_REMOVE_DEFAULT_RANGE); - + Map params = ImmutableMap + .of(PARAM_FILTER_CODES, FILTER_CODES_EXCLUDED, + PARAM_FILTER_RANGE, FILTER_RANGE_REMOVE_DEFAULT_RANGE); tested.setParameters(params); result = tested.compare(); @@ -253,101 +231,91 @@ public void compareTest_defaultRange_expectFailed() throws ProcessingException { public void setParameters() throws ParametersException { tested = createNewStatusCodesComparator("expected-data-200-result.json"); - when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); - when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE); - when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); - when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_SINGLE); - - // no parameters errors expected - unable to assert anything + Map params = ImmutableMap + .of(PARAM_FILTER_CODES, FILTER_CODES_SINGLE, + PARAM_FILTER_RANGE, FILTER_RANGE); tested.setParameters(params); + // parameters were set successfully } @Test public void setParameters_filterRange() throws ParametersException { tested = createNewStatusCodesComparator("expected-data-200-result.json"); - when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); - when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE); - - // no parameters errors expected - unable to assert anything + Map params = ImmutableMap + .of(PARAM_FILTER_RANGE, FILTER_RANGE); tested.setParameters(params); + // parameters were set successfully } @Test(expected = ParametersException.class) public void setParameters_filterRangeInvalid() throws ParametersException { tested = createNewStatusCodesComparator("expected-data-200-result.json"); - when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); - when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE_INVALID); - - // parameters exception expected - unable to assert anything + Map params = ImmutableMap + .of(PARAM_FILTER_RANGE, FILTER_RANGE_INVALID); tested.setParameters(params); + fail("parameters exception expected"); } @Test(expected = ParametersException.class) public void setParameters_filterRangeNotANumber() throws ParametersException { tested = createNewStatusCodesComparator("expected-data-200-result.json"); - when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); - when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE_NAN); - - // parameters exception expected - unable to assert anything + Map params = ImmutableMap + .of(PARAM_FILTER_RANGE, FILTER_RANGE_NAN); tested.setParameters(params); + fail("parameters exception expected"); } @Test(expected = ParametersException.class) public void setParameters_filterRangeUpperBoundLessThanLowerBound() throws ParametersException { tested = createNewStatusCodesComparator("expected-data-200-result.json"); - when(params.containsKey(PARAM_FILTER_RANGE)).thenReturn(true); - when(params.get(PARAM_FILTER_RANGE)).thenReturn(FILTER_RANGE_UPPER_LESS_THAN_LOWER); - - // parameters exception expected - unable to assert anything + Map params = ImmutableMap + .of(PARAM_FILTER_RANGE, FILTER_RANGE_UPPER_LESS_THAN_LOWER); tested.setParameters(params); + fail("parameters exception expected"); } @Test public void setParameters_filterCodes() throws ParametersException { tested = createNewStatusCodesComparator("expected-data-200-result.json"); - when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); - when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_SINGLE); - - // parameters exception expected - unable to assert anything + Map params = ImmutableMap + .of(PARAM_FILTER_CODES, FILTER_CODES_SINGLE); tested.setParameters(params); + // parameters were set successfully } @Test public void setParameters_filterCodesMultipleValues() throws ParametersException { tested = createNewStatusCodesComparator("expected-data-200-result.json"); - when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); - when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_MULTIPLE); - - // no parameters errors expected - unable to assert anything + Map params = ImmutableMap + .of(PARAM_FILTER_CODES, FILTER_CODES_MULTIPLE); tested.setParameters(params); + // parameters were set successfully } @Test(expected = ParametersException.class) public void setParameters_filterCodesNotANumber() throws ParametersException { tested = createNewStatusCodesComparator("expected-data-200-result.json"); - when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); - when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_SINGLE_NAN); - - // parameters exception expected - unable to assert anything + Map params = ImmutableMap + .of(PARAM_FILTER_CODES, FILTER_CODES_SINGLE_NAN); tested.setParameters(params); + fail("parameters exception expected"); } @Test(expected = ParametersException.class) public void setParameters_filterCodesMultipleValuesNotANumber() throws ParametersException { tested = createNewStatusCodesComparator("expected-data-200-result.json"); - when(params.containsKey(PARAM_FILTER_CODES)).thenReturn(true); - when(params.get(PARAM_FILTER_CODES)).thenReturn(FILTER_CODES_MULTIPLE_NAN); - - // parameters exception expected - unable to assert anything + Map params = ImmutableMap + .of(PARAM_FILTER_CODES, FILTER_CODES_MULTIPLE_NAN); tested.setParameters(params); + fail("parameters exception expected"); } private StatusCodesComparator createNewStatusCodesComparator(String pathToJson) { From 4cbc56488baad673dd3e0dc85fd8992f05eb966c Mon Sep 17 00:00:00 2001 From: Wiiitek Date: Tue, 7 Aug 2018 09:17:28 +0200 Subject: [PATCH 16/17] changelog updated --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01ce72a66..506b6076f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,6 @@ All notable changes to AET will be documented in this file. ## Unreleased **List of changes that are finished but not yet released in any final version.** -- [PR-296](https://github.com/Cognifide/aet/pull/296) Status Code Comparator check now range 400-600 by default, parameters validation added - [PR-300](https://github.com/Cognifide/aet/pull/300) Added creating indexes for collection - [PR-289](https://github.com/Cognifide/aet/pull/289) User now stays on the same tab while navigating between URLs - [PR-271](https://github.com/Cognifide/aet/pull/271) Added possibility to override name parameter from the aet client @@ -20,6 +19,7 @@ All notable changes to AET will be documented in this file. - [PR-286](https://github.com/Cognifide/aet/pull/286) Shared Patterns - use latest patterns of given suite name ([#121](https://github.com/Cognifide/aet/issues/121)) - [PR-291](https://github.com/Cognifide/aet/pull/291) Updated nu.validator version from 15.6.29 to 17.11.1 - [PR-298](https://github.com/Cognifide/aet/pull/298) Filtering accessibility errors by markup CSS ([#214](https://github.com/Cognifide/aet/issues/214)) +- [PR-296](https://github.com/Cognifide/aet/pull/296) Status Code Comparator now checks range 400-600 by default, parameters validation added ## Version 2.1.6 From fc7b2348575c6965760d68a8ed4530633940721a Mon Sep 17 00:00:00 2001 From: Wiiitek Date: Tue, 7 Aug 2018 09:17:37 +0200 Subject: [PATCH 17/17] documentation updates --- .../src/main/wiki/StatusCodesComparator.md | 6 +-- .../src/main/wiki/StatusCodesDataFilters.md | 49 ++++++++----------- 2 files changed, 24 insertions(+), 31 deletions(-) diff --git a/documentation/src/main/wiki/StatusCodesComparator.md b/documentation/src/main/wiki/StatusCodesComparator.md index 203bd3d96..cdf129dca 100644 --- a/documentation/src/main/wiki/StatusCodesComparator.md +++ b/documentation/src/main/wiki/StatusCodesComparator.md @@ -12,9 +12,9 @@ Resource name: status-codes | Parameter | Value | Example | Description | Mandatory | | --------- | ----- | ------- | ----------- | --------- | -| `filterRange` | x,y (default: `400,600`) | 400,500 | Defines range of status codes that should be processed | no | -| `filterCodes` | x,y,z | 400,401,404 | List of status codes that should be processed | no | -| `showExcluded` | boolean (default: `true`) | true | Flag that says if excluded codes (see [[Status Codes Data Filters | StatusCodesDataFilters]]) should be displayed in report. By default set to `true`. | no | +| `filterRange` | x,y (default: `400,600`) | 400,500 | Defines **range** of status codes that should be processed | no | +| `filterCodes` | x,y,z | 400,401,404 | **List** of status codes that should be processed | no | +| `showExcluded` | boolean (default: `true`) | true | Used to show excluded status codes on report (see *Status Codes Data Filters*). | no | If you provide both `filterRange` and `filterCodes`, it will be used as logical sum. It means that: - `` is equivalent to `` diff --git a/documentation/src/main/wiki/StatusCodesDataFilters.md b/documentation/src/main/wiki/StatusCodesDataFilters.md index d4672eeca..252527e20 100644 --- a/documentation/src/main/wiki/StatusCodesDataFilters.md +++ b/documentation/src/main/wiki/StatusCodesDataFilters.md @@ -1,6 +1,8 @@ #### Status Codes Data Filters -Data filters will be apply only for codes contained in logic sum of the `filterRange` and the `filterCodes`. If the `filterRange` isn't provided, default range will be used. +There might be a need to ignore some of the collected status codes. We can exclude them so that they no longer affect our test case. + +Data filters will be applied only for codes contained in logic sum of the `filterRange` and the `filterCodes`. If the `filterRange` isn't provided, default range will be used. ##### Exclude Filter @@ -14,14 +16,14 @@ Resource name: status-codes | Parameter | Value | Description | Mandatory | | --------- | ----- | ----------- | --------- | -| `url` | String url | Exact url to be removed from results. | At least one of parameter is required. | -| `pattern` | String regex pattern| Regex pattern that urls should match to be removed from results. | | +| `url` | String url | Exact url to be excluded from results. | At least one of parameter is required. | +| `pattern` | String regex pattern| Regex pattern that urls should match to be excluded from results. | | If both parameters are provided then result is removed when it matches at least one of the parameters. ###### Example Usage -In this sample match results with url http://www.cognifide.com/_cog_opt_js_f359581ea4bd3379b4c25591838a5dd8.js or url that matches pattern **^.\*js$** will be ignored (not included in report). +In this sample result with url http://www.external.com/_optional.js or urls that match pattern **^.\*js$** will be excluded. ```xml @@ -37,7 +39,7 @@ In this sample match results with url http://www.cognifide.com/_cog_opt_js_f3595 ... - + ... @@ -51,31 +53,20 @@ In this sample match results with url http://www.cognifide.com/_cog_opt_js_f3595 ``` -There can be more than one `exclude` tags in `status-codes` comparator. They are processed in turns. Example below is equivalent to defined above: +There can be more than one `exclude` tags in `status-codes` comparator. They are processed in turns. Example below is equivalent to previous one: ```xml - + ``` -In this case both results with url http://www.cognifide.com/_cog_opt_js_f359581ea4bd3379b4c25591838a5dd8.js and urls that match pattern **^.\*js$** (ending with js) will not be displayed on reports. - -**Exclude** and **include** modifiers can be both applied to **status-codes comparator**. They are processed in turns. Example: - -```xml - - - - -``` - -In this case, at first all urls that do not match **^.\*js$** pattern are removed. Then url http://www.cognifide.com/_cog_opt_js_f359581ea4bd3379b4c25591838a5dd8.js is removed. Therefore only urls ending with `js` except http://www.cognifide.com/_cog_opt_js_f359581ea4bd3379b4c25591838a5dd8.js will be included in reports. +In this case both results with url http://www.external.com/_optional.js and urls that match pattern **^.\*js$** (ending with `js`) will not be displayed on reports. ##### Include Filter -Include Filter removes from reports Status Codes results that **do not** match specified parameters. +Include Filter excludes from reports Status Codes results that **do not** match specified parameters. Name: **include** @@ -85,14 +76,14 @@ Resource name: status-codes | Parameter | Value | Description | Mandatory | | --------- | ----- | ----------- | --------- | -| `url` | String url | Exact url to be included in reports. Results that do not match will be removed. | At least one of parameter is required. | -| `pattern` | String regex pattern | Regex pattern that urls should match to be included in reports. Results that do not match will be removed. | | +| `url` | String url | Exact url to be included in reports. Results that do not match will be excluded. | At least one of parameter is required. | +| `pattern` | String regex pattern | Regex pattern that urls should match to be included in reports. Results that do not match will be excluded. | | If both parameters are provided then result is only included in the report when it matches both of the parameters. ###### Example Usage -In example below **only** result with url http://www.cognifide.com/_cog_opt_js_f359581ea4bd3379b4c25591838a5dd8.js will be included in report. +In example below **only** result with url http://www.cognifide.com/main.js will be included in report. ```xml @@ -108,7 +99,7 @@ In example below **only** result with url http://www.cognifide.com/_cog_opt_js_f ... - + ... @@ -127,21 +118,23 @@ There can be more than one `include` tags in `status-codes` comparator. They are ```xml - + ``` -In this case only http://www.cognifide.com/_cog_opt_js_f359581ea4bd3379b4c25591838a5dd8.js url will be included on reports: first all results that do not match **^.\*js$** pattern (ending with `js`) are removed. Then within that result all urls different that "http://www.cognifide.com/_cog_opt_js_f359581ea4bd3379b4c25591838a5dd8.js" are removed. +In this case only http://www.cognifide.com/main.js url will be included on reports: first all results that do not match **^.\*js$** pattern (ending with `js`) are excluded. Then within that result all urls different from "http://www.cognifide.com/main.js" are excluded. In example above, first `` can be omitted and result will be the same. +##### Include and Exclude + **Include** and **exclude** modifiers can be both applied to **status-codes comparator**. They are processed in turns. Example: ```xml - + ``` -In this case only first all urls that do not match **^.\*js$** pattern are removed. Then url http://www.cognifide.com/_cog_opt_js_f359581ea4bd3379b4c25591838a5dd8.js is removed. Therefore only urls ending with `js` except http://www.cognifide.com/_cog_opt_js_f359581ea4bd3379b4c25591838a5dd8.js will be included in reports. +In example above we include URLs that match **^.\*js$**, so any other URL will be excluded. Then we exclude http://www.external.com/_optional.js. Therefore only urls ending with `js` except http://www.external.com/_optional.js will be included in reports.