Search in sources :

Example 11 with SampleJsonServiceLocator

use of io.crnk.legacy.locator.SampleJsonServiceLocator in project crnk-framework by crnk-project.

the class BraveResponseFilterTest method setup.

@Before
public void setup() {
    boot = new CrnkBoot();
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery("io.crnk.test.mock.repository", new SampleJsonServiceLocator()));
    boot.boot();
    span = Mockito.mock(Span.class);
    tracing = Mockito.mock(Tracing.class);
    tracer = Mockito.mock(Tracer.class);
    Mockito.when(tracing.tracer()).thenReturn(tracer);
    Mockito.when(tracer.nextSpan()).thenReturn(span);
    moduleContext = Mockito.mock(Module.ModuleContext.class);
    Mockito.when(moduleContext.getResourceRegistry()).thenReturn(boot.getResourceRegistry());
    QuerySpec querySpec = new QuerySpec(Task.class);
    queryAdapter = new QuerySpecAdapter(querySpec, boot.getResourceRegistry());
    ResourceInformation taskResourceInformation = boot.getResourceRegistry().getEntry(Task.class).getResourceInformation();
    requestSpec = Mockito.mock(RepositoryRequestSpec.class);
    Mockito.when(requestSpec.getMethod()).thenReturn(HttpMethod.GET);
    Mockito.when(requestSpec.getQueryAdapter()).thenReturn(queryAdapter);
    Mockito.when(requestSpec.getQuerySpec(taskResourceInformation)).thenReturn(querySpec);
    filter = new BraveRepositoryFilter(tracing, moduleContext);
    filterContext = Mockito.mock(RepositoryFilterContext.class);
    Mockito.when(filterContext.getRequest()).thenReturn(requestSpec);
    filterChain = Mockito.mock(RepositoryRequestFilterChain.class);
}
Also used : ResourceInformation(io.crnk.core.engine.information.resource.ResourceInformation) Task(io.crnk.test.mock.models.Task) RepositoryRequestSpec(io.crnk.core.engine.dispatcher.RepositoryRequestSpec) Tracer(brave.Tracer) SampleJsonServiceLocator(io.crnk.legacy.locator.SampleJsonServiceLocator) BraveRepositoryFilter(io.crnk.monitor.brave.internal.BraveRepositoryFilter) RepositoryFilterContext(io.crnk.core.engine.filter.RepositoryFilterContext) QuerySpecAdapter(io.crnk.core.queryspec.internal.QuerySpecAdapter) Span(brave.Span) CrnkBoot(io.crnk.core.boot.CrnkBoot) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) Tracing(brave.Tracing) QuerySpec(io.crnk.core.queryspec.QuerySpec) RepositoryRequestFilterChain(io.crnk.core.engine.filter.RepositoryRequestFilterChain) Before(org.junit.Before)

Aggregations

SampleJsonServiceLocator (io.crnk.legacy.locator.SampleJsonServiceLocator)11 Test (org.junit.Test)7 CrnkBoot (io.crnk.core.boot.CrnkBoot)4 NullPropertiesProvider (io.crnk.core.engine.properties.NullPropertiesProvider)4 PropertiesProvider (io.crnk.core.engine.properties.PropertiesProvider)3 ReflectionsServiceDiscovery (io.crnk.core.module.discovery.ReflectionsServiceDiscovery)3 RepositoryInstanceBuilder (io.crnk.legacy.registry.RepositoryInstanceBuilder)3 Before (org.junit.Before)3 ConstantServiceUrlProvider (io.crnk.core.engine.url.ConstantServiceUrlProvider)2 Span (brave.Span)1 Tracer (brave.Tracer)1 Tracing (brave.Tracing)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 RepositoryRequestSpec (io.crnk.core.engine.dispatcher.RepositoryRequestSpec)1 RepositoryFilterContext (io.crnk.core.engine.filter.RepositoryFilterContext)1 RepositoryRequestFilterChain (io.crnk.core.engine.filter.RepositoryRequestFilterChain)1 ResourceRepositoryInformation (io.crnk.core.engine.information.repository.ResourceRepositoryInformation)1 ResourceField (io.crnk.core.engine.information.resource.ResourceField)1 ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)1 ResourceInformationProvider (io.crnk.core.engine.information.resource.ResourceInformationProvider)1