Search in sources :

Example 1 with DataBuffer

use of com.opentext.ia.sdk.support.io.DataBuffer in project infoarchive-sip-sdk by Enterprise-Content-Management.

the class WhenAssemblingPackagingInformation method shouldGenerateValidXml.

@Test
public void shouldGenerateValidXml() throws IOException {
    String application = "a_" + randomString(62);
    String holding = "h_" + randomString(62);
    String producer = "p_" + randomString(62);
    String dssId = "i_" + randomString(30);
    String pdiSchema = "s_" + randomString(254);
    String entity = "e_" + randomString(62);
    int aiuCount = randomInt(20);
    PackagingInformationFactory packagingInformationFactory = new DefaultPackagingInformationFactory(PackagingInformation.builder().dss().id(dssId).application(application).holding(holding).entity(entity).producer(producer).schema(pdiSchema).end().build());
    PackagingInformation packagingInformation = packagingInformationFactory.newInstance(aiuCount, Optional.empty());
    DataBuffer buffer = new MemoryBuffer();
    assembler.start(buffer);
    assembler.add(packagingInformation);
    assembler.end();
    try (InputStream stream = buffer.openForReading()) {
        Element dss = assertValidPackagingInformation(stream);
        assertEquals("ID", dssId, getText(dss, "id"));
        assertEquals("Application", application, getText(dss, "application"));
        assertEquals("Holding", holding, getText(dss, "holding"));
        assertEquals("PDI entity", entity, getText(dss, "entity"));
        assertEquals("Producer", producer, getText(dss, "producer"));
        assertEquals("PDI schema", pdiSchema, getText(dss, "pdi_schema"));
        assertEquals("# AIUs", Integer.toString(aiuCount), getText(dss.getParentNode(), "aiu_count"));
    }
}
Also used : MemoryBuffer(com.opentext.ia.sdk.support.io.MemoryBuffer) InputStream(java.io.InputStream) Element(org.w3c.dom.Element) DataBuffer(com.opentext.ia.sdk.support.io.DataBuffer) Test(org.junit.Test)

Aggregations

DataBuffer (com.opentext.ia.sdk.support.io.DataBuffer)1 MemoryBuffer (com.opentext.ia.sdk.support.io.MemoryBuffer)1 InputStream (java.io.InputStream)1 Test (org.junit.Test)1 Element (org.w3c.dom.Element)1