use of ddf.catalog.data.impl.MetacardImpl in project ddf by codice.
the class RegistryTransformerTest method testFullRegistryPackage.
@Test
public void testFullRegistryPackage() throws Exception {
MetacardImpl metacard = convert("/csw-full-registry-package.xml");
Date date = Date.from(ZonedDateTime.parse("2015-11-01T06:15:30-07:00").toInstant());
assertThat(RegistryUtility.getStringAttribute(metacard, Core.CREATED, null), is(date.toString()));
date = Date.from(ZonedDateTime.parse("2015-11-01T13:15:30Z").toInstant());
assertThat(RegistryUtility.getStringAttribute(metacard, DateTime.START, null), is(date.toString()));
date = Date.from(ZonedDateTime.parse("2015-12-01T23:01:40Z").toInstant());
assertThat(RegistryUtility.getStringAttribute(metacard, DateTime.END, null), is(date.toString()));
date = Date.from(ZonedDateTime.parse("2016-01-26T17:16:34.996Z").toInstant());
assertThat(RegistryUtility.getStringAttribute(metacard, Core.MODIFIED, null), is(date.toString()));
assertThat(RegistryUtility.getStringAttribute(metacard, RegistryObjectMetacardType.LINKS, null), is("https://some/link/to/my/repo"));
assertThat(RegistryUtility.getStringAttribute(metacard, Core.LOCATION, null), is("POINT (112.267472 33.467944)"));
assertThat(RegistryUtility.getStringAttribute(metacard, RegistryObjectMetacardType.REGION, null), is("USA"));
List<String> attributeValuesList = RegistryUtility.getListOfStringAttribute(metacard, RegistryObjectMetacardType.DATA_SOURCES);
assertThat(attributeValuesList.size(), is(2));
assertThat(attributeValuesList, hasItem("youtube"));
assertThat(attributeValuesList, hasItem("myCamera"));
attributeValuesList = RegistryUtility.getListOfStringAttribute(metacard, Topic.KEYWORD);
assertThat(attributeValuesList.size(), is(2));
assertThat(attributeValuesList, hasItem("video"));
assertThat(attributeValuesList, hasItem("sensor"));
assertThat(RegistryUtility.getStringAttribute(metacard, RegistryObjectMetacardType.SECURITY_LEVEL, null), is("role=guest"));
assertThat(RegistryUtility.getStringAttribute(metacard, Metacard.TITLE, null), is("Node Name"));
assertThat(RegistryUtility.getStringAttribute(metacard, Metacard.DESCRIPTION, null), is("A little something describing this node in less than 1024 characters"));
assertThat(RegistryUtility.getStringAttribute(metacard, Metacard.CONTENT_TYPE_VERSION, null), is("2.9.x"));
attributeValuesList = RegistryUtility.getListOfStringAttribute(metacard, RegistryObjectMetacardType.SERVICE_BINDING_TYPES);
assertThat(attributeValuesList.size(), is(2));
assertThat(attributeValuesList, hasItem("Csw_Federated_Source"));
assertThat(attributeValuesList, hasItem("soap13"));
attributeValuesList = RegistryUtility.getListOfStringAttribute(metacard, RegistryObjectMetacardType.SERVICE_BINDINGS);
assertThat(attributeValuesList.size(), is(2));
assertThat(attributeValuesList, hasItem("REST"));
assertThat(attributeValuesList, hasItem("SOAP"));
assertThat(RegistryUtility.getStringAttribute(metacard, Contact.POINT_OF_CONTACT_NAME, null), is("Codice"));
assertThat(RegistryUtility.getListOfStringAttribute(metacard, Contact.POINT_OF_CONTACT_ADDRESS), hasItem("1234 Some Street, Phoenix, AZ 85037, USA"));
assertThat(RegistryUtility.getListOfStringAttribute(metacard, Contact.POINT_OF_CONTACT_PHONE), hasItem("(555) 555-5555 ext 1234"));
assertThat(RegistryUtility.getListOfStringAttribute(metacard, Contact.POINT_OF_CONTACT_EMAIL), hasItem("emailaddress@something.com"));
assertThat(RegistryUtility.getStringAttribute(metacard, Metacard.POINT_OF_CONTACT, null), is("john doe, (111) 111-1111 ext 1234, emailaddress@something.com"));
}
use of ddf.catalog.data.impl.MetacardImpl in project ddf by codice.
the class CqlResultTest method distanceCheck.
private void distanceCheck(Double input, Double output) {
MetacardImpl metacard = new MetacardImpl(BasicTypes.BASIC_METACARD);
ResultImpl result = new ResultImpl(metacard);
result.setDistanceInMeters(input);
ActionRegistry actionRegistry = mock(ActionRegistry.class);
when(actionRegistry.list(any())).thenReturn(Collections.emptyList());
QueryRequest request = new QueryRequestImpl(new QueryImpl(filterBuilder.attribute("test").equalTo().text("value")));
CqlResult cqlResult = new CqlResult(result, null, request, false, filterAdapter, actionRegistry);
assertThat(cqlResult.getDistance(), is(output));
}
use of ddf.catalog.data.impl.MetacardImpl in project ddf by codice.
the class WorkspaceAccessPluginTest method testIgnoreNonWorkspaceMetacards.
@Test
public void testIgnoreNonWorkspaceMetacards() throws Exception {
Map<String, Metacard> updates = ImmutableMap.of("rand", new MetacardImpl());
UpdateRequest update = mockUpdateRequest(updates);
// should ignore all non-workspace metacards and do nothing
accessPlugin.processPreUpdate(update, updates);
}
use of ddf.catalog.data.impl.MetacardImpl in project ddf by codice.
the class AttributeInjectorImplTest method testInjectIntoMetacard.
@Test
public void testInjectIntoMetacard() {
final String title = "title";
final Date created = new Date();
final MetacardImpl basicMetacard = new MetacardImpl();
basicMetacard.setTitle(title);
basicMetacard.setCreatedDate(created);
final MetacardType expectedBasicMetacardType = new MetacardTypeImpl(BASIC_METACARD.getName(), BASIC_METACARD, Sets.newHashSet(globalAttribute, basicAttribute, basicAndNitfAttribute));
final Metacard injectedBasicMetacard = attributeInjector.injectAttributes(basicMetacard);
assertThat(injectedBasicMetacard.getMetacardType(), is(expectedBasicMetacardType));
assertThat(injectedBasicMetacard.getTitle(), is(title));
assertThat(injectedBasicMetacard.getCreatedDate(), is(created));
final MetacardImpl nitfMetacard = new MetacardImpl(NITF_TYPE);
nitfMetacard.setTitle(title);
nitfMetacard.setCreatedDate(created);
final MetacardType expectedNitfMetacardType = new MetacardTypeImpl(NITF, NITF_TYPE, Sets.newHashSet(globalAttribute, basicAndNitfAttribute));
final Metacard injectedNitfMetacard = attributeInjector.injectAttributes(nitfMetacard);
assertThat(injectedNitfMetacard.getMetacardType(), is(expectedNitfMetacardType));
assertThat(injectedNitfMetacard.getTitle(), is(title));
assertThat(injectedNitfMetacard.getCreatedDate(), is(created));
}
use of ddf.catalog.data.impl.MetacardImpl in project ddf by codice.
the class AttributeInjectorImplTest method testInjectNothingIntoMetacard.
@Test
public void testInjectNothingIntoMetacard() {
attributeInjector.setInjectableAttributes(Lists.newArrayList(basicInjection));
final Metacard original = new MetacardImpl(NITF_TYPE);
final Metacard injected = attributeInjector.injectAttributes(original);
assertThat(injected, is(sameInstance(original)));
}
Aggregations