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);
}
Aggregations