use of org.osgi.service.event.Event in project ddf by codice.
the class TestRegistryStorePublisher method setup.
@Before
public void setup() {
registryId = new AttributeImpl(RegistryObjectMetacardType.REGISTRY_ID, "registryId");
mockRegPubService = mock(RegistryPublicationService.class);
mockFedAdminService = mock(FederationAdminService.class);
executorService = mock(ScheduledExecutorService.class);
serviceReference = mock(ServiceReference.class);
mockRegistryStore = mock(RegistryStore.class);
mockServiceEvent = mock(ServiceEvent.class);
bundleContext = mock(BundleContext.class);
mockIdentity = mock(Metacard.class);
optMetacard = Optional.of(mockIdentity);
registryStorePublisher = spy(new RegistryStorePublisher() {
@Override
BundleContext getBundleContext() {
return bundleContext;
}
});
registryStorePublisher.setExecutor(executorService);
registryStorePublisher.setFederationAdminService(mockFedAdminService);
registryStorePublisher.setRegistryPublicationService(mockRegPubService);
Dictionary<String, Object> eventProperties = new Hashtable<>();
eventProperties.put(EventConstants.EVENT, mockServiceEvent);
eventProperties.put(Constants.SERVICE_PID, "servicePid");
event = new Event("org/osgi/framework/ServiceEvent/MODIFIED", eventProperties);
}
use of org.osgi.service.event.Event in project ddf by codice.
the class RegistryMetacardHandlerTest method testDeleteEvent.
@Test
public void testDeleteEvent() throws Exception {
event = new Event(EventProcessor.EVENTS_TOPIC_DELETED, eventProperties);
setupSerialExecutor();
when(federationAdmin.getRegistryMetacardsByRegistryIds(any())).thenReturn(Collections.singletonList(mcard));
when(federationAdmin.getInternalRegistryMetacardsByRegistryId(any())).thenReturn(Collections.emptyList());
rmh.handleEvent(event);
verify(federationAdmin).deleteRegistryEntriesByRegistryIds(any());
}
use of org.osgi.service.event.Event in project ddf by codice.
the class RegistryMetacardHandlerTest method setup.
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
rmh = new RegistryMetacardHandler(executorService, federationAdmin);
mcardInternal = new MetacardImpl();
mcardInternal.setModifiedDate(new Date());
mcardInternal.setId("internalId");
mcardInternal.setAttribute(Metacard.TAGS, RegistryConstants.REGISTRY_TAG_INTERNAL);
mcardInternal.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REGISTRY_ID, "testRegId"));
mcard = new MetacardImpl();
mcard.setId("id");
mcard.setModifiedDate(new Date());
mcard.setAttribute(Metacard.TAGS, RegistryConstants.REGISTRY_TAG);
mcard.setAttribute(new AttributeImpl(RegistryObjectMetacardType.REGISTRY_ID, "testRegId"));
eventProperties = new Hashtable<>();
eventProperties.put("ddf.catalog.event.metacard", mcardInternal);
event = new Event("myevent", eventProperties);
}
use of org.osgi.service.event.Event in project ddf by codice.
the class RegistryMetacardHandlerTest method testUpdateEventNoNewData.
@Test
public void testUpdateEventNoNewData() throws Exception {
event = new Event(EventProcessor.EVENTS_TOPIC_UPDATED, eventProperties);
setupSerialExecutor();
when(federationAdmin.getRegistryMetacardsByRegistryIds(any())).thenReturn(Collections.singletonList(mcard));
rmh.handleEvent(event);
verify(federationAdmin, never()).addRegistryEntry(mcardInternal);
verify(federationAdmin, never()).updateRegistryEntry(mcardInternal);
}
use of org.osgi.service.event.Event in project ddf by codice.
the class RegistryStoreCleanupHandlerTest method handleEvent.
private void handleEvent(ServiceReference bindRef, ServiceReference eventRef, int serviceEventType, String searchRegId, List<Metacard> metacards) throws Exception {
cleanupHandler.bindRegistryStore(bindRef);
ServiceEvent serviceEvent = mock(ServiceEvent.class);
when(serviceEvent.getType()).thenReturn(serviceEventType);
when(serviceEvent.getServiceReference()).thenReturn(eventRef);
eventProperties.put(EventConstants.EVENT, serviceEvent);
when(federationAdmin.getInternalRegistryMetacards()).thenReturn(metacards);
event = new Event("myevent", eventProperties);
cleanupHandler.handleEvent(event);
}
Aggregations