Search in sources :

Example 1 with Status

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

the class NetSuitePortTypeMockAdapterImpl method createSuccessStatus.

public static Status createSuccessStatus() {
    Status status = new Status();
    status.setIsSuccess(true);
    return status;
}
Also used : Status(com.netsuite.webservices.test.platform.core.Status)

Example 2 with Status

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

the class NetSuitePortTypeMockAdapterImpl method createErrorStatus.

public static Status createErrorStatus(StatusDetailCodeType code, String message) {
    Status status = new Status();
    status.setIsSuccess(false);
    StatusDetail statusDetail = new StatusDetail();
    statusDetail.setType(StatusDetailType.ERROR);
    statusDetail.setCode(code);
    statusDetail.setMessage(message);
    status.getStatusDetail().add(statusDetail);
    return status;
}
Also used : Status(com.netsuite.webservices.test.platform.core.Status) StatusDetail(com.netsuite.webservices.test.platform.core.StatusDetail)

Example 3 with Status

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

the class NetSuitePortTypeMockAdapterImpl method getDataCenterUrls.

public GetDataCenterUrlsResponse getDataCenterUrls(GetDataCenterUrlsRequest parameters) throws InvalidSessionFault, UnexpectedErrorFault, InsufficientPermissionFault, InvalidCredentialsFault, ExceededRequestSizeFault {
    GetDataCenterUrlsResponse response = null;
    if (port != null) {
        response = port.getDataCenterUrls(parameters);
    }
    if (response == null) {
        response = new GetDataCenterUrlsResponse();
        GetDataCenterUrlsResult result = new GetDataCenterUrlsResult();
        Status status = new Status();
        status.setIsSuccess(true);
        result.setStatus(status);
        DataCenterUrls urls = new DataCenterUrls();
        urls.setWebservicesDomain(endpointAddress.toString());
        urls.setSystemDomain(endpointAddress.toString());
        result.setDataCenterUrls(urls);
        response.setGetDataCenterUrlsResult(result);
        return response;
    }
    return response;
}
Also used : Status(com.netsuite.webservices.test.platform.core.Status) GetDataCenterUrlsResponse(com.netsuite.webservices.test.platform.messages.GetDataCenterUrlsResponse) DataCenterUrls(com.netsuite.webservices.test.platform.core.DataCenterUrls) GetDataCenterUrlsResult(com.netsuite.webservices.test.platform.core.GetDataCenterUrlsResult)

Example 4 with Status

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

the class TestNetSuiteClientService method doLogin.

@Override
protected void doLogin() throws NetSuiteException {
    port = getNetSuitePort(endpointUrl, credentials.getAccount());
    setHttpClientPolicy(port);
    setLoginHeaders(port);
    PortOperation<SessionResponse, NetSuitePortType> loginOp;
    if (!credentials.isUseSsoLogin()) {
        final Passport passport = createNativePassport(credentials);
        loginOp = new PortOperation<SessionResponse, NetSuitePortType>() {

            @Override
            public SessionResponse execute(NetSuitePortType port) throws Exception {
                LoginRequest request = new LoginRequest();
                request.setPassport(passport);
                LoginResponse response = port.login(request);
                return response.getSessionResponse();
            }
        };
    } else {
        throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.CLIENT_ERROR), NetSuiteRuntimeI18n.MESSAGES.getMessage("error.ssoLoginNotSupported"));
    }
    Status status = null;
    SessionResponse sessionResponse;
    String exceptionMessage = null;
    for (int i = 0; i < getRetryCount(); i++) {
        try {
            sessionResponse = loginOp.execute(port);
            status = sessionResponse.getStatus();
        } catch (InvalidCredentialsFault f) {
            throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.CLIENT_ERROR), f.getFaultInfo().getMessage());
        } catch (UnexpectedErrorFault f) {
            exceptionMessage = f.getFaultInfo().getMessage();
        } catch (Exception e) {
            exceptionMessage = e.getMessage();
        }
        if (status != null) {
            break;
        }
        if (i != getRetryCount() - 1) {
            waitForRetryInterval();
        }
    }
    checkLoginError(toNsStatus(status), exceptionMessage);
    removeLoginHeaders(port);
}
Also used : Status(com.netsuite.webservices.test.platform.core.Status) NsStatus(org.talend.components.netsuite.client.NsStatus) InvalidCredentialsFault(com.netsuite.webservices.test.platform.InvalidCredentialsFault) LoginResponse(com.netsuite.webservices.test.platform.messages.LoginResponse) NetSuiteException(org.talend.components.netsuite.client.NetSuiteException) UnexpectedErrorFault(com.netsuite.webservices.test.platform.UnexpectedErrorFault) LoginRequest(com.netsuite.webservices.test.platform.messages.LoginRequest) NetSuiteException(org.talend.components.netsuite.client.NetSuiteException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) SocketException(java.net.SocketException) MalformedURLException(java.net.MalformedURLException) NetSuitePortType(com.netsuite.webservices.test.platform.NetSuitePortType) NetSuiteErrorCode(org.talend.components.netsuite.NetSuiteErrorCode) Passport(com.netsuite.webservices.test.platform.core.Passport) SessionResponse(com.netsuite.webservices.test.platform.messages.SessionResponse)

Example 5 with Status

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

the class SearchResultSetTest method testEmptyResult.

@Test
public void testEmptyResult() throws Exception {
    NetSuiteClientService<?> conn = mock(NetSuiteClientService.class);
    SearchResult result1 = new SearchResult();
    Status status = new Status();
    status.setIsSuccess(true);
    result1.setStatus(status);
    result1.setSearchId("abc123");
    result1.setPageIndex(1);
    result1.setTotalRecords(0);
    result1.setTotalPages(0);
    SearchResponse response1 = new SearchResponse();
    response1.setSearchResult(result1);
    AccountSearch nsSearchRecord1 = new AccountSearch();
    NsSearchResult nsSearchResult1 = TestNetSuiteClientService.toNsSearchResult(result1);
    when(conn.search(eq(nsSearchRecord1))).thenReturn(nsSearchResult1);
    NetSuiteClientService<?> clientService = new TestNetSuiteClientService();
    RecordTypeInfo recordTypeInfo = clientService.getMetaDataSource().getRecordType("Account");
    SearchRecordTypeDesc searchRecordTypeDesc = clientService.getMetaDataSource().getSearchRecordType(recordTypeInfo.getRecordType().getSearchRecordType());
    SearchResultSet<Record> resultSet = new SearchResultSet<>(conn, recordTypeInfo.getRecordType(), searchRecordTypeDesc, nsSearchResult1);
    assertFalse(resultSet.next());
}
Also used : Status(com.netsuite.webservices.test.platform.core.Status) SearchRecordTypeDesc(org.talend.components.netsuite.client.model.SearchRecordTypeDesc) TestNetSuiteClientService(org.talend.components.netsuite.test.client.TestNetSuiteClientService) RecordTypeInfo(org.talend.components.netsuite.client.model.RecordTypeInfo) SearchResultSet(org.talend.components.netsuite.client.search.SearchResultSet) SearchResult(com.netsuite.webservices.test.platform.core.SearchResult) Record(com.netsuite.webservices.test.platform.core.Record) SearchResponse(com.netsuite.webservices.test.platform.messages.SearchResponse) AccountSearch(com.netsuite.webservices.test.lists.accounting.AccountSearch) Test(org.junit.Test)

Aggregations

Status (com.netsuite.webservices.test.platform.core.Status)9 Test (org.junit.Test)4 Record (com.netsuite.webservices.test.platform.core.Record)3 SearchResult (com.netsuite.webservices.test.platform.core.SearchResult)3 SearchResponse (com.netsuite.webservices.test.platform.messages.SearchResponse)3 RecordTypeInfo (org.talend.components.netsuite.client.model.RecordTypeInfo)3 SearchRecordTypeDesc (org.talend.components.netsuite.client.model.SearchRecordTypeDesc)3 SearchResultSet (org.talend.components.netsuite.client.search.SearchResultSet)3 TestNetSuiteClientService (org.talend.components.netsuite.test.client.TestNetSuiteClientService)3 AccountSearch (com.netsuite.webservices.test.lists.accounting.AccountSearch)2 RecordList (com.netsuite.webservices.test.platform.core.RecordList)2 SearchMoreWithIdResponse (com.netsuite.webservices.test.platform.messages.SearchMoreWithIdResponse)2 ArrayList (java.util.ArrayList)2 Account (com.netsuite.webservices.test.lists.accounting.Account)1 InventoryItem (com.netsuite.webservices.test.lists.accounting.InventoryItem)1 ItemSearch (com.netsuite.webservices.test.lists.accounting.ItemSearch)1 ServiceSaleItem (com.netsuite.webservices.test.lists.accounting.ServiceSaleItem)1 InvalidCredentialsFault (com.netsuite.webservices.test.platform.InvalidCredentialsFault)1 NetSuitePortType (com.netsuite.webservices.test.platform.NetSuitePortType)1 UnexpectedErrorFault (com.netsuite.webservices.test.platform.UnexpectedErrorFault)1