Package com.box.boxjavalibv2.requests

Source Code of com.box.boxjavalibv2.requests.GetAllUsersInEnterpriseRequestTest

package com.box.boxjavalibv2.requests;

import java.io.IOException;

import org.junit.Assert;

import org.apache.http.HttpStatus;
import org.junit.Test;

import com.box.boxjavalibv2.exceptions.AuthFatalFailureException;
import com.box.boxjavalibv2.testutils.TestUtils;
import com.box.restclientv2.RestMethod;
import com.box.restclientv2.exceptions.BoxRestException;
import com.box.restclientv2.requestsbase.BoxDefaultRequestObject;

public class GetAllUsersInEnterpriseRequestTest extends RequestTestBase {

    @Test
    public void testUri() {
        Assert.assertEquals("/users", GetAllUsersInEnterpriseRequest.getUri());
    }

    @Test
    public void testRequestIsWellFormed() throws BoxRestException, IllegalStateException, IOException, AuthFatalFailureException {
        int limit = 100;
        int offset = 200;
        String filterTerm = "testfilterterm";
        GetAllUsersInEnterpriseRequest request = new GetAllUsersInEnterpriseRequest(CONFIG, JSON_PARSER,
            (new BoxDefaultRequestObject()).setPage(limit, offset), filterTerm);

        testRequestIsWellFormed(request, TestUtils.getConfig().getApiUrlAuthority(),
            TestUtils.getConfig().getApiUrlPath().concat(GetAllUsersInEnterpriseRequest.getUri()), HttpStatus.SC_OK, RestMethod.GET);
        Assert.assertEquals(Integer.toString(limit), request.getQueryParams().get("limit"));
        Assert.assertEquals(Integer.toString(offset), request.getQueryParams().get("offset"));
        Assert.assertEquals(filterTerm, request.getQueryParams().get("filter_term"));
    }

    @Test
    public void testRequestDoesNotHaveFilterTermIfNotSupplied() throws BoxRestException {
        GetAllUsersInEnterpriseRequest request = new GetAllUsersInEnterpriseRequest(CONFIG, JSON_PARSER, (new BoxDefaultRequestObject()).setPage(1, 2), null);
        Assert.assertFalse(request.getQueryParams().containsKey("filter_term"));

    }

}
TOP

Related Classes of com.box.boxjavalibv2.requests.GetAllUsersInEnterpriseRequestTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.