Search in sources :

Example 6 with Document

use of com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_02.Document 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;
}
Also used : Path(java.nio.file.Path) SAXBuilder(org.jdom2.input.SAXBuilder) MigrationStepException(com.mulesoft.tools.migration.exception.MigrationStepException) IOException(java.io.IOException) Document(org.jdom2.Document) JDOMException(org.jdom2.JDOMException)

Example 7 with Document

use of com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_02.Document in project mule-migration-assistant by mulesoft.

the class SpringConfigInMuleConfig method execute.

@Override
public void execute(Element object, MigrationReport report) throws RuntimeException {
    Document muleDocument = object.getDocument();
    Document springDocument = resolveSpringDocument(muleDocument);
    for (Element element : new ArrayList<>(object.getChildren())) {
        element.detach();
        springDocument.getRootElement().addContent(element);
        moveNamespacesDeclarations(muleDocument, element, springDocument);
    }
    object.detach();
}
Also used : Element(org.jdom2.Element) ArrayList(java.util.ArrayList) Document(org.jdom2.Document)

Example 8 with Document

use of com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_02.Document in project mule-migration-assistant by mulesoft.

the class DocumentHelper method getNodesFromFile.

public static void getNodesFromFile(String Xpath, AbstractApplicationModelMigrationStep step, String filePath) throws Exception {
    Document document = getDocument(filePath);
    List<Element> nodes = getElementsFromDocument(document, Xpath);
// step.setDocument(document);
// step.setNodes(nodes);
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document)

Example 9 with Document

use of com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_02.Document in project mule-migration-assistant by mulesoft.

the class ApikitMigrationTest method execute.

@Test
public void execute() throws Exception {
    Document doc = getDocument(this.getClass().getClassLoader().getResource(configPath.toString()).toURI().getPath());
    steps.forEach(step -> getElementsFromDocument(doc, ((AbstractApikitMigrationStep) step).getAppliedTo().getExpression()).forEach(node -> step.execute(node, mock(MigrationReport.class))));
    XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
    String xmlString = outputter.outputString(doc);
    assertThat(xmlString, isSimilarTo(IOUtils.toString(this.getClass().getClassLoader().getResource(targetPath.toString()).toURI(), UTF_8)).ignoreComments().normalizeWhitespace());
}
Also used : Mockito.doCallRealMethod(org.mockito.Mockito.doCallRealMethod) RunWith(org.junit.runner.RunWith) AbstractApikitMigrationStep(com.mulesoft.tools.migration.library.apikit.steps.AbstractApikitMigrationStep) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) Matchers.anyString(org.mockito.Matchers.anyString) Document(org.jdom2.Document) MigrationStep(com.mulesoft.tools.migration.step.MigrationStep) Namespace(org.jdom2.Namespace) URI(java.net.URI) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Path(java.nio.file.Path) Parameterized(org.junit.runners.Parameterized) Before(org.junit.Before) Format(org.jdom2.output.Format) Files(java.nio.file.Files) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Test(org.junit.Test) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) File(java.io.File) XMLOutputter(org.jdom2.output.XMLOutputter) Matchers.any(org.mockito.Matchers.any) IOUtils(org.apache.commons.io.IOUtils) DocumentHelper.getDocument(com.mulesoft.tools.migration.helper.DocumentHelper.getDocument) CompareMatcher.isSimilarTo(org.xmlunit.matchers.CompareMatcher.isSimilarTo) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) ApikitMigrationTask(com.mulesoft.tools.migration.library.apikit.tasks.ApikitMigrationTask) Paths(java.nio.file.Paths) DocumentHelper.getElementsFromDocument(com.mulesoft.tools.migration.helper.DocumentHelper.getElementsFromDocument) Mockito.mock(org.mockito.Mockito.mock) XMLOutputter(org.jdom2.output.XMLOutputter) MigrationReport(com.mulesoft.tools.migration.step.category.MigrationReport) AbstractApikitMigrationStep(com.mulesoft.tools.migration.library.apikit.steps.AbstractApikitMigrationStep) Matchers.anyString(org.mockito.Matchers.anyString) Document(org.jdom2.Document) DocumentHelper.getDocument(com.mulesoft.tools.migration.helper.DocumentHelper.getDocument) DocumentHelper.getElementsFromDocument(com.mulesoft.tools.migration.helper.DocumentHelper.getElementsFromDocument) Test(org.junit.Test)

Example 10 with Document

use of com.axelor.apps.bankpayment.xsd.sepa.pain_008_001_02.Document in project mule-migration-assistant by mulesoft.

the class AbstractFederationTestCase method getTestElement.

protected Element getTestElement() {
    Element testElement = new Element(VALIDATE_TAG_NAME, getTestElementNamespace()).setAttribute(TOKEN_URL_ATTR_NAME, TOKEN_URL_ATTR_VALUE).setAttribute(THROW_ON_UNACCEPTED_ATTR_NAME, TRUE).setAttribute(ON_UNACCEPTED, ON_UNACCEPTED_ATTR_VALUE);
    Element root = new Element(MULE_4_TAG_NAME, MULE_4_CORE_NAMESPACE_NO_PREFIX);
    root.addNamespaceDeclaration(MULE_4_POLICY_NAMESPACE);
    new Document().setRootElement(root.addContent(getProcessorChainElement()).addContent(testElement));
    return testElement;
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document)

Aggregations

Document (org.jdom2.Document)1034 Element (org.jdom2.Element)587 Test (org.junit.Test)340 SAXBuilder (org.jdom2.input.SAXBuilder)271 IOException (java.io.IOException)266 XMLOutputter (org.jdom2.output.XMLOutputter)182 JDOMException (org.jdom2.JDOMException)162 File (java.io.File)148 ArrayList (java.util.ArrayList)75 InputStream (java.io.InputStream)74 StringReader (java.io.StringReader)63 Path (java.nio.file.Path)59 HashMap (java.util.HashMap)57 DocumentHelper.getDocument (com.mulesoft.tools.migration.helper.DocumentHelper.getDocument)53 DocumentHelper.getElementsFromDocument (com.mulesoft.tools.migration.helper.DocumentHelper.getElementsFromDocument)53 MCRJDOMContent (org.mycore.common.content.MCRJDOMContent)48 PID (edu.unc.lib.boxc.model.api.ids.PID)47 Attribute (org.jdom2.Attribute)44 List (java.util.List)42 Namespace (org.jdom2.Namespace)39