Skip to content

Commit

Permalink
Merge branch 'apache:main' into upgrade-quarkus-3.15
Browse files Browse the repository at this point in the history
  • Loading branch information
RishiRajAnand authored Jan 24, 2025
2 parents f27c55d + afde373 commit 3db0501
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<version.org.apache.openjpa>4.0.0</version.org.apache.openjpa>
<version.org.jpmml.model>1.6.4</version.org.jpmml.model> <!-- jpmml-model BSD 3C license - ATTENTION 1.5.1 intentional, because 1.5.1 evaluators works with 1.5.1 -->
<version.org.junit>5.10.2</version.org.junit>
<version.org.mvel>2.5.1.Final</version.org.mvel>
<version.org.mvel>2.5.2.Final</version.org.mvel>
<version.org.powermock>2.0.7</version.org.powermock>
<version.org.slf4j>2.0.6</version.org.slf4j>
<!-- simple-jndi is a small library that helps us avoid JNDI error messages during testing -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
Expand Down Expand Up @@ -205,15 +205,13 @@ public static boolean isEqualsStringCompare(Object value, Object itemFromList) {
* @return
*/
public static Boolean getBooleanOrDialectDefault(Object rawReturn, FEELDialect feelDialect) {
if (feelDialect.equals(FEELDialect.BFEEL)) {
if (rawReturn instanceof Boolean bool) {
return bool;
} else {
return false;
}
} else {
return (Boolean) rawReturn;
Boolean toReturn = null;
if (rawReturn instanceof Boolean bool) {
toReturn = bool;
} else if (feelDialect.equals(FEELDialect.BFEEL)) {
toReturn = false;
}
return toReturn;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
Expand Down Expand Up @@ -58,7 +58,12 @@ private static Collection<Object[]> data() {
{ "false and false or true", Boolean.TRUE , null},
{ "false and (false or true)", Boolean.FALSE , null},
{ "true or false and false", Boolean.TRUE , null},
{ "(true or false) and false", Boolean.FALSE , null}
{ "(true or false) and false", Boolean.FALSE , null},
//
{ "123 and false", Boolean.FALSE , null},
{ "\"true\" and false", Boolean.FALSE , null},
{ "123 or true", Boolean.TRUE , null},
{ "\"true\" or true", Boolean.TRUE , null}
};
return addAdditionalParameters(cases, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import org.mockito.Mockito;

import static org.assertj.core.api.Assertions.assertThat;
import static org.kie.dmn.feel.util.BooleanEvalHelper.getBooleanOrDialectDefault;
import static org.kie.dmn.feel.util.BooleanEvalHelper.getFalseOrDialectDefault;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.times;

Expand All @@ -50,6 +52,38 @@ void numericValuesComparative() {
assertThat(BooleanEvalHelper.compare(BigInteger.valueOf(1), 2.3, FEELDialect.FEEL,(l, r) -> l.compareTo(r) == 0)).isFalse();
}

@Test
void getBooleanOrDialectDefaultFEEL() {
assertThat(getBooleanOrDialectDefault(false, FEELDialect.FEEL)).isEqualTo(Boolean.FALSE);
assertThat(getBooleanOrDialectDefault(true, FEELDialect.FEEL)).isEqualTo(Boolean.TRUE);
assertThat(getBooleanOrDialectDefault("true", FEELDialect.FEEL)).isNull();
assertThat(getBooleanOrDialectDefault(null, FEELDialect.FEEL)).isNull();
}

@Test
void getBooleanOrDialectDefaultBFEEL() {
assertThat(getBooleanOrDialectDefault(false, FEELDialect.BFEEL)).isEqualTo(Boolean.FALSE);
assertThat(getBooleanOrDialectDefault(true, FEELDialect.BFEEL)).isEqualTo(Boolean.TRUE);
assertThat(getBooleanOrDialectDefault("true", FEELDialect.BFEEL)).isEqualTo(Boolean.FALSE);
assertThat(getBooleanOrDialectDefault(null, FEELDialect.BFEEL)).isEqualTo(Boolean.FALSE);
}

@Test
void getFalseOrDialectDefaultFEEL() {
assertThat(getFalseOrDialectDefault(false, FEELDialect.FEEL)).isEqualTo(Boolean.FALSE);
assertThat(getFalseOrDialectDefault(true, FEELDialect.FEEL)).isNull();
assertThat(getFalseOrDialectDefault("true", FEELDialect.FEEL)).isNull();
assertThat(getFalseOrDialectDefault(null, FEELDialect.FEEL)).isNull();
}

@Test
void getFalseOrDialectDefaultBFEEL() {
assertThat(getFalseOrDialectDefault(false, FEELDialect.BFEEL)).isEqualTo(Boolean.FALSE);
assertThat(getFalseOrDialectDefault(true, FEELDialect.BFEEL)).isEqualTo(Boolean.FALSE);
assertThat(getFalseOrDialectDefault("true", FEELDialect.BFEEL)).isEqualTo(Boolean.FALSE);
assertThat(getFalseOrDialectDefault(null, FEELDialect.BFEEL)).isEqualTo(Boolean.FALSE);
}

@Test
void isEqualsSCWithStringValue() {
assertThat(BooleanEvalHelper.isEqualsStringCompare("", "")).isTrue();
Expand Down

0 comments on commit 3db0501

Please sign in to comment.