use of com.netsuite.webservices.v2016_2.general.communication.Message in project components by Talend.
the class NetSuiteOutputWriterIT method testDelete.
@Test
public void testDelete() throws Exception {
NetSuiteClientService<NetSuitePortType> clientService = webServiceTestFixture.getClientService();
clientService.getMetaDataSource().setCustomizationEnabled(false);
RuntimeContainer container = mock(RuntimeContainer.class);
NetSuiteOutputProperties properties = new NetSuiteOutputProperties("test");
properties.init();
properties.connection.endpoint.setValue(webServiceTestFixture.getEndpointUrl());
properties.connection.email.setValue(webServiceTestFixture.getCredentials().getEmail());
properties.connection.password.setValue(webServiceTestFixture.getCredentials().getPassword());
properties.connection.account.setValue(webServiceTestFixture.getCredentials().getAccount());
properties.connection.role.setValue(Integer.valueOf(webServiceTestFixture.getCredentials().getRoleId()));
properties.connection.applicationId.setValue(webServiceTestFixture.getCredentials().getApplicationId());
properties.module.moduleName.setValue(RecordTypeEnum.MESSAGE.getTypeName());
properties.module.action.setValue(OutputAction.DELETE);
NetSuiteRuntimeImpl runtime = new NetSuiteRuntimeImpl();
runtime.setClientFactory(clientFactory);
NetSuiteDatasetRuntime dataSetRuntime = runtime.getDatasetRuntime(properties.getConnectionProperties());
Schema schema = dataSetRuntime.getSchema(RefType.RECORD_REF.getTypeName());
properties.module.main.schema.setValue(schema);
List<Message> recordsToAdd = makeMessageRecords(5);
final List<RecordRef> refList = new ArrayList<>(recordsToAdd.size());
List<NsWriteResponse<RecordRef>> writeResponseList = clientService.addList(recordsToAdd);
for (NsWriteResponse<RecordRef> writeResponse : writeResponseList) {
assertTrue(writeResponse.getStatus().isSuccess());
assertNotNull(writeResponse.getRef());
refList.add(writeResponse.getRef());
}
List<IndexedRecord> indexedRecordList = makeRecordRefIndexedRecords(schema, refList);
NetSuiteSink sink = new NetSuiteSinkImpl();
sink.setClientFactory(new NetSuiteClientFactoryImpl() {
@Override
public NetSuiteClientService<NetSuitePortType> createClient() throws NetSuiteException {
NetSuiteClientService<NetSuitePortType> service = super.createClient();
service.getMetaDataSource().setCustomizationEnabled(webServiceTestFixture.getClientService().getMetaDataSource().isCustomizationEnabled());
return service;
}
});
sink.initialize(container, properties);
NetSuiteWriteOperation writeOperation = (NetSuiteWriteOperation) sink.createWriteOperation();
NetSuiteOutputWriter writer = (NetSuiteOutputWriter) writeOperation.createWriter(container);
writer.open(UUID.randomUUID().toString());
for (IndexedRecord indexedRecord : indexedRecordList) {
writer.write(indexedRecord);
}
Result writerResult = writer.close();
assertNotNull(writerResult);
assertEquals(indexedRecordList.size(), writerResult.totalCount);
assertEquals(indexedRecordList.size(), writerResult.successCount);
List<NsReadResponse<Message>> readResponseList = clientService.execute(new NetSuiteClientService.PortOperation<List<NsReadResponse<Message>>, NetSuitePortType>() {
@Override
public List<NsReadResponse<Message>> execute(NetSuitePortType port) throws Exception {
GetListRequest request = new GetListRequest();
request.getBaseRef().addAll(refList);
return NetSuiteClientServiceImpl.toNsReadResponseList(port.getList(request).getReadResponseList());
}
});
for (NsReadResponse<Message> readResponse : readResponseList) {
// success=false means that NetSuite Record was not found because it was deleted
assertFalse(readResponse.getStatus().isSuccess());
}
}
use of com.netsuite.webservices.v2016_2.general.communication.Message in project components by Talend.
the class NetSuiteOutputWriterIT method makeMessageRecords.
private static List<Message> makeMessageRecords(int count) {
List<Message> messageList = new ArrayList<>(count);
for (int i = 1; i <= count; i++) {
Message record = new Message();
record.setSubject("Test subject " + i);
record.setMessage("Test body text " + i);
record.setAuthorEmail("doug@acme.com");
record.setRecipientEmail("bob@acme.com");
record.setIncoming(false);
record.setEmailed(false);
messageList.add(record);
}
return messageList;
}
Aggregations