Package org.sonatype.nexus.timeline

Examples of org.sonatype.nexus.timeline.TimelineCallback


  @Override
  public List<FeedEvent> getEvents(final Set<String> types, final Set<String> subTypes, final int from, final int count,
                                   final Predicate<Entry> filter)
  {
    final List<FeedEvent> result = Lists.newArrayList();
    final TimelineCallback callback = new TimelineCallback()
    {
      @Override
      public boolean processNext(final Entry rec) throws IOException {
        // we filter for permission only after Timeline used passed in filter predicate
        // filtering for permission is more costly than checking field equalities
View Full Code Here


      assertThat(db.countClass(DefaultTimeline.DB_CLASS), equalTo(6L));
    }

    underTest.purgeOlderThan(2);
    // ensure 1st returned entry is the latest (and still exists on timeline)
    underTest.retrieve(0, 1, null, null, null, new TimelineCallback()
    {
      public boolean processNext(final Entry rec) throws IOException {
        assertThat(rec.getType(), equalTo("TEST"));
        assertThat(rec.getSubType(), equalTo("2"));
        assertThat(rec.getData().get("day"), equalTo("3"));
        return false;
      }
    });

    try (ODatabaseDocumentTx db = underTest.openDb()) {
      partitionsPostPurge1 = Lists.newArrayList(Collections2.filter(db.getClusterNames(), new Predicate<String>()
      {
        @Override
        public boolean apply(String input) {
          return input.startsWith(DefaultTimeline.DB_CLUSTER_PREFIX);
        }
      }));
      assertThat(db.countClass(DefaultTimeline.DB_CLASS), equalTo(4L));
    }

    underTest.purgeOlderThan(1);
    // ensure 1st returned entry is the latest (and still exists on timeline)
    underTest.retrieve(0, 1, null, null, null, new TimelineCallback()
    {
      public boolean processNext(final Entry rec) throws IOException {
        assertThat(rec.getType(), equalTo("TEST"));
        assertThat(rec.getSubType(), equalTo("2"));
        assertThat(rec.getData().get("day"), equalTo("3"));
        return false;
      }
    });

    try (ODatabaseDocumentTx db = underTest.openDb()) {
      partitionsPostPurge2 = Lists.newArrayList(Collections2.filter(db.getClusterNames(), new Predicate<String>()
      {
        @Override
        public boolean apply(String input) {
          return input.startsWith(DefaultTimeline.DB_CLUSTER_PREFIX);
        }
      }));
      assertThat(db.countClass(DefaultTimeline.DB_CLASS), equalTo(2L));
    }

    underTest.purgeOlderThan(0);
    // ensure that timeline is empty, callback should not be called
    underTest.retrieve(0, 1, null, null, null, new TimelineCallback()
    {
      public boolean processNext(final Entry rec) throws IOException {
        assertThat("Timeline should be empty. callback should not be invoked!", false);
        return false;
      }
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.timeline.TimelineCallback

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.