Skip to content

Commit

Permalink
FIX proper use-case following kie-server marshalling requirements (#1)
Browse files Browse the repository at this point in the history
* FIX proper use-case following kie-server marshalling requirements

* avoid anti-pattern of using `today()` which is not pure Fn in tests.
  • Loading branch information
tarilabs committed Jun 4, 2020
1 parent 4646a25 commit 14054f7
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 11 deletions.
Expand Up @@ -11,7 +11,18 @@
<version>1.0.0.Final</version>
<packaging>kjar</packaging>

<!-- there should be no need for Kie, Kie-DMN, etc dependencies here -->
<!-- Normally, there should be no need for Kie, Kie-DMN, etc dependencies here
However this test requires to explicit JAXB converter for the dates as example here: https://github.com/kiegroup/droolsjbpm-integration/blob/e15e207945ba32581955394947d1671ea381109e/kie-server-parent/kie-server-api/src/test/java/org/kie/server/api/marshalling/objects/DateObject.java#L53
Hence this `kie-internal` with `provided` scope dependency is the bare minimum to re-create what could be defined on a Business-Central based project.
-->
<dependencies>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-internal</artifactId>
<version>${version.org.kie}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
Expand Down
@@ -0,0 +1,47 @@
package org.example.localdateunarytest;

@javax.xml.bind.annotation.XmlAccessorType(javax.xml.bind.annotation.XmlAccessType.FIELD)
public class Person implements java.io.Serializable {

static final long serialVersionUID = 1L;

private java.lang.String id;
private java.lang.String name;
@javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter(org.kie.internal.jaxb.LocalDateXmlAdapter.class)
private java.time.LocalDate dojoining;

public Person() {
}

public java.lang.String getId() {
return this.id;
}

public void setId(java.lang.String id) {
this.id = id;
}

public java.lang.String getName() {
return this.name;
}

public void setName(java.lang.String name) {
this.name = name;
}

public java.time.LocalDate getDojoining() {
return this.dojoining;
}

public void setDojoining(java.time.LocalDate dojoining) {
this.dojoining = dojoining;
}

public Person(java.lang.String id, java.lang.String name,
java.time.LocalDate dojoining) {
this.id = id;
this.name = name;
this.dojoining = dojoining;
}

}
Expand Up @@ -29,7 +29,7 @@
<dmn:annotation name=""/>
<dmn:rule id="_FFE43BB7-3314-4441-A2CD-E07A7881504C">
<dmn:inputEntry id="_567C635B-081E-4255-AD79-787FF55DECD6">
<dmn:text>&gt;today()</dmn:text>
<dmn:text>&gt;date("2020-06-04")</dmn:text>
</dmn:inputEntry>
<dmn:outputEntry id="_DE7B6538-E749-4EB3-B50E-F3C505AC7ACD">
<dmn:text>"xyz"</dmn:text>
Expand Down
Expand Up @@ -20,7 +20,6 @@
import java.util.Map;

import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.kie.api.KieServices;
import org.kie.dmn.api.core.DMNContext;
Expand All @@ -29,6 +28,7 @@
import org.kie.server.api.model.ReleaseId;
import org.kie.server.api.model.ServiceResponse;
import org.kie.server.integrationtests.shared.KieServerDeployer;
import org.kie.server.integrationtests.shared.KieServerReflections;

import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
Expand All @@ -43,6 +43,7 @@ public class DMNLocalDateIntegrationTest

private static final String CONTAINER_1_ID = "local-date-unary-check";
private static final String CONTAINER_1_ALIAS = "localdate";
private static final String PERSON_CLASS_NAME = "org.example.localdateunarytest.Person";

@BeforeClass
public static void deployArtifacts() {
Expand All @@ -54,19 +55,15 @@ public static void deployArtifacts() {
}

@Override
protected void addExtraCustomClasses(Map<String, Class<?>> extraClasses)
throws Exception {
protected void addExtraCustomClasses(Map<String, Class<?>> extraClasses) throws Exception {
extraClasses.put(PERSON_CLASS_NAME, Class.forName(PERSON_CLASS_NAME, true, kieContainer.getClassLoader()));
}

@Test
@Ignore("JBPM-9173")
public void test_evaluateLocaleDateUnaryCheck() {
DMNContext dmnContext = dmnClient.newContext();
final Map<String, Object> personData = new HashMap<>();
personData.put("id", "person-id-1");
personData.put("name", "Eager Join");
personData.put("dojoining", LocalDate.of(2021, 8, 11));
dmnContext.set("PersonData", personData);
final Object person = KieServerReflections.createInstance(PERSON_CLASS_NAME, kieContainer.getClassLoader(), "person-id-1", "Eager Join", LocalDate.of(2021, 8, 11));
dmnContext.set("PersonData", person);
ServiceResponse<DMNResult> evaluateAll = dmnClient.evaluateAll(CONTAINER_1_ID,
"https://kiegroup.org/dmn/_5851203A-5DA1-4020-B7D1-E23C89634164",
"Test",
Expand Down

0 comments on commit 14054f7

Please sign in to comment.