use of mockit.MockUp in project carbondata by apache.
the class NotInExpressionUnitTest method testEvaluateForNotInExpressionWithIntDataType.
@Test
public void testEvaluateForNotInExpressionWithIntDataType() throws FilterUnsupportedException, FilterIllegalMemberException {
ColumnExpression left = new ColumnExpression("left_id", DataTypes.INT);
left.setColIndex(0);
ColumnExpression right = new ColumnExpression("right_id", DataTypes.INT);
right.setColIndex(1);
notInExpression = new NotInExpression(left, right);
RowImpl value = new RowImpl();
Integer row = 150569;
Integer row1 = 15052;
Object[] objectRow = { row, row1 };
value.setValues(objectRow);
new MockUp<ExpressionResult>() {
@Mock
public Integer getInt() {
return 15052;
}
};
ExpressionResult result = notInExpression.evaluate(value);
assertEquals(result.getDataType(), DataTypes.BOOLEAN);
}
use of mockit.MockUp in project carbondata by apache.
the class AndExpressionTest method testEvaluateForDefault.
@Test(expected = Exception.class)
public void testEvaluateForDefault() throws FilterUnsupportedException, FilterIllegalMemberException {
RowImpl rowImpl = new RowImpl();
rowImpl.setValues(new Boolean[] { true });
final ExpressionResult expressionResult = new ExpressionResult(DataTypes.STRING, "test");
new MockUp<ColumnExpression>() {
@Mock
public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException, FilterIllegalMemberException {
return expressionResult;
}
};
andExpression.evaluate(rowImpl);
}
use of mockit.MockUp in project carbondata by apache.
the class AndExpressionTest method testEvaluate.
@Test
public void testEvaluate() throws FilterUnsupportedException, FilterIllegalMemberException {
RowImpl rowImpl = new RowImpl();
rowImpl.setValues(new Boolean[] { false });
final ExpressionResult expressionResult = new ExpressionResult(DataTypes.BOOLEAN, "test");
new MockUp<ColumnExpression>() {
@Mock
public ExpressionResult evaluate(RowIntf value) throws FilterUnsupportedException, FilterIllegalMemberException {
return expressionResult;
}
};
ExpressionResult actualValue = andExpression.evaluate(rowImpl);
assertTrue(actualValue instanceof ExpressionResult);
}
use of mockit.MockUp in project carbondata by apache.
the class ColumnExpressionTest method testEvaluate.
@Test
public void testEvaluate() {
RowImpl rowImpl = new RowImpl();
rowImpl.setValues(new Integer[] { 1 });
new MockUp<RowImpl>() {
@Mock
public Object getVal(int index) {
return 1;
}
};
ExpressionResult expectedValue = new ExpressionResult(DataTypes.INT, 1);
assertEquals(expectedValue, columnExpression.evaluate(rowImpl));
}
use of mockit.MockUp in project carbondata by apache.
the class EqualToExpressionUnitTest method testEvaluateForEqualToExpressionWithBooleanParameter.
@Test
public void testEvaluateForEqualToExpressionWithBooleanParameter() throws FilterUnsupportedException, FilterIllegalMemberException {
ColumnExpression right = new ColumnExpression("id", DataTypes.SHORT);
right.setColIndex(0);
equalToExpression = new EqualToExpression(right, right, true);
RowImpl value = new RowImpl();
Short[] row = { 15 };
Object[] objectRow = { row };
value.setValues(objectRow);
new MockUp<ExpressionResult>() {
@Mock
public Short getShort() {
return 15;
}
};
ExpressionResult result = equalToExpression.evaluate(value);
assertTrue(result.getBoolean());
}
Aggregations