Search in sources :

Example 1 with Message

use of de.fraunhofer.iosb.ilt.faaast.service.model.api.Message 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);
}
Also used : Message(de.fraunhofer.iosb.ilt.faaast.service.model.api.Message) ContentResponse(org.eclipse.jetty.client.api.ContentResponse) Date(java.util.Date) Result(de.fraunhofer.iosb.ilt.faaast.service.model.api.Result) Test(org.junit.Test)

Example 2 with Message

use of de.fraunhofer.iosb.ilt.faaast.service.model.api.Message 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);
}
Also used : Message(de.fraunhofer.iosb.ilt.faaast.service.model.api.Message) ContentResponse(org.eclipse.jetty.client.api.ContentResponse) Date(java.util.Date) Result(de.fraunhofer.iosb.ilt.faaast.service.model.api.Result) Test(org.junit.Test)

Example 3 with Message

use of de.fraunhofer.iosb.ilt.faaast.service.model.api.Message 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);
}
Also used : Identifier(io.adminshell.aas.v3.model.Identifier) DefaultIdentifier(io.adminshell.aas.v3.model.impl.DefaultIdentifier) Message(de.fraunhofer.iosb.ilt.faaast.service.model.api.Message) ContentResponse(org.eclipse.jetty.client.api.ContentResponse) DefaultIdentifier(io.adminshell.aas.v3.model.impl.DefaultIdentifier) Date(java.util.Date) Result(de.fraunhofer.iosb.ilt.faaast.service.model.api.Result) Test(org.junit.Test)

Aggregations

Message (de.fraunhofer.iosb.ilt.faaast.service.model.api.Message)3 Result (de.fraunhofer.iosb.ilt.faaast.service.model.api.Result)3 Date (java.util.Date)3 ContentResponse (org.eclipse.jetty.client.api.ContentResponse)3 Test (org.junit.Test)3 Identifier (io.adminshell.aas.v3.model.Identifier)1 DefaultIdentifier (io.adminshell.aas.v3.model.impl.DefaultIdentifier)1