Search in sources :

Example 21 with RecordMapper

use of com.datastax.oss.dsbulk.workflow.commons.schema.RecordMapper in project dsbulk by datastax.

the class SchemaSettingsTest method should_create_record_mapper_when_mapping_keyspace_and_counter_table_provided.

@Test
void should_create_record_mapper_when_mapping_keyspace_and_counter_table_provided() {
    when(col1.getType()).thenReturn(COUNTER);
    when(col2.getType()).thenReturn(COUNTER);
    when(col3.getType()).thenReturn(COUNTER);
    Config config = TestConfigUtils.createTestConfig("dsbulk.schema", "keyspace", "ks", "table", "t1");
    SchemaSettings settings = new SchemaSettings(config, MAP_AND_WRITE);
    settings.init(session, codecFactory, false, true);
    RecordMapper mapper = settings.createRecordMapper(session, recordMetadata, false);
    assertThat(mapper).isNotNull();
    ArgumentCaptor<String> argument = ArgumentCaptor.forClass(String.class);
    verify(session).prepare(argument.capture());
    assertThat(argument.getValue()).isEqualTo("UPDATE ks.t1 SET \"COL 2\" = \"COL 2\" + :\"COL 2\", c3 = c3 + :c3 WHERE c1 = :c1");
    assertMapping(mapper, C2, C2, C1, C1, C3, C3);
}
Also used : Config(com.typesafe.config.Config) RecordMapper(com.datastax.oss.dsbulk.workflow.commons.schema.RecordMapper) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Test(org.junit.jupiter.api.Test)

Aggregations

RecordMapper (com.datastax.oss.dsbulk.workflow.commons.schema.RecordMapper)21 Config (com.typesafe.config.Config)20 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)20 Test (org.junit.jupiter.api.Test)19 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)13 CQLWord (com.datastax.oss.dsbulk.mapping.CQLWord)5 EnumSet (java.util.EnumSet)5 Set (java.util.Set)5 ColumnDefinitions (com.datastax.oss.driver.api.core.cql.ColumnDefinitions)4 DefaultMapping (com.datastax.oss.dsbulk.mapping.DefaultMapping)4 DriverUtils.mockColumnDefinitions (com.datastax.oss.dsbulk.tests.driver.DriverUtils.mockColumnDefinitions)4 CqlIdentifier (com.datastax.oss.driver.api.core.CqlIdentifier)1 ColumnMetadata (com.datastax.oss.driver.api.core.metadata.schema.ColumnMetadata)1 IndexMetadata (com.datastax.oss.driver.api.core.metadata.schema.IndexMetadata)1 ConvertingCodecFactory (com.datastax.oss.dsbulk.codecs.api.ConvertingCodecFactory)1 NestedBatchException (com.datastax.oss.dsbulk.workflow.commons.schema.NestedBatchException)1 BatchSettings (com.datastax.oss.dsbulk.workflow.commons.settings.BatchSettings)1 CodecSettings (com.datastax.oss.dsbulk.workflow.commons.settings.CodecSettings)1 ConnectorSettings (com.datastax.oss.dsbulk.workflow.commons.settings.ConnectorSettings)1 DriverSettings (com.datastax.oss.dsbulk.workflow.commons.settings.DriverSettings)1