Search in sources :

Example 1 with GetResponse

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;
        }
    });
}
Also used : NetSuitePortType(com.netsuite.webservices.test.platform.NetSuitePortType) ReadResponse(com.netsuite.webservices.test.platform.messages.ReadResponse) InvocationOnMock(org.mockito.invocation.InvocationOnMock) GetRequest(com.netsuite.webservices.test.platform.messages.GetRequest) GetResponse(com.netsuite.webservices.test.platform.messages.GetResponse)

Example 2 with GetResponse

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());
}
Also used : GetRequest(com.netsuite.webservices.test.platform.messages.GetRequest) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) RecordRef(com.netsuite.webservices.test.platform.core.RecordRef) PurchaseOrder(com.netsuite.webservices.test.transactions.purchases.PurchaseOrder) LoginRequest(com.netsuite.webservices.test.platform.messages.LoginRequest) GetResponse(com.netsuite.webservices.test.platform.messages.GetResponse) Test(org.junit.Test)

Aggregations

GetRequest (com.netsuite.webservices.test.platform.messages.GetRequest)2 GetResponse (com.netsuite.webservices.test.platform.messages.GetResponse)2 NetSuitePortType (com.netsuite.webservices.test.platform.NetSuitePortType)1 RecordRef (com.netsuite.webservices.test.platform.core.RecordRef)1 LoginRequest (com.netsuite.webservices.test.platform.messages.LoginRequest)1 ReadResponse (com.netsuite.webservices.test.platform.messages.ReadResponse)1 PurchaseOrder (com.netsuite.webservices.test.transactions.purchases.PurchaseOrder)1 Test (org.junit.Test)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 TypeDesc (org.talend.components.netsuite.client.model.TypeDesc)1