Search in sources :

Example 11 with ResourceFilter

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

the class ResourceFilterDirectoryImplTest method checkMergeFieldFilterWithIgnoredNone.

@Test
public void checkMergeFieldFilterWithIgnoredNone() {
    ResourceFilter filter2 = Mockito.mock(ResourceFilter.class);
    filters.add(filter2);
    setFieldBehavior(HttpMethod.GET, FilterBehavior.IGNORED);
    Mockito.when(filter2.filterField(Mockito.eq(resourceField), Mockito.eq(HttpMethod.GET))).thenReturn(FilterBehavior.NONE);
    Assert.assertEquals(FilterBehavior.IGNORED, directory.get(resourceField, HttpMethod.GET));
    Mockito.verify(filter, Mockito.times(1)).filterField(Mockito.eq(resourceField), Mockito.any(HttpMethod.class));
    Mockito.verify(filter2, Mockito.times(1)).filterField(Mockito.eq(resourceField), Mockito.any(HttpMethod.class));
}
Also used : ResourceFilter(io.crnk.core.engine.filter.ResourceFilter) HttpMethod(io.crnk.core.engine.http.HttpMethod) Test(org.junit.Test)

Example 12 with ResourceFilter

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

the class ResourceFilterDirectoryImplTest method checkMergeResourceFilterWithNoneNone.

@Test
public void checkMergeResourceFilterWithNoneNone() {
    ResourceFilter filter2 = Mockito.mock(ResourceFilter.class);
    filters.add(filter2);
    setResourceBehavior(HttpMethod.GET, FilterBehavior.NONE);
    Mockito.when(filter2.filterResource(Mockito.eq(resourceInformation), Mockito.eq(HttpMethod.GET))).thenReturn(FilterBehavior.NONE);
    Assert.assertEquals(FilterBehavior.NONE, directory.get(resourceInformation, HttpMethod.GET));
    Mockito.verify(filter, Mockito.times(1)).filterResource(Mockito.eq(resourceInformation), Mockito.any(HttpMethod.class));
    Mockito.verify(filter2, Mockito.times(1)).filterResource(Mockito.eq(resourceInformation), Mockito.any(HttpMethod.class));
}
Also used : ResourceFilter(io.crnk.core.engine.filter.ResourceFilter) HttpMethod(io.crnk.core.engine.http.HttpMethod) Test(org.junit.Test)

Aggregations

ResourceFilter (io.crnk.core.engine.filter.ResourceFilter)12 HttpMethod (io.crnk.core.engine.http.HttpMethod)10 Test (org.junit.Test)10 FilterBehavior (io.crnk.core.engine.filter.FilterBehavior)2 ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)1 RegistryEntry (io.crnk.core.engine.registry.RegistryEntry)1