use of io.atlasmap.v2.Json in project syndesis-qe by syndesisio.
the class AtlasMapperGenerator method createDataSource.
/**
* Used to generate data source elements for atlasMapping. There are three types of them: Java, Json, XML.
*
* @param dataShape datashape of the processed step
* @param step step definition
* @param dataSourceType datasource type
* @return datasource
*/
private DataSource createDataSource(DataShape dataShape, StepDefinition step, DataSourceType dataSourceType) {
DataShapeKinds dataShapeKind = dataShape.getKind();
DataSource source = null;
if (dataShapeKind.toString().contains("json")) {
source = new JsonDataSource();
source.setUri("atlas:" + "json:" + step.getStep().getId().get());
} else if (dataShapeKind.toString().contains("java")) {
source = new DataSource();
source.setUri("atlas:" + "java:" + step.getStep().getId().get() + "?className=" + dataShape.getType());
} else if (dataShapeKind.toString().contains("xml")) {
source = new XmlDataSource();
source.setUri("atlas:xml:" + step.getStep().getId().get());
XmlNamespaces xmlNamespaces = new XmlNamespaces();
// Init the array, so that we don't have the null value
xmlNamespaces.getXmlNamespace();
((XmlDataSource) source).setXmlNamespaces(xmlNamespaces);
} else {
fail("Unknown datashape kind " + dataShapeKind.toString());
}
source.setId(step.getStep().getId().get());
source.setDataSourceType(dataSourceType);
return source;
}
use of io.atlasmap.v2.Json in project atlasmap by atlasmap.
the class JavaToXMLJSONMarshallingTest method testCombineMappingDemarshaller.
@Test
public void testCombineMappingDemarshaller() throws Exception {
// this test is for AT-466: issue saving mappings in combine mode (parser
// complaining about strategy property)
// the json has been changed from what the UI was sending, now the "actions"
// property on the output field is "null" rather than "[]"
String filename = "src/test/resources/javaToXml/javaToXmlMapping-combine.json";
AtlasMapping uMapping = mapper.readValue(new File(filename), AtlasMapping.class);
assertNotNull(uMapping);
}
use of io.atlasmap.v2.Json in project atlasmap by atlasmap.
the class AtlasServiceTest method testADMUpload.
@Test
public void testADMUpload() throws Exception {
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("json-schema-source-to-xml-schema-target.adm");
Response res = service.createMappingRequest(in, MappingFileType.ZIP, 0, generateTestUriInfo("http://localhost:8686/v2/atlas", "http://localhost:8686/v2/atlas/mapping/ZIP/0"));
assertEquals(200, res.getStatus());
res = service.getMappingRequest(MappingFileType.JSON, 0);
assertEquals(200, res.getStatus());
AtlasMapping mappings = mapper.readValue((byte[]) res.getEntity(), AtlasMapping.class);
assertEquals(4, mappings.getMappings().getMapping().size());
}
use of io.atlasmap.v2.Json in project atlasmap by atlasmap.
the class AtlasServiceTest method testProcessMapping3064.
@Test
public void testProcessMapping3064() throws Exception {
Response res = service.processMappingRequest(this.getClass().getClassLoader().getResourceAsStream("mappings/process-mapping-request-3064.json"), generateTestUriInfo("http://localhost:8686/v2/atlas", "http://localhost:8686/v2/atlas/mapping/process"));
ProcessMappingResponse resp = Json.mapper().readValue((byte[]) res.getEntity(), ProcessMappingResponse.class);
assertEquals(0, resp.getAudits().getAudit().size(), printAudit(resp.getAudits()));
Field field = resp.getMapping().getInputField().get(0);
assertEquals("/primitives/stringPrimitive", field.getPath());
}
use of io.atlasmap.v2.Json in project atlasmap by atlasmap.
the class AtlasService method listFieldActions.
/**
* Retrieves a list of available field action.
* @param uriInfo URI info
* @return {@link ActionDetails} serialized to JSON
*/
@GET
@Path("/fieldActions")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "List FieldActions", description = "Retrieves a list of available field action")
@ApiResponses(@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = ActionDetails.class)), description = "Return a list of field action detail"))
public Response listFieldActions(@Context UriInfo uriInfo) {
ActionDetails details = new ActionDetails();
if (atlasContextFactory == null || atlasContextFactory.getFieldActionService() == null) {
return Response.ok().entity(toJson(details)).build();
}
details.getActionDetail().addAll(atlasContextFactory.getFieldActionService().listActionDetails());
byte[] serialized = toJson(details);
if (LOG.isDebugEnabled()) {
LOG.debug(new String(serialized));
}
return Response.ok().entity(serialized).build();
}
Aggregations