use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.
the class RelationIdClientTest method checkResourceIdentifierField.
@Test
public void checkResourceIdentifierField() {
Schedule schedule = new Schedule();
schedule.setId(13L);
schedule.setName("mySchedule");
Schedule savedSchedule = scheduleRepo.create(schedule);
RelationIdTestResource resource = new RelationIdTestResource();
resource.setId(14L);
resource.setName("test");
resource.setTestResourceIdRefId(new ResourceIdentifier("13", "schedules"));
ResourceRepositoryV2<RelationIdTestResource, Serializable> repository = client.getRepositoryForType(RelationIdTestResource.class);
RelationIdTestResource createdResource = repository.create(resource);
Assert.assertEquals(resource.getTestResourceIdRefId(), createdResource.getTestResourceIdRefId());
RelationIdTestResource serverResource = RelationIdTestRepository.resources.get(14L);
Assert.assertEquals(resource.getTestResourceIdRefId(), serverResource.getTestResourceIdRefId());
QuerySpec querySpec = new QuerySpec(RelationIdTestResource.class);
RelationIdTestResource getResource = repository.findOne(14L, querySpec);
Assert.assertNull(getResource.getTestResourceIdRefId());
Assert.assertNull(createdResource.getTestResourceIdRef());
querySpec = new QuerySpec(RelationIdTestResource.class);
querySpec.includeRelation(Arrays.asList("testResourceIdRef"));
getResource = repository.findOne(14L, querySpec);
Assert.assertEquals(resource.getTestResourceIdRefId(), getResource.getTestResourceIdRefId());
Assert.assertNotNull(getResource.getTestResourceIdRef());
}
use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.
the class RelationIdClientTest method checkPatch.
private Schedule checkPatch(Schedule schedule) {
project2 = new Project();
project2.setName("myProject2");
project2 = projectRepo.create(project2);
schedule.setProjectId(project2.getId());
schedule.setProjectIds(Arrays.asList(project.getId(), project2.getId()));
Schedule savedSchedule = scheduleRepo.save(schedule);
Schedule serverSchedule = ScheduleRepositoryImpl.schedules.get(1L);
Assert.assertEquals(project2.getId(), serverSchedule.getProjectId());
Assert.assertEquals(2, serverSchedule.getProjectIds().size());
Assert.assertEquals(project.getId(), serverSchedule.getProjectIds().get(0));
Assert.assertEquals(project2.getId(), serverSchedule.getProjectIds().get(1));
Assert.assertNull(serverSchedule.getProject());
Assert.assertNotSame(schedule, savedSchedule);
Assert.assertEquals(project2.getId(), savedSchedule.getProjectId());
Assert.assertEquals(2, savedSchedule.getProjectIds().size());
return savedSchedule;
}
use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.
the class ExceptionTest method repoWithProxyAndInterface.
@Test
public void repoWithProxyAndInterface() {
ScheduleRepository repo = client.getRepositoryForInterface(ScheduleRepository.class);
Schedule schedule = new Schedule();
schedule.setId(10000L);
schedule.setName("test");
try {
repo.create(schedule);
Assert.fail();
} catch (TestException e) {
Assert.assertEquals("msg", e.getMessage());
}
}
use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.
the class QueryParamsClientTest method testAccessQuerySpecRepository.
@Test
public void testAccessQuerySpecRepository() {
List<Schedule> schedule = scheduleRepo.findAll(new QueryParams());
Assert.assertTrue(schedule.isEmpty());
}
use of io.crnk.test.mock.models.Schedule in project crnk-framework by crnk-project.
the class AbstractProxiedObjectsClientTest method proxyForNoneLazy.
@Test
public void proxyForNoneLazy() {
Schedule schedule = new Schedule();
schedule.setId(1L);
schedule.setName("project");
scheduleRepo.create(schedule);
Task task = new Task();
task.setId(2L);
task.setName("test");
taskRepo.create(task);
scheduleTaskRepo.setRelation(schedule, task.getId(), "task");
QuerySpec querySpec = new QuerySpec(Task.class);
schedule = scheduleRepo.findOne(1L, querySpec);
Task proxiedObject = schedule.getTask();
Assert.assertNotNull(proxiedObject);
Assert.assertEquals(2L, proxiedObject.getId().longValue());
Assert.assertNull(proxiedObject.getName());
}
Aggregations