use of io.crnk.core.engine.filter.DocumentFilterContext in project crnk-framework by crnk-project.
the class JsonApiActionResponseTest method testInvokeRepositoryActionWithException.
@Test
public void testInvokeRepositoryActionWithException() {
// resources should be received in json api format
String url = getBaseUri() + "schedules/repositoryActionWithException?msg=hello";
io.restassured.response.Response response = RestAssured.get(url);
Assert.assertEquals(403, response.getStatusCode());
response.then().assertThat().body("errors[0].status", Matchers.equalTo("403"));
// check filters
ArgumentCaptor<DocumentFilterContext> contexts = ArgumentCaptor.forClass(DocumentFilterContext.class);
Mockito.verify(filter, Mockito.times(1)).filter(contexts.capture(), Mockito.any(DocumentFilterChain.class));
DocumentFilterContext actionContext = contexts.getAllValues().get(0);
Assert.assertEquals("GET", actionContext.getMethod());
Assert.assertTrue(actionContext.getJsonPath() instanceof ActionPath);
}
use of io.crnk.core.engine.filter.DocumentFilterContext in project crnk-framework by crnk-project.
the class JsonApiActionResponseTest method testInvokeRepositoryAction.
@Test
@Ignore
public // The DocumentFilterContext is not invoked with this request any more
void testInvokeRepositoryAction() {
// tag::invokeService[]
String result = scheduleRepository.repositoryAction("hello");
Assert.assertEquals("repository action: hello", result);
// end::invokeService[]
// check filters
ArgumentCaptor<DocumentFilterContext> contexts = ArgumentCaptor.forClass(DocumentFilterContext.class);
Mockito.verify(filter, Mockito.times(1)).filter(contexts.capture(), Mockito.any(DocumentFilterChain.class));
DocumentFilterContext actionContext = contexts.getAllValues().get(0);
Assert.assertEquals("GET", actionContext.getMethod());
Assert.assertTrue(actionContext.getJsonPath() instanceof ActionPath);
}
use of io.crnk.core.engine.filter.DocumentFilterContext in project crnk-framework by crnk-project.
the class JsonApiActionResponseTest method testInvokeRepositoryActionWithResourceResult.
@Test
public void testInvokeRepositoryActionWithResourceResult() {
// resources should be received in json api format
String url = getBaseUri() + "schedules/repositoryActionWithResourceResult?msg=hello";
io.restassured.response.Response response = RestAssured.get(url);
Assert.assertEquals(200, response.getStatusCode());
response.then().assertThat().body("data.attributes.name", Matchers.equalTo("hello"));
// check filters
ArgumentCaptor<DocumentFilterContext> contexts = ArgumentCaptor.forClass(DocumentFilterContext.class);
Mockito.verify(filter, Mockito.times(1)).filter(contexts.capture(), Mockito.any(DocumentFilterChain.class));
DocumentFilterContext actionContext = contexts.getAllValues().get(0);
Assert.assertEquals("GET", actionContext.getMethod());
Assert.assertTrue(actionContext.getJsonPath() instanceof ActionPath);
}
Aggregations