Search in sources :

Example 46 with MetacardImpl

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"));
}
Also used : MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Date(java.util.Date) Test(org.junit.Test)

Example 47 with MetacardImpl

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));
}
Also used : QueryImpl(ddf.catalog.operation.impl.QueryImpl) QueryRequest(ddf.catalog.operation.QueryRequest) QueryRequestImpl(ddf.catalog.operation.impl.QueryRequestImpl) ResultImpl(ddf.catalog.data.impl.ResultImpl) ActionRegistry(ddf.action.ActionRegistry) MetacardImpl(ddf.catalog.data.impl.MetacardImpl)

Example 48 with MetacardImpl

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);
}
Also used : Metacard(ddf.catalog.data.Metacard) UpdateRequest(ddf.catalog.operation.UpdateRequest) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) WorkspaceMetacardImpl(org.codice.ddf.catalog.ui.metacard.workspace.WorkspaceMetacardImpl) Test(org.junit.Test)

Example 49 with MetacardImpl

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));
}
Also used : Metacard(ddf.catalog.data.Metacard) MetacardTypeImpl(ddf.catalog.data.impl.MetacardTypeImpl) Date(java.util.Date) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) MetacardType(ddf.catalog.data.MetacardType) Test(org.junit.Test)

Example 50 with MetacardImpl

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)));
}
Also used : Metacard(ddf.catalog.data.Metacard) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

Aggregations

MetacardImpl (ddf.catalog.data.impl.MetacardImpl)384 Test (org.junit.Test)247 Metacard (ddf.catalog.data.Metacard)144 ArrayList (java.util.ArrayList)102 Result (ddf.catalog.data.Result)62 HashMap (java.util.HashMap)59 Date (java.util.Date)52 ResultImpl (ddf.catalog.data.impl.ResultImpl)51 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)49 URI (java.net.URI)38 Matchers.anyString (org.mockito.Matchers.anyString)38 QueryRequest (ddf.catalog.operation.QueryRequest)36 QueryResponse (ddf.catalog.operation.QueryResponse)35 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)35 Serializable (java.io.Serializable)33 HashSet (java.util.HashSet)31 QueryImpl (ddf.catalog.operation.impl.QueryImpl)29 MetacardTypeImpl (ddf.catalog.data.impl.MetacardTypeImpl)28 AttributeDescriptor (ddf.catalog.data.AttributeDescriptor)27 List (java.util.List)27