use of de.fraunhofer.iosb.ilt.faaast.service.model.api.Result in project FAAAST-Service by FraunhoferIOSB.
the class HttpEndpointTest method testResultServerError.
@Test
public void testResultServerError() throws Exception {
when(serviceContext.execute(any())).thenReturn(GetSubmodelElementByPathResponse.builder().statusCode(StatusCode.ServerInternalError).payload(null).build());
Message message = Message.builder().text(HttpStatus.getMessage(500)).messageType(MessageType.Error).code(HttpStatus.getMessage(500)).timestamp(new Date()).build();
Result result = Result.builder().message(message).success(false).build();
ContentResponse response = response = execute(HttpMethod.GET, "/shells/" + EncodingHelper.base64UrlEncode("Whatever") + "/aas");
Result actual = deserializer.read(new String(response.getContent()), Result.class);
actual.getMessage().get(0).setTimestamp(message.getTimestamp());
Assert.assertEquals(result, actual);
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.api.Result in project FAAAST-Service by FraunhoferIOSB.
the class HttpEndpointTest method testResultBadRequest.
@Test
public void testResultBadRequest() throws Exception {
Message message = Message.builder().text("no matching request mapper found").messageType(MessageType.Error).code(HttpStatus.getMessage(400)).timestamp(new Date()).build();
Result result = Result.builder().message(message).success(false).build();
ContentResponse response = execute(HttpMethod.GET, "/shellsX/");
Result actual = deserializer.read(new String(response.getContent()), Result.class);
actual.getMessage().get(0).setTimestamp(message.getTimestamp());
Assert.assertEquals(result, actual);
}
use of de.fraunhofer.iosb.ilt.faaast.service.model.api.Result in project FAAAST-Service by FraunhoferIOSB.
the class HttpEndpointTest method testResultNotFound.
@Test
public void testResultNotFound() throws Exception {
when(serviceContext.execute(any())).thenReturn(GetSubmodelElementByPathResponse.builder().statusCode(StatusCode.ClientErrorResourceNotFound).payload(null).build());
Identifier id = new DefaultIdentifier();
Message message = Message.builder().text(HttpStatus.getMessage(404)).messageType(MessageType.Error).code(HttpStatus.getMessage(404)).timestamp(new Date()).build();
Result result = Result.builder().message(message).success(false).build();
ContentResponse response = execute(HttpMethod.GET, "/submodels/" + EncodingHelper.base64UrlEncode(id.toString()) + "/submodel/submodel-elements/Invalid");
Result actual = deserializer.read(new String(response.getContent()), Result.class);
actual.getMessage().get(0).setTimestamp(message.getTimestamp());
Assert.assertEquals(result, actual);
}
Aggregations