use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.
the class JsonJavaFlatMappingTest method generateJsonJavaFlatMapping.
protected AtlasMapping generateJsonJavaFlatMapping() {
AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
atlasMapping.setName("JsonJavaFlatMapping");
atlasMapping.getDataSource().add(generateDataSource("atlas:json", DataSourceType.SOURCE));
atlasMapping.getDataSource().add(generateDataSource("atlas:java?className=io.atlasmap.java.test.TargetFlatPrimitiveClass", DataSourceType.TARGET));
List<BaseMapping> mappings = atlasMapping.getMappings().getMapping();
// Add fieldMappings
for (String fieldName : FLAT_FIELDS) {
Mapping mfm = AtlasModelFactory.createMapping(MappingType.MAP);
mfm.getInputField().add(generateJsonField("/" + fieldName));
mfm.getOutputField().add(generateJavaField("/" + fieldName));
mappings.add(mfm);
}
return atlasMapping;
}
use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.
the class JsonJsonFlatMappingTest method generateJsonJsonFlatMapping.
protected AtlasMapping generateJsonJsonFlatMapping() {
AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
atlasMapping.setName("JsonJsonFlatMapping");
atlasMapping.getDataSource().add(generateDataSource("atlas:json", DataSourceType.SOURCE));
atlasMapping.getDataSource().add(generateDataSource("atlas:json", DataSourceType.TARGET));
List<BaseMapping> mappings = atlasMapping.getMappings().getMapping();
// Add fieldMappings
for (String fieldName : FLAT_FIELDS) {
Mapping mfm = AtlasModelFactory.createMapping(MappingType.MAP);
mfm.getInputField().add(generateJsonField(fieldName));
mfm.getOutputField().add(generateJavaField(fieldName));
mappings.add(mfm);
}
return atlasMapping;
}
use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.
the class XmlJsonFlatMappingTest method generateXmlJsonFlatMapping.
protected AtlasMapping generateXmlJsonFlatMapping() {
AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
atlasMapping.setName("XmlJsonFlatMapping");
atlasMapping.getDataSource().add(generateDataSource("atlas:xml?complexType=XmlFlatPrimitiveAttribute", DataSourceType.SOURCE));
atlasMapping.getDataSource().add(generateDataSource("atlas:json", DataSourceType.TARGET));
List<BaseMapping> mappings = atlasMapping.getMappings().getMapping();
// Add fieldMappings
for (String fieldName : FLAT_FIELDS) {
Mapping mfm = AtlasModelFactory.createMapping(MappingType.MAP);
mfm.getInputField().add(generateXmlField("/XmlFPA/", fieldName));
mfm.getOutputField().add(generateJsonField(fieldName));
mappings.add(mfm);
}
return atlasMapping;
}
use of io.atlasmap.v2.Mapping in project atlasmap by atlasmap.
the class AtlasCoreValidationTest method testMappingNameEmpty.
@Test
public void testMappingNameEmpty() throws AtlasException {
assertNotNull(context);
assertNotNull(session);
context.processValidation(session);
Validations validations = session.getValidations();
assertNotNull(validations);
assertNotNull(validations.getValidation());
assertFalse(validations.getValidation().isEmpty());
boolean found = false;
for (Validation v : validations.getValidation()) {
if ("Mapping name must not be null nor empty".equals(v.getMessage())) {
found = true;
assertEquals(ValidationStatus.ERROR, v.getStatus());
assertEquals(ValidationScope.ALL, v.getScope());
}
}
assertTrue(found);
}
use of io.atlasmap.v2.Mapping in project syndesis-qe by syndesisio.
the class UiComplexSteps method dbToDbIntegrationWithPeriodMs.
@Given("^db to db \"([^\"]*)\" integration with period (\\d+) ms$")
public void dbToDbIntegrationWithPeriodMs(String integrationName, int ms) throws IOException {
final Connection dbConnection = connectionsEndpoint.get(getDbConnectionId());
final Connector dbConnector = connectorsEndpoint.get("sql");
final String sqlStartQuery = "SELECT * FROM CONTACT";
final String sqlFinishQuery = "INSERT INTO TODO(task, completed) VALUES (:#TASK, 2)";
final String datamapperTemplate = "db-db.json";
// 1. @Then("^create start DB periodic sql invocation action step with query \"([^\"]*)\" and period \"([^\"]*)\" ms")
final Action dbAction1 = TestUtils.findConnectorAction(dbConnector, "sql-start-connector");
final Map<String, String> properties1 = TestUtils.map("query", sqlStartQuery, "schedulerPeriod", ms);
final ConnectorDescriptor connectorDescriptor1 = getConnectorDescriptor(dbAction1, properties1, dbConnection.getId().get());
// to be reported: period is not part of .json step (when checked via browser).
final Step dbStep1 = new Step.Builder().stepKind(StepKind.endpoint).id(UUID.randomUUID().toString()).connection(dbConnection).action(dbAction1).configuredProperties(properties1).build();
steps.getStepDefinitions().add(new StepDefinition(dbStep1, connectorDescriptor1));
// 2.A @And("start mapper definition with name: \"([^\"]*)\"")
String mapperName = "mapping 1";
final Step mapperStep = new Step.Builder().stepKind(StepKind.mapper).name(mapperName).build();
steps.getStepDefinitions().add(new StepDefinition(mapperStep, new DataMapperDefinition()));
// 2.B @Then("MAP using Step (\\d+) and field \"([^\"]*)\" to \"([^\"]*)\"")
int fromStep = 1;
String fromField = "first_name";
String toField = "TASK";
DataMapperStepDefinition newDmStep = new DataMapperStepDefinition();
newDmStep.setFromStep(fromStep);
newDmStep.setInputFields(Arrays.asList(fromField));
newDmStep.setOutputFields(Arrays.asList(toField));
newDmStep.setMappingType(MappingType.MAP);
newDmStep.setStrategy(null);
steps.getLastStepDefinition().getDataMapperDefinition().get().getDataMapperStepDefinition().add(newDmStep);
// 3. @Then("^create finish DB invoke sql action step with query \"([^\"]*)\"")
final Action dbAction2 = TestUtils.findConnectorAction(dbConnector, "sql-connector");
final Map<String, String> properties2 = TestUtils.map("query", sqlFinishQuery);
final ConnectorDescriptor connectorDescriptor2 = getConnectorDescriptor(dbAction2, properties2, dbConnection.getId().get());
final Step dbStep2 = new Step.Builder().stepKind(StepKind.endpoint).id(UUID.randomUUID().toString()).connection(dbConnection).action(dbAction2).configuredProperties(properties2).build();
steps.getStepDefinitions().add(new StepDefinition(dbStep2, connectorDescriptor2));
// 4. @When("^create integration with name: \"([^\"]*)\"")
processMapperSteps();
Integration integration = new Integration.Builder().steps(steps.getSteps()).name(integrationName).description("Awkward UI integration.").build();
log.info("Creating integration {}", integration.getName());
String integrationId = integrationsEndpoint.create(integration).getId().get();
log.info("Publish integration with ID: {}", integrationId);
publishIntegration(integrationId);
log.debug("Flushing used steps");
steps.flushStepDefinitions();
// 5. @Then("^wait for integration with name: \"([^\"]*)\" to become active")
final List<Integration> integrations = integrationsEndpoint.list().stream().filter(item -> item.getName().equals(integrationName)).collect(Collectors.toList());
final long start = System.currentTimeMillis();
// wait for activation
log.info("Waiting until integration \"{}\" becomes active. This may take a while...", integrationName);
integrationOverviewEndpoint = new IntegrationOverviewEndpoint(integrationId);
final IntegrationOverview integrationOverview = integrationOverviewEndpoint.getOverview();
final boolean activated = TestUtils.waitForPublishing(integrationOverviewEndpoint, integrationOverview, TimeUnit.MINUTES, 10);
Assertions.assertThat(activated).isEqualTo(true);
log.info("Integration pod has been started. It took {}s to build the integration.", TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - start));
}
Aggregations