Search in sources :

Example 1 with ScheduleRepository

use of io.crnk.test.mock.repository.ScheduleRepository in project crnk-framework by crnk-project.

the class QuerySpecClientTest method testInterfaceAccess.

@Test
public void testInterfaceAccess() {
    // tag::interfaceAccess[]
    ScheduleRepository scheduleRepository = client.getResourceRepository(ScheduleRepository.class);
    Schedule schedule = new Schedule();
    schedule.setId(13L);
    schedule.setName("mySchedule");
    scheduleRepository.create(schedule);
    QuerySpec querySpec = new QuerySpec(Schedule.class);
    ScheduleList list = scheduleRepository.findAll(querySpec);
    Assert.assertEquals(1, list.size());
    ScheduleListMeta meta = list.getMeta();
    ScheduleListLinks links = list.getLinks();
    Assert.assertNotNull(meta);
    Assert.assertNotNull(links);
// end::interfaceAccess[]
}
Also used : Schedule(io.crnk.test.mock.models.Schedule) ScheduleRepository(io.crnk.test.mock.repository.ScheduleRepository) ScheduleListMeta(io.crnk.test.mock.repository.ScheduleRepository.ScheduleListMeta) ScheduleList(io.crnk.test.mock.repository.ScheduleRepository.ScheduleList) ScheduleListLinks(io.crnk.test.mock.repository.ScheduleRepository.ScheduleListLinks) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Example 2 with ScheduleRepository

use of io.crnk.test.mock.repository.ScheduleRepository in project crnk-framework by crnk-project.

the class RestTemplateClientTest method testCreate.

@Test
public void testCreate() {
    ScheduleRepository scheduleRepository = client.getRepositoryForInterface(ScheduleRepository.class);
    Schedule schedule = new Schedule();
    schedule.setName("mySchedule");
    scheduleRepository.create(schedule);
    QuerySpec querySpec = new QuerySpec(Schedule.class);
    ScheduleRepository.ScheduleList list = scheduleRepository.findAll(querySpec);
    Assert.assertEquals(1, list.size());
    schedule = list.get(0);
    Assert.assertNotNull(schedule.getId());
    ScheduleRepository.ScheduleListMeta meta = list.getMeta();
    ScheduleRepository.ScheduleListLinks links = list.getLinks();
    Assert.assertNotNull(meta);
    Assert.assertNotNull(links);
}
Also used : Schedule(io.crnk.test.mock.models.Schedule) ScheduleRepository(io.crnk.test.mock.repository.ScheduleRepository) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with ScheduleRepository

use of io.crnk.test.mock.repository.ScheduleRepository in project crnk-framework by crnk-project.

the class QuerySpecClientTest method testCreate.

@Test
public void testCreate() {
    ScheduleRepository scheduleRepository = client.getResourceRepository(ScheduleRepository.class);
    Schedule schedule = new Schedule();
    schedule.setName("mySchedule");
    scheduleRepository.create(schedule);
    QuerySpec querySpec = new QuerySpec(Schedule.class);
    ScheduleList list = scheduleRepository.findAll(querySpec);
    Assert.assertEquals(1, list.size());
    schedule = list.get(0);
    Assert.assertNotNull(schedule.getId());
    ScheduleListMeta meta = list.getMeta();
    ScheduleListLinks links = list.getLinks();
    Assert.assertNotNull(meta);
    Assert.assertNotNull(links);
}
Also used : Schedule(io.crnk.test.mock.models.Schedule) ScheduleRepository(io.crnk.test.mock.repository.ScheduleRepository) ScheduleListMeta(io.crnk.test.mock.repository.ScheduleRepository.ScheduleListMeta) ScheduleList(io.crnk.test.mock.repository.ScheduleRepository.ScheduleList) ScheduleListLinks(io.crnk.test.mock.repository.ScheduleRepository.ScheduleListLinks) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Example 4 with ScheduleRepository

use of io.crnk.test.mock.repository.ScheduleRepository 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)

Aggregations

Schedule (io.crnk.test.mock.models.Schedule)4 ScheduleRepository (io.crnk.test.mock.repository.ScheduleRepository)4 Test (org.junit.Test)4 QuerySpec (io.crnk.core.queryspec.QuerySpec)3 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 TestException (io.crnk.test.mock.TestException)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1