Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #790 from zalando/aruha-1335
Browse files Browse the repository at this point in the history
aruha-1335: take all timelines not only active
  • Loading branch information
antban authored Dec 5, 2017
2 parents 11ab774 + cf52676 commit ab5b42f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public Multimap<TopicRepository, String> deleteAllTimelinesForEventType(final St
NoSuchEventTypeException {
LOG.info("Deleting all timelines for event type {}", eventTypeName);
final Multimap<TopicRepository, String> topicsToDelete = ArrayListMultimap.create();
for (final Timeline timeline : getActiveTimelinesOrdered(eventTypeName)) {
for (final Timeline timeline : getAllTimelinesOrdered(eventTypeName)) {
topicsToDelete.put(getTopicRepository(timeline), timeline.getTopic());
timelineDbRepository.deleteTimeline(timeline.getId());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.zalando.nakadi.utils.TestUtils.buildDefaultEventType;

public class TimelineServiceTest {

Expand Down Expand Up @@ -119,4 +120,20 @@ public void shouldDeleteTopicWhenTimelineCreationFails() throws Exception {
Mockito.verify(repository, Mockito.times(1)).deleteTopic(any());
}

@Test
public void shouldDeleteAllTimelinesWhenOneTimelineWasMarkedAsDeleted() throws Exception {
final EventType eventType = buildDefaultEventType();
final Timeline t1 = Timeline.createTimeline(eventType.getName(), 1, null, "topic1", new Date());
t1.setDeleted(true);
t1.setSwitchedAt(new Date());
final Timeline t2 = Timeline.createTimeline(eventType.getName(), 2, null, "topic2", new Date());
t2.setSwitchedAt(new Date());
Mockito.when(eventTypeCache.getTimelinesOrdered(eventType.getName()))
.thenReturn(ImmutableList.of(t1, t2));

timelineService.deleteAllTimelinesForEventType(eventType.getName());

Mockito.verify(timelineDbRepository, Mockito.times(2)).deleteTimeline(Mockito.any());
}

}

0 comments on commit ab5b42f

Please sign in to comment.