Search in sources :

Example 1 with ListFunctionsRequest

use of com.aliyuncs.fc.request.ListFunctionsRequest in project fc-java-sdk by aliyun.

the class FunctionComputeClientTest method testListFunctionsValidate.

@Test
public void testListFunctionsValidate() {
    try {
        ListFunctionsRequest request = new ListFunctionsRequest(null);
        client.listFunctions(request);
        fail("ClientException is expected");
    } catch (ClientException e) {
        assertTrue(e.getMessage().contains(VALIDATE_MSG));
    }
    try {
        ListFunctionsRequest request = new ListFunctionsRequest("");
        client.listFunctions(request);
        fail("ClientException is expected");
    } catch (ClientException e) {
        assertTrue(e.getMessage().contains(VALIDATE_MSG));
    }
}
Also used : ListFunctionsRequest(com.aliyuncs.fc.request.ListFunctionsRequest) ClientException(com.aliyuncs.fc.exceptions.ClientException) Test(org.junit.Test)

Example 2 with ListFunctionsRequest

use of com.aliyuncs.fc.request.ListFunctionsRequest in project fc-java-sdk by aliyun.

the class FunctionComputeClientTest method testListFunctions.

@Test
public void testListFunctions() {
    final int numServices = 10;
    final int limit = 3;
    // Create service
    createService(SERVICE_NAME);
    // Create multiple functions under the test service
    for (int i = 0; i < numServices; i++) {
        CreateFunctionResponse createFResp = createFunction(FUNCTION_NAME + i);
        assertFalse(Strings.isNullOrEmpty(createFResp.getRequestId()));
    }
    ListFunctionsRequest listRequest = new ListFunctionsRequest(SERVICE_NAME);
    listRequest.setLimit(limit);
    listRequest.setPrefix(FUNCTION_NAME);
    ListFunctionsResponse listResponse = client.listFunctions(listRequest);
    int numCalled = 1;
    String nextToken = listResponse.getNextToken();
    while (nextToken != null) {
        listRequest.setNextToken(nextToken);
        listResponse = client.listFunctions(listRequest);
        nextToken = listResponse.getNextToken();
        numCalled++;
    }
    assertEquals(numServices / limit + 1, numCalled);
}
Also used : CreateFunctionResponse(com.aliyuncs.fc.response.CreateFunctionResponse) ListFunctionsResponse(com.aliyuncs.fc.response.ListFunctionsResponse) ListFunctionsRequest(com.aliyuncs.fc.request.ListFunctionsRequest) Test(org.junit.Test)

Aggregations

ListFunctionsRequest (com.aliyuncs.fc.request.ListFunctionsRequest)2 Test (org.junit.Test)2 ClientException (com.aliyuncs.fc.exceptions.ClientException)1 CreateFunctionResponse (com.aliyuncs.fc.response.CreateFunctionResponse)1 ListFunctionsResponse (com.aliyuncs.fc.response.ListFunctionsResponse)1