use of io.crnk.core.mock.models.Schedule in project crnk-framework by crnk-project.
the class RepositoryFilterTest method findAllWithResourceListResult.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void findAllWithResourceListResult() throws Exception {
RegistryEntry scheduleRegistry = resourceRegistry.getEntry(Schedule.class);
ResourceRepositoryAdapter<Schedule, Serializable> scheduleResourceAdapter = scheduleRegistry.getResourceRepository(null);
querySpec = new QuerySpec(Schedule.class);
querySpec.setPagingSpec(new OffsetLimitPagingSpec());
queryAdapter = new QuerySpecAdapter(querySpec, resourceRegistry);
scheduleResourceAdapter.findAll(queryAdapter);
ArgumentCaptor<Iterable> linksResources = ArgumentCaptor.forClass(Iterable.class);
ArgumentCaptor<Iterable> metaResources = ArgumentCaptor.forClass(Iterable.class);
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), linksResources.capture(), Mockito.any(RepositoryLinksFilterChain.class));
Mockito.verify(filter, Mockito.times(1)).filterMeta(Mockito.any(RepositoryFilterContext.class), metaResources.capture(), Mockito.any(RepositoryMetaFilterChain.class));
Assert.assertEquals(1, linksResources.getAllValues().size());
Assert.assertEquals(1, metaResources.getAllValues().size());
Assert.assertEquals(1, contexts.getAllValues().size());
RepositoryFilterContext context = contexts.getAllValues().iterator().next();
RepositoryRequestSpec requestSpec = context.getRequest();
Assert.assertEquals(queryAdapter, requestSpec.getQueryAdapter());
Assert.assertNull(requestSpec.getId());
Assert.assertNull(requestSpec.getIds());
QuerySpec actualQuerySpec = requestSpec.getQuerySpec(scheduleInfo);
Assert.assertSame(querySpec, actualQuerySpec);
}
use of io.crnk.core.mock.models.Schedule in project crnk-framework by crnk-project.
the class LookupNoneRelationIdLookupTest method setup.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Before
public void setup() {
super.setup();
scheduleRepository = new ScheduleRepositoryImpl();
schedule = new Schedule();
schedule.setId(3L);
schedule.setName("test");
scheduleRepository.save(schedule);
}
use of io.crnk.core.mock.models.Schedule in project crnk-framework by crnk-project.
the class ResourceIdBasedRelationIdLookupTest method setup.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Before
public void setup() {
super.setup();
scheduleRepository = new ScheduleRepositoryImpl();
schedule = new Schedule();
schedule.setId(3L);
schedule.setName("test");
scheduleRepository.save(schedule);
}
use of io.crnk.core.mock.models.Schedule in project crnk-framework by crnk-project.
the class DecoratorTest method testDecoratedResourceRepositoryBase.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testDecoratedResourceRepositoryBase() {
ScheduleRepository repository = Mockito.mock(ScheduleRepository.class);
ResourceRepositoryDecoratorBase<Schedule, Long> decorator = new ResourceRepositoryDecoratorBase() {
};
decorator.setDecoratedObject(repository);
decorator.create(null);
Mockito.verify(repository, Mockito.times(1)).create(Mockito.any(Schedule.class));
decorator.delete(null);
Mockito.verify(repository, Mockito.times(1)).delete(Mockito.anyLong());
decorator.findAll(null);
Mockito.verify(repository, Mockito.times(1)).findAll(Mockito.any(QuerySpec.class));
decorator.findAll(null, null);
Mockito.verify(repository, Mockito.times(1)).findAll(Mockito.anyListOf(Long.class), Mockito.any(QuerySpec.class));
decorator.getResourceClass();
Mockito.verify(repository, Mockito.times(1)).getResourceClass();
Schedule schedule = Mockito.mock(Schedule.class);
decorator.save(schedule);
Mockito.verify(repository, Mockito.times(1)).save(Mockito.eq(schedule));
decorator.findOne(null, null);
Mockito.verify(repository, Mockito.times(1)).findOne(Mockito.anyLong(), Mockito.any(QuerySpec.class));
}
Aggregations