BotecoUser implements User { @Override public void removeDestination(MessageLocation destination) { if (destination.channel().equals(this.primaryDestination)) { throw new InvalidDestinationException("Can't remove default destination"); } if (this.destinations.containsKey(destination.channel())) { this.destinations.remove(destination.channel()); } else { throw new InvalidDestinationException("User don't have the given destination"); } } BotecoUser(String id, MessageLocation primaryDestination); @Override String id(); @Override List<MessageLocation> destinations(); @Override MessageLocation primaryDestination(); @Override MessageLocation destination(String channel); @Override void addDestination(MessageLocation destination); @Override void removeDestination(MessageLocation destination); @Override void removeDestination(String channel); void setPrimaryDestination(MessageLocation primaryDestination); @Override void setPrimaryDestination(String channel);  }
@Test public void testRemoveDestination() { Spec.given(user) .expect(removing(primaryDestination), to().raise(InvalidDestinationException.class)) .when(removing(secondaryDestination)) .expect(User::destinations, to().have(oneElement())); }