use of com.mulesoft.tools.migration.exception.MigrationStepException in project mule-migration-assistant by mulesoft.
the class AbstractMigrationTask method fetchAndProcessNodes.
private void fetchAndProcessNodes(MigrationReport report, ApplicationModelContribution s, List<Element> alreadyProcessed) {
AtomicInteger processedElements = new AtomicInteger(0);
List<Element> nodes = applicationModel.getNodes(s.getAppliedTo());
nodes.stream().filter(n -> !alreadyProcessed.contains(n)).forEach(n -> {
try {
processedElements.incrementAndGet();
s.execute(n, report);
} catch (Exception e) {
throw new MigrationStepException("Task execution exception (" + e.getMessage() + ") migrating node:" + lineSeparator() + outp.outputString(n), e);
}
});
alreadyProcessed.addAll(nodes);
nodes.removeAll(applicationModel.getNodes(s.getAppliedTo()));
if (!nodes.isEmpty()) {
// This recursive calls is here so if any task adds nodes to the config that would be processed by this task, those are
// processed.
// Also, this is recursive rather than iterative so in the case of a bug, we get a StackOverflow rather than an infinite
// loop.
fetchAndProcessNodes(report, s, alreadyProcessed);
}
report.addProcessedElements(processedElements.get());
}
use of com.mulesoft.tools.migration.exception.MigrationStepException in project mule-migration-assistant by mulesoft.
the class AbstractSpringMigratorStep method resolveSpringDocument.
protected Document resolveSpringDocument(Document currentDoc) {
Document springDocument = null;
springDocument = resolveSpringFile(currentDoc, springDocument, getApplicationModel().getApplicationDocuments());
if (springDocument == null) {
springDocument = resolveSpringFile(currentDoc, springDocument, getApplicationModel().getDomainDocuments());
if (springDocument == null) {
throw new MigrationStepException("The document of the passed element was not present in the application model");
}
}
return springDocument;
}
use of com.mulesoft.tools.migration.exception.MigrationStepException in project mule-migration-assistant by mulesoft.
the class AssertTrue method execute.
@Override
public void execute(Element element, MigrationReport report) throws RuntimeException {
try {
changeNodeName("munit-tools", "assert-that").andThen(changeAttribute("condition", of("expression"), empty())).andThen(addAttribute("is", "#[MunitTools::equalTo(true)]")).apply(element);
migrateExpression(element);
} catch (Exception e) {
throw new MigrationStepException("Fail to apply step. " + e.getMessage());
}
}
use of com.mulesoft.tools.migration.exception.MigrationStepException in project mule-migration-assistant by mulesoft.
the class Mock method execute.
@Override
public void execute(Element element, MigrationReport report) throws RuntimeException {
try {
changeNodeName(MUNIT_TOOLS_PREFIX, "mock-when").andThen(changeAttribute("messageProcessor", of("processor"), empty())).apply(element);
updateChildElementsNamespace(element.getChildren());
Element attributesNode = element.getChild("with-attributes", element.getNamespace());
attributesNode.getChildren().forEach(n -> changeAttribute("name", of("attributeName"), empty()).apply(n));
movePayloadToChildNode(element.getChild("then-return", element.getNamespace()));
} catch (Exception e) {
throw new MigrationStepException("Fail to apply step. " + e.getMessage());
}
}
use of com.mulesoft.tools.migration.exception.MigrationStepException in project mule-migration-assistant by mulesoft.
the class AssertNotEquals method execute.
@Override
public void execute(Element element, MigrationReport report) throws RuntimeException {
try {
changeNodeName("munit-tools", "assert-that").andThen(changeAttribute("expectedValue", of("expression"), empty())).andThen(changeAttribute("actualValue", of("is"), empty())).apply(element);
updateMUnitAssertionNotEqualsExpression("is").apply(element);
migrateExpression(element);
} catch (Exception e) {
throw new MigrationStepException("Fail to apply step. " + e.getMessage());
}
}
Aggregations