Search in sources :

Example 6 with RepositoryMethodParameterProvider

use of io.crnk.legacy.internal.RepositoryMethodParameterProvider in project crnk-framework by crnk-project.

the class FilterTest method test.

@Test
public void test() throws Exception {
    // WHEN
    ArgumentCaptor<DocumentFilterContext> captor = ArgumentCaptor.forClass(DocumentFilterContext.class);
    when(collectionGet.isAcceptable(any(JsonPath.class), eq(requestType))).thenCallRealMethod();
    when(filter.filter(any(DocumentFilterContext.class), any(DocumentFilterChain.class))).thenCallRealMethod();
    Map<String, Set<String>> queryParams = new HashMap<>();
    RepositoryMethodParameterProvider parameterProvider = new NewInstanceRepositoryMethodParameterProvider();
    Document requestBody = new Document();
    dispatcher.dispatchRequest(path, requestType, queryParams, parameterProvider, requestBody);
    // THEN
    verify(filter).filter(captor.capture(), any(DocumentFilterChain.class));
    verify(collectionGet, times(1)).handle(any(JsonPath.class), any(QueryAdapter.class), any(RepositoryMethodParameterProvider.class), any(Document.class));
    verify(filter, times(1)).filter(any(DocumentFilterContext.class), any(DocumentFilterChain.class));
    DocumentFilterContext value = captor.getValue();
    Assert.assertEquals("tasks", value.getJsonPath().getElementName());
    Assert.assertEquals(parameterProvider, value.getParameterProvider());
    Assert.assertEquals(requestBody, value.getRequestBody());
    Assert.assertEquals("GET", value.getMethod());
}
Also used : DocumentFilterContext(io.crnk.core.engine.filter.DocumentFilterContext) NewInstanceRepositoryMethodParameterProvider(io.crnk.core.engine.repository.mock.NewInstanceRepositoryMethodParameterProvider) Set(java.util.Set) HashMap(java.util.HashMap) QueryAdapter(io.crnk.core.engine.query.QueryAdapter) DocumentFilterChain(io.crnk.core.engine.filter.DocumentFilterChain) JsonPath(io.crnk.core.engine.internal.dispatcher.path.JsonPath) Document(io.crnk.core.engine.document.Document) NewInstanceRepositoryMethodParameterProvider(io.crnk.core.engine.repository.mock.NewInstanceRepositoryMethodParameterProvider) RepositoryMethodParameterProvider(io.crnk.legacy.internal.RepositoryMethodParameterProvider) ResourceRegistryTest(io.crnk.core.resource.registry.ResourceRegistryTest) Test(org.junit.Test)

Example 7 with RepositoryMethodParameterProvider

use of io.crnk.legacy.internal.RepositoryMethodParameterProvider in project crnk-framework by crnk-project.

the class ClientResourceUpsert method setRelations.

public void setRelations(List<Resource> resources) {
    for (Resource resource : resources) {
        String uid = getUID(resource);
        Object object = resourceMap.get(uid);
        RegistryEntry registryEntry = resourceRegistry.getEntry(resource.getType());
        // no need for any query parameters when doing POST/PATCH
        QueryAdapter queryAdapter = null;
        // no in use on the client side
        RepositoryMethodParameterProvider parameterProvider = null;
        setRelations(object, registryEntry, resource, queryAdapter, parameterProvider, true);
    }
}
Also used : QueryAdapter(io.crnk.core.engine.query.QueryAdapter) Resource(io.crnk.core.engine.document.Resource) RegistryEntry(io.crnk.core.engine.registry.RegistryEntry) RepositoryMethodParameterProvider(io.crnk.legacy.internal.RepositoryMethodParameterProvider)

Aggregations

RepositoryMethodParameterProvider (io.crnk.legacy.internal.RepositoryMethodParameterProvider)7 Set (java.util.Set)4 RequestDispatcher (io.crnk.core.engine.dispatcher.RequestDispatcher)3 Response (io.crnk.core.engine.dispatcher.Response)3 Document (io.crnk.core.engine.document.Document)3 Resource (io.crnk.core.engine.document.Resource)3 QueryAdapter (io.crnk.core.engine.query.QueryAdapter)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 JsonPath (io.crnk.core.engine.internal.dispatcher.path.JsonPath)2 OperationResponse (io.crnk.operations.OperationResponse)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ResourceIdentifier (io.crnk.core.engine.document.ResourceIdentifier)1 DocumentFilterChain (io.crnk.core.engine.filter.DocumentFilterChain)1 DocumentFilterContext (io.crnk.core.engine.filter.DocumentFilterContext)1 ResourceField (io.crnk.core.engine.information.resource.ResourceField)1 ActionPath (io.crnk.core.engine.internal.dispatcher.path.ActionPath)1 PathBuilder (io.crnk.core.engine.internal.dispatcher.path.PathBuilder)1 RegistryEntry (io.crnk.core.engine.registry.RegistryEntry)1