use of io.crnk.core.exception.InternalServerErrorException in project crnk-framework by crnk-project.
the class ClientStubBaseTest method check500AndNoBodyGivesInternalServerErrorException.
@Test
public void check500AndNoBodyGivesInternalServerErrorException() throws IOException {
HttpAdapterResponse response = Mockito.mock(HttpAdapterResponse.class);
Mockito.when(response.body()).thenReturn("");
Mockito.when(response.code()).thenReturn(500);
RuntimeException exception = stub.handleError(response);
Assert.assertTrue(exception instanceof InternalServerErrorException);
}
use of io.crnk.core.exception.InternalServerErrorException in project crnk-framework by crnk-project.
the class ClientStubBaseTest method checkBodyWithNoErrorsAnd500Status.
@Test
public void checkBodyWithNoErrorsAnd500Status() throws IOException {
Document document = new Document();
document.setErrors(new ArrayList<ErrorData>());
String body = client.getObjectMapper().writeValueAsString(document);
HttpAdapterResponse response = Mockito.mock(HttpAdapterResponse.class);
Mockito.when(response.body()).thenReturn(body);
Mockito.when(response.code()).thenReturn(500);
RuntimeException exception = stub.handleError(response);
Assert.assertTrue(exception instanceof InternalServerErrorException);
}
use of io.crnk.core.exception.InternalServerErrorException in project crnk-framework by crnk-project.
the class DynamicClientTest method testRelationship.
@Test
public void testRelationship() throws IOException {
ResourceRepositoryV2<Resource, String> resourceRepository = client.getRepositoryForPath("dynamic1");
RelationshipRepositoryV2<Resource, String, Resource, String> repository = client.getRepositoryForPath("dynamic1", "tasks");
ObjectMapper mapper = new ObjectMapper();
Resource target = repository.findOneTarget("a", "parent", new QuerySpec("tasks"));
Assert.assertEquals("doe", target.getAttributes().get("value").asText());
List<Resource> targets = repository.findManyTargets("a", "children", new QuerySpec("tasks"));
Assert.assertEquals(1, targets.size());
Assert.assertEquals("doe", targets.get(0).getAttributes().get("value").asText());
Resource source = new Resource();
source.setId("john");
source.setType("dynamic1");
source.getAttributes().put("value", mapper.readTree("\"doe\""));
resourceRepository.create(source);
repository.setRelation(source, "12", "parent");
repository.setRelations(source, Arrays.asList("12"), "children");
repository.addRelations(source, Arrays.asList("12"), "children");
repository.removeRelations(source, Arrays.asList("12"), "children");
try {
repository.setRelation(source, "13", "parent");
Assert.fail();
} catch (InternalServerErrorException e) {
// ok
}
}
Aggregations