Search in sources :

Example 1 with ContactAttributes

use of ddf.catalog.data.impl.types.ContactAttributes in project alliance by codice.

the class DAGConverterTest method setUp.

@Before
public void setUp() throws Exception {
    this.orb = ORB.init();
    int year = 2016;
    int month = 01;
    int dayOfMonth = 29;
    int hourOfDay = 17;
    int minute = 05;
    int second = 10;
    cal = new GregorianCalendar(year, month, dayOfMonth, hourOfDay, minute, second);
    dagConverter = new DAGConverter(mockResourceReader);
    List<MetacardType> types = new ArrayList<>();
    types.add(new AssociationsAttributes());
    types.add(new ContactAttributes());
    types.add(new DateTimeAttributes());
    types.add(new LocationAttributes());
    types.add(new IsrAttributes());
    types.add(new SecurityAttributes());
    MetacardTypeImpl metacardTypeImpl = new MetacardTypeImpl("NsiliMetacardType", types);
    dagConverter.setNsiliMetacardType(metacardTypeImpl);
    setupMocks();
}
Also used : ContactAttributes(ddf.catalog.data.impl.types.ContactAttributes) LocationAttributes(ddf.catalog.data.impl.types.LocationAttributes) GregorianCalendar(java.util.GregorianCalendar) ArrayList(java.util.ArrayList) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) MetacardType(ddf.catalog.data.MetacardType) SecurityAttributes(org.codice.alliance.catalog.core.api.impl.types.SecurityAttributes) ResultDAGConverter(org.codice.alliance.nsili.common.ResultDAGConverter) DateTimeAttributes(ddf.catalog.data.impl.types.DateTimeAttributes) AssociationsAttributes(ddf.catalog.data.impl.types.AssociationsAttributes) IsrAttributes(org.codice.alliance.catalog.core.api.impl.types.IsrAttributes) Before(org.junit.Before)

Example 2 with ContactAttributes

use of ddf.catalog.data.impl.types.ContactAttributes 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"));
}
Also used : CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration) ContactAttributes(ddf.catalog.data.impl.types.ContactAttributes) TransformerManager(org.codice.ddf.spatial.ogc.csw.catalog.common.transformer.TransformerManager) LocationAttributes(ddf.catalog.data.impl.types.LocationAttributes) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) MediaAttributes(ddf.catalog.data.impl.types.MediaAttributes) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) CswTransformProvider(org.codice.ddf.spatial.ogc.csw.catalog.converter.CswTransformProvider) MetacardType(ddf.catalog.data.MetacardType) TopicAttributes(ddf.catalog.data.impl.types.TopicAttributes) CswRecordConverter(org.codice.ddf.spatial.ogc.csw.catalog.converter.CswRecordConverter) MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) GetRecordsResponseConverter(org.codice.ddf.spatial.ogc.csw.catalog.converter.GetRecordsResponseConverter) Metacard(ddf.catalog.data.Metacard) AssociationsAttributes(ddf.catalog.data.impl.types.AssociationsAttributes) CswRecordCollection(org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection) Test(org.junit.Test)

Example 3 with ContactAttributes

use of ddf.catalog.data.impl.types.ContactAttributes 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"));
}
Also used : CswSourceConfiguration(org.codice.ddf.spatial.ogc.csw.catalog.common.CswSourceConfiguration) ContactAttributes(ddf.catalog.data.impl.types.ContactAttributes) TransformerManager(org.codice.ddf.spatial.ogc.csw.catalog.common.transformer.TransformerManager) LocationAttributes(ddf.catalog.data.impl.types.LocationAttributes) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) MediaAttributes(ddf.catalog.data.impl.types.MediaAttributes) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) Matchers.containsString(org.hamcrest.Matchers.containsString) Matchers.anyString(org.mockito.Matchers.anyString) CswTransformProvider(org.codice.ddf.spatial.ogc.csw.catalog.converter.CswTransformProvider) MetacardType(ddf.catalog.data.MetacardType) TopicAttributes(ddf.catalog.data.impl.types.TopicAttributes) CswRecordConverter(org.codice.ddf.spatial.ogc.csw.catalog.converter.CswRecordConverter) MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) GetRecordsResponseConverter(org.codice.ddf.spatial.ogc.csw.catalog.converter.GetRecordsResponseConverter) Metacard(ddf.catalog.data.Metacard) AssociationsAttributes(ddf.catalog.data.impl.types.AssociationsAttributes) CswRecordCollection(org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection) Test(org.junit.Test)

Example 4 with ContactAttributes

use of ddf.catalog.data.impl.types.ContactAttributes in project ddf by codice.

the class TransactionMessageBodyReaderTest method setup.

@Before
public void setup() {
    cswRecordConverter = new CswRecordConverter(CswQueryFactoryTest.getCswMetacardType());
    new CoreAttributes().getAttributeDescriptors().stream().forEach(d -> registry.register(d));
    new ContactAttributes().getAttributeDescriptors().stream().forEach(d -> registry.register(d));
    new LocationAttributes().getAttributeDescriptors().stream().forEach(d -> registry.register(d));
    new MediaAttributes().getAttributeDescriptors().stream().forEach(d -> registry.register(d));
    new TopicAttributes().getAttributeDescriptors().stream().forEach(d -> registry.register(d));
    new AssociationsAttributes().getAttributeDescriptors().stream().forEach(d -> registry.register(d));
}
Also used : ContactAttributes(ddf.catalog.data.impl.types.ContactAttributes) LocationAttributes(ddf.catalog.data.impl.types.LocationAttributes) CoreAttributes(ddf.catalog.data.impl.types.CoreAttributes) AssociationsAttributes(ddf.catalog.data.impl.types.AssociationsAttributes) MediaAttributes(ddf.catalog.data.impl.types.MediaAttributes) CswRecordConverter(org.codice.ddf.spatial.ogc.csw.catalog.converter.CswRecordConverter) TopicAttributes(ddf.catalog.data.impl.types.TopicAttributes) Before(org.junit.Before)

Example 5 with ContactAttributes

use of ddf.catalog.data.impl.types.ContactAttributes in project ddf by codice.

the class TestTransactionRequestConverter method setup.

@Before
public void setup() {
    cswRecordConverter = mock(Converter.class);
    when(cswRecordConverter.canConvert(any())).thenReturn(true);
    new CoreAttributes().getAttributeDescriptors().stream().forEach(d -> mockRegistry.register(d));
    new ContactAttributes().getAttributeDescriptors().stream().forEach(d -> mockRegistry.register(d));
    new LocationAttributes().getAttributeDescriptors().stream().forEach(d -> mockRegistry.register(d));
    new MediaAttributes().getAttributeDescriptors().stream().forEach(d -> mockRegistry.register(d));
    new TopicAttributes().getAttributeDescriptors().stream().forEach(d -> mockRegistry.register(d));
    new AssociationsAttributes().getAttributeDescriptors().stream().forEach(d -> mockRegistry.register(d));
    xStream = new XStream(new Xpp3Driver());
    xStream.registerConverter(new TransactionRequestConverter(cswRecordConverter, mockRegistry));
    xStream.alias(CswConstants.CSW_TRANSACTION, CswTransactionRequest.class);
}
Also used : Xpp3Driver(com.thoughtworks.xstream.io.xml.Xpp3Driver) ContactAttributes(ddf.catalog.data.impl.types.ContactAttributes) LocationAttributes(ddf.catalog.data.impl.types.LocationAttributes) XStream(com.thoughtworks.xstream.XStream) CoreAttributes(ddf.catalog.data.impl.types.CoreAttributes) AssociationsAttributes(ddf.catalog.data.impl.types.AssociationsAttributes) Converter(com.thoughtworks.xstream.converters.Converter) MediaAttributes(ddf.catalog.data.impl.types.MediaAttributes) TopicAttributes(ddf.catalog.data.impl.types.TopicAttributes) Before(org.junit.Before)

Aggregations

ContactAttributes (ddf.catalog.data.impl.types.ContactAttributes)9 LocationAttributes (ddf.catalog.data.impl.types.LocationAttributes)8 AssociationsAttributes (ddf.catalog.data.impl.types.AssociationsAttributes)7 MediaAttributes (ddf.catalog.data.impl.types.MediaAttributes)7 TopicAttributes (ddf.catalog.data.impl.types.TopicAttributes)7 CoreAttributes (ddf.catalog.data.impl.types.CoreAttributes)6 Before (org.junit.Before)6 MetacardTypeImpl (ddf.catalog.data.impl.MetacardTypeImpl)5 MetacardType (ddf.catalog.data.MetacardType)4 CswRecordConverter (org.codice.ddf.spatial.ogc.csw.catalog.converter.CswRecordConverter)4 DateTimeAttributes (ddf.catalog.data.impl.types.DateTimeAttributes)3 XStream (com.thoughtworks.xstream.XStream)2 Converter (com.thoughtworks.xstream.converters.Converter)2 Xpp3Driver (com.thoughtworks.xstream.io.xml.Xpp3Driver)2 Metacard (ddf.catalog.data.Metacard)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 MultivaluedHashMap (javax.ws.rs.core.MultivaluedHashMap)2 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)2