@Test public void addApplicationBelongsToUser() { User user = new User("user"); given(applicationMock.getUser()).willReturn(user); user.addApplication(applicationMock); assertThat(user.applications).containsExactly(applicationMock); }
public void addApplication(ProjectApplication application) throws IllegalArgumentException { if(!this.equals(application.getUser())) { throw new IllegalArgumentException("The application belongs to another user!"); } applications.add(application); }
User { public void addApplication(ProjectApplication application) throws IllegalArgumentException { if(!this.equals(application.getUser())) { throw new IllegalArgumentException("The application belongs to another user!"); } applications.add(application); } }
User { public void addApplication(ProjectApplication application) throws IllegalArgumentException { if(!this.equals(application.getUser())) { throw new IllegalArgumentException("The application belongs to another user!"); } applications.add(application); } User(String userId); protected  User(); }
User { public void addApplication(ProjectApplication application) throws IllegalArgumentException { if(!this.equals(application.getUser())) { throw new IllegalArgumentException("The application belongs to another user!"); } applications.add(application); } User(String userId); protected  User(); void addBookmark(Project project); void removeBookmark(Project project); void addApplication(ProjectApplication application); void removeApplication(ProjectApplication application); Optional<AccessInterval> getLatestAccessInterval(); void addAccessInterval(AccessInterval interval); void removeAccessInterval(AccessInterval interval); }
User { public void addApplication(ProjectApplication application) throws IllegalArgumentException { if(!this.equals(application.getUser())) { throw new IllegalArgumentException("The application belongs to another user!"); } applications.add(application); } User(String userId); protected  User(); void addBookmark(Project project); void removeBookmark(Project project); void addApplication(ProjectApplication application); void removeApplication(ProjectApplication application); Optional<AccessInterval> getLatestAccessInterval(); void addAccessInterval(AccessInterval interval); void removeAccessInterval(AccessInterval interval);  }