Search in sources :

Example 6 with MetacardMarshallerImpl

use of ddf.catalog.transformer.xml.MetacardMarshallerImpl in project ddf by codice.

the class XmlResponseQueueTransformerTest method testCompareSerialToFork.

@Test
public void testCompareSerialToFork() throws IOException, CatalogTransformerException, MimeTypeParseException {
    SourceResponse response = givenSourceResponse(new MetacardStub("source1", "id1"), new MetacardStub("source2", "id2"), new MetacardStub("source3", "id3"), new MetacardStub("source4", "id4"));
    PrintWriterProvider pwp = new PrintWriterProviderImpl();
    MetacardMarshaller mcm = new MetacardMarshallerImpl(parser, pwp);
    XmlResponseQueueTransformer serialXform = new XmlResponseQueueTransformer(parser, pwp, mcm, getMimeType());
    serialXform.setThreshold(2);
    XmlResponseQueueTransformer forkXForm = new XmlResponseQueueTransformer(parser, pwp, mcm, getMimeType());
    forkXForm.setThreshold(10);
    BinaryContent serialBc = serialXform.transform(response, null);
    BinaryContent forkBc = forkXForm.transform(response, null);
    String serialOutput = new String(serialBc.getByteArray());
    String forkOutput = new String(forkBc.getByteArray());
    // There are expected whitespace differences between the outputs.
    // This is an overly aggressive conversion; a better test would be to unmarshal the
    // xml metacards back into Metacard instances and compare equality.
    assertEquals(serialOutput.replaceAll("\\s", ""), forkOutput.replaceAll("\\s", ""));
}
Also used : MetacardMarshallerImpl(ddf.catalog.transformer.xml.MetacardMarshallerImpl) PrintWriterProvider(ddf.catalog.transformer.api.PrintWriterProvider) SourceResponse(ddf.catalog.operation.SourceResponse) MetacardMarshaller(ddf.catalog.transformer.api.MetacardMarshaller) PrintWriterProviderImpl(ddf.catalog.transformer.xml.PrintWriterProviderImpl) XmlResponseQueueTransformer(ddf.catalog.transformer.xml.XmlResponseQueueTransformer) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) BinaryContent(ddf.catalog.data.BinaryContent) Test(org.junit.Test)

Example 7 with MetacardMarshallerImpl

use of ddf.catalog.transformer.xml.MetacardMarshallerImpl in project ddf by codice.

the class XmlResponseQueueTransformerTest method setup.

@Before
public void setup() throws MimeTypeParseException {
    parser = new XmlParser();
    PrintWriterProvider printWriterProvider = new PrintWriterProviderImpl();
    MetacardMarshaller metacardMarshaller = new MetacardMarshallerImpl(parser, printWriterProvider);
    mimeType = getMimeType();
    transformer = new XmlResponseQueueTransformer(parser, printWriterProvider, metacardMarshaller, mimeType);
}
Also used : XmlParser(org.codice.ddf.parser.xml.XmlParser) MetacardMarshallerImpl(ddf.catalog.transformer.xml.MetacardMarshallerImpl) PrintWriterProvider(ddf.catalog.transformer.api.PrintWriterProvider) MetacardMarshaller(ddf.catalog.transformer.api.MetacardMarshaller) PrintWriterProviderImpl(ddf.catalog.transformer.xml.PrintWriterProviderImpl) XmlResponseQueueTransformer(ddf.catalog.transformer.xml.XmlResponseQueueTransformer) Before(org.junit.Before)

Aggregations

MetacardMarshaller (ddf.catalog.transformer.api.MetacardMarshaller)7 MetacardMarshallerImpl (ddf.catalog.transformer.xml.MetacardMarshallerImpl)7 PrintWriterProviderImpl (ddf.catalog.transformer.xml.PrintWriterProviderImpl)7 XmlParser (org.codice.ddf.parser.xml.XmlParser)5 PrintWriterProvider (ddf.catalog.transformer.api.PrintWriterProvider)4 XmlResponseQueueTransformer (ddf.catalog.transformer.xml.XmlResponseQueueTransformer)4 Before (org.junit.Before)4 BinaryContent (ddf.catalog.data.BinaryContent)3 XmlMetacardTransformer (ddf.catalog.transformer.xml.XmlMetacardTransformer)3 Parser (org.codice.ddf.parser.Parser)3 Test (org.junit.Test)3 SourceResponse (ddf.catalog.operation.SourceResponse)2 Attribute (ddf.catalog.data.Attribute)1 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)1 Metacard (ddf.catalog.data.Metacard)1 InputTransformer (ddf.catalog.transform.InputTransformer)1 MetacardTransformer (ddf.catalog.transform.MetacardTransformer)1 XmlInputTransformer (ddf.catalog.transformer.xml.XmlInputTransformer)1 InputStream (java.io.InputStream)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1