use of org.apache.drill.jdbc.impl.DrillColumnMetaDataList in project drill by apache.
the class DrillColumnMetaDataListTest method setUp.
@Before
public void setUp() throws Exception {
emptyList = new DrillColumnMetaDataList();
// Create mock columns
final MaterializedField exampleIntField = mock(MaterializedField.class);
MajorType exampleIntType = MajorType.newBuilder().setMinorType(MinorType.INT).build();
when(exampleIntField.getPath()).thenReturn("/path/to/testInt");
when(exampleIntField.getType()).thenReturn(exampleIntType);
when(exampleIntField.getDataMode()).thenReturn(DataMode.OPTIONAL);
final MaterializedField exampleStringField = mock(MaterializedField.class);
MajorType exampleStringType = MajorType.newBuilder().setMinorType(MinorType.VARCHAR).build();
when(exampleStringField.getPath()).thenReturn("/path/to/testString");
when(exampleStringField.getType()).thenReturn(exampleStringType);
when(exampleStringField.getDataMode()).thenReturn(DataMode.REQUIRED);
oneElementList = new DrillColumnMetaDataList();
BatchSchema oneElementSchema = mock(BatchSchema.class);
when(oneElementSchema.getFieldCount()).thenReturn(1);
doAnswer(new Answer<MaterializedField>() {
@Override
public MaterializedField answer(InvocationOnMock invocationOnMock) throws Throwable {
Integer index = (Integer) invocationOnMock.getArguments()[0];
if (index == 0) {
return exampleIntField;
}
return null;
}
}).when(oneElementSchema).getColumn(Mockito.anyInt());
List<Class<?>> oneClassList = new ArrayList<>();
oneClassList.add(Integer.class);
oneElementList.updateColumnMetaData("testCatalog", "testSchema", "testTable", oneElementSchema, oneClassList);
twoElementList = new DrillColumnMetaDataList();
BatchSchema twoElementSchema = mock(BatchSchema.class);
when(twoElementSchema.getFieldCount()).thenReturn(2);
doAnswer(new Answer<MaterializedField>() {
@Override
public MaterializedField answer(InvocationOnMock invocationOnMock) throws Throwable {
Integer index = (Integer) invocationOnMock.getArguments()[0];
if (index == 0) {
return exampleIntField;
} else if (index == 1) {
return exampleStringField;
}
return null;
}
}).when(twoElementSchema).getColumn(Mockito.anyInt());
List<Class<?>> twoClassList = new ArrayList<>();
twoClassList.add(Integer.class);
twoClassList.add(String.class);
twoElementList.updateColumnMetaData("testCatalog", "testSchema", "testTable", twoElementSchema, twoClassList);
}
Aggregations