Search in sources :

Example 16 with Schedule

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);
}
Also used : Serializable(java.io.Serializable) RepositoryRequestSpec(io.crnk.core.engine.dispatcher.RepositoryRequestSpec) OffsetLimitPagingSpec(io.crnk.core.queryspec.pagingspec.OffsetLimitPagingSpec) QuerySpecAdapter(io.crnk.core.queryspec.internal.QuerySpecAdapter) RegistryEntry(io.crnk.core.engine.registry.RegistryEntry) Schedule(io.crnk.core.mock.models.Schedule) QuerySpec(io.crnk.core.queryspec.QuerySpec) ResourceRegistryTest(io.crnk.core.resource.registry.ResourceRegistryTest) Test(org.junit.Test)

Example 17 with Schedule

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);
}
Also used : ScheduleRepositoryImpl(io.crnk.core.mock.repository.ScheduleRepositoryImpl) Schedule(io.crnk.core.mock.models.Schedule) Before(org.junit.Before)

Example 18 with 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);
}
Also used : ScheduleRepositoryImpl(io.crnk.core.mock.repository.ScheduleRepositoryImpl) Schedule(io.crnk.core.mock.models.Schedule) Before(org.junit.Before)

Example 19 with 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));
}
Also used : Schedule(io.crnk.core.mock.models.Schedule) ScheduleRepository(io.crnk.core.mock.repository.ScheduleRepository) ResourceRepositoryDecoratorBase(io.crnk.core.repository.decorate.ResourceRepositoryDecoratorBase) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Aggregations

Schedule (io.crnk.core.mock.models.Schedule)19 ScheduleRepositoryImpl (io.crnk.core.mock.repository.ScheduleRepositoryImpl)12 Before (org.junit.Before)12 Test (org.junit.Test)7 QuerySpec (io.crnk.core.queryspec.QuerySpec)4 RegistryEntry (io.crnk.core.engine.registry.RegistryEntry)3 RelationIdTestResource (io.crnk.core.mock.models.RelationIdTestResource)3 Task (io.crnk.core.mock.models.Task)3 ResourceRegistryTest (io.crnk.core.resource.registry.ResourceRegistryTest)3 CrnkBoot (io.crnk.core.boot.CrnkBoot)2 MultivaluedMap (io.crnk.core.engine.internal.utils.MultivaluedMap)2 ResourceRegistry (io.crnk.core.engine.registry.ResourceRegistry)2 ConstantServiceUrlProvider (io.crnk.core.engine.url.ConstantServiceUrlProvider)2 Project (io.crnk.core.mock.models.Project)2 ProjectRepository (io.crnk.core.mock.repository.ProjectRepository)2 RelationIdTestRepository (io.crnk.core.mock.repository.RelationIdTestRepository)2 TaskRepository (io.crnk.core.mock.repository.TaskRepository)2 ReflectionsServiceDiscovery (io.crnk.core.module.discovery.ReflectionsServiceDiscovery)2 ResourceRepositoryDecoratorBase (io.crnk.core.repository.decorate.ResourceRepositoryDecoratorBase)2 RepositoryRequestSpec (io.crnk.core.engine.dispatcher.RepositoryRequestSpec)1