Search in sources :

Example 6 with UnmappableStatement

use of com.datastax.oss.dsbulk.workflow.commons.statement.UnmappableStatement in project dsbulk by datastax.

the class DefaultRecordMapperTest method should_return_unmappable_statement_when_pk_column_unmapped.

@Test
void should_return_unmappable_statement_when_pk_column_unmapped() {
    when(boundStatementBuilder.allIndicesOf(C1.asIdentifier())).thenReturn(Collections.singletonList(0));
    when(boundStatementBuilder.isSet(0)).thenReturn(false);
    RecordMapper mapper = new DefaultRecordMapper(Collections.singletonList(insertStatement), set(C1), set(C2, C3), V4, mapping, recordMetadata, false, true, false, statement -> boundStatementBuilder);
    Statement<?> result = mapper.map(record).single().block();
    assertThat(result).isInstanceOf(UnmappableStatement.class);
    UnmappableStatement unmappableStatement = (UnmappableStatement) result;
    assertThat(unmappableStatement.getError()).isInstanceOf(InvalidMappingException.class).hasMessageContaining("Primary key column col1 cannot be left unset");
}
Also used : UnmappableStatement(com.datastax.oss.dsbulk.workflow.commons.statement.UnmappableStatement) Test(org.junit.jupiter.api.Test)

Example 7 with UnmappableStatement

use of com.datastax.oss.dsbulk.workflow.commons.statement.UnmappableStatement in project dsbulk by datastax.

the class MetricsManagerTest method setUp.

@BeforeEach
void setUp() throws Exception {
    URI resource1 = new URI("file:///file1.csv");
    URI resource2 = new URI("file:///file2.csv");
    URI resource3 = new URI("file:///file3.csv");
    String source1 = "line1\n";
    String source2 = "line2\n";
    String source3 = "line3\n";
    record1 = DefaultRecord.indexed(source1, resource1, -1, "irrelevant");
    record2 = DefaultRecord.indexed(source2, resource2, -1, "irrelevant");
    record3 = new DefaultErrorRecord(source3, resource3, -1, new RuntimeException("irrelevant"));
    BatchableStatement<?> stmt1 = new MappedSimpleStatement(record1, SimpleStatement.newInstance("irrelevant"));
    BatchableStatement<?> stmt2 = new MappedSimpleStatement(record2, SimpleStatement.newInstance("irrelevant"));
    stmt3 = new UnmappableStatement(record3, new RuntimeException("irrelevant"));
    batch = BatchStatement.newInstance(DefaultBatchType.UNLOGGED).add(stmt1).add(stmt2);
}
Also used : MappedSimpleStatement(com.datastax.oss.dsbulk.workflow.commons.statement.MappedSimpleStatement) DefaultErrorRecord(com.datastax.oss.dsbulk.connectors.api.DefaultErrorRecord) URI(java.net.URI) UnmappableStatement(com.datastax.oss.dsbulk.workflow.commons.statement.UnmappableStatement) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

UnmappableStatement (com.datastax.oss.dsbulk.workflow.commons.statement.UnmappableStatement)7 Test (org.junit.jupiter.api.Test)5 DefaultErrorRecord (com.datastax.oss.dsbulk.connectors.api.DefaultErrorRecord)3 URI (java.net.URI)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 DriverTimeoutException (com.datastax.oss.driver.api.core.DriverTimeoutException)1 BatchStatement (com.datastax.oss.driver.api.core.cql.BatchStatement)1 BatchableStatement (com.datastax.oss.driver.api.core.cql.BatchableStatement)1 ExecutionInfo (com.datastax.oss.driver.api.core.cql.ExecutionInfo)1 Row (com.datastax.oss.driver.api.core.cql.Row)1 DefaultRecord (com.datastax.oss.dsbulk.connectors.api.DefaultRecord)1 Record (com.datastax.oss.dsbulk.connectors.api.Record)1 BulkExecutionException (com.datastax.oss.dsbulk.executor.api.exception.BulkExecutionException)1 DefaultReadResult (com.datastax.oss.dsbulk.executor.api.result.DefaultReadResult)1 DefaultWriteResult (com.datastax.oss.dsbulk.executor.api.result.DefaultWriteResult)1 ReadResult (com.datastax.oss.dsbulk.executor.api.result.ReadResult)1 DriverUtils.mockRow (com.datastax.oss.dsbulk.tests.driver.DriverUtils.mockRow)1 MappedBoundStatement (com.datastax.oss.dsbulk.workflow.commons.statement.MappedBoundStatement)1 MappedSimpleStatement (com.datastax.oss.dsbulk.workflow.commons.statement.MappedSimpleStatement)1 Path (java.nio.file.Path)1