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));
}
}
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);
}
Aggregations