gianm commented on code in PR #15014:
URL: https://github.com/apache/druid/pull/15014#discussion_r1332004205
##########
processing/src/test/java/org/apache/druid/query/aggregation/constant/LongConstantBufferAggregatorTest.java:
##########
@@ -38,9 +37,7 @@ public void setup()
{
randomVal = RandomUtils.nextLong();
aggregator = new LongConstantBufferAggregator(randomVal);
- byteBuffer = EasyMock.mock(ByteBuffer.class);
- EasyMock.replay(byteBuffer);
- EasyMock.verifyUnexpectedCalls(byteBuffer);
+ byteBuffer = ByteBuffer.allocate(Long.BYTES);
Review Comment:
I think the original test was trying to verify that the aggregator did not
make any calls to the buffer. In that case setting `byteBuffer = null`
accomplishes the original goal without using EasyMock.
##########
sql/src/test/java/org/apache/druid/sql/calcite/rule/DruidLogicalValuesRuleTest.java:
##########
@@ -101,7 +102,7 @@ private static RexLiteral makeLiteral(Comparable<?> val,
SqlTypeName typeName, C
Mockito.when(dataType.getSqlTypeName()).thenReturn(typeName);
RexLiteral literal = Mockito.mock(RexLiteral.class);
try {
- Field field =
literal.getClass().getSuperclass().getDeclaredField("value");
Review Comment:
We can also avoid mocks entirely and make literals directly:
```
private static RexLiteral makeLiteral(Comparable<?> val, SqlTypeName
typeName)
{
return (RexLiteral) new
RexBuilder(DruidTypeSystem.TYPE_FACTORY).makeLiteral(
typeName == SqlTypeName.DECIMAL && val != null ? new
BigDecimal(String.valueOf(val)) : val,
DruidTypeSystem.TYPE_FACTORY.createSqlType(typeName),
false
);
}
```
(from https://github.com/apache/druid/issues/14502#issuecomment-1613900607)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]