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

Sync main branch with Apache main branch #80

Merged
merged 17 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
1753209
NO ISSUE: Migrating to JUnit5 (#6076)
pibizza Sep 11, 2024
7b1e8cf
Migrated impact analysis to junit5 (#6079)
pibizza Sep 11, 2024
2a06dce
Migrated assertions to assertj (#6081)
pibizza Sep 12, 2024
92f0c6d
[incubator-kie-issues#1474] Fix NPE when loading multiple Signavio MI…
samuel-beniamin Sep 13, 2024
56c4399
Migrated tests in decisiontables to Junit5 (#6084)
pibizza Sep 13, 2024
c021782
[DROOLS-7631] unify coercion checks between plain drl and executable …
mariofusco Sep 18, 2024
85acd95
[incubator-kie-issues-1439] UserTask Decouple codegen and interface f…
elguardian Sep 18, 2024
06d47ec
kie-issues#1448: `matches()` function wrongly behaves (#6085)
yesamer Sep 18, 2024
08a5a4b
Bump com.google.protobuf:protobuf-java in /build-parent (#6094)
dependabot[bot] Sep 20, 2024
ed3c4a1
[incubator-kie-drools-6093] flaky test: org.drools.compiler.integrati…
tkobayas Sep 23, 2024
2e77f95
Cache compiled dtables during the building of a KieProject (#6097)
mariofusco Sep 24, 2024
6f1bcc1
[KIE-1492] Allow KieRuntimeBuilder to also create and provide Statele…
mariofusco Sep 27, 2024
d4376af
[incubator-kie-drools-6098] apache-rat-plugin license check for drool…
tkobayas Sep 27, 2024
83e0465
Enhance ConstraintOperator capability (#6104)
tkobayas Oct 1, 2024
d42d615
[incubator-kie-issues#1500] Add javadoc to KOGITO_GENERATE_REST and K…
gitgabrio Oct 2, 2024
ccd42cc
[incubator-kie-issues#1504] Conditionally build all or only reproduci…
rgdoliveira Oct 3, 2024
bfd675b
[incubator-kie-issues#1473] Add withTransactional method to Dependen…
gitgabrio Oct 3, 2024
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
4 changes: 4 additions & 0 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ This product also includes the following third-party components:
Downloaded from: https://lunrjs.com/
License: MIT

* Saxon-HE
Downloaded from: https://www.saxonica.com/
License: Mozilla Public License 2.0

* search-ui
Downloaded from: https://gitlab.com/antora/antora-lunr-extension
License: Mozilla Public License 2.0
2 changes: 1 addition & 1 deletion build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<version.com.github.victools>4.31.0</version.com.github.victools> <!-- victools should align with Jackson if possible -->
<version.com.miglayout>3.7.4</version.com.miglayout>
<version.domino-slf4j-logger>1.0.1</version.domino-slf4j-logger>
<version.com.google.protobuf>3.25.0</version.com.google.protobuf>
<version.com.google.protobuf>3.25.5</version.com.google.protobuf>
<version.com.h2database>2.2.220</version.com.h2database>
<version.com.networknt.json-schema-validator>1.0.86</version.com.networknt.json-schema-validator>
<version.com.sun.xml.bind>4.0.4</version.com.sun.xml.bind>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,12 @@ private static void buildKieProject( BuildContext buildContext,
kieRepository.addKieModule( kDep );
}
}

clearBuilderCache();
}

private static void clearBuilderCache() {
DecisionTableFactory.clearCompilerCache();
}

private void addKBasesFilesToTrg() {
Expand Down
14 changes: 7 additions & 7 deletions drools-decisiontables/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,13 @@
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<!-- Logging -->
Expand All @@ -101,11 +106,6 @@
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.drools.decisiontable.parser.xls.PropertiesSheetListener;
import org.drools.drl.extensions.DecisionTableProvider;
Expand All @@ -42,16 +43,16 @@ public class DecisionTableProviderImpl
implements
DecisionTableProvider {

private static final transient Logger logger = LoggerFactory.getLogger( DecisionTableProviderImpl.class );
private static final Logger logger = LoggerFactory.getLogger( DecisionTableProviderImpl.class );

private Map<String, String> compiledDtablesCache = new ConcurrentHashMap<>();

@Override
public String loadFromResource(Resource resource,
DecisionTableConfiguration configuration) {

try {
return compileResource( resource, configuration );
} catch (IOException e) {
throw new UncheckedIOException( e );
} catch (Exception e) {
throw new DecisionTableParseException(resource, e);
}
Expand All @@ -78,29 +79,46 @@ public List<String> loadFromInputStreamWithTemplates(Resource resource,
return drls;
}

private String compileResource(Resource resource,
DecisionTableConfiguration configuration) throws IOException {
private String compileResource(Resource resource, DecisionTableConfiguration configuration) {
if (resource.getSourcePath() == null) {
return internalCompileResource(resource, configuration);
}
String resourceKey = resource.getSourcePath() + "?trimCell=" + configuration.isTrimCell() + "&worksheetName=" + configuration.getWorksheetName();
return compiledDtablesCache.computeIfAbsent(resourceKey, path -> internalCompileResource(resource, configuration));
}

private String internalCompileResource(Resource resource, DecisionTableConfiguration configuration) throws UncheckedIOException {
SpreadsheetCompiler compiler = new SpreadsheetCompiler(configuration.isTrimCell());

switch ( configuration.getInputType() ) {
case XLS :
case XLSX :
if ( StringUtils.isEmpty( configuration.getWorksheetName() ) ) {
return compiler.compile( resource,
InputType.XLS );
return compiler.compile( resource, InputType.XLS );
} else {
return compiler.compile( resource.getInputStream(),
configuration.getWorksheetName() );
try {
return compiler.compile( resource.getInputStream(), configuration.getWorksheetName() );
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
case CSV : {
return compiler.compile( resource.getInputStream(),
InputType.CSV );
try {
return compiler.compile( resource.getInputStream(), InputType.CSV );
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}

return null;
}

@Override
public void clearCompilerCache() {
compiledDtablesCache.clear();
}

@Override
public Map<String, List<String[]>> loadPropertiesFromFile(File file, DecisionTableConfiguration configuration) {
switch (configuration.getInputType()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
import java.util.Calendar;
import java.util.concurrent.TimeUnit;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.kie.api.KieServices;
import org.kie.api.builder.KieBuilder;
import org.kie.api.builder.KieFileSystem;
Expand All @@ -42,7 +42,7 @@ public class CalendarTimerResourcesTest {

private SessionPseudoClock clock;

@Before
@BeforeEach
public void init() {

final KieServices ks = KieServices.Factory.get();
Expand All @@ -66,7 +66,7 @@ public void init() {
clock = ksession.getSessionClock();
}

@After
@AfterEach
public void tearDown() {

if (ksession != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.drools.base.definitions.rule.impl.RuleImpl;
import org.drools.kiesession.rulebase.InternalKnowledgeBase;
import org.drools.kiesession.rulebase.KnowledgeBaseFactory;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.kie.api.io.ResourceType;
import org.kie.internal.builder.DecisionTableConfiguration;
import org.kie.internal.builder.DecisionTableInputType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@

import java.util.Locale;

import org.junit.After;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.kie.api.KieServices;
import org.kie.api.builder.KieBuilder;
import org.kie.api.builder.KieFileSystem;
Expand Down Expand Up @@ -56,7 +56,7 @@ public void init() {
ksession = ks.newKieContainer(ks.getRepository().getDefaultReleaseId()).newKieSession();
}

@After
@AfterEach
public void tearDown() {
if (ksession != null) {
ksession.dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@

import org.apache.commons.io.FileUtils;
import org.drools.util.IoUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.kie.api.KieServices;
import org.kie.api.builder.ReleaseId;
import org.kie.api.io.Resource;
Expand Down Expand Up @@ -57,7 +57,7 @@ public class DumpGeneratedDrlTest {
private File dumpDir;
private String dumpDirPropOrigValue;

@Before
@BeforeEach
public void setUp() {
dumpDir = new File("target/drools-dump-dir");
// delete the dir before test to remove possible leftovers from previous runs
Expand All @@ -71,7 +71,7 @@ public void setUp() {
System.setProperty(DumpDirOption.PROPERTY_NAME, dumpDir.getAbsolutePath());
}

@After
@AfterEach
public void tearDown() {
if (dumpDirPropOrigValue != null) {
System.setProperty(DumpDirOption.PROPERTY_NAME, dumpDirPropOrigValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,36 @@
package org.drools.decisiontable;

import org.drools.template.parser.DecisionTableParseException;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.kie.internal.builder.DecisionTableConfiguration;
import org.kie.internal.builder.KnowledgeBuilder;
import org.kie.internal.builder.KnowledgeBuilderFactory;

import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import static org.kie.api.io.ResourceType.DTABLE;
import static org.kie.internal.builder.DecisionTableInputType.CSV;
import static org.kie.internal.builder.DecisionTableInputType.XLS;
import static org.kie.internal.io.ResourceFactory.newClassPathResource;

public class EmptyHeaderTest {

@Test(expected = DecisionTableParseException.class)
@Test
public void testEmptyConditionInXLS() {
DecisionTableConfiguration dtconf = KnowledgeBuilderFactory.newDecisionTableConfiguration();
dtconf.setInputType(XLS);
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory .newKnowledgeBuilder();

kbuilder.add(newClassPathResource("emptyCondition.drl.xls", getClass()), DTABLE, dtconf);
assertThatExceptionOfType((DecisionTableParseException.class)).isThrownBy(
() -> kbuilder.add(newClassPathResource("emptyCondition.drl.xls", getClass()), DTABLE, dtconf));
}

@Test(expected = DecisionTableParseException.class)
@Test
public void testEmptyActionInCSV() {
DecisionTableConfiguration dtconf = KnowledgeBuilderFactory.newDecisionTableConfiguration();
dtconf.setInputType(CSV);
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

kbuilder.add(newClassPathResource("emptyAction.drl.csv", getClass()), DTABLE, dtconf);
assertThatExceptionOfType((DecisionTableParseException.class)).isThrownBy(
() -> kbuilder.add(newClassPathResource("emptyAction.drl.csv", getClass()), DTABLE, dtconf));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import org.drools.kiesession.rulebase.KnowledgeBaseFactory;
import org.drools.template.parser.DataListener;
import org.drools.template.parser.TemplateDataListener;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.kie.api.io.ResourceType;
import org.kie.api.runtime.KieSession;
import org.kie.internal.builder.KnowledgeBuilder;
Expand All @@ -49,7 +49,7 @@ public class ExternalSpreadsheetCompilerTest {

private ExternalSpreadsheetCompiler converter;

@Before
@BeforeEach
public void setUp() {
converter = new ExternalSpreadsheetCompiler();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

import org.drools.kiesession.rulebase.InternalKnowledgeBase;
import org.drools.kiesession.rulebase.KnowledgeBaseFactory;
import org.junit.After;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.kie.api.io.ResourceType;
import org.kie.api.runtime.KieSession;
import org.kie.internal.builder.DecisionTableConfiguration;
Expand All @@ -40,7 +40,7 @@ public class FixedPatternTest {

private KieSession ksession;

@After
@AfterEach
public void tearDown() {
if (ksession != null) {
ksession.dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

import org.drools.kiesession.rulebase.InternalKnowledgeBase;
import org.drools.kiesession.rulebase.KnowledgeBaseFactory;
import org.junit.After;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.kie.api.io.ResourceType;
import org.kie.api.runtime.KieSession;
import org.kie.internal.builder.DecisionTableConfiguration;
Expand All @@ -40,7 +40,7 @@ public class IgnoreNumericFormatTest {

private KieSession ksession;

@After
@AfterEach
public void tearDown() {
if (ksession != null) {
ksession.dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import com.sample.FactData;
import org.drools.kiesession.rulebase.InternalKnowledgeBase;
import org.drools.kiesession.rulebase.KnowledgeBaseFactory;
import org.junit.After;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.kie.api.io.ResourceType;
import org.kie.api.runtime.KieSession;
import org.kie.internal.builder.DecisionTableConfiguration;
Expand All @@ -38,7 +38,7 @@ public class LineBreakXLSTest {

private KieSession ksession;

@After
@AfterEach
public void tearDown() {
if (ksession != null) {
ksession.dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import java.io.InputStream;

import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.kie.api.KieBase;
import org.kie.api.io.ResourceType;
import org.kie.internal.io.ResourceFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,18 @@

import java.io.InputStream;

import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.kie.api.KieBase;
import org.kie.api.io.ResourceType;
import org.kie.internal.io.ResourceFactory;
import org.kie.internal.utils.KieHelper;

import static org.assertj.core.api.Assertions.assertThat;

@Ignore
@Disabled
public class MakeSureMultiLinesWorkTest {

@Test
@org.junit.jupiter.api.Test
public void makeSureMultiLinesWork() {

KieHelper kieHelper = new KieHelper();
Expand Down
Loading
Loading