Search in sources :

Example 1 with ApplicationNameWithInvalidCharactersException

use of org.wso2.carbon.apimgt.api.ApplicationNameWithInvalidCharactersException in project carbon-apimgt by wso2.

the class RestApiUtilTest method testisDueToApplicationNameWhiteSpaceValidationWithInvalidException.

@Test
public void testisDueToApplicationNameWhiteSpaceValidationWithInvalidException() throws Exception {
    ApplicationNameWithInvalidCharactersException applicationNameWithInvalidCharactersException = new ApplicationNameWithInvalidCharactersException("New Sample exception");
    Throwable testThrowable = new Throwable();
    PowerMockito.spy(RestApiUtil.class);
    PowerMockito.doReturn(applicationNameWithInvalidCharactersException).when(RestApiUtil.class, "getPossibleErrorCause", testThrowable);
    Assert.assertFalse("Invalid exception has been passed.", RestApiUtil.isDueToApplicationNameWhiteSpaceValidation(testThrowable));
}
Also used : ApplicationNameWithInvalidCharactersException(org.wso2.carbon.apimgt.api.ApplicationNameWithInvalidCharactersException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with ApplicationNameWithInvalidCharactersException

use of org.wso2.carbon.apimgt.api.ApplicationNameWithInvalidCharactersException in project carbon-apimgt by wso2.

the class RestApiUtilTest method testisDueToApplicationNameWithInvalidCharacters.

@Test
public void testisDueToApplicationNameWithInvalidCharacters() throws Exception {
    ApplicationNameWithInvalidCharactersException applicationNameWithInvalidCharactersException = new ApplicationNameWithInvalidCharactersException("New Sample exception");
    Throwable testThrowable = new Throwable();
    PowerMockito.spy(RestApiUtil.class);
    PowerMockito.doReturn(applicationNameWithInvalidCharactersException).when(RestApiUtil.class, "getPossibleErrorCause", testThrowable);
    Assert.assertTrue("Invalid exception has been passed.", RestApiUtil.isDueToApplicationNameWithInvalidCharacters(testThrowable));
}
Also used : ApplicationNameWithInvalidCharactersException(org.wso2.carbon.apimgt.api.ApplicationNameWithInvalidCharactersException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2 ApplicationNameWithInvalidCharactersException (org.wso2.carbon.apimgt.api.ApplicationNameWithInvalidCharactersException)2