use of io.crnk.core.engine.dispatcher.RepositoryRequestSpec in project crnk-framework by crnk-project.
the class RepositoryFilterTest method findBulkManyTargetsNoBulkImpl.
@SuppressWarnings({ "unchecked" })
@Test
public void findBulkManyTargetsNoBulkImpl() throws Exception {
projectRelationAdapter.findBulkManyTargets(Arrays.asList(13L, 14L), assignedProjectsField, queryAdapter);
ArgumentCaptor<RepositoryFilterContext> contexts = ArgumentCaptor.forClass(RepositoryFilterContext.class);
Mockito.verify(filter, Mockito.times(2)).filterRequest(contexts.capture(), Mockito.any(RepositoryRequestFilterChain.class));
Mockito.verify(filter, Mockito.times(0)).filterBulkRequest(contexts.capture(), Mockito.any(RepositoryBulkRequestFilterChain.class));
Mockito.verify(filter, Mockito.times(2)).filterResult(Mockito.any(RepositoryFilterContext.class), Mockito.any(RepositoryResultFilterChain.class));
Mockito.verify(filter, Mockito.times(2)).filterLinks(Mockito.any(RepositoryFilterContext.class), Mockito.any(Iterable.class), Mockito.any(RepositoryLinksFilterChain.class));
Mockito.verify(filter, Mockito.times(2)).filterMeta(Mockito.any(RepositoryFilterContext.class), Mockito.any(Iterable.class), Mockito.any(RepositoryMetaFilterChain.class));
Assert.assertEquals(2, contexts.getAllValues().size());
RepositoryFilterContext context1 = contexts.getAllValues().get(0);
RepositoryFilterContext context2 = contexts.getAllValues().get(1);
RepositoryRequestSpec requestSpec1 = context1.getRequest();
RepositoryRequestSpec requestSpec2 = context2.getRequest();
Assert.assertEquals(queryAdapter, requestSpec1.getQueryAdapter());
Assert.assertNull(requestSpec1.getEntity());
Assert.assertEquals("assignedProjects", requestSpec1.getRelationshipField().getUnderlyingName());
Assert.assertEquals(HttpMethod.GET, requestSpec1.getMethod());
Assert.assertEquals(13L, requestSpec1.getId());
Assert.assertEquals(14L, requestSpec2.getId());
Assert.assertSame(querySpec, requestSpec1.getQuerySpec(userInfo));
}
use of io.crnk.core.engine.dispatcher.RepositoryRequestSpec in project crnk-framework by crnk-project.
the class RepositoryFilterTest method findManyTarget.
@SuppressWarnings({ "unchecked" })
@Test
public void findManyTarget() throws Exception {
projectRelationAdapter.findManyTargets(1L, assignedProjectsField, queryAdapter);
ArgumentCaptor<RepositoryFilterContext> contexts = ArgumentCaptor.forClass(RepositoryFilterContext.class);
Mockito.verify(filter, Mockito.times(1)).filterRequest(contexts.capture(), Mockito.any(RepositoryRequestFilterChain.class));
Mockito.verify(filter, Mockito.times(1)).filterResult(Mockito.any(RepositoryFilterContext.class), Mockito.any(RepositoryResultFilterChain.class));
Mockito.verify(filter, Mockito.times(1)).filterLinks(Mockito.any(RepositoryFilterContext.class), Mockito.any(Iterable.class), Mockito.any(RepositoryLinksFilterChain.class));
Mockito.verify(filter, Mockito.times(1)).filterMeta(Mockito.any(RepositoryFilterContext.class), Mockito.any(Iterable.class), Mockito.any(RepositoryMetaFilterChain.class));
Assert.assertEquals(1, contexts.getAllValues().size());
RepositoryFilterContext context = contexts.getAllValues().iterator().next();
RepositoryRequestSpec requestSpec = context.getRequest();
Assert.assertEquals(queryAdapter, requestSpec.getQueryAdapter());
Assert.assertEquals(1L, requestSpec.getId());
Assert.assertEquals("assignedProjects", requestSpec.getRelationshipField().getUnderlyingName());
Assert.assertEquals(HttpMethod.GET, requestSpec.getMethod());
Assert.assertEquals(Arrays.asList(1L), requestSpec.getIds());
Assert.assertSame(querySpec, requestSpec.getQuerySpec(userInfo));
}
use of io.crnk.core.engine.dispatcher.RepositoryRequestSpec in project crnk-framework by crnk-project.
the class RepositoryFilterTest method setRelations.
@SuppressWarnings({ "unchecked" })
@Test
public void setRelations() throws Exception {
projectRelationAdapter.setRelations(user1, Arrays.asList(13L, 14L), assignedProjectsField, queryAdapter);
ArgumentCaptor<RepositoryFilterContext> contexts = ArgumentCaptor.forClass(RepositoryFilterContext.class);
Mockito.verify(filter, Mockito.times(1)).filterRequest(contexts.capture(), Mockito.any(RepositoryRequestFilterChain.class));
Mockito.verify(filter, Mockito.times(0)).filterResult(Mockito.any(RepositoryFilterContext.class), Mockito.any(RepositoryResultFilterChain.class));
Mockito.verify(filter, Mockito.times(0)).filterLinks(Mockito.any(RepositoryFilterContext.class), Mockito.any(Iterable.class), Mockito.any(RepositoryLinksFilterChain.class));
Mockito.verify(filter, Mockito.times(0)).filterMeta(Mockito.any(RepositoryFilterContext.class), Mockito.any(Iterable.class), Mockito.any(RepositoryMetaFilterChain.class));
Assert.assertEquals(1, contexts.getAllValues().size());
RepositoryFilterContext context = contexts.getAllValues().iterator().next();
RepositoryRequestSpec requestSpec = context.getRequest();
Assert.assertEquals(queryAdapter, requestSpec.getQueryAdapter());
Assert.assertEquals(user1, requestSpec.getEntity());
Assert.assertEquals("assignedProjects", requestSpec.getRelationshipField().getUnderlyingName());
Assert.assertEquals(HttpMethod.PATCH, requestSpec.getMethod());
Assert.assertEquals(Arrays.asList(13L, 14L), requestSpec.getIds());
Assert.assertSame(querySpec, requestSpec.getQuerySpec(userInfo));
}
use of io.crnk.core.engine.dispatcher.RepositoryRequestSpec in project crnk-framework by crnk-project.
the class RepositoryFilterTest method setRelation.
@SuppressWarnings({ "unchecked" })
@Test
public void setRelation() throws Exception {
projectRelationAdapter.setRelation(user1, 13L, assignedProjectsField, queryAdapter);
ArgumentCaptor<RepositoryFilterContext> contexts = ArgumentCaptor.forClass(RepositoryFilterContext.class);
Mockito.verify(filter, Mockito.times(1)).filterRequest(contexts.capture(), Mockito.any(RepositoryRequestFilterChain.class));
Mockito.verify(filter, Mockito.times(0)).filterResult(Mockito.any(RepositoryFilterContext.class), Mockito.any(RepositoryResultFilterChain.class));
Mockito.verify(filter, Mockito.times(0)).filterLinks(Mockito.any(RepositoryFilterContext.class), Mockito.any(Iterable.class), Mockito.any(RepositoryLinksFilterChain.class));
Mockito.verify(filter, Mockito.times(0)).filterMeta(Mockito.any(RepositoryFilterContext.class), Mockito.any(Iterable.class), Mockito.any(RepositoryMetaFilterChain.class));
Assert.assertEquals(1, contexts.getAllValues().size());
RepositoryFilterContext context = contexts.getAllValues().iterator().next();
RepositoryRequestSpec requestSpec = context.getRequest();
Assert.assertEquals(queryAdapter, requestSpec.getQueryAdapter());
Assert.assertEquals(13L, requestSpec.getId());
Assert.assertEquals(user1, requestSpec.getEntity());
Assert.assertEquals("assignedProjects", requestSpec.getRelationshipField().getUnderlyingName());
Assert.assertEquals(HttpMethod.PATCH, requestSpec.getMethod());
Assert.assertEquals(Arrays.asList(13L), requestSpec.getIds());
Assert.assertSame(querySpec, requestSpec.getQuerySpec(userInfo));
}
use of io.crnk.core.engine.dispatcher.RepositoryRequestSpec in project crnk-framework by crnk-project.
the class RepositoryFilterTest method delete.
@SuppressWarnings({ "unchecked" })
@Test
public void delete() throws Exception {
resourceAdapter.delete(2L, queryAdapter);
ArgumentCaptor<RepositoryFilterContext> contexts = ArgumentCaptor.forClass(RepositoryFilterContext.class);
Mockito.verify(filter, Mockito.times(1)).filterRequest(contexts.capture(), Mockito.any(RepositoryRequestFilterChain.class));
Mockito.verify(filter, Mockito.times(0)).filterResult(Mockito.any(RepositoryFilterContext.class), Mockito.any(RepositoryResultFilterChain.class));
Mockito.verify(filter, Mockito.times(0)).filterLinks(Mockito.any(RepositoryFilterContext.class), Mockito.any(Iterable.class), Mockito.any(RepositoryLinksFilterChain.class));
Mockito.verify(filter, Mockito.times(0)).filterMeta(Mockito.any(RepositoryFilterContext.class), Mockito.any(Iterable.class), Mockito.any(RepositoryMetaFilterChain.class));
Assert.assertEquals(1, contexts.getAllValues().size());
RepositoryFilterContext context = contexts.getAllValues().iterator().next();
RepositoryRequestSpec requestSpec = context.getRequest();
Assert.assertEquals(queryAdapter, requestSpec.getQueryAdapter());
Assert.assertEquals(2L, requestSpec.getId());
Assert.assertEquals(HttpMethod.DELETE, requestSpec.getMethod());
Assert.assertEquals(Arrays.asList(2L), requestSpec.getIds());
Assert.assertSame(querySpec, requestSpec.getQuerySpec(userInfo));
}
Aggregations