Search in sources :

Example 1 with Dependency

use of com.mulesoft.tools.migration.project.model.pom.Dependency in project mule-migration-assistant by mulesoft.

the class AbstractJmsEndpoint method addActiveMqConnection.

private static Element addActiveMqConnection(final Element m4JmsConfig, final Element m3Connector, ApplicationModel appModel) {
    Dependency activeMqClient = new DependencyBuilder().withGroupId("org.apache.activemq").withArtifactId("activemq-client").withVersion("${activeMq.version}").build();
    addSharedLibs(appModel.getPomModel().get(), activeMqClient);
    Element amqConnection = new Element("active-mq-connection", JMS_NAMESPACE);
    m4JmsConfig.addContent(amqConnection);
    boolean addFactory = false;
    Element factoryConfiguration = new Element("factory-configuration", JMS_NAMESPACE);
    if (m3Connector.getAttribute("brokerURL") != null) {
        factoryConfiguration.setAttribute("brokerUrl", m3Connector.getAttributeValue("brokerURL"));
        addFactory = true;
    }
    if (m3Connector.getAttributeValue("maxRedelivery") != null) {
        factoryConfiguration.setAttribute("maxRedelivery", m3Connector.getAttributeValue("maxRedelivery"));
        addFactory = true;
    }
    if (addFactory) {
        amqConnection.addContent(factoryConfiguration);
    }
    return amqConnection;
}
Also used : DependencyBuilder(com.mulesoft.tools.migration.project.model.pom.Dependency.DependencyBuilder) XmlDslUtils.addTopLevelElement(com.mulesoft.tools.migration.step.util.XmlDslUtils.addTopLevelElement) Element(org.jdom2.Element) Dependency(com.mulesoft.tools.migration.project.model.pom.Dependency)

Example 2 with Dependency

use of com.mulesoft.tools.migration.project.model.pom.Dependency in project mule-migration-assistant by mulesoft.

the class ClientIdEnforcementPomContributionMigrationStepTestCase method pomContributionTest.

@Test
public void pomContributionTest() {
    PomModel pm = new PomModel();
    ClientIdEnforcementPomContributionMigrationStep step = new ClientIdEnforcementPomContributionMigrationStep();
    step.execute(pm, mock(MigrationReport.class));
    assertThat(pm.getDependencies().size(), is(1));
    Dependency clientIdEnforcementDependency = pm.getDependencies().get(0);
    assertThat(clientIdEnforcementDependency.getGroupId(), is(COM_MULESOFT_ANYPOINT_GROUP_ID));
    assertThat(clientIdEnforcementDependency.getArtifactId(), is(MULE_CLIENT_ID_ENFORCEMENT_EXTENSION_ARTIFACT_ID));
    assertThat(clientIdEnforcementDependency.getVersion(), is(notNullValue()));
    assertThat(clientIdEnforcementDependency.getClassifier(), is(MULE_PLUGIN_CLASSIFIER));
}
Also used : ClientIdEnforcementPomContributionMigrationStep(com.mulesoft.tools.migration.library.gateway.steps.policy.clientidenforcement.ClientIdEnforcementPomContributionMigrationStep) PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) Dependency(com.mulesoft.tools.migration.project.model.pom.Dependency) Test(org.junit.Test)

Example 3 with Dependency

use of com.mulesoft.tools.migration.project.model.pom.Dependency in project mule-migration-assistant by mulesoft.

the class MelToDwExpressionMigrator method translateSingleExpression.

public String translateSingleExpression(String unwrappedExpression, boolean dataWeaveBodyOnly, Element element, boolean enricher) {
    logger.debug("  --->> Evaluating MEL expression at element {} -> {}", element != null ? element.getName() : "null", unwrappedExpression);
    String migratedExpression;
    MigrationResult result;
    try {
        result = Migrator.migrate(unwrappedExpression);
        migratedExpression = result.getGeneratedCode();
    } catch (Exception e) {
        return compatibilityResolver.resolve(unwrappedExpression, element, report, model, this, enricher);
    }
    if (result.metadata().children().exists(a -> a instanceof NonMigratable)) {
        List<NonMigratable> metadata = (List<NonMigratable>) (List<?>) JavaConverters.seqAsJavaList(result.metadata().children()).stream().filter(a -> a instanceof NonMigratable).collect(toList());
        metadata.forEach(a -> report.report(a.reason(), element, element));
        return new DefaultMelCompatibilityResolver().resolve(unwrappedExpression, element, report, model, this, enricher);
    }
    if (migratedExpression.contains("message.inboundAttachments")) {
        report.report("message.expressionsAttachments", element, element);
    }
    if (result.metadata().children().exists(a -> a instanceof JavaModuleRequired)) {
        Dependency javaModuleDependency = new Dependency.DependencyBuilder().withGroupId("org.mule.module").withArtifactId("mule-java-module").withVersion(targetVersion("mule-java-module")).withClassifier("mule-plugin").build();
        model.getPomModel().ifPresent(m -> m.addDependency(javaModuleDependency));
    }
    migratedExpression = resolveServerContext(migratedExpression);
    migratedExpression = resolveIdentifiers(migratedExpression);
    if (dataWeaveBodyOnly) {
        migratedExpression = migratedExpression.replaceFirst("%dw 2\\.0\n---", "").trim();
    }
    report.melExpressionSuccess(unwrappedExpression);
    return escapeUnderscores(migratedExpression);
}
Also used : MelCompatibilityResolver(com.mulesoft.tools.migration.library.tools.mel.MelCompatibilityResolver) Arrays(java.util.Arrays) LoggerFactory(org.slf4j.LoggerFactory) StringUtils(org.apache.commons.lang3.StringUtils) Function(java.util.function.Function) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) StringUtils.join(org.apache.commons.lang3.StringUtils.join) ExpressionMigrator(com.mulesoft.tools.migration.util.ExpressionMigrator) Matcher(java.util.regex.Matcher) Objects.requireNonNull(java.util.Objects.requireNonNull) EMPTY(org.apache.commons.lang3.StringUtils.EMPTY) DefaultMelCompatibilityResolver(com.mulesoft.tools.migration.library.tools.mel.DefaultMelCompatibilityResolver) Logger(org.slf4j.Logger) com.mulesoft.tools(com.mulesoft.tools) PluginsVersions.targetVersion(com.mulesoft.tools.migration.library.tools.PluginsVersions.targetVersion) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Dependency(com.mulesoft.tools.migration.project.model.pom.Dependency) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) JavaConverters(scala.collection.JavaConverters) Pattern(java.util.regex.Pattern) XmlDslUtils.addCompatibilityNamespace(com.mulesoft.tools.migration.step.util.XmlDslUtils.addCompatibilityNamespace) Element(org.jdom2.Element) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) Dependency(com.mulesoft.tools.migration.project.model.pom.Dependency) DefaultMelCompatibilityResolver(com.mulesoft.tools.migration.library.tools.mel.DefaultMelCompatibilityResolver)

Example 4 with Dependency

use of com.mulesoft.tools.migration.project.model.pom.Dependency in project mule-migration-assistant by mulesoft.

the class FixedTimeAlgorithmMigrationStepTestCase method rateLimitPomContributionTest.

@Test
public void rateLimitPomContributionTest() throws Exception {
    FixedTimeFrameAlgorithmMigrationStep step = new FixedTimeFrameAlgorithmMigrationStep();
    step.setApplicationModel(appModel);
    Element element = createPolicy(1, FIXED_TIME_FRAME_ALGORITHM_TAG_NAME, false);
    step.execute(element, reportMock);
    PomModel pm = appModel.getPomModel().get();
    assertThat(pm.getDependencies().size(), is(2));
    Dependency policyTransformExtensionDependency = pm.getDependencies().get(1);
    assertThat(policyTransformExtensionDependency.getGroupId(), is(COM_MULESOFT_ANYPOINT_GROUP_ID));
    assertThat(policyTransformExtensionDependency.getArtifactId(), is(MULE_THROTTLING_EXTENSION_ARTIFACT_ID));
    assertThat(policyTransformExtensionDependency.getVersion(), is(notNullValue()));
    assertThat(policyTransformExtensionDependency.getClassifier(), is(MULE_PLUGIN_CLASSIFIER));
}
Also used : Element(org.jdom2.Element) PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) FixedTimeFrameAlgorithmMigrationStep(com.mulesoft.tools.migration.library.gateway.steps.policy.throttling.FixedTimeFrameAlgorithmMigrationStep) Dependency(com.mulesoft.tools.migration.project.model.pom.Dependency) Test(org.junit.Test)

Example 5 with Dependency

use of com.mulesoft.tools.migration.project.model.pom.Dependency in project mule-migration-assistant by mulesoft.

the class RamlValidatorPomContributionMigrationStepTestCase method pomContributionTestWithPreviousDependency.

@Test
public void pomContributionTestWithPreviousDependency() {
    PomModel pm = new PomModel();
    pm.addDependency(getRamlDependency());
    RamlValidatorPomContributionMigrationStep step = new RamlValidatorPomContributionMigrationStep();
    step.execute(pm, mock(MigrationReport.class));
    assertThat(pm.getDependencies().size(), is(1));
    Dependency httpPolicyTransformExtension = pm.getDependencies().get(0);
    assertThat(httpPolicyTransformExtension.getGroupId(), is(COM_MULESOFT_ANYPOINT_GROUP_ID));
    assertThat(httpPolicyTransformExtension.getArtifactId(), is(MULE_REST_VALIDATOR_EXTENSION));
    assertThat(httpPolicyTransformExtension.getVersion(), is(notNullValue()));
    assertThat(httpPolicyTransformExtension.getClassifier(), is(MULE_PLUGIN_CLASSIFIER));
}
Also used : PomModel(com.mulesoft.tools.migration.project.model.pom.PomModel) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) Dependency(com.mulesoft.tools.migration.project.model.pom.Dependency) Test(org.junit.Test)

Aggregations

Dependency (com.mulesoft.tools.migration.project.model.pom.Dependency)30 PomModel (com.mulesoft.tools.migration.project.model.pom.PomModel)24 Test (org.junit.Test)16 Element (org.jdom2.Element)10 MigrationReport (com.mulesoft.tools.migration.step.category.MigrationReport)6 DependencyBuilder (com.mulesoft.tools.migration.project.model.pom.Dependency.DependencyBuilder)2 com.mulesoft.tools (com.mulesoft.tools)1 ClientIdEnforcementPomContributionMigrationStep (com.mulesoft.tools.migration.library.gateway.steps.policy.clientidenforcement.ClientIdEnforcementPomContributionMigrationStep)1 FederationPomContributionMigrationStep (com.mulesoft.tools.migration.library.gateway.steps.policy.federation.FederationPomContributionMigrationStep)1 IpFilterPomContributionMigrationStep (com.mulesoft.tools.migration.library.gateway.steps.policy.ipfilter.IpFilterPomContributionMigrationStep)1 HttpTransformPomContributionMigrationStep (com.mulesoft.tools.migration.library.gateway.steps.policy.mule.HttpTransformPomContributionMigrationStep)1 SetPropertyMigrationStep (com.mulesoft.tools.migration.library.gateway.steps.policy.mule.SetPropertyMigrationStep)1 JsonPolicyTagMigrationStep (com.mulesoft.tools.migration.library.gateway.steps.policy.threatprotection.JsonPolicyTagMigrationStep)1 XmlPolicyTagMigrationStep (com.mulesoft.tools.migration.library.gateway.steps.policy.threatprotection.XmlPolicyTagMigrationStep)1 FixedTimeFrameAlgorithmMigrationStep (com.mulesoft.tools.migration.library.gateway.steps.policy.throttling.FixedTimeFrameAlgorithmMigrationStep)1 SlaBasedAlgorithmMigrationStep (com.mulesoft.tools.migration.library.gateway.steps.policy.throttling.SlaBasedAlgorithmMigrationStep)1 PluginsVersions.targetVersion (com.mulesoft.tools.migration.library.tools.PluginsVersions.targetVersion)1 DefaultMelCompatibilityResolver (com.mulesoft.tools.migration.library.tools.mel.DefaultMelCompatibilityResolver)1 MelCompatibilityResolver (com.mulesoft.tools.migration.library.tools.mel.MelCompatibilityResolver)1 ApplicationModel (com.mulesoft.tools.migration.project.model.ApplicationModel)1