use of com.aliyuncs.fc.request.CreateServiceRequest in project fc-java-sdk by aliyun.
the class FunctionComputeClientTest method testCreateServiceValidate.
@Test
public void testCreateServiceValidate() {
try {
CreateServiceRequest request = new CreateServiceRequest();
client.createService(request);
fail("ClientException is expected");
} catch (ClientException e) {
assertEquals(ErrorCodes.INVALID_ARGUMENT, e.getErrorCode());
}
try {
CreateServiceRequest request = new CreateServiceRequest();
client.createService(request);
fail("ClientException is expected");
} catch (ClientException e) {
assertEquals(ErrorCodes.INVALID_ARGUMENT, e.getErrorCode());
}
}
use of com.aliyuncs.fc.request.CreateServiceRequest in project fc-java-sdk by aliyun.
the class FunctionComputeClientTest method createService.
private CreateServiceResponse createService(String serviceName) {
CreateServiceRequest createSReq = new CreateServiceRequest();
createSReq.setServiceName(serviceName);
createSReq.setDescription(SERVICE_DESC_OLD);
createSReq.setRole(ROLE);
return client.createService(createSReq);
}
use of com.aliyuncs.fc.request.CreateServiceRequest in project fc-java-sdk by aliyun.
the class FunctionComputeClientTest method testListServices.
@Test
public void testListServices() {
final int numServices = 10;
final int limit = 3;
// Create multiple services
for (int i = 0; i < numServices; i++) {
try {
client.getService(new GetServiceRequest(SERVICE_NAME + i));
cleanupService(SERVICE_NAME + i);
} catch (ClientException e) {
if (!ErrorCodes.SERVICE_NOT_FOUND.equals(e.getErrorCode())) {
throw new RuntimeException("Cleanup failed");
}
}
CreateServiceRequest request = new CreateServiceRequest();
request.setServiceName(SERVICE_NAME + i);
request.setDescription(SERVICE_DESC_OLD);
request.setRole(ROLE);
CreateServiceResponse response = client.createService(request);
assertFalse(Strings.isNullOrEmpty(response.getRequestId()));
}
ListServicesRequest listRequest = new ListServicesRequest();
listRequest.setLimit(limit);
listRequest.setPrefix(SERVICE_NAME);
ListServicesResponse listResponse = client.listServices(listRequest);
int numCalled = 1;
String nextToken = listResponse.getNextToken();
while (nextToken != null) {
listRequest.setNextToken(nextToken);
listResponse = client.listServices(listRequest);
nextToken = listResponse.getNextToken();
numCalled++;
}
assertEquals(numServices / limit + 1, numCalled);
// Delete services
for (int i = 0; i < numServices; i++) {
cleanupService(SERVICE_NAME + i);
}
}
Aggregations