-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove OperatorWrapper. Add more assertion. Better error message
- Loading branch information
Showing
5 changed files
with
291 additions
and
180 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
...ok-integration-api/src/main/java/org/drools/ansible/rulebook/integration/api/LogUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.drools.ansible.rulebook.integration.api; | ||
|
||
import java.util.Map; | ||
|
||
public class LogUtil { | ||
|
||
private LogUtil() { | ||
// utility class | ||
} | ||
|
||
// convert java class to python class | ||
private static Map<Class<?>, String> convertMap = Map.of( | ||
java.lang.Integer.class, "int", | ||
java.lang.Boolean.class, "bool", | ||
java.lang.String.class, "str", | ||
java.lang.Double.class, "float", | ||
java.util.List.class, "list", | ||
java.util.ArrayList.class, "list", | ||
java.util.Map.class, "dict", | ||
java.util.LinkedHashMap.class, "dict", | ||
java.util.HashMap.class, "dict" | ||
); | ||
|
||
public static String convertJavaClassToPythonClass(Class<?> javaClass) { | ||
return convertMap.getOrDefault(javaClass, javaClass.getSimpleName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...tion-api/src/test/java/org/drools/ansible/rulebook/integration/api/StringPrintStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.drools.ansible.rulebook.integration.api; | ||
|
||
import java.io.PrintStream; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class StringPrintStream extends PrintStream { | ||
|
||
public static final String LINE_SEP = System.getProperty("line.separator"); | ||
PrintStream other; | ||
List<String> stringList = new ArrayList<>(); | ||
|
||
public StringPrintStream(PrintStream ps) { | ||
super(ps); | ||
other = ps; | ||
} | ||
|
||
public void print(String s) { | ||
other.print(s); | ||
stringList.add(s); | ||
} | ||
|
||
public void println(String s) { | ||
other.println(s); | ||
stringList.add(s); | ||
} | ||
|
||
public void println(Object o) { | ||
other.println(o); | ||
stringList.add(o.toString()); | ||
} | ||
|
||
public List<String> getStringList() { | ||
return stringList; | ||
} | ||
} |
Oops, something went wrong.