Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/goldmansachs/jdmn
Browse files Browse the repository at this point in the history
  • Loading branch information
opatrascoiu committed Jul 23, 2024
2 parents c6610e7 + 34ebdb8 commit 42ebb2c
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ protected String makeCondition(String feelOperator, Expression<Type> leftOperand

protected String makeCondition(String feelOperator, String leftOpd, String rightOpd, NativeOperator javaOperator) {
if (javaOperator == null) {
handleError(String.format("Operator '%s' cannot be applied to '%s' and '%s'", feelOperator, leftOpd, rightOpd));
handleError(makeOperatorErrorMessage(feelOperator, leftOpd, rightOpd));
return null;
} else {
if (javaOperator.getCardinality() == 2) {
Expand All @@ -779,7 +779,7 @@ protected String makeCondition(String feelOperator, String leftOpd, String right
}
}
} else {
handleError(String.format("Operator '%s' cannot be applied to '%s' and '%s'", feelOperator, leftOpd, rightOpd));
handleError(makeOperatorErrorMessage(feelOperator, leftOpd, rightOpd));
return null;
}
}
Expand All @@ -790,7 +790,7 @@ protected String listTestOperator(String feelOperatorName, Expression<Type> left
if (javaOperator != null) {
return javaOperator.getName();
} else {
handleError(String.format("Operator '%s' cannot be applied to '%s' and '%s'", feelOperatorName, leftOperand, rightOperand));
handleError(makeOperatorErrorMessage(feelOperatorName, leftOperand, rightOperand));
return null;
}
}
Expand All @@ -814,4 +814,8 @@ protected String rangeGetter(String memberName) {
return this.dmnTransformer.getter(memberName);
}
}

private static String makeOperatorErrorMessage(String feelOperator, Object leftOpd, Object rightOpd) {
return String.format("Operator '%s' cannot be applied to '%s' and '%s'", feelOperator, leftOpd, rightOpd);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@

public class JavaTimeKotlinNativeTypeFactory extends KotlinTypeFactory {
private static final Map<String, String> FEEL_TYPE_TO_JAVA_TYPE = new LinkedHashMap<>();

public static final String KOTLIN_ANY = "kotlin.Any";

static {
FEEL_TYPE_TO_JAVA_TYPE.put(ENUMERATION.getName(), String.class.getName());
FEEL_TYPE_TO_JAVA_TYPE.put(YEARS_AND_MONTHS_DURATION.getName(), java.time.temporal.TemporalAmount.class.getName());
Expand All @@ -39,8 +42,8 @@ public class JavaTimeKotlinNativeTypeFactory extends KotlinTypeFactory {
FEEL_TYPE_TO_JAVA_TYPE.put(STRING.getName(), String.class.getSimpleName());
FEEL_TYPE_TO_JAVA_TYPE.put(BOOLEAN.getName(), Boolean.class.getSimpleName());
FEEL_TYPE_TO_JAVA_TYPE.put(NUMBER.getName(), java.lang.Number.class.getName());
FEEL_TYPE_TO_JAVA_TYPE.put(ANY.getName(), "kotlin.Any");
FEEL_TYPE_TO_JAVA_TYPE.put(NULL.getName(), "kotlin.Any");
FEEL_TYPE_TO_JAVA_TYPE.put(ANY.getName(), KOTLIN_ANY);
FEEL_TYPE_TO_JAVA_TYPE.put(NULL.getName(), KOTLIN_ANY);
}

private static final Map<String, String> FEEL_TYPE_TO_QUALIFIED_JAVA_TYPE = new LinkedHashMap<>();
Expand All @@ -54,8 +57,8 @@ public class JavaTimeKotlinNativeTypeFactory extends KotlinTypeFactory {
FEEL_TYPE_TO_QUALIFIED_JAVA_TYPE.put(STRING.getName(), String.class.getName());
FEEL_TYPE_TO_QUALIFIED_JAVA_TYPE.put(BOOLEAN.getName(), Boolean.class.getName());
FEEL_TYPE_TO_QUALIFIED_JAVA_TYPE.put(NUMBER.getName(), java.lang.Number.class.getName());
FEEL_TYPE_TO_QUALIFIED_JAVA_TYPE.put(ANY.getName(), "kotlin.Any");
FEEL_TYPE_TO_QUALIFIED_JAVA_TYPE.put(NULL.getName(), "kotlin.Any");
FEEL_TYPE_TO_QUALIFIED_JAVA_TYPE.put(ANY.getName(), KOTLIN_ANY);
FEEL_TYPE_TO_QUALIFIED_JAVA_TYPE.put(NULL.getName(), KOTLIN_ANY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

public class XStreamMarshaller implements TCKMarshaller {
private static final Logger LOGGER = LoggerFactory.getLogger(XStreamMarshaller.class);
private static final StaxDriver STAX_DRIVER = new StaxDriver();

private static TCKVersion inferTCKVersion(Reader firstStringReader) {
return LATEST;
Expand Down Expand Up @@ -72,7 +71,7 @@ public TestCases unmarshal(String input, boolean validateSchema) {
}
return unmarshal(tckVersion, secondStringReader);
} catch (Exception e) {
LOGGER.error("Error unmarshalling TCK content from reader.", e);
LOGGER.error("Error unmarshalling TCK content from String.", e);
}
return null;
}
Expand All @@ -88,7 +87,7 @@ public TestCases unmarshal(File input, boolean validateSchema) {
}
return unmarshal(tckVersion, secondStringReader);
} catch (Exception e) {
LOGGER.error("Error unmarshalling TCK content from reader.", e);
LOGGER.error("Error unmarshalling TCK content from File.", e);
}
return null;
}
Expand All @@ -104,7 +103,7 @@ public TestCases unmarshal(URL input, boolean validateSchema) {
}
return unmarshal(tckVersion, secondStringReader);
} catch (Exception e) {
LOGGER.error("Error unmarshalling TCK content from reader.", e);
LOGGER.error("Error unmarshalling TCK content from URL.", e);
}
return null;
}
Expand All @@ -120,7 +119,7 @@ public TestCases unmarshal(InputStream input, boolean validateSchema) {
}
return unmarshal(tckVersion, secondStringReader);
} catch (Exception e) {
LOGGER.error("Error unmarshalling TCK content from reader.", e);
LOGGER.error("Error unmarshalling TCK content from InputStream.", e);
}
return null;
}
Expand All @@ -131,7 +130,7 @@ public TestCases unmarshal(Reader input, boolean validateSchema) {
String xml = buffer.lines().collect(Collectors.joining("\n"));
return unmarshal(xml, validateSchema);
} catch (Exception e) {
LOGGER.error("Error unmarshalling TCK content from reader.", e);
LOGGER.error("Error unmarshalling TCK content from Reader.", e);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import java.util.List;

public class MixedItemDefinitionsTransformer extends SimpleDMNTransformer<TestCases> {
private boolean transformRepository = true;
private final Visitor<?, Object> visitor = new MixedItemDefinitionsVisitor<>(this.logger, new NopErrorHandler());

public MixedItemDefinitionsTransformer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,6 @@ protected boolean shouldTransformFile(File inputFile) {

@Override
protected void transformFile(File child, File root, Path outputPath) {
// NOP transformer for testing
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,18 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;
import java.util.ArrayList;
import java.util.List;

public class InOutCorrectPathsInDecisionsTransformer extends SimpleDMNTransformer<TestLab> {
protected static final Logger LOGGER = LoggerFactory.getLogger(InOutCorrectPathsInDecisionsTransformer.class);

protected final BuildLogger logger;
protected boolean transformRepository = true;

public InOutCorrectPathsInDecisionsTransformer() {
this(new Slf4jBuildLogger(LOGGER));
}

protected InOutCorrectPathsInDecisionsTransformer(BuildLogger logger) {
this.logger = logger;
super(logger);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public List<String> annotations(TDRGElement element, List<String> annotationText
} catch (Exception e) {
LOGGER.error(String.format("Cannot process annotation '%s' for element '%s'", annotationText, element == null ? "" : element.getName()));
// Add unevaluated annotation text
annotationStatements.add(String.format("\"%s\"", annotationText.replaceAll("\"", "\\\\\"")));
annotationStatements.add(String.format("\"%s\"", annotationText.replace("\"", "\\\\\"")));
}
}
return annotationStatements;
Expand Down

0 comments on commit 42ebb2c

Please sign in to comment.