### Question:
TriggerCleanup extends AbstractNiFiProcessor implements CleanupListener { @Override public void triggered(@Nonnull final FeedCleanupTriggerEvent event) { getLog().debug("Cleanup event triggered: {}", new Object[]{event}); queue.add(event); }  @Override Set<Relationship> getRelationships(); @OnScheduled void onScheduled(@Nonnull final ProcessContext context); @Override void onTrigger(@Nonnull final ProcessContext context, @Nonnull final ProcessSession session); @OnUnscheduled void onUnscheduled(@Nonnull final ProcessContext context); @Override void triggered(@Nonnull final FeedCleanupTriggerEvent event); static final PropertyDescriptor CATEGORY_NAME; static final PropertyDescriptor CLEANUP_SERVICE; static final PropertyDescriptor METADATA_SERVICE; static final PropertyDescriptor FEED_NAME; static final Relationship REL_SUCCESS; }### Answer:
@Test(expected = AssertionError.class) public void testTriggeredWithException() { runner.setProperty(TriggerCleanup.CATEGORY_NAME, "invalid"); runner.setProperty(TriggerCleanup.FEED_NAME, "invalid"); ((TriggerCleanup) runner.getProcessor()).triggered(new FeedCleanupTriggerEvent("FEEDID")); runner.run(); }
@Test public void testTriggered() { runner.setProperty(TriggerCleanup.CATEGORY_NAME, "cat"); runner.setProperty(TriggerCleanup.FEED_NAME, "feed"); ((TriggerCleanup) runner.getProcessor()).triggered(new FeedCleanupTriggerEvent("FEEDID")); runner.run(); List<MockFlowFile> flowFiles = runner.getFlowFilesForRelationship(TriggerCleanup.REL_SUCCESS); Assert.assertEquals(1, flowFiles.size()); flowFiles.get(0).assertAttributeEquals("category", "cat"); flowFiles.get(0).assertAttributeEquals("feed", "feed"); }
@Test public void testTriggeredWhenDisabled() { runner.setProperty(TriggerCleanup.CATEGORY_NAME, "cat"); runner.setProperty(TriggerCleanup.FEED_NAME, "disabled"); ((TriggerCleanup) runner.getProcessor()).triggered(new FeedCleanupTriggerEvent("FEEDID")); runner.run(); Assert.assertEquals(0, runner.getFlowFilesForRelationship(TriggerCleanup.REL_SUCCESS).size()); }
@Test(expected = AssertionError.class) public void testTriggeredWhenUnavailable() { runner.setProperty(TriggerCleanup.CATEGORY_NAME, "cat"); runner.setProperty(TriggerCleanup.FEED_NAME, "unavailable"); ((TriggerCleanup) runner.getProcessor()).triggered(new FeedCleanupTriggerEvent("FEEDID")); runner.run(); Assert.assertEquals(0, runner.getFlowFilesForRelationship(TriggerCleanup.REL_SUCCESS).size()); }