Search in sources :

Example 1 with ConsolidatedRate

use of com.netsuite.webservices.test.lists.accounting.types.ConsolidatedRate in project components by Talend.

the class ValueConverterTest method testEnumConverter.

@Test
public void testEnumConverter() throws Exception {
    NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName());
    FieldDesc fieldDesc = typeDesc.getField("acctType");
    AvroConverter<Enum<AccountType>, String> converter1 = (AvroConverter<Enum<AccountType>, String>) transducer.getValueConverter(fieldDesc);
    assertEquals(AvroUtils._string(), converter1.getSchema());
    assertEquals(AccountType.class, converter1.getDatumClass());
    assertEquals(AccountType.ACCOUNTS_PAYABLE.value(), converter1.convertToAvro(AccountType.ACCOUNTS_PAYABLE));
    assertEquals(AccountType.ACCOUNTS_PAYABLE, converter1.convertToDatum(AccountType.ACCOUNTS_PAYABLE.value()));
    assertEquals(AccountType.ACCOUNTS_PAYABLE, converter1.convertToDatum(AccountType.ACCOUNTS_PAYABLE.name()));
    fieldDesc = typeDesc.getField("generalRate");
    assertNotNull(fieldDesc);
    AvroConverter<Enum<ConsolidatedRate>, String> converter2 = (AvroConverter<Enum<ConsolidatedRate>, String>) transducer.getValueConverter(fieldDesc);
    assertEquals(ConsolidatedRate.HISTORICAL.value(), converter2.convertToAvro(ConsolidatedRate.HISTORICAL));
    assertEquals(ConsolidatedRate.HISTORICAL, converter2.convertToDatum(ConsolidatedRate.HISTORICAL.value()));
}
Also used : ConsolidatedRate(com.netsuite.webservices.test.lists.accounting.types.ConsolidatedRate) NsObjectInputTransducer(org.talend.components.netsuite.input.NsObjectInputTransducer) AccountType(com.netsuite.webservices.test.lists.accounting.types.AccountType) AvroConverter(org.talend.daikon.avro.converter.AvroConverter) FieldDesc(org.talend.components.netsuite.client.model.FieldDesc) Test(org.junit.Test)

Aggregations

AccountType (com.netsuite.webservices.test.lists.accounting.types.AccountType)1 ConsolidatedRate (com.netsuite.webservices.test.lists.accounting.types.ConsolidatedRate)1 Test (org.junit.Test)1 FieldDesc (org.talend.components.netsuite.client.model.FieldDesc)1 NsObjectInputTransducer (org.talend.components.netsuite.input.NsObjectInputTransducer)1 AvroConverter (org.talend.daikon.avro.converter.AvroConverter)1