Search in sources :

Example 1 with SetMultimap

use of com.datastax.oss.driver.shaded.guava.common.collect.SetMultimap in project dsbulk by datastax.

the class SchemaSettingsTest method assertMapping.

private static void assertMapping(DefaultMapping mapping, Object... fieldsAndVars) {
    ImmutableSetMultimap.Builder<Object, Object> expected = ImmutableSetMultimap.builder();
    for (int i = 0; i < fieldsAndVars.length; i += 2) {
        String first = fieldsAndVars[i] instanceof String ? (String) fieldsAndVars[i] : ((CqlIdentifier) fieldsAndVars[i]).asInternal();
        CQLWord second = fieldsAndVars[i + 1] instanceof String ? CQLWord.fromInternal((String) fieldsAndVars[i + 1]) : CQLWord.fromCqlIdentifier((CqlIdentifier) fieldsAndVars[i + 1]);
        if (CharMatcher.inRange('0', '9').matchesAllOf(first)) {
            expected.put(new DefaultIndexedField(Integer.parseInt(first)), second);
        } else {
            expected.put(new DefaultMappedField(first), second);
        }
    }
    @SuppressWarnings("unchecked") SetMultimap<Field, CQLWord> fieldsToVariables = (SetMultimap<Field, CQLWord>) getInternalState(mapping, "fieldsToVariables");
    assertThat(fieldsToVariables).isEqualTo(expected.build());
}
Also used : DefaultIndexedField(com.datastax.oss.dsbulk.connectors.api.DefaultIndexedField) ImmutableSetMultimap(com.datastax.oss.driver.shaded.guava.common.collect.ImmutableSetMultimap) DefaultMappedField(com.datastax.oss.dsbulk.connectors.api.DefaultMappedField) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CqlIdentifier(com.datastax.oss.driver.api.core.CqlIdentifier) Field(com.datastax.oss.dsbulk.connectors.api.Field) DefaultIndexedField(com.datastax.oss.dsbulk.connectors.api.DefaultIndexedField) DefaultMappedField(com.datastax.oss.dsbulk.connectors.api.DefaultMappedField) SetMultimap(com.datastax.oss.driver.shaded.guava.common.collect.SetMultimap) ImmutableSetMultimap(com.datastax.oss.driver.shaded.guava.common.collect.ImmutableSetMultimap) CQLWord(com.datastax.oss.dsbulk.mapping.CQLWord)

Aggregations

CqlIdentifier (com.datastax.oss.driver.api.core.CqlIdentifier)1 ImmutableSetMultimap (com.datastax.oss.driver.shaded.guava.common.collect.ImmutableSetMultimap)1 SetMultimap (com.datastax.oss.driver.shaded.guava.common.collect.SetMultimap)1 DefaultIndexedField (com.datastax.oss.dsbulk.connectors.api.DefaultIndexedField)1 DefaultMappedField (com.datastax.oss.dsbulk.connectors.api.DefaultMappedField)1 Field (com.datastax.oss.dsbulk.connectors.api.Field)1 CQLWord (com.datastax.oss.dsbulk.mapping.CQLWord)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1