Search in sources :

Example 1 with MetaService

use of io.dingodb.meta.MetaService in project dingo by dingodb.

the class MockMetaServiceProvider method get.

@Override
public MetaService get() {
    MetaService metaService = Mockito.spy(MetaService.class);
    try {
        when(metaService.getTableDefinitions()).thenReturn(ImmutableMap.of(TABLE_NAME, TableDefinition.readJson(getClass().getResourceAsStream("/table-test.json")), TABLE_1_NAME, TableDefinition.readJson(getClass().getResourceAsStream("/table-test1.json"))));
        when(metaService.getTableKey(anyString())).then(args -> {
            String tableName = args.getArgument(0);
            return tableName.getBytes(StandardCharsets.UTF_8);
        });
    } catch (IOException e) {
        e.printStackTrace();
    }
    when(metaService.getPartLocations(TABLE_NAME)).thenReturn(ImmutableMap.of("0", LOC_0, "1", LOC_1));
    when(metaService.currentLocation()).thenReturn(LOC_0);
    return metaService;
}
Also used : MetaService(io.dingodb.meta.MetaService) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) IOException(java.io.IOException)

Aggregations

MetaService (io.dingodb.meta.MetaService)1 IOException (java.io.IOException)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1