Search in sources :

Example 86 with MetacardImpl

use of ddf.catalog.data.impl.MetacardImpl in project ddf by codice.

the class RegistryPublicationServiceImplTest method setup.

@Before
public void setup() {
    federationAdminService = mock(FederationAdminService.class);
    registryPublicationService = Mockito.spy(new RegistryPublicationServiceImpl());
    registryPublicationService.setFederationAdminService(federationAdminService);
    metacard = new MetacardImpl(new RegistryObjectMetacardType());
    metacard.setId("mcardId");
    metacard.setTags(Collections.singleton(RegistryConstants.REGISTRY_TAG));
    when(registryPublicationService.getBundleContext()).thenReturn(bundleContext);
    when(bundleContext.getService(serviceReference)).thenReturn(registryStore);
    doReturn(REGISTRY_STORE_REGISTRY_ID).when(registryStore).getRegistryId();
    doReturn(REGISTRY_STORE_ID).when(registryStore).getId();
    registryPublicationService.bindRegistryStore(serviceReference);
}
Also used : FederationAdminService(org.codice.ddf.registry.federationadmin.service.internal.FederationAdminService) RegistryObjectMetacardType(org.codice.ddf.registry.common.metacard.RegistryObjectMetacardType) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Before(org.junit.Before)

Example 87 with MetacardImpl

use of ddf.catalog.data.impl.MetacardImpl in project ddf by codice.

the class RefreshRegistryEntriesTest method getPopulatedTestRegistryMetacard.

private MetacardImpl getPopulatedTestRegistryMetacard(String id, String regId, long dateOffset, boolean internal, String remoteMcardId) {
    MetacardImpl registryMetacard = new MetacardImpl(new RegistryObjectMetacardType());
    registryMetacard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REGISTRY_ID, regId));
    registryMetacard.setAttribute(new AttributeImpl(Metacard.MODIFIED, new Date(new Date().getTime() + dateOffset)));
    if (internal) {
        registryMetacard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REMOTE_METACARD_ID, remoteMcardId));
        registryMetacard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REMOTE_REGISTRY_ID, "remoteRegId"));
        registryMetacard.setAttribute(new AttributeImpl(Metacard.TAGS, Collections.singletonList(RegistryConstants.REGISTRY_TAG_INTERNAL)));
    } else {
        registryMetacard.setAttribute(new AttributeImpl(Metacard.TAGS, Collections.singletonList(RegistryConstants.REGISTRY_TAG)));
    }
    registryMetacard.setAttribute(new AttributeImpl(Metacard.ID, id));
    registryMetacard.setAttribute(new AttributeImpl(Metacard.METADATA, TEST_XML_STRING));
    return registryMetacard;
}
Also used : AttributeImpl(ddf.catalog.data.impl.AttributeImpl) RegistryObjectMetacardType(org.codice.ddf.registry.common.metacard.RegistryObjectMetacardType) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Date(java.util.Date)

Example 88 with MetacardImpl

use of ddf.catalog.data.impl.MetacardImpl in project ddf by codice.

the class RefreshRegistryEntriesTest method testNoUpdatesOnLocal.

@Test
public void testNoUpdatesOnLocal() throws Exception {
    MetacardImpl localMcard = getPopulatedTestRegistryMetacard(TEST_METACARD_ID, RegistryObjectMetacardType.REGISTRY_ID, 0, true);
    localMcard.setAttribute(RegistryObjectMetacardType.REGISTRY_LOCAL_NODE, true);
    Metacard remoteMcard = getPopulatedTestRegistryMetacard("remoteMcardId", RegistryObjectMetacardType.REGISTRY_ID, 1000L);
    when(federationAdminService.getInternalRegistryMetacards()).thenReturn(Collections.singletonList(localMcard));
    SourceResponse response = new SourceResponseImpl(null, Collections.singletonList(new ResultImpl(remoteMcard)));
    when(registryStore.query(any(QueryRequest.class))).thenReturn(response);
    refreshRegistryEntries.setRegistryStores(Collections.singletonList(registryStore));
    when(registryStore.isPullAllowed()).thenReturn(true);
    when(registryStore.isAvailable()).thenReturn(true);
    refreshRegistryEntries.refreshRegistryEntries();
    verify(federationAdminService, never()).updateRegistryEntry(any(Metacard.class));
}
Also used : Metacard(ddf.catalog.data.Metacard) SourceResponse(ddf.catalog.operation.SourceResponse) QueryRequest(ddf.catalog.operation.QueryRequest) SourceResponseImpl(ddf.catalog.operation.impl.SourceResponseImpl) ResultImpl(ddf.catalog.data.impl.ResultImpl) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Test(org.junit.Test)

Example 89 with MetacardImpl

use of ddf.catalog.data.impl.MetacardImpl in project ddf by codice.

the class RegistryIdPostIngestPluginTest method testProcessDeleteLocal.

@Test
public void testProcessDeleteLocal() throws Exception {
    MetacardImpl metacard = getDefaultMetacard();
    metacard.setAttribute(RegistryObjectMetacardType.REGISTRY_LOCAL_NODE, true);
    CreateResponse createResponse = new CreateResponseImpl(null, null, Collections.singletonList(metacard));
    registryIdPostIngestPlugin.process(createResponse);
    assertThat(registryIdPostIngestPlugin.getLocalRegistryIds().size(), equalTo(1));
    DeleteResponse deleteResponse = new DeleteResponseImpl(null, null, Collections.singletonList(metacard));
    registryIdPostIngestPlugin.process(deleteResponse);
    assertThat(registryIdPostIngestPlugin.getLocalRegistryIds().size(), equalTo(0));
}
Also used : DeleteResponse(ddf.catalog.operation.DeleteResponse) DeleteResponseImpl(ddf.catalog.operation.impl.DeleteResponseImpl) CreateResponse(ddf.catalog.operation.CreateResponse) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) CreateResponseImpl(ddf.catalog.operation.impl.CreateResponseImpl) Test(org.junit.Test)

Example 90 with MetacardImpl

use of ddf.catalog.data.impl.MetacardImpl in project ddf by codice.

the class RegistryIdPostIngestPluginTest method testProcessCreateLocal.

@Test
public void testProcessCreateLocal() throws Exception {
    MetacardImpl metacard = getDefaultMetacard();
    metacard.setAttribute(RegistryObjectMetacardType.REGISTRY_LOCAL_NODE, true);
    CreateResponse response = new CreateResponseImpl(null, null, Collections.singletonList(metacard));
    registryIdPostIngestPlugin.process(response);
    assertThat(registryIdPostIngestPlugin.getRegistryIds().size(), equalTo(1));
    assertThat(registryIdPostIngestPlugin.getLocalRegistryIds().size(), equalTo(1));
    assertThat(registryIdPostIngestPlugin.getLocalRegistryIds().iterator().next(), equalTo("regId"));
}
Also used : CreateResponse(ddf.catalog.operation.CreateResponse) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) CreateResponseImpl(ddf.catalog.operation.impl.CreateResponseImpl) 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