Search in sources :

Example 6 with ApplicationModelBuilder

use of com.mulesoft.tools.migration.project.model.ApplicationModel.ApplicationModelBuilder in project mule-migration-assistant by mulesoft.

the class SecurePropertiesTest method execute.

@Test
public void execute() throws Exception {
    Path resolvedConfigPath = Paths.get(this.getClass().getClassLoader().getResource(configPath.toString()).toURI());
    ApplicationModel appModel = new ApplicationModelBuilder().withProjectBasePath(Paths.get(this.getClass().getClassLoader().getResource(SECURE_PROPS_EXAMPLES_PATH.toString()).toURI())).withConfigurationFiles(asList(resolvedConfigPath)).withMuleVersion(muleVersion).withProjectType(MULE_FOUR_APPLICATION).build();
    Document doc = appModel.getApplicationDocuments().get(configPath.getFileName());
    securePropertiesPlaceholder.setApplicationModel(appModel);
    getElementsFromDocument(doc, securePropertiesPlaceholder.getAppliedTo().getExpression()).forEach(node -> securePropertiesPlaceholder.execute(node, report.getReport()));
    XMLOutputter muleOutputter = new XMLOutputter(Format.getPrettyFormat());
    String muleXmlString = muleOutputter.outputString(doc);
    assertThat(muleXmlString, isSimilarTo(IOUtils.toString(this.getClass().getClassLoader().getResource(targetMulePath.toString()).toURI(), UTF_8)).ignoreComments().normalizeWhitespace());
}
Also used : Path(java.nio.file.Path) XMLOutputter(org.jdom2.output.XMLOutputter) ApplicationModelBuilder(com.mulesoft.tools.migration.project.model.ApplicationModel.ApplicationModelBuilder) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) Document(org.jdom2.Document) DocumentHelper.getElementsFromDocument(com.mulesoft.tools.migration.helper.DocumentHelper.getElementsFromDocument) Test(org.junit.Test)

Aggregations

ApplicationModelBuilder (com.mulesoft.tools.migration.project.model.ApplicationModel.ApplicationModelBuilder)6 Test (org.junit.Test)5 Document (org.jdom2.Document)4 DocumentHelper.getElementsFromDocument (com.mulesoft.tools.migration.helper.DocumentHelper.getElementsFromDocument)3 ApplicationModel (com.mulesoft.tools.migration.project.model.ApplicationModel)3 Path (java.nio.file.Path)3 XMLOutputter (org.jdom2.output.XMLOutputter)3 MuleProjectFactory.getMuleProject (com.mulesoft.tools.migration.engine.project.MuleProjectFactory.getMuleProject)1 ProjectTypeFactory (com.mulesoft.tools.migration.engine.project.ProjectTypeFactory)1 MuleProject (com.mulesoft.tools.migration.engine.project.structure.mule.MuleProject)1 ProjectType (com.mulesoft.tools.migration.project.ProjectType)1 Element (org.jdom2.Element)1 Namespace (org.jdom2.Namespace)1