use of org.codice.ddf.registry.api.internal.RegistryStore in project ddf by codice.
the class FederationAdminTest method testRegistryStatusNoConfig.
@Test
public void testRegistryStatusNoConfig() throws Exception {
RegistryStore source = mock(RegistryStore.class);
when(source.isAvailable()).thenReturn(true);
when(helper.getRegistrySources()).thenReturn(Collections.singletonList(source));
when(helper.getConfiguration(any(ConfiguredService.class))).thenReturn(null);
assertThat(federationAdmin.registryStatus("servicePid"), is(false));
}
use of org.codice.ddf.registry.api.internal.RegistryStore in project ddf by codice.
the class RegistryPublicationServiceImplTest method testUpdate.
@Test
public void testUpdate() throws Exception {
String registryId1 = "registryId1";
String registryId2 = "registryId2";
String registryId3 = "registryId3";
String storeId1 = "store1";
String storeId3 = "store3";
// Purposely leave out mock for registry store 2
// so a store id won't be found for registryId2
// Not a likely case but should be handled
RegistryStore store1 = mock(RegistryStore.class);
when(store1.getId()).thenReturn(storeId1);
when(store1.getRegistryId()).thenReturn(registryId1);
RegistryStore store3 = mock(RegistryStore.class);
when(store3.getId()).thenReturn(storeId3);
when(store3.getRegistryId()).thenReturn(registryId3);
when(bundleContext.getService(serviceReference)).thenReturn(store1);
registryPublicationService.bindRegistryStore(serviceReference);
when(bundleContext.getService(serviceReference)).thenReturn(store3);
registryPublicationService.bindRegistryStore(serviceReference);
List<Serializable> publishedLocations = ImmutableList.of(registryId1, registryId2, registryId3);
Date now = new Date();
Date before = new Date(now.getTime() - 100000);
MetacardImpl metacard = new MetacardImpl();
metacard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.PUBLISHED_LOCATIONS, publishedLocations));
metacard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.LAST_PUBLISHED, before));
registryPublicationService.update(metacard);
// update will only be callled with storeIds 1 and 3, 2 didn't have a storeId match for registryId2
verify(federationAdminService, times(1)).updateRegistryEntry(eq(metacard), (Set<String>) argThat(contains(storeId1, storeId3)));
verify(federationAdminService, times(1)).updateRegistryEntry(metacard);
Attribute lastPublished = metacard.getAttribute(RegistryObjectMetacardType.LAST_PUBLISHED);
assertThat(lastPublished, notNullValue());
Date lastPublishedDate = (Date) lastPublished.getValue();
assertThat(lastPublishedDate.after(before), is(equalTo(true)));
}
use of org.codice.ddf.registry.api.internal.RegistryStore in project ddf by codice.
the class RefreshRegistryEntriesTest method testMultipleStores.
@Test
public void testMultipleStores() throws Exception {
Metacard mcard = getPopulatedTestRegistryMetacard();
RegistryStore registryStore2 = mock(RegistryStore.class);
when(registryStore2.getId()).thenReturn("id2");
when(registryStore2.getRegistryId()).thenReturn("regId2");
when(registryStore2.isAvailable()).thenReturn(true);
when(registryStore2.isPullAllowed()).thenReturn(true);
SourceResponse response = new SourceResponseImpl(null, Collections.singletonList(new ResultImpl(mcard)));
when(registryStore2.query(any(QueryRequest.class))).thenReturn(response);
when(registryStore.query(any(QueryRequest.class))).thenThrow(new UnsupportedQueryException());
when(registryStore.isAvailable()).thenReturn(true);
when(registryStore.isPullAllowed()).thenReturn(true);
when(registryStore2.query(any(QueryRequest.class))).thenReturn(response);
List<RegistryStore> stores = new ArrayList<>();
stores.add(registryStore);
stores.add(registryStore2);
refreshRegistryEntries.setRegistryStores(stores);
refreshRegistryEntries.refreshRegistryEntries();
verify(federationAdminService).addRegistryEntries(Collections.singletonList(mcard), null);
}
Aggregations