Search in sources :

Example 81 with Document

use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.Document in project Squid by CIRDLES.

the class PhysicalConstantsModelXMLConverterTest method testPhysicalConstantsXMLConverter.

@Test
public void testPhysicalConstantsXMLConverter() {
    try {
        ResourceExtractor extractor = new ResourceExtractor(PhysicalConstantsModel.class);
        File initialFile = extractor.extractResourceAsFile("EARTHTIME Physical Constants Model v.1.1.xml");
        PhysicalConstantsModel model = (PhysicalConstantsModel) (new PhysicalConstantsModel()).readXMLObject(initialFile.getAbsolutePath(), false);
        File convertedFile = new File("physicalConstantsCopy.xml");
        model.serializeXMLObject(convertedFile.getAbsolutePath());
        model = (PhysicalConstantsModel) model.readXMLObject(convertedFile.getAbsolutePath(), false);
        File convertedConvertedFile = new File("physicalConstantsCopyOfCopy.xml");
        model.serializeXMLObject(convertedConvertedFile.getAbsolutePath());
        SAXBuilder builder = new SAXBuilder();
        Document doc = builder.build(convertedFile);
        Element initialElement = doc.getRootElement();
        doc = builder.build(convertedConvertedFile);
        Element convertedElement = doc.getRootElement();
        convertedFile.delete();
        convertedConvertedFile.delete();
        assertTrue(ElementComparer.compareElements(initialElement, convertedElement));
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) PhysicalConstantsModel(org.cirdles.squid.parameters.parameterModels.physicalConstantsModels.PhysicalConstantsModel) Element(org.jdom2.Element) Document(org.jdom2.Document) File(java.io.File) ResourceExtractor(org.cirdles.commons.util.ResourceExtractor) Test(org.junit.Test)

Example 82 with Document

use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.Document in project Squid by CIRDLES.

the class ReferenceMaterialXMlConverterTest method testReferenceMaterialXMLConverter.

@Test
public void testReferenceMaterialXMLConverter() {
    try {
        ResourceExtractor extractor = new ResourceExtractor(ReferenceMaterialModel.class);
        File initialFile = extractor.extractResourceAsFile("z6266 ID-TIMS (559.0 Ma) v.1.0.xml");
        ParametersModel model = (ReferenceMaterialModel) (new ReferenceMaterialModel()).readXMLObject(initialFile.getAbsolutePath(), false);
        File convertedFile = new File("zirconCopy.xml");
        model.serializeXMLObject(convertedFile.getAbsolutePath());
        model = (ReferenceMaterialModel) model.readXMLObject(convertedFile.getAbsolutePath(), false);
        File convertedConvertedFile = new File("zirconCopyOfCopy.xml");
        model.serializeXMLObject(convertedConvertedFile.getAbsolutePath());
        SAXBuilder builder = new SAXBuilder();
        Document doc = builder.build(convertedFile);
        Element initialElement = doc.getRootElement();
        doc = builder.build(convertedConvertedFile);
        Element convertedElement = doc.getRootElement();
        convertedFile.delete();
        convertedConvertedFile.delete();
        assertTrue(ElementComparer.compareElements(initialElement, convertedElement));
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : ReferenceMaterialModel(org.cirdles.squid.parameters.parameterModels.referenceMaterialModels.ReferenceMaterialModel) SAXBuilder(org.jdom2.input.SAXBuilder) ParametersModel(org.cirdles.squid.parameters.parameterModels.ParametersModel) Element(org.jdom2.Element) Document(org.jdom2.Document) File(java.io.File) ResourceExtractor(org.cirdles.commons.util.ResourceExtractor) Test(org.junit.Test)

Example 83 with Document

use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.Document in project sscs-evidence-share by hmcts.

the class SendLetterServiceConsumerTest method buildLetter.

private LetterV3 buildLetter() throws IOException, URISyntaxException {
    Path pdfPath = Paths.get(ClassLoader.getSystemResource("files/myPdf.pdf").toURI());
    byte[] pdf = Files.readAllBytes(pdfPath);
    String response = Base64.getEncoder().encodeToString(pdf);
    Map<String, Object> additionalData = new HashMap<>();
    additionalData.put(ADDITIONAL_DATA_CASE_REFERENCE, "123421323");
    return new LetterV3(XEROX_TYPE_PARAMETER, Arrays.asList(new Document(response, 2)), additionalData);
}
Also used : Path(java.nio.file.Path) LetterV3(uk.gov.hmcts.reform.sendletter.api.model.v3.LetterV3) HashMap(java.util.HashMap) Document(uk.gov.hmcts.reform.sendletter.api.model.v3.Document)

Example 84 with Document

use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.Document in project maven-release by apache.

the class JDomBuildTest method testGetPlugins.

@Test
public void testGetPlugins() throws Exception {
    String content = "<build></build>";
    Document document = builder.build(new StringReader(content));
    assertNotNull(new JDomBuild(document.getRootElement()).getPlugins());
    assertEquals(0, new JDomBuild(document.getRootElement()).getPlugins().size());
    content = "<build><plugins/></build>";
    document = builder.build(new StringReader(content));
    assertEquals(0, new JDomBuild(document.getRootElement()).getPlugins().size());
    content = "<build><plugins><plugin/></plugins></build>";
    document = builder.build(new StringReader(content));
    assertEquals(1, new JDomBuild(document.getRootElement()).getPlugins().size());
}
Also used : StringReader(java.io.StringReader) Document(org.jdom2.Document) Test(org.junit.Test)

Example 85 with Document

use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.Document in project maven-release by apache.

the class JDomDependencyManagementTest method testGetDependencies.

@Test
public void testGetDependencies() throws Exception {
    String content = "<dependencyManamgement></dependencyManamgement>";
    Document document = builder.build(new StringReader(content));
    assertNotNull(new JDomDependencyManagement(document.getRootElement()).getDependencies());
    assertEquals(0, new JDomDependencyManagement(document.getRootElement()).getDependencies().size());
    content = "<dependencyManamgement><dependencies/></dependencyManamgement>";
    document = builder.build(new StringReader(content));
    assertEquals(0, new JDomDependencyManagement(document.getRootElement()).getDependencies().size());
    content = "<dependencyManamgement><dependencies><dependency/></dependencies></dependencyManamgement>";
    document = builder.build(new StringReader(content));
    assertEquals(1, new JDomDependencyManagement(document.getRootElement()).getDependencies().size());
}
Also used : StringReader(java.io.StringReader) Document(org.jdom2.Document) Test(org.junit.Test)

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