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"));
}
}
Aggregations