Search in sources :

Example 1 with ApplicationNameWhiteSpaceValidationException

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

the class RestApiUtilTest method testisDueToApplicationNameWhiteSpaceValidation.

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

Example 2 with ApplicationNameWhiteSpaceValidationException

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

the class RestApiUtilTest method testisDueToApplicationNameWithInvalidCharactersWithInvalidException.

@Test
public void testisDueToApplicationNameWithInvalidCharactersWithInvalidException() throws Exception {
    ApplicationNameWhiteSpaceValidationException applicationNameWhiteSpaceValidationException = new ApplicationNameWhiteSpaceValidationException("New Sample exception");
    Throwable testThrowable = new Throwable();
    PowerMockito.spy(RestApiUtil.class);
    PowerMockito.doReturn(applicationNameWhiteSpaceValidationException).when(RestApiUtil.class, "getPossibleErrorCause", testThrowable);
    Assert.assertFalse("Invalid exception has been passed.", RestApiUtil.isDueToApplicationNameWithInvalidCharacters(testThrowable));
}
Also used : ApplicationNameWhiteSpaceValidationException(org.wso2.carbon.apimgt.api.ApplicationNameWhiteSpaceValidationException) 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 ApplicationNameWhiteSpaceValidationException (org.wso2.carbon.apimgt.api.ApplicationNameWhiteSpaceValidationException)2