use of io.crnk.core.mock.models.Schedule in project crnk-framework by crnk-project.
the class SerializeEagerRelationIdLookupTest 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 OwnerFowardingRelationshipRepositoryTest 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 = (ForwardingRelationshipRepository) entry.getRelationshipRepository("testSerializeEager", null).getRelationshipRepository();
RelationshipMatcher taskProjectMatcher = new RelationshipMatcher().rule().source(Task.class).target(Project.class).add();
taskProjectRepository = new ForwardingRelationshipRepository(Task.class, taskProjectMatcher, ForwardingDirection.OWNER, ForwardingDirection.OWNER);
taskProjectRepository.setResourceRegistry(resourceRegistry);
projectTaskRepository = new ForwardingRelationshipRepository(Project.class, taskProjectMatcher, ForwardingDirection.OWNER, ForwardingDirection.OWNER);
projectTaskRepository.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);
}
}
use of io.crnk.core.mock.models.Schedule in project crnk-framework by crnk-project.
the class JsonApiRelationIdInformationProviderTest method shouldAutoDetectWithDefaultName.
@Test
public void shouldAutoDetectWithDefaultName() {
ResourceInformation resourceInformation = resourceInformationProvider.build(Schedule.class);
ResourceField field = resourceInformation.findFieldByName("project");
Assert.assertNotNull(field);
Assert.assertNull(resourceInformation.findFieldByName("projectId"));
Assert.assertTrue(field.hasIdField());
Schedule schedule = new Schedule();
Assert.assertNull(field.getIdAccessor().getValue(schedule));
field.getIdAccessor().setValue(schedule, 13L);
Assert.assertEquals(13L, schedule.getProjectId().longValue());
Assert.assertEquals(13L, field.getIdAccessor().getValue(schedule));
}
use of io.crnk.core.mock.models.Schedule in project crnk-framework by crnk-project.
the class ImplicitOwnerBasedRelationshipRepositoryTest 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());
}
use of io.crnk.core.mock.models.Schedule in project crnk-framework by crnk-project.
the class NestedRelationIdLookupTest 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);
testRepository = new RelationIdTestRepository();
child = new RelationIdTestResource();
child.setId(1L);
child.setName("child");
testRepository.save(child);
child.setTestSerializeEager(schedule);
}
Aggregations