@Test public void applyUpdate() throws Exception { AccountChangeUpdate update1 = new AccountChangeUpdate(date, creator1, account1); update1.applyUpdate(mockRepos); verify(mockUserRepository).addUser(mockUser); AccountChangeUpdate update2 = new AccountChangeUpdate(date, creator1, account2); update2.applyUpdate(mockRepos); verify(mockUser).setUsername(account2.username); verify(mockUserRepository).updateUser(mockUser); }
@Override public void applyUpdate(RepositorySet repositorySet) { User user = repositorySet.userRepository.getUser(account.id); if (user != null) { user.setUsername(account.username); repositorySet.userRepository.updateUser(user); } else { user = new User(account.id, account.username, false, false, false, false, new Location("update")); repositorySet.userRepository.addUser(user); } }
AccountChangeUpdate extends Update { @Override public void applyUpdate(RepositorySet repositorySet) { User user = repositorySet.userRepository.getUser(account.id); if (user != null) { user.setUsername(account.username); repositorySet.userRepository.updateUser(user); } else { user = new User(account.id, account.username, false, false, false, false, new Location("update")); repositorySet.userRepository.addUser(user); } } }
AccountChangeUpdate extends Update { @Override public void applyUpdate(RepositorySet repositorySet) { User user = repositorySet.userRepository.getUser(account.id); if (user != null) { user.setUsername(account.username); repositorySet.userRepository.updateUser(user); } else { user = new User(account.id, account.username, false, false, false, false, new Location("update")); repositorySet.userRepository.addUser(user); } } AccountChangeUpdate(@JsonProperty("time-created") Date timeCreated,
                               @JsonProperty("creator") int creator,
                               @JsonProperty("account")
                                       CompleteAccount account); }
AccountChangeUpdate extends Update { @Override public void applyUpdate(RepositorySet repositorySet) { User user = repositorySet.userRepository.getUser(account.id); if (user != null) { user.setUsername(account.username); repositorySet.userRepository.updateUser(user); } else { user = new User(account.id, account.username, false, false, false, false, new Location("update")); repositorySet.userRepository.addUser(user); } } AccountChangeUpdate(@JsonProperty("time-created") Date timeCreated,
                               @JsonProperty("creator") int creator,
                               @JsonProperty("account")
                                       CompleteAccount account); @Override void applyUpdate(RepositorySet repositorySet); }
AccountChangeUpdate extends Update { @Override public void applyUpdate(RepositorySet repositorySet) { User user = repositorySet.userRepository.getUser(account.id); if (user != null) { user.setUsername(account.username); repositorySet.userRepository.updateUser(user); } else { user = new User(account.id, account.username, false, false, false, false, new Location("update")); repositorySet.userRepository.addUser(user); } } AccountChangeUpdate(@JsonProperty("time-created") Date timeCreated,
                               @JsonProperty("creator") int creator,
                               @JsonProperty("account")
                                       CompleteAccount account); @Override void applyUpdate(RepositorySet repositorySet);  }