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);
}
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");
}
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", "?");
}
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");
}
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());
}
Aggregations