use of org.codice.ddf.spatial.ogc.csw.catalog.converter.GetRecordsResponseConverter in project ddf by codice.
the class GetRecordsMessageBodyReaderTest method testFullThreadCswRecordCollection.
@Test
public void testFullThreadCswRecordCollection() throws Exception {
Metacard metacard = createMetacard();
List<Metacard> inputMetacards = Collections.singletonList(metacard);
CswRecordCollection collection = new CswRecordCollection();
collection.setCswRecords(inputMetacards);
MetacardType cswMetacardType = new MetacardTypeImpl(CswConstants.CSW_METACARD_TYPE_NAME, Arrays.asList(new ContactAttributes(), new LocationAttributes(), new MediaAttributes(), new TopicAttributes(), new AssociationsAttributes()));
CswRecordConverter recordConverter = new CswRecordConverter(cswMetacardType);
TransformerManager mockInputManager = mock(TransformerManager.class);
when(mockInputManager.getTransformerByProperty(anyString(), anyString())).thenReturn(recordConverter);
CswTransformProvider metacardProvider = new CswTransformProvider(null, mockInputManager);
GetRecordsResponseConverter provider = new GetRecordsResponseConverter(metacardProvider);
CswSourceConfiguration config = createConfig();
GetRecordsMessageBodyReader reader = new GetRecordsMessageBodyReader(provider, config);
CswRecordCollection cswRecords = null;
try (InputStream is = GetRecordsMessageBodyReaderTest.class.getResourceAsStream("/getRecordsResponse.xml")) {
MultivaluedMap<String, String> httpHeaders = new MultivaluedHashMap<>();
cswRecords = reader.readFrom(CswRecordCollection.class, null, null, null, httpHeaders, is);
}
List<Metacard> metacards = cswRecords.getCswRecords();
assertThat(metacards, hasSize(3));
assertThat(metacards.get(0).getMetacardType().getName(), is("csw:Record"));
assertThat(metacards.get(0).getTitle(), containsString("title"));
}
use of org.codice.ddf.spatial.ogc.csw.catalog.converter.GetRecordsResponseConverter in project ddf by codice.
the class GetRecordsMessageBodyReaderTest method testFullThreadCswRecordCollectionAltPrefixes.
@Test
public void testFullThreadCswRecordCollectionAltPrefixes() throws Exception {
Metacard metacard = createMetacard();
List<Metacard> inputMetacards = Collections.singletonList(metacard);
CswRecordCollection collection = new CswRecordCollection();
collection.setCswRecords(inputMetacards);
MetacardType cswMetacardType = new MetacardTypeImpl(CswConstants.CSW_METACARD_TYPE_NAME, Arrays.asList(new ContactAttributes(), new LocationAttributes(), new MediaAttributes(), new TopicAttributes(), new AssociationsAttributes()));
CswRecordConverter recordConverter = new CswRecordConverter(cswMetacardType);
TransformerManager mockInputManager = mock(TransformerManager.class);
when(mockInputManager.getTransformerByProperty(anyString(), anyString())).thenReturn(recordConverter);
CswTransformProvider metacardProvider = new CswTransformProvider(null, mockInputManager);
GetRecordsResponseConverter provider = new GetRecordsResponseConverter(metacardProvider);
CswSourceConfiguration config = createConfig();
GetRecordsMessageBodyReader reader = new GetRecordsMessageBodyReader(provider, config);
CswRecordCollection cswRecords = null;
try (InputStream is = GetRecordsMessageBodyReaderTest.class.getResourceAsStream("/getRecordsResponse-alt-prefixes.xml")) {
MultivaluedMap<String, String> httpHeaders = new MultivaluedHashMap<>();
cswRecords = reader.readFrom(CswRecordCollection.class, null, null, null, httpHeaders, is);
}
List<Metacard> metacards = cswRecords.getCswRecords();
assertThat(metacards.size(), is(3));
assertThat(metacards.get(0).getMetacardType().getName(), is("csw:Record"));
assertThat(metacards.get(0).getTitle(), containsString("title"));
}
Aggregations