use of org.eclipse.vorto.repository.web.core.dto.mapping.TestMappingResponse in project vorto by eclipse.
the class PayloadMappingController method testMapping.
@PutMapping(value = "/test")
@PreAuthorize("hasAuthority('model_viewer')")
public TestMappingResponse testMapping(@RequestBody TestMappingRequest testRequest) throws Exception {
Object content = null;
if (testRequest.getContentType().equals(TestContentType.csv)) {
content = CSV_DESERIALIZER.deserialize(testRequest.getContent());
} else {
content = JSON_DESERIALIZER.deserialize(testRequest.getContent());
}
InfomodelValue mappedOutput = mappingService.runTest(testRequest.getSpecification(), content);
TestMappingResponse response = new TestMappingResponse();
response.setCanonical(new ObjectMapper().writeValueAsString(mappedOutput.serialize()));
response.setDitto(new Gson().toJson(org.eclipse.vorto.mapping.targetplatform.ditto.TwinPayloadFactory.toDittoProtocol(mappedOutput, "com.acme:4711")));
response.setAwsiot(new Gson().toJson(org.eclipse.vorto.mapping.targetplatform.awsiot.TwinPayloadFactory.toShadowUpdateRequest(mappedOutput)));
response.setReport(mappedOutput.validate());
return response;
}
Aggregations