-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95e5eb5
commit a1b7dcb
Showing
16 changed files
with
389 additions
and
28 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...main/java/com/mulesoft/tools/migration/step/AbstractUnsupportedElementsMigrationStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2020, Mulesoft, LLC. All rights reserved. | ||
* Use of this source code is governed by a BSD 3-Clause License | ||
* license that can be found in the LICENSE.txt file. | ||
*/ | ||
package com.mulesoft.tools.migration.step; | ||
|
||
import com.mulesoft.tools.migration.step.category.MigrationReport; | ||
import com.mulesoft.tools.migration.step.util.XmlDslUtils; | ||
import org.jdom2.Element; | ||
import org.jdom2.Namespace; | ||
|
||
import java.util.List; | ||
|
||
import static com.google.common.base.Preconditions.checkArgument; | ||
import static com.google.common.collect.Lists.newArrayList; | ||
|
||
/** | ||
* Takes unsupported or blocked elements and comments them, mark them as failed | ||
* | ||
* @author Mulesoft Inc. | ||
* @since 1.0.0 | ||
*/ | ||
public abstract class AbstractUnsupportedElementsMigrationStep extends AbstractApplicationModelMigrationStep { | ||
|
||
public static final String COMPONENTS_UNSUPPORTED_ERROR_KEY = "components.unsupported"; | ||
public static final String NAME_ATTRIBUTE_TEMPLATE = "(name = %s)"; | ||
|
||
public AbstractUnsupportedElementsMigrationStep(Namespace namespace) { | ||
checkArgument(getUnsupportedElements() != null, "The unsupported elements list must not be null."); | ||
this.setAppliedTo(XmlDslUtils.getAllElementsFromNamespaceXpathSelector(namespace.getURI(), getUnsupportedElements(), false)); | ||
this.setNamespacesContributions(newArrayList(namespace)); | ||
} | ||
|
||
public abstract List<String> getUnsupportedElements(); | ||
|
||
@Override | ||
public void execute(Element node, MigrationReport report) throws RuntimeException { | ||
if (getUnsupportedElements().contains(node.getName())) { | ||
report.report(COMPONENTS_UNSUPPORTED_ERROR_KEY, node, node, | ||
report.getComponentKey(node) + " " + String.format(NAME_ATTRIBUTE_TEMPLATE, node.getAttributeValue("name"))); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
.../java/com/mulesoft/tools/migration/step/AbstractUnsupportedElementsMigrationStepTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright (c) 2020, Mulesoft, LLC. All rights reserved. | ||
* Use of this source code is governed by a BSD 3-Clause License | ||
* license that can be found in the LICENSE.txt file. | ||
*/ | ||
package com.mulesoft.tools.migration.step; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.mulesoft.tools.migration.step.category.MigrationReport; | ||
import org.jdom2.Element; | ||
import org.jdom2.Namespace; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.util.List; | ||
|
||
import static com.mulesoft.tools.migration.step.AbstractUnsupportedElementsMigrationStep.COMPONENTS_UNSUPPORTED_ERROR_KEY; | ||
import static org.mockito.ArgumentMatchers.eq; | ||
import static org.mockito.ArgumentMatchers.isA; | ||
import static org.mockito.Mockito.*; | ||
import static org.powermock.api.mockito.PowerMockito.when; | ||
|
||
/** | ||
* @author Mulesoft Inc. | ||
*/ | ||
public class AbstractUnsupportedElementsMigrationStepTest { | ||
|
||
public static final Namespace TEST_NAMESPACE = Namespace.getNamespace("test", "http://test.com"); | ||
|
||
private AbstractUnsupportedElementsMigrationStep migrationStep; | ||
private Element elementMock; | ||
private Element parentElementMock; | ||
private MigrationReport reportMock; | ||
private static final String BLOCKED_ELEMENT_NAME = "blocked"; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
migrationStep = new AbstractUnsupportedElementsMigrationStepTest.MigrationStepImpl(); | ||
elementMock = mock(Element.class); | ||
parentElementMock = mock(Element.class); | ||
when(elementMock.getName()).thenReturn(BLOCKED_ELEMENT_NAME); | ||
when(elementMock.getParentElement()).thenReturn(parentElementMock); | ||
when(elementMock.getNamespace()).thenReturn(TEST_NAMESPACE); | ||
reportMock = mock(MigrationReport.class); | ||
when(reportMock.getComponentKey(elementMock)).thenReturn(BLOCKED_ELEMENT_NAME); | ||
} | ||
|
||
@Test | ||
public void testExecute_handleUnsupported() { | ||
migrationStep.execute(elementMock, reportMock); | ||
verify(reportMock).report(eq(COMPONENTS_UNSUPPORTED_ERROR_KEY), eq(elementMock), eq(elementMock), isA(String.class)); | ||
} | ||
|
||
@Test | ||
public void testExecute_handleAllSupported() { | ||
when(elementMock.getName()).thenReturn("another_supported_element"); | ||
migrationStep.execute(elementMock, reportMock); | ||
verifyZeroInteractions(reportMock); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testExecute_NullUnsupportedList() { | ||
new AbstractUnsupportedElementsMigrationStep(TEST_NAMESPACE) { | ||
|
||
@Override | ||
public List<String> getUnsupportedElements() { | ||
return null; | ||
} | ||
}.execute(elementMock, reportMock); | ||
} | ||
|
||
private static final class MigrationStepImpl extends AbstractUnsupportedElementsMigrationStep { | ||
|
||
public MigrationStepImpl() { | ||
super(TEST_NAMESPACE); | ||
} | ||
|
||
@Override | ||
public List<String> getUnsupportedElements() { | ||
return ImmutableList.of(BLOCKED_ELEMENT_NAME); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...t/resources/e2e/gaps/salesforce_config_oauth_user_pass/input/src/main/app/mule-config.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<mule xmlns="http://www.mulesoft.org/schema/mule/core" | ||
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" | ||
xmlns:sfdc="http://www.mulesoft.org/schema/mule/sfdc" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd"> | ||
<sfdc:config-oauth-user-pass name="Salesforce__Basic_Authentication" | ||
consumerKey="${cbms.sfdc.consumerkey}" consumerSecret="${cbms.sfdc.consumersecret}" | ||
username="${cbms.sfdc.username}" password="${cbms.sfdc.password}" | ||
securityToken="${cbms.sfdc.securitytoken}" tokenEndpoint="${cbms.sfdc.authurl}" | ||
doc:name="ct_salesforce" readTimeout="${cbms.sfdc.read.timeout}" | ||
disableSessionInvalidation="true"> | ||
<reconnect count="${cbms.sfdc.reconnect.attemptcount}" | ||
frequency="${cbms.sfdc.reconnect.frequency}" /> | ||
</sfdc:config-oauth-user-pass> | ||
|
||
<sfdc:config-oauth-user-pass name="Salesforce__Basic_Authentication2" | ||
consumerKey="${cbms.sfdc.consumerkey}" consumerSecret="${cbms.sfdc.consumersecret}" | ||
username="${cbms.sfdc.username}" password="${cbms.sfdc.password}" | ||
securityToken="${cbms.sfdc.securitytoken}" tokenEndpoint="${cbms.sfdc.authurl}" | ||
doc:name="ct_salesforce" readTimeout="${cbms.sfdc.read.timeout}" | ||
disableSessionInvalidation="true"> | ||
<reconnect count="${cbms.sfdc.reconnect.attemptcount}" | ||
frequency="${cbms.sfdc.reconnect.frequency}" /> | ||
</sfdc:config-oauth-user-pass> | ||
</mule> |
57 changes: 57 additions & 0 deletions
57
...ol-e2e-tests/src/test/resources/e2e/gaps/salesforce_config_oauth_user_pass/output/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.mule.migrated</groupId> | ||
<artifactId>salesforce_config_oauth_user_pass</artifactId> | ||
<version>1.0.0-M4-SNAPSHOT</version> | ||
<packaging>mule-application</packaging> | ||
<description>Application migrated with MMA</description> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.mulesoft.mule.modules</groupId> | ||
<artifactId>mule-compatibility-module</artifactId> | ||
<version>1.4.0</version> | ||
<classifier>mule-plugin</classifier> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.mulesoft.connectors</groupId> | ||
<artifactId>mule-salesforce-connector</artifactId> | ||
<version>10.14.0</version> | ||
<classifier>mule-plugin</classifier> | ||
</dependency> | ||
</dependencies> | ||
<repositories> | ||
<repository> | ||
<id>mulesoft-releases</id> | ||
<name>MuleSoft Releases Repository</name> | ||
<url>https://repository.mulesoft.org/releases/</url> | ||
</repository> | ||
<repository> | ||
<id>anypoint-exchange</id> | ||
<name>Anypoint Exchange</name> | ||
<url>https://maven.anypoint.mulesoft.com/api/v1/maven</url> | ||
</repository> | ||
</repositories> | ||
<pluginRepositories> | ||
<pluginRepository> | ||
<snapshots> | ||
<enabled>true</enabled> | ||
</snapshots> | ||
<id>mulesoft-releases</id> | ||
<name>MuleSoft Releases Repository</name> | ||
<url>https://repository.mulesoft.org/releases/</url> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.mule.tools.maven</groupId> | ||
<artifactId>mule-maven-plugin</artifactId> | ||
<version>3.2.1</version> | ||
<extensions>true</extensions> | ||
<configuration /> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
56 changes: 56 additions & 0 deletions
56
...s/src/test/resources/e2e/gaps/salesforce_config_oauth_user_pass/output/report/report.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
"projectType": "MULE_THREE_APPLICATION", | ||
"projectName": "input", | ||
"connectorsMigrated": | ||
[ | ||
"com.mulesoft.connectors:mule-salesforce-connector:VERSION" | ||
], | ||
"numberOfMuleComponents": 3, | ||
"numberOfMuleComponentsMigrated": 1, | ||
"componentDetails": | ||
{ | ||
"mule": | ||
{ | ||
"success": 1, | ||
"failure": 0 | ||
}, | ||
"sfdc:config-oauth-user-pass": | ||
{ | ||
"success": 0, | ||
"failure": 2 | ||
} | ||
}, | ||
"numberOfMELExpressions": 0, | ||
"numberOfMELExpressionsMigrated": 0, | ||
"numberOfMELExpressionLines": 0, | ||
"numberOfMELExpressionLinesMigrated": 0, | ||
"numberOfDWTransformations": 0, | ||
"numberOfDWTransformationsMigrated": 0, | ||
"numberOfDWTransformationLines": 0, | ||
"numberOfDWTransformationLinesMigrated": 0, | ||
"detailedMessages": | ||
[ | ||
{ | ||
"level": "ERROR", | ||
"key": "components.unsupported", | ||
"component": "sfdc:config-oauth-user-pass", | ||
"lineNumber": 4, | ||
"columnNumber": 403, | ||
"message": "The migration of 'sfdc:config-oauth-user-pass (name = Salesforce__Basic_Authentication)' is not supported.", | ||
"filePath": "src/main/mule/mule-config.xml", | ||
"documentationLinks": | ||
[] | ||
}, | ||
{ | ||
"level": "ERROR", | ||
"key": "components.unsupported", | ||
"component": "sfdc:config-oauth-user-pass", | ||
"lineNumber": 12, | ||
"columnNumber": 404, | ||
"message": "The migration of 'sfdc:config-oauth-user-pass (name = Salesforce__Basic_Authentication2)' is not supported.", | ||
"filePath": "src/main/mule/mule-config.xml", | ||
"documentationLinks": | ||
[] | ||
} | ||
] | ||
} |
19 changes: 19 additions & 0 deletions
19
...resources/e2e/gaps/salesforce_config_oauth_user_pass/output/src/main/mule/mule-config.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd"> | ||
|
||
<!--Migration ERROR: The migration of 'sfdc:config-oauth-user-pass' (name Salesforce__Basic_Authentication) is not supported.--> | ||
<!-- For more information refer to:--> | ||
<!-- * https://docs.mulesoft.com/mule-runtime/4.3/migration-connectors--> | ||
<!-- * https://github.com/mulesoft/mule-migration-assistant/blob/master/docs/user-docs/migration-tool.adoc#unsupported_connectors--> | ||
<sfdc:config-oauth-user-pass xmlns:sfdc="http://www.mulesoft.org/schema/mule/sfdc" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" name="Salesforce__Basic_Authentication" consumerKey="${cbms.sfdc.consumerkey}" consumerSecret="${cbms.sfdc.consumersecret}" username="${cbms.sfdc.username}" password="${cbms.sfdc.password}" securityToken="${cbms.sfdc.securitytoken}" tokenEndpoint="${cbms.sfdc.authurl}" doc:name="ct_salesforce" readTimeout="${cbms.sfdc.read.timeout}" disableSessionInvalidation="true"> | ||
<reconnect xmlns="http://www.mulesoft.org/schema/mule/core" count="${cbms.sfdc.reconnect.attemptcount}" frequency="${cbms.sfdc.reconnect.frequency}" /> | ||
</sfdc:config-oauth-user-pass> | ||
|
||
<!--Migration ERROR: The migration of 'sfdc:config-oauth-user-pass' (name Salesforce__Basic_Authentication2) is not supported.--> | ||
<!-- For more information refer to:--> | ||
<!-- * https://docs.mulesoft.com/mule-runtime/4.3/migration-connectors--> | ||
<!-- * https://github.com/mulesoft/mule-migration-assistant/blob/master/docs/user-docs/migration-tool.adoc#unsupported_connectors--> | ||
<sfdc:config-oauth-user-pass xmlns:sfdc="http://www.mulesoft.org/schema/mule/sfdc" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" name="Salesforce__Basic_Authentication2" consumerKey="${cbms.sfdc.consumerkey}" consumerSecret="${cbms.sfdc.consumersecret}" username="${cbms.sfdc.username}" password="${cbms.sfdc.password}" securityToken="${cbms.sfdc.securitytoken}" tokenEndpoint="${cbms.sfdc.authurl}" doc:name="ct_salesforce" readTimeout="${cbms.sfdc.read.timeout}" disableSessionInvalidation="true"> | ||
<reconnect xmlns="http://www.mulesoft.org/schema/mule/core" count="${cbms.sfdc.reconnect.attemptcount}" frequency="${cbms.sfdc.reconnect.frequency}" /> | ||
</sfdc:config-oauth-user-pass> | ||
</mule> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 7 additions & 8 deletions
15
...2e-tests/src/test/resources/e2e/gaps/unknown_element/output/src/main/mule/mule-config.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd"> | ||
<mule xmlns="http://www.mulesoft.org/schema/mule/core" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd"> | ||
|
||
<flow name="unknown-elements"> | ||
<unknown-source> | ||
<logger message="nested" /> | ||
<unknown-nested /> | ||
<logger message="nested"/> | ||
<unknown-nested/> | ||
</unknown-source> | ||
|
||
<logger message="bye" /> | ||
|
||
<unknown-operation /> | ||
|
||
<logger message="bye"/> | ||
<unknown-operation/> | ||
</flow> | ||
|
||
</mule> |
Oops, something went wrong.