@Test public void testCreate() { new Expectations() {{ systemService.currentTimeMillis(); result = 1563200810123L; times = 1; passwordService.createPasswordHash("test_pwd"); result = "test_pwd_hash"; times = 1; }}; String result = accountCreate .setUsername("my_user_name") .setFirstName("my_first_name") .setLastName("my_last_name") .setEmail("test@example.com") .setPassword("test_pwd") .setDescription("test_desp") .create(); new Verifications(){{ AccountModel accountModel; storage.createAccount(accountModel = withCapture()); times = 1; Assert.assertEquals(accountModel.getUsername(), "my_user_name"); Assert.assertEquals(accountModel.getFirstName(), "my_first_name"); Assert.assertEquals(accountModel.getLastName(), "my_last_name"); Assert.assertEquals(accountModel.getLastName(), "my_last_name"); Assert.assertEquals(accountModel.getEmail(), "test@example.com"); Assert.assertEquals(accountModel.getPasswordHash(), "test_pwd_hash"); Assert.assertEquals(accountModel.getDescription(), "test_desp"); Assert.assertEquals(accountModel.getCreateTs(), 1563200810123L); Assert.assertEquals(accountModel.getUpdateTs(), 1563200810123L); Assert.assertFalse(accountModel.isEmailVerified()); }}; Assert.assertEquals(result, "my_user_name"); }
@Nonnull @Override public String create() throws IdentityException { Validate.notNull(account.getUsername(), "username must be set"); Validate.notNull(account.getFirstName(), "first name must be set"); Validate.notNull(account.getLastName(), "last name must be set"); Validate.notNull(account.getPasswordHash(), "password must be set"); Validate.notNull(account.getEmail(), "email must be set"); Validate.notNull(account.getDescription(), "description must be set"); long nowMs = systemService.currentTimeMillis(); account.setCreateTs(nowMs); account.setUpdateTs(nowMs); account.setEmailVerified(false); storage.createAccount(account); return account.getUsername(); }
AccountCreateImpl implements AccountCreate { @Nonnull @Override public String create() throws IdentityException { Validate.notNull(account.getUsername(), "username must be set"); Validate.notNull(account.getFirstName(), "first name must be set"); Validate.notNull(account.getLastName(), "last name must be set"); Validate.notNull(account.getPasswordHash(), "password must be set"); Validate.notNull(account.getEmail(), "email must be set"); Validate.notNull(account.getDescription(), "description must be set"); long nowMs = systemService.currentTimeMillis(); account.setCreateTs(nowMs); account.setUpdateTs(nowMs); account.setEmailVerified(false); storage.createAccount(account); return account.getUsername(); } }
AccountCreateImpl implements AccountCreate { @Nonnull @Override public String create() throws IdentityException { Validate.notNull(account.getUsername(), "username must be set"); Validate.notNull(account.getFirstName(), "first name must be set"); Validate.notNull(account.getLastName(), "last name must be set"); Validate.notNull(account.getPasswordHash(), "password must be set"); Validate.notNull(account.getEmail(), "email must be set"); Validate.notNull(account.getDescription(), "description must be set"); long nowMs = systemService.currentTimeMillis(); account.setCreateTs(nowMs); account.setUpdateTs(nowMs); account.setEmailVerified(false); storage.createAccount(account); return account.getUsername(); } AccountCreateImpl(
        @Nonnull Storage storage,
        @Nonnull PasswordService passwordService,
        @Nonnull SystemService systemService); }
AccountCreateImpl implements AccountCreate { @Nonnull @Override public String create() throws IdentityException { Validate.notNull(account.getUsername(), "username must be set"); Validate.notNull(account.getFirstName(), "first name must be set"); Validate.notNull(account.getLastName(), "last name must be set"); Validate.notNull(account.getPasswordHash(), "password must be set"); Validate.notNull(account.getEmail(), "email must be set"); Validate.notNull(account.getDescription(), "description must be set"); long nowMs = systemService.currentTimeMillis(); account.setCreateTs(nowMs); account.setUpdateTs(nowMs); account.setEmailVerified(false); storage.createAccount(account); return account.getUsername(); } AccountCreateImpl(
        @Nonnull Storage storage,
        @Nonnull PasswordService passwordService,
        @Nonnull SystemService systemService); @Override @Nonnull AccountCreate setUsername(@Nonnull String username); @Override @Nonnull AccountCreate setFirstName(@Nonnull String firstName); @Override @Nonnull AccountCreate setLastName(@Nonnull String lastName); @Override @Nonnull AccountCreate setEmail(@Nonnull String email); @Override @Nonnull AccountCreate setPassword(@Nonnull String password); @Nonnull @Override AccountCreate setDescription(@Nonnull String description); @Nonnull @Override String create(); }
AccountCreateImpl implements AccountCreate { @Nonnull @Override public String create() throws IdentityException { Validate.notNull(account.getUsername(), "username must be set"); Validate.notNull(account.getFirstName(), "first name must be set"); Validate.notNull(account.getLastName(), "last name must be set"); Validate.notNull(account.getPasswordHash(), "password must be set"); Validate.notNull(account.getEmail(), "email must be set"); Validate.notNull(account.getDescription(), "description must be set"); long nowMs = systemService.currentTimeMillis(); account.setCreateTs(nowMs); account.setUpdateTs(nowMs); account.setEmailVerified(false); storage.createAccount(account); return account.getUsername(); } AccountCreateImpl(
        @Nonnull Storage storage,
        @Nonnull PasswordService passwordService,
        @Nonnull SystemService systemService); @Override @Nonnull AccountCreate setUsername(@Nonnull String username); @Override @Nonnull AccountCreate setFirstName(@Nonnull String firstName); @Override @Nonnull AccountCreate setLastName(@Nonnull String lastName); @Override @Nonnull AccountCreate setEmail(@Nonnull String email); @Override @Nonnull AccountCreate setPassword(@Nonnull String password); @Nonnull @Override AccountCreate setDescription(@Nonnull String description); @Nonnull @Override String create();  }