use of com.mulesoft.tools.migration.exception.MigrationStepException in project mule-migration-assistant by mulesoft.
the class AbstractSpringMigratorStep method resolveSpringFile.
protected Document resolveSpringFile(Document currentDoc, Document springDocument, final Map<Path, Document> artifactDocs) {
Path beansPath = null;
// Check if a spring file already exists for this mule config
for (Entry<Path, Document> entry : artifactDocs.entrySet()) {
if (currentDoc.equals(entry.getValue())) {
beansPath = resolveSpringBeansPath(entry);
if (artifactDocs.containsKey(Paths.get(SPRING_FOLDER + beansPath.getFileName().toString()))) {
return artifactDocs.get(Paths.get(SPRING_FOLDER + beansPath.getFileName().toString()));
}
}
}
// If not, create it and link it
for (Entry<Path, Document> entry : artifactDocs.entrySet()) {
if (currentDoc.equals(entry.getValue())) {
beansPath = resolveSpringBeansPath(entry);
try {
SAXBuilder saxBuilder = new SAXBuilder();
springDocument = saxBuilder.build(AbstractSpringMigratorStep.class.getClassLoader().getResourceAsStream("spring/empty-beans.xml"));
} catch (JDOMException | IOException e) {
throw new MigrationStepException(e.getMessage(), e);
}
addSpringModuleConfig(currentDoc, "spring/" + beansPath.getFileName().toString());
break;
}
}
if (beansPath == null) {
return null;
}
artifactDocs.put(Paths.get(SPRING_FOLDER + beansPath.getFileName().toString()), springDocument);
return springDocument;
}
use of com.mulesoft.tools.migration.exception.MigrationStepException in project mule-migration-assistant by mulesoft.
the class AssertEquals 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);
updateMUnitAssertionEqualsExpression("is").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 AssertFalse 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(false)]")).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 MuleAppProperties method execute.
@Override
public void execute(ApplicationModel appModel, MigrationReport report) throws RuntimeException {
try {
List<String> properties = resolveProperties(appModel.getProjectBasePath(), MULE_PROPS_FILE);
if (!properties.isEmpty()) {
properties.forEach(p -> {
appModel.getDocumentsContainString("${" + p + "}").forEach(n -> addConfigFileReference(n, appModel));
appModel.getDocumentsContainString("p(\\\"" + p + "\\\")").forEach(n -> addConfigFileReference(n, appModel));
appModel.getDocumentsContainString("p('" + p + "')").forEach(n -> addConfigFileReference(n, appModel));
});
}
} catch (IOException e) {
throw new MigrationStepException("Could not update mule-app.properties references on Files.", e);
}
}
use of com.mulesoft.tools.migration.exception.MigrationStepException in project mule-migration-assistant by mulesoft.
the class AssertPayload method execute.
@Override
public void execute(Element element, MigrationReport report) throws RuntimeException {
try {
changeNodeName("munit-tools", "assert-that").andThen(addAttribute("expression", "#[payload]")).andThen(changeAttribute("expectedValue", of("is"), empty())).apply(element);
Attribute isAttribute = element.getAttribute("is");
if (isAttribute != null) {
String attributeValue = isAttribute.getValue();
if (getExpressionMigrator().isWrapped(attributeValue)) {
attributeValue = "#[MunitTools::equalTo(" + getExpressionMigrator().unwrap(attributeValue) + ")]";
} else {
attributeValue = "#[MunitTools::equalTo(" + attributeValue + ")]";
}
isAttribute.setValue(attributeValue);
}
} catch (Exception e) {
throw new MigrationStepException("Fail to apply step. " + e.getMessage());
}
}
Aggregations