use of org.talend.components.snowflake.tsnowflakeoutput.TSnowflakeOutputProperties in project components by Talend.
the class SnowflakeWritersTestIT method testSchemaSerialized2.
@Test
public void testSchemaSerialized2() throws Throwable {
ComponentDefinition definition = getComponentService().getComponentDefinition(TSnowflakeOutputDefinition.COMPONENT_NAME);
TSnowflakeOutputProperties outputProps = (TSnowflakeOutputProperties) getComponentService().getComponentProperties(TSnowflakeOutputDefinition.COMPONENT_NAME);
Schema reject = SchemaBuilder.record("Reject").fields().name("A").type().stringType().noDefault().name("B").type().stringType().noDefault().endRecord();
Schema main = SchemaBuilder.record("Main").fields().name("C").type().stringType().noDefault().name("D").type().stringType().noDefault().endRecord();
outputProps.setValue("table.main.schema", main);
outputProps.setValue("schemaReject.schema", reject);
Schema main2 = (Schema) outputProps.getValuedProperty("table.main.schema").getValue();
Schema reject2 = (Schema) outputProps.getValuedProperty("schemaReject.schema").getValue();
assertEquals(main.toString(), main2.toString());
assertEquals(reject.toString(), reject2.toString());
String serialized = outputProps.toSerialized();
TSnowflakeOutputProperties afterSerialized = org.talend.daikon.properties.Properties.Helper.fromSerializedPersistent(serialized, TSnowflakeOutputProperties.class).object;
main2 = (Schema) afterSerialized.getValuedProperty("table.main.schema").getValue();
reject2 = (Schema) afterSerialized.getValuedProperty("schemaReject.schema").getValue();
assertEquals(main.toString(), main2.toString());
assertEquals(reject.toString(), reject2.toString());
}
use of org.talend.components.snowflake.tsnowflakeoutput.TSnowflakeOutputProperties in project components by Talend.
the class SnowflakeWriterTest method setup.
@Before
public void setup() throws Exception {
properties = new TSnowflakeOutputProperties("outputProperties");
properties.init();
sink = Mockito.mock(SnowflakeSink.class);
Mockito.when(sink.getSnowflakeOutputProperties()).thenReturn(properties);
writeOperation = new SnowflakeWriteOperation(sink);
writer = new SnowflakeWriter(writeOperation, null);
Schema schema = SchemaBuilder.record("record").fields().name("id").prop(SchemaConstants.TALEND_COLUMN_IS_KEY, Boolean.TRUE.toString()).prop(SchemaConstants.TALEND_COLUMN_DB_COLUMN_NAME, "id").type().stringType().noDefault().requiredString("column").requiredString("field").endRecord();
schema.getField("column").addProp(SchemaConstants.TALEND_COLUMN_DB_COLUMN_NAME, "column");
schema.getField("field").addProp(SchemaConstants.TALEND_COLUMN_DB_COLUMN_NAME, "field");
Mockito.when(sink.createConnection(null)).thenReturn(Mockito.mock(Connection.class));
Mockito.when(sink.getRuntimeSchema(null)).thenReturn(schema);
properties.table.main.schema.setValue(schema);
properties.table.tableName.setValue("Table");
properties.connection.schemaName.setValue("dbSchema");
properties.connection.db.setValue("db");
properties.outputAction.setValue(OutputAction.INSERT);
PowerMockito.mockStatic(LoaderFactory.class);
loader = Mockito.mock(StreamLoader.class);
Mockito.when(LoaderFactory.createLoader(Mockito.anyMapOf(LoaderProperty.class, Object.class), Mockito.any(Connection.class), Mockito.any(Connection.class))).thenReturn(loader);
}
Aggregations