Search in sources :

Example 31 with Schedule

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());
}
Also used : ResourceIdentifier(io.crnk.core.engine.document.ResourceIdentifier) Serializable(java.io.Serializable) Schedule(io.crnk.test.mock.models.Schedule) QuerySpec(io.crnk.core.queryspec.QuerySpec) RelationIdTestResource(io.crnk.test.mock.models.RelationIdTestResource) Test(org.junit.Test)

Example 32 with Schedule

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;
}
Also used : Project(io.crnk.test.mock.models.Project) Schedule(io.crnk.test.mock.models.Schedule)

Example 33 with Schedule

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());
    }
}
Also used : TestException(io.crnk.test.mock.TestException) Schedule(io.crnk.test.mock.models.Schedule) ScheduleRepository(io.crnk.test.mock.repository.ScheduleRepository) Test(org.junit.Test)

Example 34 with Schedule

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());
}
Also used : Schedule(io.crnk.test.mock.models.Schedule) QueryParams(io.crnk.legacy.queryParams.QueryParams) Test(org.junit.Test)

Example 35 with Schedule

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());
}
Also used : Task(io.crnk.test.mock.models.Task) Schedule(io.crnk.test.mock.models.Schedule) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Aggregations

Schedule (io.crnk.test.mock.models.Schedule)37 Test (org.junit.Test)24 QuerySpec (io.crnk.core.queryspec.QuerySpec)21 Task (io.crnk.test.mock.models.Task)10 ScheduleRepository (io.crnk.test.mock.repository.ScheduleRepository)5 AbstractClientTest (io.crnk.client.AbstractClientTest)4 ObjectProxy (io.crnk.client.internal.proxy.ObjectProxy)4 Project (io.crnk.test.mock.models.Project)3 DocumentFilterChain (io.crnk.core.engine.filter.DocumentFilterChain)2 DocumentFilterContext (io.crnk.core.engine.filter.DocumentFilterContext)2 ActionPath (io.crnk.core.engine.internal.dispatcher.path.ActionPath)2 ScheduleList (io.crnk.test.mock.repository.ScheduleRepository.ScheduleList)2 ScheduleListLinks (io.crnk.test.mock.repository.ScheduleRepository.ScheduleListLinks)2 ScheduleListMeta (io.crnk.test.mock.repository.ScheduleRepository.ScheduleListMeta)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ApprovalManager (io.crnk.activiti.example.approval.ApprovalManager)1 ApprovalMapper (io.crnk.activiti.example.approval.ApprovalMapper)1 ApprovalRelationshipRepository (io.crnk.activiti.example.approval.ApprovalRelationshipRepository)1 ApproveTask (io.crnk.activiti.example.model.ApproveTask)1