Search in sources :

Example 1 with OperationFilter

use of io.crnk.operations.server.OperationFilter in project crnk-framework by crnk-project.

the class OperationsExceptionTest method testUnknownErrorTriggerInternalError.

@Test
public void testUnknownErrorTriggerInternalError() {
    operationsModule.addFilter(new OperationFilter() {

        @Override
        public List<OperationResponse> filter(OperationFilterContext context, OperationFilterChain chain) {
            throw new IllegalStateException("test");
        }
    });
    MovieEntity movie1 = newMovie("1");
    MovieEntity movie2 = newMovie("2");
    OperationsCall insertCall = operationsClient.createCall();
    insertCall.add(HttpMethod.POST, movie1);
    insertCall.add(HttpMethod.POST, movie2);
    try {
        insertCall.execute();
        Assert.fail();
    } catch (InternalServerErrorException e) {
    // ok
    }
}
Also used : MovieEntity(io.crnk.operations.model.MovieEntity) OperationFilterContext(io.crnk.operations.server.OperationFilterContext) OperationFilter(io.crnk.operations.server.OperationFilter) OperationFilterChain(io.crnk.operations.server.OperationFilterChain) InternalServerErrorException(io.crnk.core.exception.InternalServerErrorException) List(java.util.List) OperationsCall(io.crnk.operations.client.OperationsCall) Test(org.junit.Test)

Example 2 with OperationFilter

use of io.crnk.operations.server.OperationFilter in project crnk-framework by crnk-project.

the class OperationsModuleTest method testRemoveFilter.

@Test
public void testRemoveFilter() {
    OperationFilter filter = Mockito.mock(OperationFilter.class);
    module.addFilter(filter);
    Assert.assertEquals(1, module.getFilters().size());
    module.removeFilter(filter);
    Assert.assertEquals(0, module.getFilters().size());
}
Also used : OperationFilter(io.crnk.operations.server.OperationFilter) Test(org.junit.Test)

Aggregations

OperationFilter (io.crnk.operations.server.OperationFilter)2 Test (org.junit.Test)2 InternalServerErrorException (io.crnk.core.exception.InternalServerErrorException)1 OperationsCall (io.crnk.operations.client.OperationsCall)1 MovieEntity (io.crnk.operations.model.MovieEntity)1 OperationFilterChain (io.crnk.operations.server.OperationFilterChain)1 OperationFilterContext (io.crnk.operations.server.OperationFilterContext)1 List (java.util.List)1