use of org.talend.components.netsuite.client.model.TypeDesc in project components by Talend.
the class NetSuiteClientServiceTest method testLogin.
@Test
public void testLogin() throws Exception {
clientService.login();
verify(port, times(1)).login(argThat(new AssertMatcher<LoginRequest>() {
@Override
protected void doAssert(LoginRequest request) throws Exception {
assertNotNull(request);
Passport passport = request.getPassport();
assertNotNull(passport);
}
}));
// Verify that logging in not performed for already logged in client
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("RecordRef");
RecordRef recordRef = new NsObjectComposer<RecordRef>(clientService.getMetaDataSource(), typeDesc).composeObject();
DeleteResponse response = new DeleteResponse();
response.setWriteResponse(createSuccessWriteResponse());
when(port.delete(notNull(DeleteRequest.class))).thenReturn(response);
clientService.delete(recordRef);
verify(port, times(1)).login(any(LoginRequest.class));
}
use of org.talend.components.netsuite.client.model.TypeDesc in project components by Talend.
the class NetSuiteClientServiceTest method testAdd.
@Test
public void testAdd() throws Exception {
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("PurchaseOrder");
PurchaseOrder record = new NsObjectComposer<PurchaseOrder>(clientService.getMetaDataSource(), typeDesc).composeObject();
AddResponse response = new AddResponse();
response.setWriteResponse(createSuccessWriteResponse());
when(port.add(notNull(AddRequest.class))).thenReturn(response);
clientService.add(record);
verify(port, times(1)).login(notNull(LoginRequest.class));
verify(port, times(1)).add(notNull(AddRequest.class));
NsWriteResponse writeResponse = clientService.add(null);
assertNull(writeResponse.getStatus());
assertNull(writeResponse.getRef());
}
use of org.talend.components.netsuite.client.model.TypeDesc in project components by Talend.
the class NsObjectInputTransducerTest method testNonRecordObjects.
@Test
public void testNonRecordObjects() throws Exception {
Collection<String> typeNames = Arrays.asList(RefType.RECORD_REF.getTypeName(), RefType.CUSTOMIZATION_REF.getTypeName());
for (String typeName : typeNames) {
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo(typeName);
final List<?> nsObjects = makeNsObjects(new NsObjectComposer<>(clientService.getMetaDataSource(), typeDesc), 10);
Schema schema = NetSuiteDatasetRuntimeImpl.inferSchemaForType(typeDesc.getTypeName(), typeDesc.getFields());
NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName());
for (Object record : nsObjects) {
IndexedRecord indexedRecord = transducer.read(record);
assertIndexedRecord(typeDesc, indexedRecord);
}
}
}
use of org.talend.components.netsuite.client.model.TypeDesc in project components by Talend.
the class NsObjectInputTransducerTest method testDynamicSchemaWithCustomRecordType.
@Test
public void testDynamicSchemaWithCustomRecordType() throws Exception {
CustomMetaDataSource customMetaDataSource = new TestCustomMetaDataSource(clientService);
clientService.getMetaDataSource().setCustomMetaDataSource(customMetaDataSource);
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("custom_record_type_1");
final List<CustomRecord> recordList = makeNsObjects(new NsObjectComposer<CustomRecord>(clientService.getMetaDataSource(), typeDesc), 10);
mockSearchRequestResults(recordList, 100);
Schema schema = getDynamicSchema();
NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName());
SearchResultSet<CustomRecord> rs = clientService.newSearch().target(typeDesc.getTypeName()).search();
while (rs.next()) {
CustomRecord record = rs.get();
IndexedRecord indexedRecord = transducer.read(record);
assertIndexedRecord(typeDesc, indexedRecord);
}
}
use of org.talend.components.netsuite.client.model.TypeDesc in project components by Talend.
the class NsObjectInputTransducerTest method testGetApiVersion.
@Test
public void testGetApiVersion() throws Exception {
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("Opportunity");
Schema schema = NetSuiteDatasetRuntimeImpl.inferSchemaForType(typeDesc.getTypeName(), typeDesc.getFields());
NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName());
transducer.setApiVersion("2016.2");
assertNull(transducer.getPicklistClass());
}
Aggregations