Search in sources :

Example 11 with ErrorDataBuilder

use of io.crnk.core.engine.document.ErrorDataBuilder in project crnk-framework by crnk-project.

the class ClientDocumentMapperTest method testCannotHaveErrors.

@Test(expected = IllegalStateException.class)
public void testCannotHaveErrors() throws IOException {
    Document doc = new Document();
    doc.setErrors(Arrays.asList(new ErrorDataBuilder().build()));
    doc.setData(Nullable.nullValue());
    documentMapper.fromDocument(doc, false);
}
Also used : ErrorDataBuilder(io.crnk.core.engine.document.ErrorDataBuilder) Document(io.crnk.core.engine.document.Document) Test(org.junit.Test)

Example 12 with ErrorDataBuilder

use of io.crnk.core.engine.document.ErrorDataBuilder in project crnk-framework by crnk-project.

the class BraveResponseFilterTest method statusCodeNotOkWhenEmptyErrors.

@Test
public void statusCodeNotOkWhenEmptyErrors() {
    ErrorData errorData = new ErrorDataBuilder().setId("test").build();
    JsonApiResponse response = new JsonApiResponse();
    response.setErrors(Arrays.asList(errorData));
    Mockito.when(filterChain.doFilter(Mockito.any(RepositoryFilterContext.class))).thenReturn(response);
    filter.filterRequest(filterContext, filterChain);
    Mockito.verify(span, Mockito.times(1)).tag(BraveRepositoryFilter.STATUS_CODE_ANNOTATION, BraveRepositoryFilter.STRING_EXCEPTION);
}
Also used : ErrorDataBuilder(io.crnk.core.engine.document.ErrorDataBuilder) JsonApiResponse(io.crnk.core.repository.response.JsonApiResponse) RepositoryFilterContext(io.crnk.core.engine.filter.RepositoryFilterContext) ErrorData(io.crnk.core.engine.document.ErrorData) Test(org.junit.Test)

Aggregations

ErrorDataBuilder (io.crnk.core.engine.document.ErrorDataBuilder)12 ErrorData (io.crnk.core.engine.document.ErrorData)8 Test (org.junit.Test)7 Document (io.crnk.core.engine.document.Document)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 HttpAdapterResponse (io.crnk.client.http.HttpAdapterResponse)2 ResourceNotFoundException (io.crnk.core.exception.ResourceNotFoundException)2 ArrayList (java.util.ArrayList)2 CrnkBoot (io.crnk.core.boot.CrnkBoot)1 RepositoryFilterContext (io.crnk.core.engine.filter.RepositoryFilterContext)1 ResourceRegistry (io.crnk.core.engine.registry.ResourceRegistry)1 ReflectionsServiceDiscovery (io.crnk.core.module.discovery.ReflectionsServiceDiscovery)1 JsonApiResponse (io.crnk.core.repository.response.JsonApiResponse)1 Map (java.util.Map)1 Before (org.junit.Before)1 HttpStatus (org.springframework.http.HttpStatus)1 ResponseEntity (org.springframework.http.ResponseEntity)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1