use of com.netsuite.webservices.test.platform.messages.GetResponse in project components by Talend.
the class NetSuiteMockTestBase method mockGetRequestResults.
protected <T extends Record> void mockGetRequestResults(final T record) throws Exception {
final NetSuitePortType port = webServiceMockTestFixture.getPortMock();
when(port.get(any(GetRequest.class))).then(new Answer<GetResponse>() {
@Override
public GetResponse answer(InvocationOnMock invocationOnMock) throws Throwable {
GetResponse response = new GetResponse();
ReadResponse readResponse = new ReadResponse();
if (record != null) {
readResponse.setStatus(createSuccessStatus());
} else {
readResponse.setStatus(createNotFoundStatus());
}
readResponse.setRecord(record);
response.setReadResponse(readResponse);
return response;
}
});
}
use of com.netsuite.webservices.test.platform.messages.GetResponse in project components by Talend.
the class NetSuiteClientServiceTest method testGet.
@Test
public void testGet() throws Exception {
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("PurchaseOrder");
TypeDesc refTypeDesc = clientService.getMetaDataSource().getTypeInfo("RecordRef");
PurchaseOrder record = new NsObjectComposer<PurchaseOrder>(clientService.getMetaDataSource(), typeDesc).composeObject();
RecordRef recordRef = new NsObjectComposer<RecordRef>(clientService.getMetaDataSource(), refTypeDesc).composeObject();
GetResponse response = new GetResponse();
response.setReadResponse(createSuccessReadResponse(record));
when(port.get(notNull(GetRequest.class))).thenReturn(response);
clientService.get(recordRef);
verify(port, times(1)).login(notNull(LoginRequest.class));
verify(port, times(1)).get(notNull(GetRequest.class));
NsReadResponse readResponse = clientService.get(null);
assertNull(readResponse.getStatus());
assertNull(readResponse.getRecord());
}
Aggregations