Search in sources :

Example 1 with Schedule

use of io.crnk.core.mock.models.Schedule in project crnk-framework by crnk-project.

the class ImplicitOwnerBasedRelationshipRepositoryTest method setup.

@Before
public void setup() {
    MockRepositoryUtil.clear();
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider(ResourceRegistryTest.TEST_MODELS_URL));
    boot.boot();
    resourceRegistry = boot.getResourceRegistry();
    RegistryEntry entry = resourceRegistry.getEntry(RelationIdTestResource.class);
    relRepository = new ImplicitOwnerBasedRelationshipRepository(RelationIdTestResource.class, Schedule.class);
    relRepository.setResourceRegistry(resourceRegistry);
    taskProjectRepository = new ImplicitOwnerBasedRelationshipRepository(Task.class, Project.class);
    taskProjectRepository.setResourceRegistry(resourceRegistry);
    testRepository = (RelationIdTestRepository) entry.getResourceRepository().getResourceRepository();
    testRepository.setResourceRegistry(resourceRegistry);
    resource = new RelationIdTestResource();
    resource.setId(2L);
    resource.setName("relationId");
    testRepository.create(resource);
    scheduleRepository = new ScheduleRepositoryImpl();
    schedule3 = new Schedule();
    schedule3.setId(3L);
    schedule3.setName("schedule");
    scheduleRepository.create(schedule3);
    for (int i = 0; i < 10; i++) {
        schedule = new Schedule();
        schedule.setId(4L + i);
        schedule.setName("schedule");
        scheduleRepository.create(schedule);
        projectRepository = new ProjectRepository();
        project = new Project();
        project.setId(42L + i);
        project.setName("project");
        projectRepository.save(project);
        taskRepository = new TaskRepository();
        task = new Task();
        task.setId(13L + i);
        task.setName("task");
        taskRepository.save(task);
    }
}
Also used : Task(io.crnk.core.mock.models.Task) ProjectRepository(io.crnk.core.mock.repository.ProjectRepository) TaskRepository(io.crnk.core.mock.repository.TaskRepository) RegistryEntry(io.crnk.core.engine.registry.RegistryEntry) ScheduleRepositoryImpl(io.crnk.core.mock.repository.ScheduleRepositoryImpl) Project(io.crnk.core.mock.models.Project) CrnkBoot(io.crnk.core.boot.CrnkBoot) ImplicitOwnerBasedRelationshipRepository(io.crnk.core.repository.implicit.ImplicitOwnerBasedRelationshipRepository) Schedule(io.crnk.core.mock.models.Schedule) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) RelationIdTestResource(io.crnk.core.mock.models.RelationIdTestResource) Before(org.junit.Before)

Example 2 with Schedule

use of io.crnk.core.mock.models.Schedule in project crnk-framework by crnk-project.

the class DecoratorTest method testRelationshipRegistryAwareDecoration.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testRelationshipRegistryAwareDecoration() {
    RegistryAwareRelationshipRepository repository = Mockito.mock(RegistryAwareRelationshipRepository.class);
    RelationshipRepositoryDecoratorBase<Schedule, Long, Task, Long> decorator = new RelationshipRepositoryDecoratorBase() {
    };
    decorator.setDecoratedObject(repository);
    ResourceRegistry resourceRegistry = Mockito.mock(ResourceRegistry.class);
    decorator.setResourceRegistry(resourceRegistry);
    Mockito.verify(repository, Mockito.times(1)).setResourceRegistry(Mockito.eq(resourceRegistry));
}
Also used : Task(io.crnk.core.mock.models.Task) RelationshipRepositoryDecoratorBase(io.crnk.core.repository.decorate.RelationshipRepositoryDecoratorBase) Schedule(io.crnk.core.mock.models.Schedule) ResourceRegistry(io.crnk.core.engine.registry.ResourceRegistry) Test(org.junit.Test)

Example 3 with Schedule

use of io.crnk.core.mock.models.Schedule in project crnk-framework by crnk-project.

the class DecoratorTest method testResourceRegistryAwareDecoration.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Test
public void testResourceRegistryAwareDecoration() {
    RegistryAwareResourceRepository repository = Mockito.mock(RegistryAwareResourceRepository.class);
    ResourceRepositoryDecoratorBase<Schedule, Long> decorator = new ResourceRepositoryDecoratorBase() {
    };
    decorator.setDecoratedObject(repository);
    ResourceRegistry resourceRegistry = Mockito.mock(ResourceRegistry.class);
    decorator.setResourceRegistry(resourceRegistry);
    Mockito.verify(repository, Mockito.times(1)).setResourceRegistry(Mockito.eq(resourceRegistry));
}
Also used : Schedule(io.crnk.core.mock.models.Schedule) ResourceRepositoryDecoratorBase(io.crnk.core.repository.decorate.ResourceRepositoryDecoratorBase) ResourceRegistry(io.crnk.core.engine.registry.ResourceRegistry) Test(org.junit.Test)

Example 4 with Schedule

use of io.crnk.core.mock.models.Schedule in project crnk-framework by crnk-project.

the class OwnerFowardingRelationshipRepositoryTest method checkSetRelationIds.

@Test
public void checkSetRelationIds() {
    relRepository.setRelations(resource, Arrays.asList(3L, 4L), "testMultipleValues");
    Assert.assertEquals(Arrays.asList(3L, 4L), resource.getTestMultipleValueIds());
    List<Schedule> targets = relRepository.findManyTargets(resource.getId(), "testMultipleValues", new QuerySpec(Schedule.class));
    Assert.assertEquals(2, targets.size());
    Assert.assertSame(schedule3, targets.get(0));
    Assert.assertSame(4L, targets.get(1).getId().longValue());
    MultivaluedMap targetsMap = relRepository.findTargets(Arrays.asList(resource.getId()), "testMultipleValues", new QuerySpec(Schedule.class));
    Assert.assertEquals(1, targetsMap.keySet().size());
    targets = targetsMap.getList(resource.getId());
    Assert.assertEquals(2, targets.size());
    Assert.assertSame(3L, targets.get(0).getId().longValue());
    Assert.assertSame(4L, targets.get(1).getId().longValue());
}
Also used : Schedule(io.crnk.core.mock.models.Schedule) QuerySpec(io.crnk.core.queryspec.QuerySpec) MultivaluedMap(io.crnk.core.engine.internal.utils.MultivaluedMap) ResourceRegistryTest(io.crnk.core.resource.registry.ResourceRegistryTest) Test(org.junit.Test)

Example 5 with Schedule

use of io.crnk.core.mock.models.Schedule in project crnk-framework by crnk-project.

the class ResourceIdControllerTest method prepare.

@Before
public void prepare() {
    super.prepare();
    ScheduleRepositoryImpl scheduleRepository = new ScheduleRepositoryImpl();
    schedule2 = new Schedule();
    schedule2.setId(2L);
    schedule2.setName("test");
    scheduleRepository.save(schedule2);
    schedule2Id = new ResourceIdentifier(schedule2.getId().toString(), "schedules");
    schedule3 = new Schedule();
    schedule3.setId(3L);
    schedule3.setName("test");
    scheduleRepository.save(schedule3);
    schedule3Id = new ResourceIdentifier(schedule3.getId().toString(), "schedules");
    repository = new RelationIdTestRepository();
    repository.setResourceRegistry(resourceRegistry);
}
Also used : ScheduleRepositoryImpl(io.crnk.core.mock.repository.ScheduleRepositoryImpl) RelationIdTestRepository(io.crnk.core.mock.repository.RelationIdTestRepository) ResourceIdentifier(io.crnk.core.engine.document.ResourceIdentifier) Schedule(io.crnk.core.mock.models.Schedule) Before(org.junit.Before)

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