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

[DROOLS-6875] Correct import for assertj assertions #4295

Merged
merged 9 commits into from
Apr 8, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@

import java.util.ArrayList;

import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.kie.api.runtime.KieSession;

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

public class LargeAlphaNetworkTest extends BaseModelTest {

public LargeAlphaNetworkTest(RUN_TYPE testRunType) {
Expand Down Expand Up @@ -52,7 +53,7 @@ public void testLargeCompiledAlphaNetwork() {

try {
ksession.fireAllRules();
Assertions.assertThat(results).contains(a, b, c);
assertThat(results).contains(a, b, c);
} finally {
ksession.dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@

import java.util.ArrayList;

import org.assertj.core.api.Assertions;
import org.junit.Ignore;
import org.junit.Test;
import org.kie.api.runtime.KieSession;

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

public class MixedConstraintsTest extends BaseModelTest {

public MixedConstraintsTest(RUN_TYPE testRunType) {
Expand Down Expand Up @@ -55,7 +56,7 @@ public void testMixedConstraints() {

try {
ksession.fireAllRules();
Assertions.assertThat(results).contains(a, b, c);
assertThat(results).contains(a, b, c);
} finally {
ksession.dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@

import java.util.ArrayList;

import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.kie.api.runtime.KieSession;

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

public class MultipleIndexableConstraintsTest extends BaseModelTest {

public MultipleIndexableConstraintsTest(RUN_TYPE testRunType) {
Expand Down Expand Up @@ -54,7 +55,7 @@ public void testMultipleIndexedConstraintTest() {

try {
ksession.fireAllRules();
Assertions.assertThat(results).contains(a, b, c);
assertThat(results).contains(a, b, c);
} finally {
ksession.dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.ArrayList;
import java.util.List;

import org.assertj.core.api.Assertions;
import org.junit.Test;
import org.kie.api.KieBase;
import org.kie.api.KieBaseConfiguration;
Expand All @@ -28,6 +27,7 @@
import org.kie.api.runtime.KieSession;
import org.kie.internal.conf.AlphaRangeIndexThresholdOption;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;

public class RangeIndexANCTest extends BaseModelTest {
Expand Down Expand Up @@ -119,12 +119,12 @@ public void testMixedRangeHashAndOther() {

ksession.insert(new Person("John", 18));
ksession.fireAllRules();
Assertions.assertThat(results).containsOnly("test1", "test2", "test3");
assertThat(results).containsOnly("test1", "test2", "test3");
results.clear();

ksession.insert(new Person("Paul", 60));
ksession.fireAllRules();
Assertions.assertThat(results).containsOnly("test1", "test3", "test4", "test7");
assertThat(results).containsOnly("test1", "test3", "test4", "test7");
}

@Test
Expand Down Expand Up @@ -171,12 +171,12 @@ public void testChainRange() {

ksession.insert(new Person("John", 35));
ksession.fireAllRules();
Assertions.assertThat(results).containsOnly("test3", "test5");
assertThat(results).containsOnly("test3", "test5");
results.clear();

ksession.insert(new Person("Paul", 20));
ksession.fireAllRules();
Assertions.assertThat(results).containsOnly("test2", "test3");
assertThat(results).containsOnly("test2", "test3");
results.clear();
}

Expand Down Expand Up @@ -221,12 +221,12 @@ public void testRangeWithBeta() {

ksession.insert(new Person("John", 35));
ksession.fireAllRules();
Assertions.assertThat(results).containsOnly("test1");
assertThat(results).containsOnly("test1");
results.clear();

ksession.insert(new Person("Paul", 25));
ksession.fireAllRules();
Assertions.assertThat(results).containsOnly("test1", "test2", "test3");
assertThat(results).containsOnly("test1", "test2", "test3");
results.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
import java.io.ObjectOutputStream;
import java.nio.charset.StandardCharsets;

import org.assertj.core.api.Assertions;
import org.junit.Test;

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

public class ByteArrayResourceSerializationTest {

//FIX https://issues.redhat.com/browse/DROOLS-5681
Expand All @@ -29,7 +30,7 @@ public void bytesAttributesIsStillSerializedDeserializedCorrectly() throws IOExc
try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(serializedBar))){
desBar = (ByteArrayResource) ois.readObject();
}
Assertions.assertThat(desBar.getBytes()).isEqualTo(content);
assertThat(desBar.getBytes()).isEqualTo(content);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@

package org.drools.core.util.index;

import org.assertj.core.api.Assertions;
import org.drools.core.test.model.Person;
import org.junit.Test;

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

public class RangeIndexTest {

// This DRL is not actually used but test() simulates this DRL use case.
Expand Down Expand Up @@ -60,20 +61,20 @@ public void test() {
index.addIndex(RangeIndex.IndexType.GT, 12, "E");
index.addIndex(RangeIndex.IndexType.LE, 4, "F");

Assertions.assertThat(index.getValues(18)).containsExactlyInAnyOrder("A", "B", "C", "D", "E");
Assertions.assertThat(index.getValues(60)).containsExactlyInAnyOrder("A", "C", "E");
Assertions.assertThat(index.getValues(59)).containsExactlyInAnyOrder("A", "C", "D", "E");
Assertions.assertThat(index.getValues(4)).containsExactlyInAnyOrder("B", "D", "F");
Assertions.assertThat(index.getAllValues()).containsExactlyInAnyOrder("A", "B", "C", "D", "E", "F");
assertThat(index.getValues(18)).containsExactlyInAnyOrder("A", "B", "C", "D", "E");
assertThat(index.getValues(60)).containsExactlyInAnyOrder("A", "C", "E");
assertThat(index.getValues(59)).containsExactlyInAnyOrder("A", "C", "D", "E");
assertThat(index.getValues(4)).containsExactlyInAnyOrder("B", "D", "F");
assertThat(index.getAllValues()).containsExactlyInAnyOrder("A", "B", "C", "D", "E", "F");

index.removeIndex(RangeIndex.IndexType.GT, 8); // "C"
index.removeIndex(RangeIndex.IndexType.LT, 60); // "D"

Assertions.assertThat(index.getValues(18)).containsExactlyInAnyOrder("A", "B", "E");
Assertions.assertThat(index.getValues(60)).containsExactlyInAnyOrder("A", "E");
Assertions.assertThat(index.getValues(59)).containsExactlyInAnyOrder("A", "E");
Assertions.assertThat(index.getValues(4)).containsExactlyInAnyOrder("B", "F");
Assertions.assertThat(index.getAllValues()).containsExactlyInAnyOrder("A", "B", "E", "F");
assertThat(index.getValues(18)).containsExactlyInAnyOrder("A", "B", "E");
assertThat(index.getValues(60)).containsExactlyInAnyOrder("A", "E");
assertThat(index.getValues(59)).containsExactlyInAnyOrder("A", "E");
assertThat(index.getValues(4)).containsExactlyInAnyOrder("B", "F");
assertThat(index.getAllValues()).containsExactlyInAnyOrder("A", "B", "E", "F");
}

@Test
Expand All @@ -84,9 +85,9 @@ public void testBoundary() {
index.addIndex(RangeIndex.IndexType.GE, 40, "C");
index.addIndex(RangeIndex.IndexType.GT, 60, "D");

Assertions.assertThat(index.getValues(25)).containsExactlyInAnyOrder("B");
Assertions.assertThat(index.getValues(26)).isEmpty();
Assertions.assertThat(index.getValues(39)).isEmpty();
Assertions.assertThat(index.getValues(40)).containsExactlyInAnyOrder("C");
assertThat(index.getValues(25)).containsExactlyInAnyOrder("B");
assertThat(index.getValues(26)).isEmpty();
assertThat(index.getValues(39)).isEmpty();
assertThat(index.getValues(40)).containsExactlyInAnyOrder("C");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@
import java.util.regex.Pattern;
import java.util.stream.Stream;

import org.assertj.core.api.Assertions;
import org.drools.kiesession.rulebase.InternalKnowledgeBase;
import org.drools.decisiontable.parser.DefaultRuleSheetListener;
import org.drools.decisiontable.parser.RuleMatrixSheetListener;
import org.drools.decisiontable.parser.RuleSheetParserUtil;
import org.drools.decisiontable.parser.xls.ExcelParser;
import org.drools.kiesession.rulebase.InternalKnowledgeBase;
import org.drools.kiesession.rulebase.KnowledgeBaseFactory;
import org.drools.template.model.Global;
import org.drools.template.model.Import;
Expand All @@ -45,6 +44,7 @@
import org.kie.internal.builder.KnowledgeBuilderFactory;
import org.kie.internal.io.ResourceFactory;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
Expand Down Expand Up @@ -91,7 +91,7 @@ public void testMultilineActions() {
final String drl = converter.compile(stream,
InputType.XLS);

Assertions.assertThat(drl).doesNotContain("\\n");
assertThat(drl).doesNotContain("\\n");
}

@Test
Expand All @@ -101,7 +101,7 @@ public void testMultilineActionsAndMultiLineInConstant() {
final String drl = converter.compile(stream,
InputType.XLS);

Assertions.assertThat(drl).contains(" **\n** ");
assertThat(drl).contains(" **\n** ");
}

@Test
Expand All @@ -111,7 +111,7 @@ public void testMultilineActionsAndMultiLineAsConstant() {
final String drl = converter.compile(stream,
InputType.XLS);

Assertions.assertThat(drl).contains(" **\\n** ");
assertThat(drl).contains(" **\\n** ");
}

@Test
Expand All @@ -121,8 +121,8 @@ public void testMultilineCommentsInDescription() {
final String drl = converter.compile(stream,
InputType.XLS);

Assertions.assertThat(drl).containsSubsequence("/* Say", "Hello */", "/* Say", "Goobye */");
Assertions.assertThat(drl).doesNotContain("// Say");
assertThat(drl).containsSubsequence("/* Say", "Hello */", "/* Say", "Goobye */");
assertThat(drl).doesNotContain("// Say");
}

@Test
Expand All @@ -132,15 +132,15 @@ public void testMultilineComplexCommentsInDescription() {
final String drl = converter.compile(stream,
InputType.XLS);

Assertions.assertThat(drl).containsSubsequence("/* Do these actions:",
assertThat(drl).containsSubsequence("/* Do these actions:",
"- Print Greeting",
"- Set params: {message:'bye cruel world', status:'bye'} */",
"/* Print message: \"Bye!\"",
"Author: james@company.org */");

Assertions.assertThat(drl).doesNotContain("* - Print Greeting");
Assertions.assertThat(drl).doesNotContain("* - Set params: {message:'bye cruel world', status:'bye'}");
Assertions.assertThat(drl).doesNotContain("* Author: james@company.org");
assertThat(drl).doesNotContain("* - Print Greeting");
assertThat(drl).doesNotContain("* - Set params: {message:'bye cruel world', status:'bye'}");
assertThat(drl).doesNotContain("* Author: james@company.org");
}

@Test
Expand Down Expand Up @@ -522,7 +522,7 @@ public void testNoConstraintsEmptyCells() {
"end";
//No Pattern generated when all constraints have empty values

Assertions.assertThat(expected).isEqualToIgnoringWhitespace(drl);
assertThat(expected).isEqualToIgnoringWhitespace(drl);
}

@Test
Expand Down Expand Up @@ -570,7 +570,7 @@ public void testNoConstraintsSpacesInCells() {
"end";
//No Pattern generated when all constraints have empty values

Assertions.assertThat(expected).isEqualToIgnoringWhitespace(drl);
assertThat(expected).isEqualToIgnoringWhitespace(drl);
}

@Test
Expand Down Expand Up @@ -637,7 +637,7 @@ public void testNoConstraintsDelimitedSpacesInCells() {
" then\n" +
"end";

Assertions.assertThat(expected).isEqualToIgnoringWhitespace(drl);
assertThat(expected).isEqualToIgnoringWhitespace(drl);
}

@Test
Expand Down Expand Up @@ -695,7 +695,7 @@ public void testForAllConstraintQuoteRemoval() {
" System.out.println(false);\n" +
"end\n";

Assertions.assertThat(expected).isEqualToIgnoringWhitespace(drl);
assertThat(expected).isEqualToIgnoringWhitespace(drl);
}

public static class IntHolder {
Expand Down Expand Up @@ -806,7 +806,7 @@ public void checkLhsBuilderFixValue() {
" System.out.println(m.getMessage());\n" +
"end\n";

Assertions.assertThat(expected).isEqualToIgnoringWhitespace(drl);
assertThat(expected).isEqualToIgnoringWhitespace(drl);
}

@Test
Expand All @@ -815,7 +815,7 @@ public void testLhsOrder() {
final SpreadsheetCompiler converter = new SpreadsheetCompiler();
String drl = converter.compile("/data/LhsOrder.drl.xls", InputType.XLS);

Assertions.assertThat(Stream.of(drl.split("\n")).map(String::trim).toArray())
assertThat(Stream.of(drl.split("\n")).map(String::trim).toArray())
.as("Lhs order is wrong")
.containsSequence("accumulate(Person(name == \"John\", $a : age); $max:max($a))",
"$p:Person(name == \"John\", age == $max)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.Arrays;
import java.util.List;

import org.assertj.core.api.Assertions;
import org.drools.impact.analysis.graph.Graph;
import org.drools.impact.analysis.graph.ImpactAnalysisHelper;
import org.drools.impact.analysis.graph.ModelToGraphConverter;
Expand All @@ -30,6 +29,7 @@
import org.drools.impact.analysis.parser.ModelBuilder;
import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;
import static org.drools.impact.analysis.graph.TextReporter.INDENT;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
Expand Down Expand Up @@ -112,15 +112,15 @@ public void testOrderRules() {
// TextReporter test
String hierarchyText = TextReporter.toHierarchyText(impactedSubGraph);
List<String> lines = Arrays.asList(hierarchyText.split(System.lineSeparator()));
Assertions.assertThat(lines).containsExactlyInAnyOrder("R2[*]",
assertThat(lines).containsExactlyInAnyOrder("R2[*]",
INDENT + "R3[+]",
INDENT + INDENT + "R6[+]",
INDENT + INDENT + "R5[+]",
INDENT + INDENT + INDENT + "(R3)");

String flatText = TextReporter.toFlatText(impactedSubGraph);
List<String> lines2 = Arrays.asList(flatText.split(System.lineSeparator()));
Assertions.assertThat(lines2).containsExactlyInAnyOrder("R2[*]",
assertThat(lines2).containsExactlyInAnyOrder("R2[*]",
"R3[+]",
"R6[+]",
"R5[+]");
Expand All @@ -147,7 +147,7 @@ public void testOrderRulesBackward() {
// TextReporter test
String hierarchyText = TextReporter.toHierarchyText(impactingSubGraph);
List<String> lines = Arrays.asList(hierarchyText.split(System.lineSeparator()));
Assertions.assertThat(lines).containsExactlyInAnyOrder("R1[!]",
assertThat(lines).containsExactlyInAnyOrder("R1[!]",
INDENT + "R3[!]",
INDENT + INDENT + "R5[@]",
INDENT + INDENT + INDENT + "(R3)",
Expand All @@ -158,7 +158,7 @@ public void testOrderRulesBackward() {

String flatText = TextReporter.toFlatText(impactingSubGraph);
List<String> lines2 = Arrays.asList(flatText.split(System.lineSeparator()));
Assertions.assertThat(lines2).containsExactlyInAnyOrder("R1[!]",
assertThat(lines2).containsExactlyInAnyOrder("R1[!]",
"R2[!]",
"R3[!]",
"R4[!]",
Expand Down
Loading