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 -> assertEquals(expected.get(i), 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/lang/ast/forexpressioniterators/ForIterationUtilsTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ForIterationUtilsTest.java
index 0b4da928e6f..226d2e1797d 100644
--- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ForIterationUtilsTest.java
+++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ForIterationUtilsTest.java
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -31,8 +31,7 @@
import org.kie.dmn.feel.lang.impl.FEELEventListenersManager;
import org.mockito.ArgumentCaptor;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.kie.dmn.feel.codegen.feel11.CodegenTestUtil.newEmptyEvaluationContext;
import static org.kie.dmn.feel.lang.ast.forexpressioniterators.ForIterationUtils.getForIteration;
import static org.kie.dmn.feel.lang.ast.forexpressioniterators.ForIterationUtils.validateValues;
@@ -60,10 +59,10 @@ void setup() {
@Test
void getForIterationValidTest() {
ForIteration retrieved = getForIteration(ctx, "iteration", BigDecimal.valueOf(1), BigDecimal.valueOf(3));
- assertNotNull(retrieved);
+ assertThat(retrieved).isNotNull();
verify(listener, never()).onEvent(any(FEELEvent.class));
retrieved = getForIteration(ctx, "iteration", LocalDate.of(2021, 1, 1), LocalDate.of(2021, 1, 3));
- assertNotNull(retrieved);
+ assertThat(retrieved).isNotNull();
verify(listener, never()).onEvent(any(FEELEvent.class));
}
@@ -72,7 +71,7 @@ void getForIterationNotValidTest() {
try {
getForIteration(ctx, "iteration", "NOT", "VALID");
} catch (Exception e) {
- assertTrue(e instanceof EndpointOfRangeNotValidTypeException);
+ assertThat(e).isInstanceOf(EndpointOfRangeNotValidTypeException.class);
final ArgumentCaptor captor = ArgumentCaptor.forClass(FEELEvent.class);
verify(listener, times(1)).onEvent(captor.capture());
reset(listener);
@@ -80,7 +79,7 @@ void getForIterationNotValidTest() {
try {
getForIteration(ctx, "iteration", BigDecimal.valueOf(1), LocalDate.of(2021, 1, 1));
} catch (Exception e) {
- assertTrue(e instanceof EndpointOfRangeOfDifferentTypeException);
+ assertThat(e).isInstanceOf(EndpointOfRangeOfDifferentTypeException.class);
final ArgumentCaptor captor = ArgumentCaptor.forClass(FEELEvent.class);
verify(listener, times(1)).onEvent(captor.capture());
reset(listener);
@@ -88,7 +87,7 @@ void getForIterationNotValidTest() {
try {
getForIteration(ctx, "iteration", LocalDate.of(2021, 1, 1), BigDecimal.valueOf(1));
} catch (Exception e) {
- assertTrue(e instanceof EndpointOfRangeOfDifferentTypeException);
+ assertThat(e).isInstanceOf(EndpointOfRangeOfDifferentTypeException.class);
final ArgumentCaptor captor = ArgumentCaptor.forClass(FEELEvent.class);
verify(listener, times(1)).onEvent(captor.capture());
reset(listener);
@@ -108,7 +107,7 @@ void valueMustBeValidFalseTest() {
try {
valueMustBeValid(ctx, "INVALID");
} catch (Exception e) {
- assertTrue(e instanceof EndpointOfRangeNotValidTypeException);
+ assertThat(e).isInstanceOf(EndpointOfRangeNotValidTypeException.class);
final ArgumentCaptor captor = ArgumentCaptor.forClass(FEELEvent.class);
verify(listener, times(1)).onEvent(captor.capture());
}
@@ -127,7 +126,7 @@ void validateValuesFalseTest() {
try {
validateValues(ctx, "INVALID", "INVALID");
} catch (Exception e) {
- assertTrue(e instanceof EndpointOfRangeNotValidTypeException);
+ assertThat(e).isInstanceOf(EndpointOfRangeNotValidTypeException.class);
final ArgumentCaptor captor = ArgumentCaptor.forClass(FEELEvent.class);
verify(listener, times(1)).onEvent(captor.capture());
reset(listener);
@@ -135,7 +134,7 @@ void validateValuesFalseTest() {
try {
validateValues(ctx, BigDecimal.valueOf(1), LocalDate.of(2021, 1, 1));
} catch (Exception e) {
- assertTrue(e instanceof EndpointOfRangeOfDifferentTypeException);
+ assertThat(e).isInstanceOf(EndpointOfRangeOfDifferentTypeException.class);
final ArgumentCaptor captor = ArgumentCaptor.forClass(FEELEvent.class);
verify(listener, times(1)).onEvent(captor.capture());
reset(listener);
@@ -143,12 +142,10 @@ void validateValuesFalseTest() {
try {
validateValues(ctx, LocalDate.of(2021, 1, 1), BigDecimal.valueOf(1));
} catch (Exception e) {
- assertTrue(e instanceof EndpointOfRangeOfDifferentTypeException);
+ assertThat(e).isInstanceOf(EndpointOfRangeOfDifferentTypeException.class);
final ArgumentCaptor captor = ArgumentCaptor.forClass(FEELEvent.class);
verify(listener, times(1)).onEvent(captor.capture());
reset(listener);
}
}
-
-
}
\ No newline at end of file
diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/LocalDateRangeIteratorTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/LocalDateRangeIteratorTest.java
index eaf378f26e7..6f932c15d24 100644
--- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/LocalDateRangeIteratorTest.java
+++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/LocalDateRangeIteratorTest.java
@@ -19,16 +19,11 @@
package org.kie.dmn.feel.lang.ast.forexpressioniterators;
import java.time.LocalDate;
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.IntStream;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
class LocalDateRangeIteratorTest {
@@ -44,39 +39,37 @@ static void setup() {
@Test
void hasNextAscendantTest() {
LocalDateRangeIterator iterator = new LocalDateRangeIterator(before, after);
- assertTrue(iterator.hasNext());
+ assertThat(iterator).hasNext();
LocalDate next = iterator.next();
while (!next.equals(after)) {
- assertTrue(iterator.hasNext());
+ assertThat(iterator).hasNext();
next = iterator.next();
}
- assertFalse(iterator.hasNext());
+ assertThat(iterator).isExhausted();
}
@Test
void hasNextDescendantTest() {
LocalDateRangeIterator iterator = new LocalDateRangeIterator(after, before);
- assertTrue(iterator.hasNext());
+ assertThat(iterator).hasNext();
LocalDate next = iterator.next();
while (!next.equals(before)) {
- assertTrue(iterator.hasNext());
+ assertThat(iterator).hasNext();
next = iterator.next();
}
- assertFalse(iterator.hasNext());
+ assertThat(iterator).isExhausted();
}
@Test
void nextAscendantTest() {
- List expected = Arrays.asList(LocalDate.of(2021, 1, 1), LocalDate.of(2021, 1, 2), LocalDate.of(2021, 1, 3));
LocalDateRangeIterator iterator = new LocalDateRangeIterator(before, after);
- IntStream.range(0, 3).forEach(i -> assertEquals(expected.get(i), iterator.next()));
+ assertThat(iterator).toIterable().containsExactly(LocalDate.of(2021, 1, 1), LocalDate.of(2021, 1, 2), LocalDate.of(2021, 1, 3));
}
@Test
void nextDescendantTest() {
- List expected = Arrays.asList(LocalDate.of(2021, 1, 3), LocalDate.of(2021, 1, 2), LocalDate.of(2021, 1, 1));
LocalDateRangeIterator iterator = new LocalDateRangeIterator(after, before);
- IntStream.range(0, 3).forEach(i -> assertEquals(expected.get(i), iterator.next()));
+ assertThat(iterator).toIterable().containsExactly(LocalDate.of(2021, 1, 3), LocalDate.of(2021, 1, 2), LocalDate.of(2021, 1, 1));
}
diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ZonedDateTimeRangeIteratorTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ZonedDateTimeRangeIteratorTest.java
index 9290ec8fa21..c11f203619a 100644
--- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ZonedDateTimeRangeIteratorTest.java
+++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/lang/ast/forexpressioniterators/ZonedDateTimeRangeIteratorTest.java
@@ -21,16 +21,11 @@
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.IntStream;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
class ZonedDateTimeRangeIteratorTest {
@@ -47,43 +42,41 @@ static void setup() {
@Test
void hasNextAscendantTest() {
ZonedDateTimeRangeIterator iterator = new ZonedDateTimeRangeIterator(before, after);
- assertTrue(iterator.hasNext());
+ assertThat(iterator).hasNext();
ZonedDateTime next = iterator.next();
while (next.isBefore(after)) {
- assertTrue(iterator.hasNext());
+ assertThat(iterator).hasNext();
next = iterator.next();
}
- assertFalse(iterator.hasNext());
+ assertThat(iterator).isExhausted();
}
@Test
void hasNextDescendantTest() {
ZonedDateTimeRangeIterator iterator = new ZonedDateTimeRangeIterator(after, before);
- assertTrue(iterator.hasNext());
+ assertThat(iterator).hasNext();
ZonedDateTime next = iterator.next();
while (!next.equals(before)) {
- assertTrue(iterator.hasNext());
+ assertThat(iterator).hasNext();
next = iterator.next();
}
- assertFalse(iterator.hasNext());
+ assertThat(iterator).isExhausted();
}
@Test
void nextAscendantTest() {
- List expected = Arrays.asList(getZonedDateTime(2021, 1, 1, 10, 15),
+ ZonedDateTimeRangeIterator iterator = new ZonedDateTimeRangeIterator(before, after);
+ assertThat(iterator).toIterable().containsExactly(getZonedDateTime(2021, 1, 1, 10, 15),
getZonedDateTime(2021, 1, 2, 10, 15),
getZonedDateTime(2021, 1, 3, 10, 15));
- ZonedDateTimeRangeIterator iterator = new ZonedDateTimeRangeIterator(before, after);
- IntStream.range(0, 3).forEach(i -> assertEquals(expected.get(i), iterator.next()));
}
@Test
void nextDescendantTest() {
- List expected = Arrays.asList(getZonedDateTime(2021, 1, 3, 10, 15),
+ ZonedDateTimeRangeIterator iterator = new ZonedDateTimeRangeIterator(after, before);
+ assertThat(iterator).toIterable().containsExactly(getZonedDateTime(2021, 1, 3, 10, 15),
getZonedDateTime(2021, 1, 2, 10, 15),
getZonedDateTime(2021, 1, 1, 10, 15));
- ZonedDateTimeRangeIterator iterator = new ZonedDateTimeRangeIterator(after, before);
- IntStream.range(0, 3).forEach(i -> assertEquals(expected.get(i), iterator.next()));
}
@@ -93,8 +86,8 @@ void hasNotNextAscendantTest() {
ZonedDateTime end = getZonedDateTime(2021, 1, 2, 10, 14);
ZonedDateTimeRangeIterator iterator = new ZonedDateTimeRangeIterator(start, end);
ZonedDateTime retrieved = iterator.next();
- assertEquals(start, retrieved);
- assertFalse(iterator.hasNext());
+ assertThat(retrieved).isEqualTo(start);
+ assertThat(iterator).isExhausted();
}
@Test
@@ -103,8 +96,8 @@ void hasNotNextDescendantTest() {
ZonedDateTime end = getZonedDateTime(2021, 1, 1, 10, 15);
ZonedDateTimeRangeIterator iterator = new ZonedDateTimeRangeIterator(start, end);
ZonedDateTime retrieved = iterator.next();
- assertEquals(start, retrieved);
- assertFalse(iterator.hasNext());
+ assertThat(retrieved).isEqualTo(start);
+ assertThat(iterator).isExhausted();
}
private static ZonedDateTime getZonedDateTime(int year, int month, int dayOfMonth, int hour, int minute) {
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 af286aad609..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,12 +30,11 @@
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;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.kie.dmn.feel.runtime.custom.ZoneTime.ZONED_OFFSET_WITH_SECONDS;
import static org.kie.dmn.feel.runtime.custom.ZoneTime.ZONED_OFFSET_WITHOUT_SECONDS;
@@ -59,29 +58,29 @@ static void setUpClass() {
@Test
void of() {
ZoneTime retrieved = ZoneTime.of(localTime, zoneId, true);
- assertNotNull(retrieved);
- assertEquals(offsetTime, retrieved.getOffsetTime());
- assertEquals(zoneId, retrieved.getZoneId());
+ assertThat(retrieved).isNotNull();
+ assertThat(retrieved.getOffsetTime()).isEqualTo(offsetTime);
+ assertThat(retrieved.getZoneId()).isEqualTo(zoneId);
}
@Test
void getTimezone() {
- assertEquals(REFERENCED_ZONE, zoneTime.getTimezone());
+ assertThat(zoneTime.getTimezone()).isEqualTo(REFERENCED_ZONE);
}
@Test
void compareTo() {
ZoneTime toCompare = ZoneTime.of(DateTimeFormatter.ISO_TIME.parse("09:34:31", LocalTime::from), zoneId, false);
OffsetTime comparison = toCompare.getOffsetTime();
- assertEquals(offsetTime.compareTo(comparison), zoneTime.compareTo(toCompare));
+ assertThat(zoneTime.compareTo(toCompare)).isEqualTo(offsetTime.compareTo(comparison));
}
@Test
void withTemporalField() {
ZoneTime expected = new ZoneTime(offsetTime.with(ChronoField.HOUR_OF_DAY, 3), zoneId, false);
- assertEquals(expected, zoneTime.with(ChronoField.HOUR_OF_DAY, 3));
+ assertThat(zoneTime.with(ChronoField.HOUR_OF_DAY, 3)).isEqualTo(expected);
}
@Test
@@ -89,37 +88,37 @@ void withTemporalAdjuster() {
TemporalAdjuster adjuster = ZoneTime.of(DateTimeFormatter.ISO_TIME.parse("09:34:31", LocalTime::from), zoneId
, false);
ZoneTime expected = new ZoneTime(offsetTime.with(adjuster), zoneId, false);
- assertEquals(expected, zoneTime.with(adjuster));
+ assertThat(zoneTime.with(adjuster)).isEqualTo(expected);
adjuster = DateTimeFormatter.ISO_TIME.parse("09:34:31", LocalTime::from );
expected = new ZoneTime(offsetTime.with(adjuster), zoneId, false);
- assertEquals(expected, zoneTime.with(adjuster));
+ assertThat(zoneTime.with(adjuster)).isEqualTo(expected);
}
@Test
void plusLong() {
ZoneTime expected = new ZoneTime(offsetTime.plus(3, ChronoUnit.HOURS), zoneId, false);
- assertEquals(expected, zoneTime.plus(3, ChronoUnit.HOURS));
+ assertThat(zoneTime.plus(3, ChronoUnit.HOURS)).isEqualTo(expected);
}
@Test
void plusTemporalAmount() {
TemporalAmount amount = Duration.of(23, ChronoUnit.MINUTES);
ZoneTime expected = new ZoneTime(offsetTime.plus(amount), zoneId, false);
- assertEquals(expected, zoneTime.plus(amount));
+ assertThat(zoneTime.plus(amount)).isEqualTo(expected);
}
@Test
void minusLong() {
ZoneTime expected = new ZoneTime(offsetTime.minus(3, ChronoUnit.HOURS), zoneId, false);
- assertEquals(expected, zoneTime.minus(3, ChronoUnit.HOURS));
+ assertThat(zoneTime.minus(3, ChronoUnit.HOURS)).isEqualTo(expected);
}
@Test
void minusTemporalAmount() {
TemporalAmount amount = Duration.of(23, ChronoUnit.MINUTES);
ZoneTime expected = new ZoneTime(offsetTime.minus(amount), zoneId, false);
- assertEquals(expected, zoneTime.minus(amount));
+ assertThat(zoneTime.minus(amount)).isEqualTo(expected);
}
@Test
@@ -128,63 +127,59 @@ void until() {
false);
long expected = offsetTime.until(endExclusive, ChronoUnit.SECONDS);
long retrieved = zoneTime.until(endExclusive, ChronoUnit.SECONDS);
- assertEquals(expected, retrieved);
+ assertThat(retrieved).isEqualTo(expected);
}
@Test
void isSupportedTemporalUnit() {
- for (ChronoUnit unit : ChronoUnit.values()) {
- assertEquals(offsetTime.isSupported(unit), zoneTime.isSupported(unit));
- }
+ assertThat(ChronoUnit.values()).allMatch(unit -> zoneTime.isSupported(unit) == offsetTime.isSupported(unit));
}
@Test
void isSupportedTemporalField() {
- for (ChronoField field : ChronoField.values()) {
- assertEquals(offsetTime.isSupported(field), zoneTime.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 -> assertEquals(offsetTime.getLong(field), zoneTime.getLong(field)));
+ assertThat(ChronoField.values()).filteredOn(offsetTime::isSupported)
+ .allMatch(field -> offsetTime.getLong(field) == (zoneTime.getLong(field)));
}
@Test
void adjustInto() {
ZoneTime temporal = ZoneTime.of(DateTimeFormatter.ISO_TIME.parse("09:34:31", LocalTime::from), zoneId, false);
- assertEquals(offsetTime.adjustInto(temporal), zoneTime.adjustInto(temporal));
+ assertThat(zoneTime.adjustInto(temporal)).isEqualTo(offsetTime.adjustInto(temporal));
}
@Test
void query() {
- assertEquals(zoneId, zoneTime.query(TemporalQueries.zoneId()));
- assertEquals(zoneId, zoneTime.query(TemporalQueries.zone()));
- assertEquals(offsetTime.query(TemporalQueries.localTime()), zoneTime.query(TemporalQueries.localTime()));
- assertEquals(offsetTime.query(TemporalQueries.offset()), zoneTime.query(TemporalQueries.offset()));
+ assertThat(zoneTime.query(TemporalQueries.zoneId())).isEqualTo(zoneId);
+ assertThat(zoneTime.query(TemporalQueries.zone())).isEqualTo(zoneId);
+ assertThat(zoneTime.query(TemporalQueries.localTime())).isEqualTo(offsetTime.query(TemporalQueries.localTime()));
+ assertThat(zoneTime.query(TemporalQueries.offset())).isEqualTo(offsetTime.query(TemporalQueries.offset()));
}
@Test
void range() {
- Arrays.stream(ChronoField.values()).filter(offsetTime::isSupported)
- .forEach(field -> assertEquals(offsetTime.range(field), 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 -> assertEquals(offsetTime.get(field), 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
void testEquals() {
ZoneTime toCompare = ZoneTime.of(DateTimeFormatter.ISO_TIME.parse("09:34:31", LocalTime::from), zoneId, false);
- assertFalse(zoneTime.equals(toCompare));
+ assertThat(toCompare).isNotEqualTo(zoneTime);
toCompare = ZoneTime.of(localTime, zoneId, false);
- assertTrue(zoneTime.equals(toCompare));
+ assertThat(toCompare).isEqualTo(zoneTime);
}
@Test
@@ -192,7 +187,7 @@ void testZONED_OFFSET_WITHOUT_SECONDS() {
String timeString = "09:34";
ZoneTime toFormat = ZoneTime.of(DateTimeFormatter.ISO_TIME.parse(timeString, LocalTime::from), zoneId, false);
String expected = String.format("%s@%s", timeString, REFERENCED_ZONE);
- assertEquals(expected, ZONED_OFFSET_WITHOUT_SECONDS.format(toFormat));
+ assertThat(ZONED_OFFSET_WITHOUT_SECONDS.format(toFormat)).isEqualTo(expected);
}
@Test
@@ -200,12 +195,12 @@ void testZONED_OFFSET_WITH_SECONDS() {
String timeString = "09:34:34";
ZoneTime toFormat = ZoneTime.of(DateTimeFormatter.ISO_TIME.parse(timeString, LocalTime::from), zoneId, true);
String expected = String.format("%s@%s", timeString, REFERENCED_ZONE);
- assertEquals(expected, ZONED_OFFSET_WITH_SECONDS.format(toFormat));
+ assertThat(ZONED_OFFSET_WITH_SECONDS.format(toFormat)).isEqualTo(expected);
timeString = "09:34:00";
toFormat = ZoneTime.of(DateTimeFormatter.ISO_TIME.parse(timeString, LocalTime::from), zoneId, true);
expected = String.format("%s@%s", timeString, REFERENCED_ZONE);
- assertEquals(expected, ZONED_OFFSET_WITH_SECONDS.format(toFormat));
+ assertThat(ZONED_OFFSET_WITH_SECONDS.format(toFormat)).isEqualTo(expected);
}
@Test
@@ -213,7 +208,7 @@ void testFormatWithoutSeconds() {
String timeString = "09:34";
ZoneTime toFormat = ZoneTime.of(DateTimeFormatter.ISO_TIME.parse(timeString, LocalTime::from), zoneId, false);
String expected = String.format("%s@%s", timeString, REFERENCED_ZONE);
- assertEquals(expected, toFormat.format());
+ assertThat(toFormat.format()).isEqualTo(expected);
}
@Test
@@ -221,12 +216,12 @@ void testFormatWithSeconds() {
String timeString = "09:34:00";
ZoneTime toFormat = ZoneTime.of(DateTimeFormatter.ISO_TIME.parse(timeString, LocalTime::from), zoneId, true);
String expected = String.format("%s@%s", timeString, REFERENCED_ZONE);
- assertEquals(expected, toFormat.format());
+ assertThat(toFormat.format()).isEqualTo(expected);
timeString = "09:34:34";
toFormat = ZoneTime.of(DateTimeFormatter.ISO_TIME.parse(timeString, LocalTime::from), zoneId, true);
expected = String.format("%s@%s", timeString, REFERENCED_ZONE);
- assertEquals(expected, toFormat.format());
+ assertThat(toFormat.format()).isEqualTo(expected);
}
private static OffsetTime getCorrectOffsetTime() {
diff --git a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/BaseFEELFunctionHelperTest.java b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/BaseFEELFunctionHelperTest.java
index 39106d29d10..9143712030a 100644
--- a/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/BaseFEELFunctionHelperTest.java
+++ b/kie-dmn/kie-dmn-feel/src/test/java/org/kie/dmn/feel/runtime/functions/BaseFEELFunctionHelperTest.java
@@ -37,13 +37,6 @@
import org.kie.dmn.feel.util.NumberEvalHelper;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertInstanceOf;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
class BaseFEELFunctionHelperTest {
@@ -58,14 +51,14 @@ public void setUp() {
void getAdjustedParametersForMethod() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
// StddevFunction.invoke(@ParameterName( "list" ) List> list)
Method method = StddevFunction.class.getMethod("invoke", List.class);
- assertNotNull(method);
+ assertThat(method).isNotNull();
Object actualValue = Arrays.asList(2, 4, 7, 5);
Object[] parameters = {new NamedParameter("list", actualValue)};
Object[] retrieved = BaseFEELFunctionHelper.getAdjustedParametersForMethod(ctx, parameters, true, method);
- assertNotNull(retrieved);
- assertEquals(parameters.length, retrieved.length);
- assertEquals(actualValue, retrieved[0]);
+ assertThat(retrieved).isNotNull();
+ assertThat(retrieved.length).isEqualTo(parameters.length);
+ assertThat(retrieved[0]).isEqualTo(actualValue);
}
@Test
@@ -75,103 +68,102 @@ void adjustByCoercion() {
Class>[] parameterTypes = new Class[]{List.class};
Object[] actualParams = {actualParam};
Object[] retrieved = BaseFEELFunctionHelper.adjustByCoercion(parameterTypes, actualParams);
- assertEquals(actualParams, retrieved);
+ assertThat(retrieved).isEqualTo(actualParams);
actualParam = "StringA";
parameterTypes = new Class[]{String.class};
actualParams = new Object[]{actualParam};
retrieved = BaseFEELFunctionHelper.adjustByCoercion(parameterTypes, actualParams);
- assertEquals(actualParams, retrieved);
+ assertThat(retrieved).isEqualTo(actualParams);
// coercing more objects to different types: fails
parameterTypes = new Class[]{String.class, Integer.class};
actualParams = new Object[]{"String", 34 };
retrieved = BaseFEELFunctionHelper.adjustByCoercion(parameterTypes, actualParams);
- assertEquals(actualParams, retrieved);
+ assertThat(retrieved).isEqualTo(actualParams);
// not coercing null value to not-list type
actualParam = null;
actualParams = new Object[]{actualParam};
retrieved = BaseFEELFunctionHelper.adjustByCoercion(parameterTypes, actualParams);
- assertEquals(actualParams, retrieved);
+ assertThat(retrieved).isEqualTo(actualParams);
// not coercing null value to singleton list
parameterTypes = new Class[]{List.class};
retrieved = BaseFEELFunctionHelper.adjustByCoercion(parameterTypes, actualParams);
- assertEquals(actualParams, retrieved);
+ assertThat(retrieved).isEqualTo(actualParams);
// coercing not-null value to singleton list
actualParam = "StringA";
actualParams = new Object[]{actualParam};
retrieved = BaseFEELFunctionHelper.adjustByCoercion(parameterTypes, actualParams);
- assertNotNull(retrieved);
- assertNotEquals(actualParams, retrieved);
- assertEquals(1, retrieved.length);
- assertNotNull(retrieved[0]);
+ assertThat(retrieved).isNotNull();
+ assertThat(retrieved).isNotEqualTo(actualParams);
+ assertThat(retrieved.length).isEqualTo(1);
+ assertThat(retrieved[0]).isNotNull();
assertThat(retrieved[0]).isInstanceOf(List.class);
List retrievedList = (List) retrieved[0];
- assertEquals(1, retrievedList.size());
- assertEquals(actualParam, retrievedList.get(0));
+ assertThat(retrievedList.size()).isEqualTo(1);
+ assertThat(retrievedList.get(0)).isEqualTo(actualParam);
// coercing null value to array: fails
parameterTypes = new Class[]{Object.class.arrayType()};
retrieved = BaseFEELFunctionHelper.adjustByCoercion(parameterTypes, actualParams);
- assertNull(retrieved);
+ assertThat(retrieved).isNull();
// coercing one object to different type: fails
actualParam = 45;
parameterTypes = new Class[]{String.class};
actualParams = new Object[]{actualParam};
retrieved = BaseFEELFunctionHelper.adjustByCoercion(parameterTypes, actualParams);
- assertNull(retrieved);
+ assertThat(retrieved).isNull();
// coercing more objects to different types: fails
parameterTypes = new Class[]{String.class, Integer.class};
actualParams = new Object[]{"String", "34" };
retrieved = BaseFEELFunctionHelper.adjustByCoercion(parameterTypes, actualParams);
- assertNull(retrieved);
-
+ assertThat(retrieved).isNull();
}
@Test
void addCtxParamIfRequired() throws NoSuchMethodException {
// AllFunction.invoke(@ParameterName( "list" ) List list)
Method method = AllFunction.class.getMethod("invoke", List.class);
- assertNotNull(method);
+ assertThat(method).isNotNull();
Object[] parameters = {List.of(true, false)};
Object[] retrieved = BaseFEELFunctionHelper.addCtxParamIfRequired(ctx, parameters, true, method);
- assertNotNull(retrieved);
- assertEquals(parameters.length, retrieved.length);
+ assertThat(retrieved).isNotNull();
+ assertThat(retrieved.length).isEqualTo(parameters.length);
for (int i = 0; i < parameters.length; i++) {
- assertEquals(parameters[i], retrieved[i]);
+ assertThat(retrieved[i]).isEqualTo(parameters[i]);
}
// SortFunction.invoke(@ParameterName( "ctx" ) EvaluationContext ctx,
// @ParameterName("list") List list,
// @ParameterName("precedes") FEELFunction function)
method = SortFunction.class.getMethod("invoke", EvaluationContext.class, List.class, FEELFunction.class);
- assertNotNull(method);
+ assertThat(method).isNotNull();
parameters = new Object[]{List.of(1, 2), AllFunction.INSTANCE};
// direct reference to ctx
retrieved = BaseFEELFunctionHelper.addCtxParamIfRequired(ctx, parameters, false, method);
- assertNotNull(retrieved);
- assertEquals(parameters.length + 1, retrieved.length);
- assertEquals(ctx, retrieved[0]);
+ assertThat(retrieved).isNotNull();
+ assertThat(retrieved.length).isEqualTo(parameters.length + 1);
+ assertThat(retrieved[0]).isEqualTo(ctx);
for (int i = 0; i < parameters.length; i++) {
- assertEquals(parameters[i], retrieved[i + 1]);
+ assertThat(retrieved[i + 1]).isEqualTo(parameters[i]);
}
// NamedParameter reference to ctx
retrieved = BaseFEELFunctionHelper.addCtxParamIfRequired(ctx, parameters, true, method);
- assertNotNull(retrieved);
- assertEquals(parameters.length + 1, retrieved.length);
- assertEquals(NamedParameter.class, retrieved[0].getClass());
+ assertThat(retrieved).isNotNull();
+ assertThat(retrieved.length).isEqualTo(parameters.length + 1);
+ assertThat(retrieved[0].getClass()).isEqualTo(NamedParameter.class);
NamedParameter retrievedNamedParameter = (NamedParameter) retrieved[0];
- assertEquals("ctx", retrievedNamedParameter.getName());
- assertEquals(ctx, retrievedNamedParameter.getValue());
+ assertThat(retrievedNamedParameter.getName()).isEqualTo("ctx");
+ assertThat(retrievedNamedParameter.getValue()).isEqualTo(ctx);
for (int i = 0; i < parameters.length; i++) {
- assertEquals(parameters[i], retrieved[i + 1]);
+ assertThat(retrieved[i + 1]).isEqualTo(parameters[i]);
}
}
@@ -179,16 +171,16 @@ void addCtxParamIfRequired() throws NoSuchMethodException {
void calculateActualParams() throws NoSuchMethodException {
// CeilingFunction.invoke(@ParameterName( "n" ) BigDecimal n)
Method m = CeilingFunction.class.getMethod("invoke", BigDecimal.class);
- assertNotNull(m);
+ assertThat(m).isNotNull();
NamedParameter[] parameters = {new NamedParameter("n", BigDecimal.valueOf(1.5))};
Object[] retrieved = BaseFEELFunctionHelper.calculateActualParams(m, parameters);
- assertNotNull(retrieved);
- assertEquals(parameters.length, retrieved.length);
- assertEquals(parameters[0].getValue(), retrieved[0]);
+ assertThat(retrieved).isNotNull();
+ assertThat(retrieved.length).isEqualTo(parameters.length);
+ assertThat(retrieved[0]).isEqualTo(parameters[0].getValue());
parameters = new NamedParameter[]{new NamedParameter("undefined", BigDecimal.class)};
retrieved = BaseFEELFunctionHelper.calculateActualParams(m, parameters);
- assertNull(retrieved);
+ assertThat(retrieved).isNull();
}
@Test
@@ -200,14 +192,14 @@ void calculateActualParam() {
boolean isVariableParameters = false;
String variableParamPrefix = null;
List