Search in sources :

Example 26 with Task

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

the class UriInfoServiceUrlProviderTest method setup.

@Before
public void setup() {
    TaskRepository repo = new TaskRepository();
    Task task = new Task();
    task.setName("test");
    task.setId(1L);
    repo.save(task);
}
Also used : Task(io.crnk.test.mock.models.Task) TaskRepository(io.crnk.test.mock.repository.TaskRepository) Before(org.junit.Before)

Example 27 with Task

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

the class SleuthModuleTest method testFindTargets.

@Test
public void testFindTargets() {
    RelationshipRepositoryV2<Project, Serializable, Task, Serializable> relRepo = client.getQuerySpecRepository(Project.class, Task.class);
    relRepo.findManyTargets(123L, "tasks", new QuerySpec(Task.class));
    // check client call and link span
    ArgumentCaptor<Span> clientSpanCaptor = ArgumentCaptor.forClass(Span.class);
    List<Span> clientSpans = clientSpanCaptor.getAllValues();
    Span callSpan = clientSpans.get(0);
    Assert.assertEquals("get", callSpan.getName());
    Assert.assertTrue(callSpan.toString().contains("\"cs\""));
    Assert.assertTrue(callSpan.toString().contains("\"cr\""));
    // check server local span
    Assert.assertEquals(2, reportedSpans.spans.size());
    Span repositorySpan0 = reportedSpans.spans.get(0);
    Assert.assertEquals("crnk:get:/tasks", repositorySpan0.getName());
    Assert.assertTrue(repositorySpan0.toString().contains("\"lc\""));
    assertBinaryAnnotation(repositorySpan0, "lc", "crnk");
    assertBinaryAnnotation(repositorySpan0, "crnk.results", "0");
    assertBinaryAnnotation(repositorySpan0, "crnk.status", "OK");
    Span repositorySpan1 = reportedSpans.spans.get(1);
    Assert.assertEquals("crnk:get:/projects/123/tasks", repositorySpan1.getName());
    Assert.assertTrue(repositorySpan1.toString().contains("\"lc\""));
    assertBinaryAnnotation(repositorySpan1, "lc", "crnk");
    assertBinaryAnnotation(repositorySpan1, "crnk.query", "?");
    assertBinaryAnnotation(repositorySpan1, "crnk.results", "0");
    assertBinaryAnnotation(repositorySpan1, "crnk.status", "OK");
}
Also used : Project(io.crnk.test.mock.models.Project) Serializable(java.io.Serializable) Task(io.crnk.test.mock.models.Task) QuerySpec(io.crnk.core.queryspec.QuerySpec) Span(org.springframework.cloud.sleuth.Span) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 28 with Task

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

the class SleuthModuleTest method testCreate.

@Test
public void testCreate() {
    Task task = new Task();
    task.setId(13L);
    task.setName("myTask");
    taskRepo.create(task);
    // check client call and link span
    ArgumentCaptor<Span> clientSpanCaptor = ArgumentCaptor.forClass(Span.class);
    List<Span> clientSpans = clientSpanCaptor.getAllValues();
    Span callSpan = clientSpans.get(0);
    Assert.assertEquals("post", callSpan.getName());
    Assert.assertTrue(callSpan.toString().contains("\"cs\""));
    Assert.assertTrue(callSpan.toString().contains("\"cr\""));
    // check server local span
    Assert.assertEquals(1, reportedSpans.spans.size());
    Span repositorySpan = reportedSpans.spans.get(0);
    Assert.assertEquals("crnk:post:/tasks/13", repositorySpan.getName());
    Assert.assertTrue(repositorySpan.toString().contains("\"lc\""));
    assertBinaryAnnotation(repositorySpan, "lc", "crnk");
    assertBinaryAnnotation(repositorySpan, "crnk.query", "?");
}
Also used : Task(io.crnk.test.mock.models.Task) Span(org.springframework.cloud.sleuth.Span) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 29 with Task

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

the class SleuthModuleTest method testFindAll.

@Test
public void testFindAll() {
    Task task = new Task();
    task.setId(13L);
    task.setName("myTask");
    QuerySpec querySpec = new QuerySpec(Task.class);
    querySpec.addFilter(new FilterSpec(Arrays.asList("name"), FilterOperator.EQ, "doe"));
    taskRepo.findAll(querySpec);
    // check client call and link span
    ArgumentCaptor<Span> clientSpanCaptor = ArgumentCaptor.forClass(Span.class);
    List<Span> clientSpans = clientSpanCaptor.getAllValues();
    Span callSpan = clientSpans.get(0);
    Assert.assertEquals("get", callSpan.getName());
    Assert.assertTrue(callSpan.toString().contains("\"cs\""));
    Assert.assertTrue(callSpan.toString().contains("\"cr\""));
    // check server local span
    Assert.assertEquals(1, reportedSpans.spans.size());
    Span repositorySpan = reportedSpans.spans.get(0);
    Assert.assertEquals("crnk:get:/tasks", repositorySpan.getName());
    Assert.assertTrue(repositorySpan.toString().contains("\"lc\""));
    assertBinaryAnnotation(repositorySpan, "lc", "crnk");
    assertBinaryAnnotation(repositorySpan, "crnk.query", "?filter[tasks][name][EQ]=doe");
    assertBinaryAnnotation(repositorySpan, "crnk.results", "0");
    assertBinaryAnnotation(repositorySpan, "crnk.status", "OK");
}
Also used : Task(io.crnk.test.mock.models.Task) QuerySpec(io.crnk.core.queryspec.QuerySpec) FilterSpec(io.crnk.core.queryspec.FilterSpec) Span(org.springframework.cloud.sleuth.Span) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 30 with Task

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

the class RestTemplateClientTest 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 QuerySpec(Task.class));
    Assert.assertEquals(0, tasks.size());
}
Also used : Task(io.crnk.test.mock.models.Task) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

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