Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JNG-5544 Fix enumeration switch expressions #334

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
* #L%
*/

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

import com.google.inject.Inject;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.ternarytest.ternarytest.aaa.AAA;
import hu.blackbelt.judo.psm.generator.sdk.core.test.api.ternarytest.ternarytest.aaa.AAADao;
Expand All @@ -29,17 +33,16 @@
import hu.blackbelt.judo.requirement.report.annotation.Requirement;
import hu.blackbelt.judo.runtime.core.jsl.fixture.JudoRuntimeExtension;
import lombok.extern.slf4j.Slf4j;
import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
import org.junit.Assert;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.*;
import static org.junit.jupiter.api.Assertions.*;

@Slf4j
public class TernaryTest {
Expand Down Expand Up @@ -69,15 +72,15 @@ public class TernaryTest {
public void testTernaries() {

final String stringValue = "STRING";
final Integer integerValue = 10;
final Double doubleValue = 3.14159265;
final int integerValue = 10;
final BigDecimal doubleValue = BigDecimal.valueOf(3.14159265);
final LocalDate dateValue = LocalDate.of(2020, 10, 20);
final LocalDateTime timestampValue = LocalDateTime.of(2020, 10, 20, 16, 30, 5, 0);

AAA a = aDao.create(AAAForCreate.builder()
.withStringR(stringValue)
.withIntegerR(integerValue)
.withDoubleR(BigDecimal.valueOf(doubleValue))
.withDoubleR(doubleValue)
.withBooleanR(true)
.withDateR(dateValue)
.withTimestampR(timestampValue)
Expand All @@ -88,11 +91,12 @@ public void testTernaries() {
assertThat(a.getConstantString().orElseThrow(), equalTo("X"));
assertThat(a.getString().orElseThrow(), equalTo(stringValue));
assertThat(a.getInteger().orElseThrow(), equalTo(integerValue));
assertThat(a.getDouble_().orElseThrow(), equalTo(BigDecimal.valueOf(doubleValue)));
assertThat(a.getDouble_().orElseThrow(), equalTo(doubleValue));
assertThat(a.getBoolean_().orElseThrow(), equalTo(true));
assertThat(a.getDate().orElseThrow(), equalTo(dateValue));
assertThat(a.getTimestamp().orElseThrow(), equalTo(timestampValue));
assertThat(a.getUnknownCondition().orElseThrow(), equalTo(stringValue));
assertThat(a.getEnum1().orElseThrow(), equalTo(Enum.Literal1));


assertEquals("true", a.getTs().orElseThrow());
Expand All @@ -113,11 +117,11 @@ public void testTernaries() {
AAA a1 = aDao.create(AAAForCreate.builder()
.withStringR(stringValue)
.withIntegerR(integerValue)
.withDoubleR(BigDecimal.valueOf(doubleValue))
.withDoubleR(doubleValue)
.withBooleanR(false)
.withDateR(dateValue)
.withTimestampR(timestampValue)
.withEnumR(Enum.Literal2)
.withEnumO(Enum.Literal2)
.build()
);

Expand All @@ -131,6 +135,7 @@ public void testTernaries() {
assertTrue(a1.getDate().isEmpty());
assertTrue(a1.getTimestamp().isEmpty());
assertThat(a1.getUnknownCondition().orElseThrow(), equalTo(stringValue));
assertThat(a1.getEnum1().orElseThrow(), equalTo(Enum.Literal2));


// TODO https://blackbelt.atlassian.net/browse/JNG-5543
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ entity AAA {
field Enum enumR;
field Enum enumO;

//field Enum enum1 <= self.booleanR ? self.enumR : self.enumO; // TODO JNG-5544 error in runtime
field Enum enum1 <= self.booleanR ? self.enumR : self.enumO;

field String FirstLetterIsUpper;
field String FirstLetterIsUpperWithDefault default: "Hello";
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
javax.resource;version="[1.6,2)"
</osgi-transaction-import>

<judo-tatami-jsl-version>1.1.4.20241211_160519_93bf866b_feature_JNG_6021_SQL_Error_on_filter_with_count</judo-tatami-jsl-version>
<judo-runtime-core-version>1.0.6.20241211_154309_7e8dda02_feature_JNG_6021_SQL_Error_on_filter_with_count</judo-runtime-core-version>
<judo-tatami-jsl-version>1.1.4.20241212_134634_e1bccdcc_feature_JNG_5544_Fix_enumeration_switch_expressions</judo-tatami-jsl-version>
<judo-runtime-core-version>1.0.6.20241212_134241_404ab490_feature_JNG_5544_Fix_enumeration_switch_expressions</judo-runtime-core-version>
<judo-psm-generator-sdk-core-version>1.0.0.20241202_042521_49b75de5_develop</judo-psm-generator-sdk-core-version>

<judo-meta-psm-version>1.3.0.20241202_042213_d30645b4_develop</judo-meta-psm-version>
Expand Down
Loading