use of io.crnk.monitor.brave.mock.models.Project in project crnk-framework by crnk-project.
the class AbstractBraveModuleTest method testFindTargets.
@Test
public void testFindTargets() {
RelationshipRepositoryV2<Project, Serializable, Task, Serializable> relRepo = client.getRepositoryForType(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);
Mockito.verify(clientReporter, Mockito.times(1)).report(clientSpanCaptor.capture());
List<Span> clientSpans = clientSpanCaptor.getAllValues();
Span callSpan = clientSpans.get(0);
Assert.assertEquals("get", callSpan.name());
Assert.assertEquals(Span.Kind.CLIENT, callSpan.kind());
// check server local span
ArgumentCaptor<Span> serverSpanCaptor = ArgumentCaptor.forClass(Span.class);
Mockito.verify(serverReporter, Mockito.times(2)).report(serverSpanCaptor.capture());
List<Span> serverSpans = serverSpanCaptor.getAllValues();
Span repositorySpan0 = serverSpans.get(0);
Assert.assertEquals("crnk:get:/tasks/", repositorySpan0.name());
Assert.assertTrue(repositorySpan0.toString().contains("\"lc\""));
assertTag(repositorySpan0, "lc", "crnk");
assertTag(repositorySpan0, "crnk.results", "0");
assertTag(repositorySpan0, "crnk.status", "OK");
Span repositorySpan1 = serverSpans.get(1);
Assert.assertEquals("crnk:get:/projects/123/tasks/", repositorySpan1.name());
Assert.assertTrue(repositorySpan1.toString().contains("\"lc\""));
assertTag(repositorySpan1, "lc", "crnk");
assertTag(repositorySpan1, "crnk.query", "?");
assertTag(repositorySpan1, "crnk.results", "0");
assertTag(repositorySpan1, "crnk.status", "OK");
}