Search in sources :

Example 26 with Event

use of org.osgi.service.event.Event in project ddf by codice.

the class RegistryPublicationHandlerTest method setup.

@Before
public void setup() {
    MockitoAnnotations.initMocks(this);
    mcard = new MetacardImpl();
    mcard.setAttribute(Metacard.TAGS, RegistryConstants.REGISTRY_TAG);
    rph = new RegistryPublicationHandler(service, executorService);
    eventProperties = new Hashtable<>();
    eventProperties.put("ddf.catalog.event.metacard", mcard);
    event = new Event("myevent", eventProperties);
}
Also used : Event(org.osgi.service.event.Event) MetacardImpl(ddf.catalog.data.impl.MetacardImpl) Before(org.junit.Before)

Example 27 with Event

use of org.osgi.service.event.Event in project ddf by codice.

the class RegistryPublicationManagerTest method testHandleEventDelete.

@Test
public void testHandleEventDelete() throws Exception {
    publicationManager.handleEvent(getRegistryEvent(CREATED_TOPIC));
    assertThat(publicationManager.getPublications().size(), is(1));
    Event event = getRegistryEvent(DELETED_TOPIC);
    publicationManager.handleEvent(event);
    assertThat(publicationManager.getPublications().size(), is(0));
}
Also used : Event(org.osgi.service.event.Event) Test(org.junit.Test)

Example 28 with Event

use of org.osgi.service.event.Event in project ddf by codice.

the class FederationAdminTest method testHandleEventDelete.

@Test
public void testHandleEventDelete() throws Exception {
    performCreateEvent();
    Dictionary<String, Object> eventProperties = new Hashtable<>();
    eventProperties.put("ddf.catalog.event.metacard", mcard);
    Event event = new Event("ddf/catalog/event/DELETED", eventProperties);
    federationAdmin.handleEvent(event);
    List<Map<String, Object>> result = (List<Map<String, Object>>) federationAdmin.allRegistryMetacardsSummary().get("nodes");
    assertThat(result.size(), is(0));
}
Also used : Hashtable(java.util.Hashtable) Event(org.osgi.service.event.Event) List(java.util.List) ArrayList(java.util.ArrayList) Matchers.anyList(org.mockito.Matchers.anyList) Map(java.util.Map) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 29 with Event

use of org.osgi.service.event.Event in project ddf by codice.

the class FederationAdminTest method performCreateEvent.

private void performCreateEvent() throws Exception {
    List<Map<String, Object>> result = (List<Map<String, Object>>) federationAdmin.allRegistryMetacardsSummary().get("nodes");
    assertThat(result.size(), is(0));
    Date timestamp = setupSummary(false);
    Dictionary<String, Object> eventProperties = new Hashtable<>();
    eventProperties.put("ddf.catalog.event.metacard", mcard);
    Event event = new Event("ddf/catalog/event/CREATED", eventProperties);
    federationAdmin.handleEvent(event);
    result = (List<Map<String, Object>>) federationAdmin.allRegistryMetacardsSummary().get("nodes");
    assertThat(result.size(), is(1));
    Map<String, Object> mcardMap = result.get(0);
    assertSummary(mcardMap, timestamp);
}
Also used : Hashtable(java.util.Hashtable) Event(org.osgi.service.event.Event) List(java.util.List) ArrayList(java.util.ArrayList) Matchers.anyList(org.mockito.Matchers.anyList) Map(java.util.Map) HashMap(java.util.HashMap) Date(java.util.Date)

Example 30 with Event

use of org.osgi.service.event.Event in project ddf by codice.

the class AbstractEventController method adminCancelDownload.

/**
     * Called by {@link  ddf.catalog.event.retrievestatus.DownloadStatusInfoImpl.cancelDownload} to fire a
     * cancel event.
     *
     * @param userId             The Id assigned to the user who is downloading.
     * @param downloadIdentifier The randomly generated downloadId string assigned to the download at its start.
     */
public void adminCancelDownload(String userId, String downloadIdentifier) {
    String downloadId = userId + downloadIdentifier;
    Map<String, Object> propMap = new HashMap<>();
    propMap.put(ActivityEvent.DOWNLOAD_ID_KEY, downloadId);
    Event event = new Event(ActivityEvent.EVENT_TOPIC_DOWNLOAD_CANCEL, propMap);
    eventAdmin.postEvent(event);
}
Also used : HashMap(java.util.HashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ActivityEvent(org.codice.ddf.activities.ActivityEvent) Event(org.osgi.service.event.Event)

Aggregations

Event (org.osgi.service.event.Event)142 Test (org.junit.Test)79 HashMap (java.util.HashMap)48 Hashtable (java.util.Hashtable)44 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)23 ContentTypePredicate (ddf.catalog.pubsub.predicate.ContentTypePredicate)20 EventAdmin (org.osgi.service.event.EventAdmin)19 GeospatialPredicate (ddf.catalog.pubsub.predicate.GeospatialPredicate)18 Predicate (ddf.catalog.pubsub.predicate.Predicate)16 ArrayList (java.util.ArrayList)16 ActivityEvent (org.codice.ddf.activities.ActivityEvent)13 EventHandler (org.osgi.service.event.EventHandler)13 SubscriptionFilterVisitor (ddf.catalog.pubsub.internal.SubscriptionFilterVisitor)11 Date (java.util.Date)11 Job (org.apache.sling.event.jobs.Job)9 Map (java.util.Map)8 List (java.util.List)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 JobManager (org.apache.sling.event.jobs.JobManager)7 JobConsumer (org.apache.sling.event.jobs.consumer.JobConsumer)7