SubscriptionAssignmentView { public SubscriptionAssignmentView additions(SubscriptionAssignmentView target) { return difference(target, this); } SubscriptionAssignmentView(Map<SubscriptionName, Set<SubscriptionAssignment>> view); Set<SubscriptionName> getSubscriptions(); int getSubscriptionsCount(); Set<String> getConsumerNodes(); List<SubscriptionAssignment> getAllAssignments(); Set<String> getConsumerNodesForSubscription(SubscriptionName subscriptionName); Set<SubscriptionAssignment> getAssignmentsForSubscription(SubscriptionName subscriptionName); Set<SubscriptionName> getSubscriptionsForConsumerNode(String nodeId); Set<SubscriptionAssignment> getAssignmentsForConsumerNode(String nodeId); SubscriptionAssignmentView deletions(SubscriptionAssignmentView target); SubscriptionAssignmentView additions(SubscriptionAssignmentView target); static SubscriptionAssignmentView of(Set<SubscriptionAssignment> assignments); static SubscriptionAssignmentView copyOf(SubscriptionAssignmentView currentState); int getAssignmentsCountForSubscription(SubscriptionName subscription); int getAssignmentsCountForConsumerNode(String nodeId); @Override int hashCode(); @Override boolean equals(Object o); SubscriptionAssignmentView transform(BiConsumer<SubscriptionAssignmentView, Transformer> consumer);  }
@Test public void shouldAddToEmptyView() { SubscriptionName s1 = anySubscriptionName(); SubscriptionAssignmentView current = emptySubscriptionAssignmentView(); SubscriptionAssignmentView target = assignmentView().withAssignment(s1, "c1").build(); SubscriptionAssignmentView additions = current.additions(target); assertThat(additions).isEqualTo(target); }