use of com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep in project mule-migration-assistant by mulesoft.
the class ProxyMigrationTaskTestCase method execute.
@Test
public void execute() throws Exception {
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
steps.forEach(step -> migrate((AbstractApplicationModelMigrationStep) step));
String xmlString = outputter.outputString(doc);
assertThat(xmlString, isSimilarTo(IOUtils.toString(this.getClass().getClassLoader().getResource(targetPath.toString()).toURI(), UTF_8)).ignoreComments().normalizeWhitespace());
PomModel pm = appModel.getPomModel().get();
String filename = configPath.toFile().getName();
if (filename.equals("wsdl-mule3.xml")) {
assertThat(pm.getDependencies().size(), is(3));
assertWsdlDependency(pm, 2);
} else if (filename.equals("custom-processor-mule3.xml")) {
assertThat(pm.getDependencies().size(), is(3));
assertCustomProcessorDependency(pm);
} else {
assertThat(pm.getDependencies().size(), is(4));
assertCustomProcessorDependency(pm);
assertWsdlDependency(pm, 3);
}
}
use of com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep in project mule-migration-assistant by mulesoft.
the class InboundEndpoint method execute.
@Override
public void execute(Element object, MigrationReport report) throws RuntimeException {
object.getChildren("property", CORE_NAMESPACE).forEach(p -> {
object.setAttribute(p.getAttributeValue("key"), p.getAttributeValue("value"));
});
object.removeChildren("property", CORE_NAMESPACE);
addMigrationAttributeToElement(object, new Attribute("isMessageSource", "true"));
AbstractApplicationModelMigrationStep migrator = null;
if (object.getAttribute("address") != null) {
String address = object.getAttributeValue("address");
// TODO MMT-132 make available migrators discoverable
if (address.startsWith("file://")) {
migrator = new FileInboundEndpoint();
object.setNamespace(Namespace.getNamespace(FILE_NS_PREFIX, FILE_NS_URI));
} else if (address.startsWith("ftp://")) {
migrator = new FtpEeInboundEndpoint();
object.setNamespace(Namespace.getNamespace(FTP_NS_PREFIX, FTP_NS_URI));
} else if (address.startsWith("sftp://")) {
migrator = new SftpInboundEndpoint();
object.setNamespace(Namespace.getNamespace(SFTP_NS_PREFIX, SFTP_NS_URI));
} else if (address.startsWith("http://")) {
migrator = new HttpInboundEndpoint();
object.setNamespace(Namespace.getNamespace(HTTP_NS_PREFIX, HTTP_NS_URI));
} else if (address.startsWith("https://")) {
migrator = new HttpsInboundEndpoint();
object.setNamespace(Namespace.getNamespace("https", "http://www.mulesoft.org/schema/mule/https"));
} else if (address.startsWith("imap://")) {
migrator = new ImapInboundEndpoint();
object.setNamespace(Namespace.getNamespace("imap", "http://www.mulesoft.org/schema/mule/imap"));
} else if (address.startsWith("imaps://")) {
migrator = new ImapsInboundEndpoint();
object.setNamespace(Namespace.getNamespace("imaps", "http://www.mulesoft.org/schema/mule/imaps"));
} else if (address.startsWith("pop3://")) {
migrator = new Pop3InboundEndpoint();
object.setNamespace(Namespace.getNamespace("pop3", "http://www.mulesoft.org/schema/mule/pop3"));
} else if (address.startsWith("pop3s://")) {
migrator = new Pop3sInboundEndpoint();
object.setNamespace(Namespace.getNamespace("pop3s", "http://www.mulesoft.org/schema/mule/pop3s"));
} else if (address.startsWith("jms://")) {
migrator = new JmsInboundEndpoint();
object.setNamespace(Namespace.getNamespace(JMS_NS_PREFIX, JMS_NS_URI));
} else if (address.startsWith("vm://")) {
migrator = new VmInboundEndpoint();
object.setNamespace(Namespace.getNamespace(VM_NS_PREFIX, VM_NS_URI));
}
if (migrator != null) {
migrator.setApplicationModel(getApplicationModel());
if (migrator instanceof ExpressionMigratorAware) {
((ExpressionMigratorAware) migrator).setExpressionMigrator(getExpressionMigrator());
}
migrator.execute(object, report);
}
object.removeAttribute("address");
} else if (object.getAttribute("ref") != null) {
Element globalEndpoint = getApplicationModel().getNode("/*/*[@name = '" + object.getAttributeValue("ref") + "']");
// TODO MMT-132 make available migrators discoverable
if (globalEndpoint.getAttribute("address") != null) {
String address = globalEndpoint.getAttributeValue("address");
if (address.startsWith("file://")) {
migrator = new FileInboundEndpoint();
object.setNamespace(Namespace.getNamespace(FILE_NS_PREFIX, FILE_NS_URI));
} else if (address.startsWith("ftp://")) {
migrator = new FtpEeInboundEndpoint();
object.setNamespace(Namespace.getNamespace(FTP_NS_PREFIX, FTP_NS_URI));
} else if (address.startsWith("sftp://")) {
migrator = new SftpInboundEndpoint();
object.setNamespace(Namespace.getNamespace(SFTP_NS_PREFIX, SFTP_NS_URI));
} else if (address.startsWith("http://")) {
migrator = new HttpInboundEndpoint();
object.setNamespace(Namespace.getNamespace(HTTP_NS_PREFIX, HTTP_NS_URI));
} else if (address.startsWith("https://")) {
migrator = new HttpsInboundEndpoint();
object.setNamespace(Namespace.getNamespace("https", "http://www.mulesoft.org/schema/mule/https"));
} else if (address.startsWith("imap://")) {
migrator = new ImapInboundEndpoint();
object.setNamespace(Namespace.getNamespace("imap", "http://www.mulesoft.org/schema/mule/imap"));
} else if (address.startsWith("imaps://")) {
migrator = new ImapsInboundEndpoint();
object.setNamespace(Namespace.getNamespace("imaps", "http://www.mulesoft.org/schema/mule/imaps"));
} else if (address.startsWith("pop3://")) {
migrator = new Pop3InboundEndpoint();
object.setNamespace(Namespace.getNamespace("pop3", "http://www.mulesoft.org/schema/mule/pop3"));
} else if (address.startsWith("pop3s://")) {
migrator = new Pop3sInboundEndpoint();
object.setNamespace(Namespace.getNamespace("pop3s", "http://www.mulesoft.org/schema/mule/pop3s"));
} else if (address.startsWith("jms://")) {
migrator = new JmsInboundEndpoint();
object.setNamespace(Namespace.getNamespace(JMS_NS_PREFIX, JMS_NS_URI));
} else if (address.startsWith("vm://")) {
migrator = new VmInboundEndpoint();
object.setNamespace(Namespace.getNamespace(VM_NS_PREFIX, VM_NS_URI));
}
if (migrator != null) {
migrator.setApplicationModel(getApplicationModel());
if (migrator instanceof ExpressionMigratorAware) {
((ExpressionMigratorAware) migrator).setExpressionMigrator(getExpressionMigrator());
}
for (Attribute attribute : globalEndpoint.getAttributes()) {
if (object.getAttribute(attribute.getName()) == null) {
object.setAttribute(attribute.getName(), attribute.getValue());
}
}
migrator.execute(object, report);
}
}
}
if (object.getAttribute("exchange-pattern") != null) {
object.removeAttribute("exchange-pattern");
}
}
use of com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep in project mule-migration-assistant by mulesoft.
the class ProxyMigrationTaskTestCase method setUp.
@Before
public void setUp() throws Exception {
ApplicationModel.ApplicationModelBuilder amb = new ApplicationModel.ApplicationModelBuilder();
amb.withProjectType(ProjectType.MULE_THREE_POLICY);
amb.withProjectBasePath(APPLICATION_MODEL_PATH);
amb.withPom(POM_PATH);
appModel = amb.build();
doc = getDocument(this.getClass().getClassLoader().getResource(configPath.toString()).toURI().getPath());
ProxyMigrationTask task = new ProxyMigrationTask();
task.setApplicationModel(appModel);
steps = task.getSteps().stream().filter(step -> step instanceof AbstractApplicationModelMigrationStep).collect(toList());
}
use of com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep in project mule-migration-assistant by mulesoft.
the class ThrottlingPolicyMigrationTestCase method setUp.
@Before
public void setUp() throws Exception {
ApplicationModel.ApplicationModelBuilder amb = new ApplicationModel.ApplicationModelBuilder();
amb.withProjectType(ProjectType.MULE_THREE_POLICY);
amb.withProjectBasePath(POLICY_APPLICATION_MODEL_PATH);
amb.withPom(pomPath);
appModel = amb.build();
doc = getDocument(this.getClass().getClassLoader().getResource(configPath.toString()).toURI().getPath());
ThrottlingMigrationTask throttlingMigrationTask = new ThrottlingMigrationTask();
throttlingMigrationTask.setApplicationModel(appModel);
steps = throttlingMigrationTask.getSteps().stream().filter(step -> step instanceof AbstractApplicationModelMigrationStep).collect(toList());
BasicStructureMigrationTask basicStructureTask = new BasicStructureMigrationTask();
basicStructureTask.setApplicationModel(appModel);
List<MigrationStep> basicStructureSteps = basicStructureTask.getSteps().stream().filter(step -> step instanceof AbstractApplicationModelMigrationStep).collect(toList());
steps.addAll(basicStructureSteps);
}
use of com.mulesoft.tools.migration.step.AbstractApplicationModelMigrationStep in project mule-migration-assistant by mulesoft.
the class FederationPolicyMigrationTestCase method execute.
@Test
public void execute() throws Exception {
XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
steps.forEach(step -> migrate((AbstractApplicationModelMigrationStep) step));
String xmlString = outputter.outputString(doc);
assertThat(xmlString, isSimilarTo(IOUtils.toString(this.getClass().getClassLoader().getResource(targetPath.toString()).toURI(), UTF_8)).ignoreComments().normalizeWhitespace());
}
Aggregations