BotecoUser implements User { @Override public MessageLocation destination(String channel) { if (this.destinations.containsKey(channel)) { return Destination.channel(channel).to(this.destinations.get(channel)); } throw new InvalidDestinationException("User don't have the channel '" + channel + "' registered"); } 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 testConstructor() { Spec.given(user) .expect(User::id, to().be("user")) .expect(User::primaryDestination, to().be(primaryDestination)) .expect(User::destinations, to().have(twoElements())) .expect(user -> user.destination("mychannel"), to().be(primaryDestination)) .expect((Consumer<User>) user -> user.destination("foo"), to().raise(InvalidDestinationException.class)); }