Search in sources :

Example 6 with BulkResult

use of org.talend.components.salesforce.runtime.BulkResult in project components by Talend.

the class BulkResultAdapterFactoryTest method testConvertToAvro.

@Test
public void testConvertToAvro() throws IOException {
    converter.setSchema(SCHEMA);
    assertNotNull(converter.getSchema());
    assertEquals(BulkResult.class, converter.getDatumClass());
    BulkResult result = new BulkResult();
    result.setValue("Id", "12345");
    result.setValue("Name", "Qwerty");
    result.setValue("FieldX", "42");
    result.setValue("FieldY", "true");
    IndexedRecord indexedRecord = converter.convertToAvro(result);
    assertNotNull(indexedRecord);
    assertNotNull(indexedRecord.getSchema());
    assertEquals(SCHEMA, indexedRecord.getSchema());
    assertEquals("12345", indexedRecord.get(0));
    assertEquals("Qwerty", indexedRecord.get(1));
    assertEquals(Integer.valueOf(42), indexedRecord.get(2));
    assertEquals(Boolean.TRUE, indexedRecord.get(3));
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) BulkResult(org.talend.components.salesforce.runtime.BulkResult) Test(org.junit.Test)

Example 7 with BulkResult

use of org.talend.components.salesforce.runtime.BulkResult in project components by Talend.

the class BulkResultAdapterFactoryTest method testIndexedRecordUnmodifiable.

@Test(expected = IndexedRecordConverter.UnmodifiableAdapterException.class)
public void testIndexedRecordUnmodifiable() throws IOException {
    converter.setSchema(SCHEMA);
    BulkResult result = new BulkResult();
    result.setValue("Id", "12345");
    result.setValue("Name", "Qwerty");
    result.setValue("FieldX", "42");
    result.setValue("FieldY", "true");
    IndexedRecord indexedRecord = converter.convertToAvro(result);
    indexedRecord.put(1, "Asdfgh");
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) BulkResult(org.talend.components.salesforce.runtime.BulkResult) Test(org.junit.Test)

Aggregations

BulkResult (org.talend.components.salesforce.runtime.BulkResult)7 Test (org.junit.Test)6 IndexedRecord (org.apache.avro.generic.IndexedRecord)4 CsvReader (com.csvreader.CsvReader)2 CsvWriter (com.csvreader.CsvWriter)2 BufferedInputStream (java.io.BufferedInputStream)2 BufferedOutputStream (java.io.BufferedOutputStream)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 BulkResultSet (org.talend.components.salesforce.runtime.BulkResultSet)2