Skip to content

Commit

Permalink
adjust naming, add kie-maven-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
aasaru committed Dec 27, 2023
1 parent 35bd0d8 commit e41d36f
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 11 deletions.
13 changes: 12 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0">

<modelVersion>4.0.0</modelVersion>
<artifactId>drools-training</artifactId>
Expand Down Expand Up @@ -62,6 +62,17 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<!-- uncomment if you don't want to run tests
<configuration>
<skipTests>true</skipTests>
</configuration>
-->
</plugin>
<plugin>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
<version>8.44.0.Final</version><!-- in future need to match ${drools.version} -->
<extensions>true</extensions>
</plugin>
</plugins>
</build>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/github/aasaru/drools/Common.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public static int promptForStep(int section, String[] args, int minStep, int max
return promptForStepInternal("Section " + section, args, minStep, maxStep);
}

public static int promptForStepD8(int section, String[] args, int minStep, int maxStep) {
return promptForStepInternal("D8 section " + section, args, minStep, maxStep);
public static int promptForStepOo(int section, String[] args, int minStep, int maxStep) {
return promptForStepInternal("OOPath section " + section, args, minStep, maxStep);
}

private static int promptForStepInternal(String sectionStr, String[] args, int minStep, int maxStep) {
Expand Down Expand Up @@ -67,7 +67,7 @@ public static boolean promptForYesNoQuestion(String question) {
while (true) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
System.out.print(String.format("%s Enter 'yes' or 'no': ", question));
System.out.printf("%s Enter 'yes' or 'no': ", question);
enteredStr = br.readLine().trim();

if ("yes".equalsIgnoreCase(enteredStr) || "y".equalsIgnoreCase(enteredStr)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
import org.drools.ruleunits.api.RuleUnitInstance;
import org.drools.ruleunits.api.RuleUnitProvider;

import java.time.LocalDate;
import java.util.List;

public class PassportValidationOO {
public static void main(final String[] args) {
execute(Common.promptForStepD8(3, args, 1, 6));
execute(Common.promptForStepOo(3, args, 1, 6));
}

static void execute(int step) {
Expand All @@ -38,10 +39,19 @@ static void execute(int step) {

System.out.println("==== DROOLS START ==== ");
instance.fire();

System.out.println("about to sleep");
ruleUnit.getPassports().append(Passport.newBuilder()
.withPassportNumber("ABC123")
.withExpiresOn(LocalDate.of(2200,12,12))
.withUnusedVisaPages(3)
.build());
instance.fire();

System.out.println("==== DROOLS END ==== ");
}

if (step >= 4) {
if (step >= 4) {
System.out.println("==== PASSPORTS AFTER RULES WERE FIRED ==== ");

passports.forEach(passport -> System.out.println(passport + " validation " + passport.getValidation()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
public class StatefulPassportValidationOO {

public static void main(final String[] args) {
execute(Common.promptForStepD8(4, args, 1, 2));
execute(Common.promptForStepOo(4, args, 1, 2));
}

static void execute(int step) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

public class VisaApplicationValidationOO {
public static void main(final String[] args) {
execute(Common.promptForStepD8(5, args, 1, 3));
execute(Common.promptForStepOo(5, args, 1, 3));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

public class VisaIssueOO {
public static void main(final String[] args) {
execute(Common.promptForStepD8(6, args, 1, 3));
execute(Common.promptForStepOo(6, args, 1, 3));
}

static Collection<Visa> execute(int step) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

public class VisaAddLogicalOO {
public static void main(final String[] args) {
execute(Common.promptForStepD8(7, args, 1, 4));
execute(Common.promptForStepOo(7, args, 1, 4));
}

public static SessionQueryUtil<RuleUnitSection07> sessionQueryUtil = new SessionQueryUtil<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class FamilyVisaApplicationValidationOO {
public static SessionQueryUtil<RuleUnitSection08> sessionQueryUtil = new SessionQueryUtil<>();

public static void main(final String[] args) {
execute(Common.promptForStepD8(8, args, 1, 5));
execute(Common.promptForStepOo(8, args, 1, 5));
}

static SessionData execute(int step) {
Expand Down

0 comments on commit e41d36f

Please sign in to comment.