Search in sources :

Example 11 with RecordRef

use of com.netsuite.webservices.test.platform.core.RecordRef in project components by Talend.

the class NetSuiteClientServiceTest method testDelete.

@Test
public void testDelete() throws Exception {
    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(notNull(LoginRequest.class));
    verify(port, times(1)).delete(notNull(DeleteRequest.class));
    NsWriteResponse writeResponse = clientService.delete(null);
    assertNull(writeResponse.getStatus());
    assertNull(writeResponse.getRef());
}
Also used : DeleteResponse(com.netsuite.webservices.test.platform.messages.DeleteResponse) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) RecordRef(com.netsuite.webservices.test.platform.core.RecordRef) LoginRequest(com.netsuite.webservices.test.platform.messages.LoginRequest) DeleteRequest(com.netsuite.webservices.test.platform.messages.DeleteRequest) Test(org.junit.Test)

Example 12 with RecordRef

use of com.netsuite.webservices.test.platform.core.RecordRef in project components by Talend.

the class NetSuiteClientServiceTest method createSuccessWriteResponse.

private WriteResponse createSuccessWriteResponse() {
    WriteResponse writeResponse = new WriteResponse();
    writeResponse.setStatus(NetSuitePortTypeMockAdapterImpl.createSuccessStatus());
    RecordRef recordRef = new RecordRef();
    recordRef.setInternalId(Integer.valueOf(10000 + rnd.nextInt()).toString());
    writeResponse.setBaseRef(recordRef);
    return writeResponse;
}
Also used : WriteResponse(com.netsuite.webservices.test.platform.messages.WriteResponse) RecordRef(com.netsuite.webservices.test.platform.core.RecordRef)

Example 13 with RecordRef

use of com.netsuite.webservices.test.platform.core.RecordRef 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));
}
Also used : Passport(com.netsuite.webservices.test.platform.core.Passport) DeleteResponse(com.netsuite.webservices.test.platform.messages.DeleteResponse) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) RecordRef(com.netsuite.webservices.test.platform.core.RecordRef) LoginRequest(com.netsuite.webservices.test.platform.messages.LoginRequest) AssertMatcher(org.talend.components.netsuite.test.AssertMatcher) DeleteRequest(com.netsuite.webservices.test.platform.messages.DeleteRequest) Test(org.junit.Test)

Aggregations

RecordRef (com.netsuite.webservices.test.platform.core.RecordRef)13 Test (org.junit.Test)11 TypeDesc (org.talend.components.netsuite.client.model.TypeDesc)7 LoginRequest (com.netsuite.webservices.test.platform.messages.LoginRequest)6 DeleteRequest (com.netsuite.webservices.test.platform.messages.DeleteRequest)3 DeleteResponse (com.netsuite.webservices.test.platform.messages.DeleteResponse)3 NsObjectInputTransducer (org.talend.components.netsuite.input.NsObjectInputTransducer)3 AvroConverter (org.talend.daikon.avro.converter.AvroConverter)3 CustomRecordRef (com.netsuite.webservices.test.platform.core.CustomRecordRef)2 Passport (com.netsuite.webservices.test.platform.core.Passport)2 PurchaseOrder (com.netsuite.webservices.test.transactions.purchases.PurchaseOrder)2 FieldDesc (org.talend.components.netsuite.client.model.FieldDesc)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 Account (com.netsuite.webservices.test.lists.accounting.Account)1 InvalidSessionFault (com.netsuite.webservices.test.platform.InvalidSessionFault)1 BooleanCustomFieldRef (com.netsuite.webservices.test.platform.core.BooleanCustomFieldRef)1 CustomFieldList (com.netsuite.webservices.test.platform.core.CustomFieldList)1 RecordRefList (com.netsuite.webservices.test.platform.core.RecordRefList)1