Skip to content

Commit

Permalink
merge minor unit test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bernhardttom2 committed Feb 24, 2020
1 parent 5d30f71 commit 04b8ae7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ public void testGetPropertyType() {
Schema lvl2Schema = record("lvl2Schema").fields()
.name("nestedValue").type().stringBuilder().prop(PROP_JAVA_STRING_KEY, PROP_JAVA_STRING_VALUE).endString().noDefault()
.name("nestedIndexed").type().array().items().intBuilder().endInt().arrayDefault(Collections.emptyList())
.name("nestedMapped").type().map().prop(PROP_JAVA_STRING_KEY, PROP_JAVA_STRING_VALUE).values().stringBuilder().prop(PROP_JAVA_STRING_KEY, PROP_JAVA_STRING_VALUE).endString().mapDefault(null)
.name("nestedMapped").type().map().prop(PROP_JAVA_STRING_KEY, PROP_JAVA_STRING_VALUE).values().stringBuilder().prop(PROP_JAVA_STRING_KEY, PROP_JAVA_STRING_VALUE).endString().noDefault()
.endRecord();

Schema lvl1Schema = record("lvl1Schema").fields()
.name("lvl2").type(lvl2Schema).noDefault()
.requiredInt("intPrimitive")
.name("indexed").type().array().items().intBuilder().endInt().arrayDefault(Collections.emptyList())
.name("mapped").type().map().prop(PROP_JAVA_STRING_KEY, PROP_JAVA_STRING_VALUE).values().stringBuilder().prop(PROP_JAVA_STRING_KEY, PROP_JAVA_STRING_VALUE).endString().mapDefault(null)
.name("mapped").type().map().prop(PROP_JAVA_STRING_KEY, PROP_JAVA_STRING_VALUE).values().stringBuilder().prop(PROP_JAVA_STRING_KEY, PROP_JAVA_STRING_VALUE).endString().noDefault()
.endRecord();

Schema schema = record("typename").fields()
Expand Down Expand Up @@ -169,8 +169,8 @@ public void testOptionalType() {
public void testNullableType() {
Schema schema = record("typename").fields()
.nullableInt("myInt", Integer.MIN_VALUE)
.nullableString("myCharSeq", null)
.name("myString").type().nullable().stringBuilder().prop(PROP_JAVA_STRING_KEY, PROP_JAVA_STRING_VALUE).endString().stringDefault(null)
.nullableString("myCharSeq", "")
.name("myString").type().nullable().stringBuilder().prop(PROP_JAVA_STRING_KEY, PROP_JAVA_STRING_VALUE).endString().stringDefault("")
.nullableBoolean("myBoolean", false)
.nullableBytes("myBytes", new byte[0])
.nullableDouble("myDouble", Double.MIN_VALUE)
Expand Down Expand Up @@ -243,7 +243,7 @@ public void testArrayOfPrimitive() {

public void testMapOfString() {
Schema schema = record("typename").fields()
.name("anMap").type().map().prop(PROP_JAVA_STRING_KEY, PROP_JAVA_STRING_VALUE).values().stringBuilder().prop(PROP_JAVA_STRING_KEY, PROP_JAVA_STRING_VALUE).endString().mapDefault(null)
.name("anMap").type().map().prop(PROP_JAVA_STRING_KEY, PROP_JAVA_STRING_VALUE).values().stringBuilder().prop(PROP_JAVA_STRING_KEY, PROP_JAVA_STRING_VALUE).endString().noDefault()
.endRecord();
EventType eventType = makeAvroSupportEventType(schema);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ public ExprNode validate(ExprValidationContext validationContext) throws ExprVal
}

public ExprEvaluator getExprEvaluator() {
if (evaluator == null) {
evaluator = getChildNodes()[0].getForge().getExprEvaluator();
}
initEvaluator();
return this;
}

Expand Down Expand Up @@ -85,6 +83,7 @@ public boolean isConstantResult() {
}

public Object evaluate(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext exprEvaluatorContext) {
initEvaluator();
Boolean evaluated = (Boolean) evaluator.evaluate(eventsPerStream, isNewData, exprEvaluatorContext);
if (evaluated == null) {
return null;
Expand All @@ -111,4 +110,10 @@ public boolean equalsNode(ExprNode node, boolean ignoreStreamPrefix) {
public ExprForgeConstantType getForgeConstantType() {
return ExprForgeConstantType.NONCONST;
}

private void initEvaluator() {
if (evaluator == null) {
evaluator = getChildNodes()[0].getForge().getExprEvaluator();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ static void assertFileConfig(Configuration config) {
assertEquals("jdbc:mysql://localhost/test", dsFactory.getProperties().getProperty("url"));
assertEquals("myusername", dsFactory.getProperties().getProperty("username"));
assertEquals("mypassword", dsFactory.getProperties().getProperty("password"));
assertEquals("com.mysql.cj.jdbc.Driver", dsFactory.getProperties().getProperty("driverClassName"));
assertEquals("com.mysql.jdbc.Driver", dsFactory.getProperties().getProperty("driverClassName"));
assertEquals("2", dsFactory.getProperties().getProperty("initialSize"));

assertEquals(PropertyResolutionStyle.DISTINCT_CASE_INSENSITIVE, common.getEventMeta().getClassPropertyResolutionStyle());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public void testWalkCreateVariable() throws Exception {
StatementSpecRaw raw = walker.getStatementSpec();

CreateVariableDesc createVarDesc = raw.getCreateVariableDesc();
assertEquals("sometype", createVarDesc.getVariableType());
assertEquals("sometype", createVarDesc.getVariableType().getClassIdentifier());
assertEquals("var1", createVarDesc.getVariableName());
assertTrue(createVarDesc.getAssignment() instanceof ExprConstantNode);
assertTrue(createVarDesc.isConstant());
Expand Down

0 comments on commit 04b8ae7

Please sign in to comment.