diff --git a/easy-cucumber-core/pom.xml b/easy-cucumber-core/pom.xml index 295ca8a..dba058a 100644 --- a/easy-cucumber-core/pom.xml +++ b/easy-cucumber-core/pom.xml @@ -6,7 +6,7 @@ io.github.osvaldjr easy-cucumber-parent - 1.0.1 + 1.0.2 easy-cucumber-core jar diff --git a/easy-cucumber-datasource/pom.xml b/easy-cucumber-datasource/pom.xml index c220183..da76eeb 100644 --- a/easy-cucumber-datasource/pom.xml +++ b/easy-cucumber-datasource/pom.xml @@ -6,7 +6,7 @@ io.github.osvaldjr easy-cucumber-parent - 1.0.1 + 1.0.2 easy-cucumber-datasource jar diff --git a/easy-cucumber-datasource/src/main/java/io/github/osvaldjr/datasource/utils/DatabaseTableMatch.java b/easy-cucumber-datasource/src/main/java/io/github/osvaldjr/datasource/utils/DatabaseTableMatch.java index e580fd7..fc2a820 100644 --- a/easy-cucumber-datasource/src/main/java/io/github/osvaldjr/datasource/utils/DatabaseTableMatch.java +++ b/easy-cucumber-datasource/src/main/java/io/github/osvaldjr/datasource/utils/DatabaseTableMatch.java @@ -33,20 +33,14 @@ public boolean execute(String tableName, List> lines) { String selectQuery = getSelectQuery(tableName, lines.get(0)); List> resultList = jdbcTemplate.queryForList(selectQuery); - return lines.stream() - .allMatch(line -> matchLine(tableName, new ArrayList<>(line.values()), resultList)); + return lines.stream().allMatch(line -> matchLine(tableName, line, resultList)); } private boolean matchLine( - String tableName, List expectedLine, List> allResults) { + String tableName, Map expectedLine, List> allResults) { boolean matchAllColumns = - allResults.stream() - .anyMatch( - resultLine -> { - ArrayList objects = new ArrayList(resultLine.values()); - return matchAllColumns(expectedLine, objects); - }); + allResults.stream().anyMatch(resultLine -> matchAllColumns(expectedLine, resultLine)); if (!matchAllColumns) { throw new AssertionError( @@ -58,14 +52,12 @@ private boolean matchLine( return matchAllColumns; } - private boolean matchAllColumns(List expectedLine, List resultLine) { - return expectedLine.stream() - .allMatch( - column -> - resultLine.stream().anyMatch(resultColumn -> matchColumn(column, resultColumn))); + private boolean matchAllColumns(Map expectedLine, Map resultLine) { + return expectedLine.entrySet().stream() + .allMatch(expected -> matchColumn(expected.getValue(), resultLine.get(expected.getKey()))); } - private boolean matchColumn(V column, V resultColumn) { + private boolean matchColumn(V column, Object resultColumn) { String returnValue = trim(valueOf(resultColumn)); String expectValue = valueOf(column); return returnValue.equals(expectValue) || returnValue.matches(expectValue); diff --git a/easy-cucumber-jms/pom.xml b/easy-cucumber-jms/pom.xml index b4125f3..4918da3 100644 --- a/easy-cucumber-jms/pom.xml +++ b/easy-cucumber-jms/pom.xml @@ -6,7 +6,7 @@ io.github.osvaldjr easy-cucumber-parent - 1.0.1 + 1.0.2 easy-cucumber-jms jar diff --git a/easy-cucumber-mock/pom.xml b/easy-cucumber-mock/pom.xml index 018acdb..ef839ca 100644 --- a/easy-cucumber-mock/pom.xml +++ b/easy-cucumber-mock/pom.xml @@ -6,7 +6,7 @@ io.github.osvaldjr easy-cucumber-parent - 1.0.1 + 1.0.2 easy-cucumber-mock jar diff --git a/easy-cucumber-mock/src/main/java/io/github/osvaldjr/mock/stepdefinitions/MockSteps.java b/easy-cucumber-mock/src/main/java/io/github/osvaldjr/mock/stepdefinitions/MockSteps.java index 728f1c8..6f2005e 100644 --- a/easy-cucumber-mock/src/main/java/io/github/osvaldjr/mock/stepdefinitions/MockSteps.java +++ b/easy-cucumber-mock/src/main/java/io/github/osvaldjr/mock/stepdefinitions/MockSteps.java @@ -59,9 +59,13 @@ public void aHaveAMockForDependency(String mockName, String serviceName) throws public void iExpectMockForDependencyToHaveBeenCalledTimes( String mockName, String serviceName, Integer times) { String mapKey = getStubbyKey(scenarioName, serviceName, mockName); - Object stubbyId = stubbyIdMap.get(mapKey); - assertThat(getMockHitsUsecase.execute(stubbyId), equalTo(times)); + Integer mockHits = 0; + if(stubbyIdMap.containsKey(mapKey)) { + Object stubbyId = stubbyIdMap.get(mapKey); + mockHits = getMockHitsUsecase.execute(stubbyId); + } + assertThat(mockHits, equalTo(times)); } @Given("I clear all mocks") diff --git a/easy-cucumber-owasp-zap/pom.xml b/easy-cucumber-owasp-zap/pom.xml index 1dbe24b..6358d72 100644 --- a/easy-cucumber-owasp-zap/pom.xml +++ b/easy-cucumber-owasp-zap/pom.xml @@ -6,7 +6,7 @@ io.github.osvaldjr easy-cucumber-parent - 1.0.1 + 1.0.2 easy-cucumber-owasp-zap jar diff --git a/examples/complete-springboot/pom.xml b/examples/complete-springboot/pom.xml index 555b25c..04284d7 100644 --- a/examples/complete-springboot/pom.xml +++ b/examples/complete-springboot/pom.xml @@ -17,41 +17,42 @@ 1.8 Greenwich.SR2 + 1.0.2 io.github.osvaldjr easy-cucumber-core - 1.0.1 + ${easy-cucumber.version} test io.github.osvaldjr easy-cucumber-mock - 1.0.1 + ${easy-cucumber.version} test io.github.osvaldjr easy-cucumber-datasource - 1.0.1 + ${easy-cucumber.version} test io.github.osvaldjr easy-cucumber-jms - 1.0.1 + ${easy-cucumber.version} test io.github.osvaldjr easy-cucumber-owasp-zap - 1.0.1 + ${easy-cucumber.version} test diff --git a/examples/simple-springboot-activemq/pom.xml b/examples/simple-springboot-activemq/pom.xml index 1de4d28..5ffe738 100644 --- a/examples/simple-springboot-activemq/pom.xml +++ b/examples/simple-springboot-activemq/pom.xml @@ -17,13 +17,14 @@ 1.8 Greenwich.SR2 + 1.0.2 io.github.osvaldjr easy-cucumber-jms - 1.0.1 + ${easy-cucumber.version} test diff --git a/examples/simple-springboot-core/pom.xml b/examples/simple-springboot-core/pom.xml index e093f4d..e825ccf 100644 --- a/examples/simple-springboot-core/pom.xml +++ b/examples/simple-springboot-core/pom.xml @@ -17,13 +17,14 @@ 1.8 Greenwich.SR2 + 1.0.2 io.github.osvaldjr easy-cucumber-core - 1.0.1 + ${easy-cucumber.version} test diff --git a/examples/simple-springboot-datasource/pom.xml b/examples/simple-springboot-datasource/pom.xml index eceb114..daef369 100644 --- a/examples/simple-springboot-datasource/pom.xml +++ b/examples/simple-springboot-datasource/pom.xml @@ -17,13 +17,14 @@ 1.8 Greenwich.SR2 + 1.0.2 io.github.osvaldjr easy-cucumber-datasource - 1.0.1 + ${easy-cucumber.version} test diff --git a/examples/simple-springboot-mockserver/pom.xml b/examples/simple-springboot-mockserver/pom.xml index 01569df..dd6962e 100644 --- a/examples/simple-springboot-mockserver/pom.xml +++ b/examples/simple-springboot-mockserver/pom.xml @@ -17,13 +17,14 @@ 1.8 Greenwich.SR2 + 1.0.2 io.github.osvaldjr easy-cucumber-mock - 1.0.1 + ${easy-cucumber.version} test diff --git a/examples/simple-springboot-mockserver/src/test/resources/features/default.feature b/examples/simple-springboot-mockserver/src/test/resources/features/default.feature index 3675651..b652da7 100644 --- a/examples/simple-springboot-mockserver/src/test/resources/features/default.feature +++ b/examples/simple-springboot-mockserver/src/test/resources/features/default.feature @@ -39,4 +39,10 @@ Feature: Default Given I have a mock http_post_successful for dependency mock_alias When I make a request defined in http_post_defined_body_request.json Then I expect to receive a 200 status - And response is valid according to schema schemas/schema.json \ No newline at end of file + And response is valid according to schema schemas/schema.json + + Scenario: Validate mock with error + Given I have a mock http_patch_successful for dependency mock_alias + When I make a request defined in http_patch_defined_body_request.json + Then I expect to receive a 200 status + And I expect mock http_patch_successful_error for dependency mock_alias to have been called 0 times \ No newline at end of file diff --git a/examples/simple-springboot-owaspzap/pom.xml b/examples/simple-springboot-owaspzap/pom.xml index f8f7a59..0c1fd43 100644 --- a/examples/simple-springboot-owaspzap/pom.xml +++ b/examples/simple-springboot-owaspzap/pom.xml @@ -17,13 +17,14 @@ 1.8 Greenwich.SR2 + 1.0.2 io.github.osvaldjr easy-cucumber-owasp-zap - 1.0.1 + ${easy-cucumber.version} test diff --git a/examples/simple-springboot-stubby/pom.xml b/examples/simple-springboot-stubby/pom.xml index 3305066..60f47bb 100644 --- a/examples/simple-springboot-stubby/pom.xml +++ b/examples/simple-springboot-stubby/pom.xml @@ -17,13 +17,14 @@ 1.8 Greenwich.SR2 + 1.0.2 io.github.osvaldjr easy-cucumber-mock - 1.0.1 + ${easy-cucumber.version} test diff --git a/pom.xml b/pom.xml index 8f657e6..2307f3a 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ io.github.osvaldjr easy-cucumber-parent - 1.0.1 + 1.0.2 pom io.github.osvaldjr:easy-cucumber Easy Cucumber JVM Testing