Search in sources :

Example 1 with GetRecordByIdResponseType

use of net.opengis.cat.csw.v_2_0_2.GetRecordByIdResponseType in project ddf by codice.

the class TestGetRecordsResponseConverter method testMarshalRecordCollectionById.

@Ignore
public void testMarshalRecordCollectionById() throws UnsupportedEncodingException, JAXBException {
    final int totalResults = 2;
    XStream xstream = createXStream(CswConstants.GET_RECORD_BY_ID_RESPONSE);
    CswRecordCollection collection = createCswRecordCollection(null, totalResults);
    collection.setById(true);
    ArgumentCaptor<MarshallingContext> captor = ArgumentCaptor.forClass(MarshallingContext.class);
    String xml = xstream.toXML(collection);
    // Verify the context arguments were set correctly
    verify(mockProvider, times(totalResults)).marshal(any(Object.class), any(HierarchicalStreamWriter.class), captor.capture());
    MarshallingContext context = captor.getValue();
    assertThat(context, not(nullValue()));
    assertThat(context.get(CswConstants.OUTPUT_SCHEMA_PARAMETER), is(CswConstants.CSW_OUTPUT_SCHEMA));
    assertThat(context.get(CswConstants.ELEMENT_SET_TYPE), is(nullValue()));
    assertThat(context.get(CswConstants.ELEMENT_NAMES), is(nullValue()));
    JAXBElement<GetRecordByIdResponseType> jaxb = (JAXBElement<GetRecordByIdResponseType>) getJaxBContext().createUnmarshaller().unmarshal(new ByteArrayInputStream(xml.getBytes("UTF-8")));
    GetRecordByIdResponseType response = jaxb.getValue();
    // Assert the GetRecordsResponse elements and attributes
    assertThat(response, not(nullValue()));
}
Also used : GetRecordByIdResponseType(net.opengis.cat.csw.v_2_0_2.GetRecordByIdResponseType) HierarchicalStreamWriter(com.thoughtworks.xstream.io.HierarchicalStreamWriter) ByteArrayInputStream(java.io.ByteArrayInputStream) XStream(com.thoughtworks.xstream.XStream) CswRecordCollection(org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection) MarshallingContext(com.thoughtworks.xstream.converters.MarshallingContext) Matchers.anyString(org.mockito.Matchers.anyString) JAXBElement(javax.xml.bind.JAXBElement) Ignore(jdk.nashorn.internal.ir.annotations.Ignore)

Aggregations

XStream (com.thoughtworks.xstream.XStream)1 MarshallingContext (com.thoughtworks.xstream.converters.MarshallingContext)1 HierarchicalStreamWriter (com.thoughtworks.xstream.io.HierarchicalStreamWriter)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 JAXBElement (javax.xml.bind.JAXBElement)1 Ignore (jdk.nashorn.internal.ir.annotations.Ignore)1 GetRecordByIdResponseType (net.opengis.cat.csw.v_2_0_2.GetRecordByIdResponseType)1 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)1 Matchers.anyString (org.mockito.Matchers.anyString)1