Search in sources :

Example 1 with ClientException

use of com.aliyuncs.fc.exceptions.ClientException in project fc-java-sdk by aliyun.

the class FunctionComputeClientTest method testCreateTriggerValidate.

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

Example 2 with ClientException

use of com.aliyuncs.fc.exceptions.ClientException 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());
    }
}
Also used : CreateServiceRequest(com.aliyuncs.fc.request.CreateServiceRequest) ClientException(com.aliyuncs.fc.exceptions.ClientException) Test(org.junit.Test)

Example 3 with ClientException

use of com.aliyuncs.fc.exceptions.ClientException in project fc-java-sdk by aliyun.

the class FunctionComputeClientTest method testCreateFunctionValidate.

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

Example 4 with ClientException

use of com.aliyuncs.fc.exceptions.ClientException 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 5 with ClientException

use of com.aliyuncs.fc.exceptions.ClientException in project fc-java-sdk by aliyun.

the class FunctionComputeClientTest method testUpdateServiceValidate.

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

Aggregations

ClientException (com.aliyuncs.fc.exceptions.ClientException)26 Test (org.junit.Test)13 IOException (java.io.IOException)6 Gson (com.google.gson.Gson)5 ServerException (com.aliyuncs.fc.exceptions.ServerException)4 FunctionComputeClient (com.aliyuncs.fc.client.FunctionComputeClient)3 PrepareUrl (com.aliyuncs.fc.model.PrepareUrl)3 JsonParseException (com.google.gson.JsonParseException)3 SocketTimeoutException (java.net.SocketTimeoutException)3 InvalidKeyException (java.security.InvalidKeyException)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 HttpResponse (com.aliyuncs.fc.http.HttpResponse)2 CreateServiceRequest (com.aliyuncs.fc.request.CreateServiceRequest)2 GetServiceRequest (com.aliyuncs.fc.request.GetServiceRequest)2 URISyntaxException (java.net.URISyntaxException)2 DefaultAcsClient (com.aliyuncs.DefaultAcsClient)1 IAcsClient (com.aliyuncs.IAcsClient)1 BasicSessionCredentials (com.aliyuncs.auth.BasicSessionCredentials)1 SignURLConfig (com.aliyuncs.fc.auth.SignURLConfig)1 Config (com.aliyuncs.fc.config.Config)1