Search in sources :

Example 46 with Task

use of io.crnk.test.mock.models.Task in project crnk-framework by crnk-project.

the class ExceptionTest method genericRepo.

@Test
public void genericRepo() {
    Task task = new Task();
    task.setId(10000L);
    task.setName("test");
    try {
        taskRepo.create(task);
        Assert.fail();
    } catch (TestException e) {
        Assert.assertEquals("msg", e.getMessage());
    }
}
Also used : Task(io.crnk.test.mock.models.Task) TestException(io.crnk.test.mock.TestException) Test(org.junit.Test)

Example 47 with Task

use of io.crnk.test.mock.models.Task in project crnk-framework by crnk-project.

the class QueryParamsClientTest method testDelete.

@Test
public void testDelete() {
    Task task = new Task();
    task.setId(1L);
    task.setName("test");
    taskRepo.create(task);
    taskRepo.delete(1L);
    List<Task> tasks = taskRepo.findAll(new QueryParams());
    Assert.assertEquals(0, tasks.size());
}
Also used : Task(io.crnk.test.mock.models.Task) QueryParams(io.crnk.legacy.queryParams.QueryParams) Test(org.junit.Test)

Example 48 with Task

use of io.crnk.test.mock.models.Task in project crnk-framework by crnk-project.

the class QueryParamsClientTest method testSaveAndFind.

@Test
public void testSaveAndFind() {
    Task task = new Task();
    task.setId(1L);
    task.setName("test");
    taskRepo.create(task);
    // check retrievable with findAll
    List<Task> tasks = taskRepo.findAll(new QueryParams());
    Assert.assertEquals(1, tasks.size());
    Task savedTask = tasks.get(0);
    Assert.assertEquals(task.getId(), savedTask.getId());
    Assert.assertEquals(task.getName(), savedTask.getName());
    // check retrievable with findAll(ids)
    tasks = taskRepo.findAll(Arrays.asList(1L), new QueryParams());
    Assert.assertEquals(1, tasks.size());
    savedTask = tasks.get(0);
    Assert.assertEquals(task.getId(), savedTask.getId());
    Assert.assertEquals(task.getName(), savedTask.getName());
    // check retrievable with findOne
    savedTask = taskRepo.findOne(1L, new QueryParams());
    Assert.assertEquals(task.getId(), savedTask.getId());
    Assert.assertEquals(task.getName(), savedTask.getName());
}
Also used : Task(io.crnk.test.mock.models.Task) QueryParams(io.crnk.legacy.queryParams.QueryParams) Test(org.junit.Test)

Example 49 with Task

use of io.crnk.test.mock.models.Task in project crnk-framework by crnk-project.

the class QueryParamsClientTest method testGeneratedId.

@Test
public void testGeneratedId() {
    Task task = new Task();
    task.setId(null);
    task.setName("test");
    Task savedTask = taskRepo.create(task);
    Assert.assertNotNull(savedTask.getId());
}
Also used : Task(io.crnk.test.mock.models.Task) Test(org.junit.Test)

Example 50 with Task

use of io.crnk.test.mock.models.Task in project crnk-framework by crnk-project.

the class QueryParamsClientTest method testFindEmpty.

@Test
public void testFindEmpty() {
    List<Task> tasks = taskRepo.findAll(new QueryParams());
    Assert.assertTrue(tasks.isEmpty());
}
Also used : Task(io.crnk.test.mock.models.Task) QueryParams(io.crnk.legacy.queryParams.QueryParams) Test(org.junit.Test)

Aggregations

Task (io.crnk.test.mock.models.Task)53 Test (org.junit.Test)42 QuerySpec (io.crnk.core.queryspec.QuerySpec)27 Project (io.crnk.test.mock.models.Project)11 Schedule (io.crnk.test.mock.models.Schedule)10 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 QueryParams (io.crnk.legacy.queryParams.QueryParams)6 ObjectProxy (io.crnk.client.internal.proxy.ObjectProxy)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)4 Resource (io.crnk.core.engine.document.Resource)4 ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)4 Span (org.springframework.cloud.sleuth.Span)4 SortSpec (io.crnk.core.queryspec.SortSpec)3 DefaultResourceList (io.crnk.core.resource.list.DefaultResourceList)3 TaskRepository (io.crnk.test.mock.repository.TaskRepository)3 Interceptor (okhttp3.Interceptor)3 Before (org.junit.Before)3 OkHttpAdapter (io.crnk.client.http.okhttp.OkHttpAdapter)2 OkHttpAdapterListener (io.crnk.client.http.okhttp.OkHttpAdapterListener)2 FilterSpec (io.crnk.core.queryspec.FilterSpec)2