use of org.zalando.nakadi.service.subscription.model.Partition.State.ASSIGNED in project nakadi by zalando.
the class SubscriptionRebalancerTest method rebalanceShouldRemoveDeadSessions.
@Test
public void rebalanceShouldRemoveDeadSessions() {
final Partition[] changeset = new SubscriptionRebalancer().apply(ImmutableList.of(new Session("1", 1), new Session("2", 1)), new Partition[] { new Partition("0", "0", "0", null, ASSIGNED), new Partition("0", "1", "0", "1", REASSIGNING), new Partition("1", "0", "1", null, ASSIGNED), new Partition("1", "1", "0", null, ASSIGNED) });
assertEquals(3, changeset.length);
// All partitions must be in assigned state
assertFalse(Stream.of(changeset).anyMatch(p -> p.getState() != ASSIGNED));
// All partitions must not have nextSessionId
assertFalse(Stream.of(changeset).anyMatch(p -> p.getNextSession() != null));
assertFalse(Stream.of(changeset).anyMatch(p -> p.getKey().equals(new EventTypePartition("1", "0"))));
assertEquals(1, Stream.of(changeset).filter(p -> p.getSession().equals("1")).count());
assertEquals(2, Stream.of(changeset).filter(p -> p.getSession().equals("2")).count());
assertFalse(Stream.of(changeset).anyMatch(p -> p.getState() != ASSIGNED));
}
Aggregations