diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNCompilerTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNCompilerTest.java index e4b14aa3602..7e9874ef7da 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNCompilerTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/DMNCompilerTest.java @@ -341,8 +341,6 @@ void testNestedImports(VariantTestConf conf) { LOG.debug("{}", evaluateModelCDecision); assertThat(evaluateModelCDecision.getDecisionResults()).hasSize(3); assertThat(evaluateModelCDecision.getDecisionResults()).allMatch(dmnDecisionResult -> dmnDecisionResult.getEvaluationStatus().equals(SUCCEEDED)); - - evaluateModelCDecision.getDecisionResults().forEach(dmnDecisionResult -> assertThat(dmnDecisionResult.getEvaluationStatus()).isEqualTo(SUCCEEDED)); } @ParameterizedTest @@ -417,13 +415,11 @@ void wrongComparisonOps(VariantTestConf conf) { assertThat(dmnModel.hasErrors()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isFalse(); assertThat(dmnModel.getMessages()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).hasSize(4); assertThat(dmnModel.getMessages(DMNMessage.Severity.WARN)).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).hasSize(4); - assertThat(dmnModel.getMessages(DMNMessage.Severity.WARN) - .stream() - .filter(m -> m.getSourceId().equals("_d72d6fab-1e67-4fe7-9c12-54800d6fe294") || + assertThat(dmnModel.getMessages(DMNMessage.Severity.WARN)).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())) + .filteredOn(m -> m.getSourceId().equals("_d72d6fab-1e67-4fe7-9c12-54800d6fe294") || m.getSourceId().equals("_2390dd99-094d-4f97-aecc-9cccb697ce05") || m.getSourceId().equals("_0c292d34-498e-4b08-ae99-3c694197b69f") || - m.getSourceId().equals("_21c7d800-b806-4b2e-9a10-00828de7f2d2")) - .count()).as(DMNRuntimeUtil.formatMessages(dmnModel.getMessages())).isEqualTo(4L); + m.getSourceId().equals("_21c7d800-b806-4b2e-9a10-00828de7f2d2")).hasSize(4); } @ParameterizedTest diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/impl/DMNModelImplTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/impl/DMNModelImplTest.java index 7663612df49..8ec9697fa07 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/impl/DMNModelImplTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/impl/DMNModelImplTest.java @@ -53,7 +53,7 @@ void addDecisionSameModel() { decisionNodeList.add(toAdd); }); - decisionNodeList.forEach(decisionNode -> { + assertThat(decisionNodeList).allSatisfy(decisionNode -> { assertThat(model.getDecisionByName(decisionNode.getName())) .isNotNull() .isEqualTo(decisionNode); @@ -72,7 +72,7 @@ void addDecisionWithoutIdSameModel() { decisionNodeList.add(toAdd); }); - decisionNodeList.forEach(decisionNode -> + assertThat(decisionNodeList).allSatisfy(decisionNode -> assertThat(model.getDecisionByName(decisionNode.getName())) .isNotNull() .isEqualTo(decisionNode)); @@ -86,7 +86,7 @@ void addDecisionWithoutNameSameModel() { model.addDecision(toAdd); decisionNodeList.add(toAdd); }); - decisionNodeList.forEach(decisionNode -> + assertThat(decisionNodeList).allSatisfy(decisionNode -> assertThat(model.getDecisionById(decisionNode.getId())) .isNotNull() .isEqualTo(decisionNode)); @@ -104,7 +104,7 @@ void addDecisionImportedModel() { decisionNodeList.add(toAdd); }); - decisionNodeList.forEach(decisionNode -> { + assertThat(decisionNodeList).allSatisfy(decisionNode -> { assertThat(model.getDecisionByName(String.format("%s.%s", importedNameSpace, decisionNode.getName()))) .isNotNull() .isEqualTo(decisionNode); @@ -126,7 +126,7 @@ void addDecisionWithoutIdImportedModel() { decisionNodeList.add(toAdd); }); - decisionNodeList.forEach(decisionNode -> + assertThat(decisionNodeList).allSatisfy(decisionNode -> assertThat(model.getDecisionByName(String.format("%s.%s", importedNameSpace, decisionNode.getName()))) .isNotNull() .isEqualTo(decisionNode)); @@ -143,7 +143,7 @@ void addDecisionWithoutNameImportedModel() { model.addDecision(toAdd); decisionNodeList.add(toAdd); }); - decisionNodeList.forEach(decisionNode -> + assertThat(decisionNodeList).allSatisfy(decisionNode -> assertThat(model.getDecisionById(String.format("%s#%s", importedNameSpace, decisionNode.getId()))) .isNotNull() .isEqualTo(decisionNode)); diff --git a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/DMNRuntimeTypesTest.java b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/DMNRuntimeTypesTest.java index 2e14a803bc3..f090219c183 100644 --- a/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/DMNRuntimeTypesTest.java +++ b/kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/stronglytyped/DMNRuntimeTypesTest.java @@ -1035,11 +1035,11 @@ void collectionOfCollectionOfCollection(VariantTestConf conf) { Map allProperties = outputSet.allFEELProperties(); List>> colCOut = (List>>) allProperties.get("Decision-1"); List personOutList = colCOut.stream().flatMap(colB -> colB.stream()).flatMap(colA -> colA.stream()).collect(Collectors.toList()); - personOutList.stream().forEach(person -> assertPersonInDeepCol(person)); + assertThat(personOutList).allSatisfy(person -> assertPersonInDeepCol(person)); } else { List>>> colCOut = (List>>>)dmnResult.getContext().get("Decision-1"); List> personOutList = colCOut.stream().flatMap(colB -> colB.stream()).flatMap(colA -> colA.stream()).collect(Collectors.toList()); - personOutList.stream().forEach(person -> assertPersonMapInDeepCol(person)); + assertThat(personOutList).allSatisfy(person -> assertPersonMapInDeepCol(person)); } } diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ForIterationTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ForIterationTest.java index b9980f6f119..89ecdf56300 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ForIterationTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ForIterationTest.java @@ -20,9 +20,6 @@ import java.math.BigDecimal; import java.time.LocalDate; -import java.util.Arrays; -import java.util.List; -import java.util.stream.IntStream; import org.junit.jupiter.api.Test; @@ -62,19 +59,21 @@ void hasNextValueLocalDateTest() { void getNextValueBigDecimalTest() { BigDecimal start = BigDecimal.valueOf(1); BigDecimal end = BigDecimal.valueOf(3); - List expected = Arrays.asList(BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(3)); ForIteration iteration = new ForIteration("iteration", start, end); - iteration.hasNextValue(); - IntStream.range(0, 3).forEach(i -> assertThat(expected.get(i)).isEqualTo(iteration.getNextValue())); + assertThat(iteration.hasNextValue()).isTrue(); + assertThat(iteration.getNextValue()).isEqualTo(BigDecimal.valueOf(1)); + assertThat(iteration.getNextValue()).isEqualTo(BigDecimal.valueOf(2)); + assertThat(iteration.getNextValue()).isEqualTo(BigDecimal.valueOf(3)); } @Test void getNextValueLocalDateTest() { LocalDate start = LocalDate.of(2021, 1, 3); LocalDate end = LocalDate.of(2021, 1, 1); - List expected = Arrays.asList(LocalDate.of(2021, 1, 3), LocalDate.of(2021, 1, 2), LocalDate.of(2021, 1, 1)); ForIteration iteration = new ForIteration("iteration", start, end); - iteration.hasNextValue(); - IntStream.range(0, 3).forEach(i -> assertThat(expected.get(i)).isEqualTo(iteration.getNextValue())); + assertThat(iteration.hasNextValue()).isTrue(); + assertThat(iteration.getNextValue()).isEqualTo(LocalDate.of(2021, 1, 3)); + assertThat(iteration.getNextValue()).isEqualTo(LocalDate.of(2021, 1, 2)); + assertThat(iteration.getNextValue()).isEqualTo(LocalDate.of(2021, 1, 1)); } } \ No newline at end of file diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/custom/ZoneTimeTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/custom/ZoneTimeTest.java index f602e091051..26c49b8317c 100644 --- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/custom/ZoneTimeTest.java +++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/custom/ZoneTimeTest.java @@ -30,7 +30,6 @@ import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalQueries; -import java.util.Arrays; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -133,22 +132,18 @@ void until() { @Test void isSupportedTemporalUnit() { - for (ChronoUnit unit : ChronoUnit.values()) { - assertThat(zoneTime.isSupported(unit)).isEqualTo(offsetTime.isSupported(unit)); - } + assertThat(ChronoUnit.values()).allMatch(unit -> zoneTime.isSupported(unit) == offsetTime.isSupported(unit)); } @Test void isSupportedTemporalField() { - for (ChronoField field : ChronoField.values()) { - assertThat(zoneTime.isSupported(field)).isEqualTo(offsetTime.isSupported(field)); - } + assertThat(ChronoField.values()).allMatch(field -> zoneTime.isSupported(field) == offsetTime.isSupported(field)); } @Test void getLong() { - Arrays.stream(ChronoField.values()).filter(offsetTime::isSupported) - .forEach(field -> assertThat(offsetTime.getLong(field)).isEqualTo(zoneTime.getLong(field))); + assertThat(ChronoField.values()).filteredOn(offsetTime::isSupported) + .allMatch(field -> offsetTime.getLong(field) == (zoneTime.getLong(field))); } @Test @@ -167,16 +162,16 @@ void query() { @Test void range() { - Arrays.stream(ChronoField.values()).filter(offsetTime::isSupported) - .forEach(field -> assertThat(offsetTime.range(field)).isEqualTo(zoneTime.range(field))); + assertThat(ChronoField.values()).filteredOn(offsetTime::isSupported) + .allMatch(field -> offsetTime.range(field).equals(zoneTime.range(field))); } @Test void get() { - Arrays.stream(ChronoField.values()) - .filter(offsetTime::isSupported) - .filter(field -> field != ChronoField.NANO_OF_DAY && field != ChronoField.MICRO_OF_DAY) // Unsupported by offsettime.get() - .forEach(field -> assertThat(offsetTime.get(field)).isEqualTo(zoneTime.get(field))); + assertThat(ChronoField.values()) + .filteredOn(offsetTime::isSupported) + .filteredOn(field -> field != ChronoField.NANO_OF_DAY && field != ChronoField.MICRO_OF_DAY) // Unsupported by offsettime.get() + .allMatch(field -> offsetTime.get(field) == zoneTime.get(field)); } @Test diff --git a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/EnumGenerationTest.java b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/EnumGenerationTest.java index 81cd1b9b459..9c2c11accb8 100644 --- a/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/EnumGenerationTest.java +++ b/kie-dmn/kie-dmn-openapi/src/test/java/org/kie/dmn/openapi/EnumGenerationTest.java @@ -60,7 +60,8 @@ void numberAllowedValues() { ArrayNode arrayNode = (ArrayNode) node.get("enum"); assertThat(arrayNode).isNotNull(); List expected = Arrays.asList(BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.valueOf(2)); - arrayNode.iterator().forEachRemaining(e -> { + + assertThat(arrayNode).allSatisfy(e -> { assertThat(e).isInstanceOf(DecimalNode.class); assertThat(expected).contains(e.decimalValue()); }); @@ -75,7 +76,7 @@ void stringAllowedValues() { ArrayNode arrayNode = (ArrayNode) node.get("enum"); assertThat(arrayNode).isNotNull(); List expected = Arrays.asList("a", "b", "c"); - arrayNode.iterator().forEachRemaining(e -> { + assertThat(arrayNode).allSatisfy(e -> { assertThat(e).isInstanceOf(TextNode.class); assertThat(expected).contains(e.textValue()); }); @@ -90,7 +91,7 @@ void stringNullableAllowedValues() { ArrayNode arrayNode = (ArrayNode) node.get("enum"); assertThat(arrayNode).isNotNull(); List expected = Arrays.asList("a", "b", "c", null); - arrayNode.iterator().forEachRemaining(e -> { + assertThat(arrayNode).allSatisfy(e -> { assertThat(expected).contains(e.textValue()); }); assertThat(node.get("nullable")).isNotNull().isInstanceOf(BooleanNode.class); @@ -104,7 +105,7 @@ void numberTypeConstraint() { ArrayNode arrayNode = (ArrayNode) node.get("enum"); assertThat(arrayNode).isNotNull(); List expected = Arrays.asList(BigDecimal.ZERO, BigDecimal.ONE, BigDecimal.valueOf(2)); - arrayNode.iterator().forEachRemaining(e -> { + assertThat(arrayNode).allSatisfy(e -> { assertThat(e).isInstanceOf(DecimalNode.class); assertThat(expected).contains(e.decimalValue()); }); @@ -119,7 +120,7 @@ void stringTypeConstraint() { ArrayNode arrayNode = (ArrayNode) node.get("enum"); assertThat(arrayNode).isNotNull(); List expected = Arrays.asList("a", "b", "c"); - arrayNode.iterator().forEachRemaining(e -> { + assertThat(arrayNode).allSatisfy(e -> { assertThat(e).isInstanceOf(TextNode.class); assertThat(expected).contains(e.textValue()); });