Search in sources :

Example 6 with DocumentFilter

use of io.crnk.core.engine.filter.DocumentFilter in project crnk-framework by crnk-project.

the class ModuleRegistryTest method checkDocumentFilterPriority.

@Test
public void checkDocumentFilterPriority() {
    PrioDocumentFilter filter1 = Mockito.mock(PrioDocumentFilter.class);
    PrioDocumentFilter filter2 = Mockito.mock(PrioDocumentFilter.class);
    Mockito.when(filter1.getPriority()).thenReturn(2);
    Mockito.when(filter2.getPriority()).thenReturn(1);
    ModuleRegistry moduleRegistry = new ModuleRegistry();
    SimpleModule module = new SimpleModule("test");
    module.addFilter(filter1);
    module.addFilter(filter2);
    moduleRegistry.addModule(module);
    moduleRegistry.init(new ObjectMapper());
    List<DocumentFilter> filters = moduleRegistry.getFilters();
    Assert.assertSame(filter2, filters.get(0));
    Assert.assertSame(filter1, filters.get(1));
}
Also used : DocumentFilter(io.crnk.core.engine.filter.DocumentFilter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

DocumentFilter (io.crnk.core.engine.filter.DocumentFilter)6 SimpleModule (io.crnk.core.module.SimpleModule)4 DocumentFilterChain (io.crnk.core.engine.filter.DocumentFilterChain)3 DocumentFilterContext (io.crnk.core.engine.filter.DocumentFilterContext)3 Test (org.junit.Test)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Response (io.crnk.core.engine.dispatcher.Response)1 JsonApiExceptionMapper (io.crnk.core.engine.error.JsonApiExceptionMapper)1 CoreModule (io.crnk.core.engine.internal.CoreModule)1 JsonApiRequestProcessor (io.crnk.core.engine.internal.http.JsonApiRequestProcessor)1 ConstantServiceUrlProvider (io.crnk.core.engine.url.ConstantServiceUrlProvider)1 ServiceUrlProvider (io.crnk.core.engine.url.ServiceUrlProvider)1 Module (io.crnk.core.module.Module)1 ModuleRegistry (io.crnk.core.module.ModuleRegistry)1 ResourceLookup (io.crnk.core.module.discovery.ResourceLookup)1 JsonApiRelationshipRepository (io.crnk.legacy.repository.annotations.JsonApiRelationshipRepository)1 JsonApiResourceRepository (io.crnk.legacy.repository.annotations.JsonApiResourceRepository)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1