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);
}
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;
}
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));
}
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));
}
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"));
}
Aggregations