@Test(expected = NullPointerException.class) public void throw_exception_when_oauthid_is_null_on_social_account_creation() { createSocialAccountService.createAccount(OAuthProvider.GOOGLE, null); }
public Account createAccount(OAuthProvider provider, String oauthId) { Preconditions.checkNotNull(provider); Preconditions.checkNotNull(oauthId); Account account = accountRepository.save( new Account() .setProvider(provider) .setOauthId(oauthId) .setRegisteredAt(LocalDateTime.now()) .setDefaultLanguage(SessionLanguage.fr) .setValid(false) ); account.addAuthority(authorityRepository.findByName(Role.MEMBER)); accountRepository.save(account); return account; }
CreateSocialAccountService { public Account createAccount(OAuthProvider provider, String oauthId) { Preconditions.checkNotNull(provider); Preconditions.checkNotNull(oauthId); Account account = accountRepository.save( new Account() .setProvider(provider) .setOauthId(oauthId) .setRegisteredAt(LocalDateTime.now()) .setDefaultLanguage(SessionLanguage.fr) .setValid(false) ); account.addAuthority(authorityRepository.findByName(Role.MEMBER)); accountRepository.save(account); return account; } }
CreateSocialAccountService { public Account createAccount(OAuthProvider provider, String oauthId) { Preconditions.checkNotNull(provider); Preconditions.checkNotNull(oauthId); Account account = accountRepository.save( new Account() .setProvider(provider) .setOauthId(oauthId) .setRegisteredAt(LocalDateTime.now()) .setDefaultLanguage(SessionLanguage.fr) .setValid(false) ); account.addAuthority(authorityRepository.findByName(Role.MEMBER)); accountRepository.save(account); return account; }  }
CreateSocialAccountService { public Account createAccount(OAuthProvider provider, String oauthId) { Preconditions.checkNotNull(provider); Preconditions.checkNotNull(oauthId); Account account = accountRepository.save( new Account() .setProvider(provider) .setOauthId(oauthId) .setRegisteredAt(LocalDateTime.now()) .setDefaultLanguage(SessionLanguage.fr) .setValid(false) ); account.addAuthority(authorityRepository.findByName(Role.MEMBER)); accountRepository.save(account); return account; }  Account createAccount(OAuthProvider provider, String oauthId); void updateAccount(Account account, String token, String oauthId); }
CreateSocialAccountService { public Account createAccount(OAuthProvider provider, String oauthId) { Preconditions.checkNotNull(provider); Preconditions.checkNotNull(oauthId); Account account = accountRepository.save( new Account() .setProvider(provider) .setOauthId(oauthId) .setRegisteredAt(LocalDateTime.now()) .setDefaultLanguage(SessionLanguage.fr) .setValid(false) ); account.addAuthority(authorityRepository.findByName(Role.MEMBER)); accountRepository.save(account); return account; }  Account createAccount(OAuthProvider provider, String oauthId); void updateAccount(Account account, String token, String oauthId);  }