use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class FederationAdminServiceImplTest method getPopulatedRemoteTestRegistryMetacard.
private Metacard getPopulatedRemoteTestRegistryMetacard() {
Metacard mcard = getPopulatedTestRegistryMetacard();
mcard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REMOTE_REGISTRY_ID, "RemoteRegId"));
return mcard;
}
use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class FederationAdminServiceImplTest method testAddRegistryEntryWithInvalidMetacardNoRegistryTag.
@Test(expected = FederationAdminException.class)
public void testAddRegistryEntryWithInvalidMetacardNoRegistryTag() throws Exception {
String destination = TEST_DESTINATION;
Metacard metacard = getTestMetacard();
metacard.setAttribute(new AttributeImpl(Metacard.TAGS, Collections.singletonList(null)));
Set<String> destinations = new HashSet<>();
destinations.add(destination);
federationAdminServiceImpl.addRegistryEntry(metacard, destinations);
verify(catalogFramework, never()).create(any(CreateRequest.class));
}
use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class FederationAdminServiceImplTest method testGetLocalRegistryObjectsWithEmptyMetadata.
@Test(expected = FederationAdminException.class)
public void testGetLocalRegistryObjectsWithEmptyMetadata() throws Exception {
Metacard localMetacard = getTestMetacard();
localMetacard.setAttribute(new AttributeImpl(Metacard.METADATA, ""));
List<Metacard> localMetacards = new ArrayList<>();
localMetacards.add(localMetacard);
doReturn(localMetacards).when(federationAdminServiceImpl).getLocalRegistryMetacards();
federationAdminServiceImpl.getLocalRegistryObjects();
verify(parser, never()).unmarshal(any(ParserConfigurator.class), eq(JAXBElement.class), any(InputStream.class));
}
use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class GenericFeatureConverter method unmarshal.
/**
* This method will unmarshal an XML instance of a "gml:featureMember" to a {@link Metacard}.
*
* @param hreader the stream reader responsible for reading this xml doc
* @param context a reference back to the Xstream unmarshalling context. Allows you to call
* "convertAnother" which will lookup other registered converters.
*/
@Override
public Object unmarshal(HierarchicalStreamReader hreader, UnmarshallingContext context) {
LOGGER.debug("Entering: {} : unmarshal", this.getClass().getName());
String fid = hreader.getAttribute(FID);
MetacardImpl mc;
if (metacardType != null) {
mc = (MetacardImpl) createMetacardFromFeature(hreader, metacardType);
} else {
throw new IllegalArgumentException("No MetacardType registered on the FeatureConverter. Unable to to convert features to metacards.");
}
mc.setId(fid);
mc.setSourceId(sourceId);
// set some default values that we can't get from a generic
// featureCollection if they are not already set
Date genericDate = new Date();
if (mc.getEffectiveDate() == null) {
mc.setEffectiveDate(genericDate);
}
ifAttributeSet(mc.getAttribute(Core.CREATED), attribute -> mc.setAttribute(new AttributeImpl(Core.CREATED, genericDate)));
ifAttributeSet(mc.getAttribute(Core.MODIFIED), attribute -> mc.setAttribute(new AttributeImpl(Core.MODIFIED, genericDate)));
ifAttributeSet(mc.getAttribute(Core.TITLE), attribute -> mc.setAttribute(new AttributeImpl(Core.MODIFIED, genericDate)));
mc.setContentTypeName(metacardType.getName());
try {
mc.setTargetNamespace(new URI(WfsConstants.NAMESPACE_URN_ROOT + metacardType.getName()));
} catch (URISyntaxException e) {
LOGGER.debug("Unable to set Target Namespace on metacard: {}, Exception {}", WfsConstants.NAMESPACE_URN_ROOT + metacardType.getName(), e);
}
return mc;
}
use of ddf.catalog.data.impl.AttributeImpl in project ddf by codice.
the class TestAttributeMetacardTransformer method testNotAString.
/**
* Tests exception thrown for {@code null} string
*
* @throws CatalogTransformerException
* @throws IOException
*/
@Test(expected = CatalogTransformerException.class)
public void testNotAString() throws CatalogTransformerException, IOException {
Metacard mockMetacard = mock(Metacard.class);
when(mockMetacard.getAttribute(isA(String.class))).thenReturn(new AttributeImpl(Metacard.METADATA, new Date()));
METADATA_TRANSFORMER.transform(mockMetacard, null);
}
Aggregations