From cbbda99d73d7bd49657da6d8cf4bbb83b895dac7 Mon Sep 17 00:00:00 2001 From: Ralitsa Todorova Date: Fri, 31 Aug 2018 16:49:50 +0300 Subject: [PATCH 1/8] NY-3044: Add authentication identifier and type to AccountDetails response Signed-off-by: Ralitsa Todorova --- src/main/java/biz/nynja/account/models/Account.java | 3 ++- src/main/java/biz/nynja/account/models/AccountByProfileId.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/biz/nynja/account/models/Account.java b/src/main/java/biz/nynja/account/models/Account.java index 0c44ff7..cffdbaf 100644 --- a/src/main/java/biz/nynja/account/models/Account.java +++ b/src/main/java/biz/nynja/account/models/Account.java @@ -286,7 +286,8 @@ public class Account { public AccountDetails toProto() { Builder builder = AccountDetails.newBuilder().setAccountId(getAccountId().toString()) - .setProfileId(getProfileId().toString()).setAccountMark(getAccountMark()) + .setProfileId(getProfileId().toString()).setAuthenticationIdentifier(getAuthenticationProvider()) + .setAuthenticationType(getAuthenticationProviderType()).setAccountMark(getAccountMark()) .setAccountName(getAccountName()).setFirstName(getFirstName()).setLastName(getLastName()) .setUsername(getUsername()).setAccountStatus(getAccountStatus()).setQrCode(getQrCode()); diff --git a/src/main/java/biz/nynja/account/models/AccountByProfileId.java b/src/main/java/biz/nynja/account/models/AccountByProfileId.java index def5fe0..21573a3 100644 --- a/src/main/java/biz/nynja/account/models/AccountByProfileId.java +++ b/src/main/java/biz/nynja/account/models/AccountByProfileId.java @@ -272,7 +272,8 @@ public class AccountByProfileId { public biz.nynja.account.grpc.AccountDetails toProto() { Builder builder = biz.nynja.account.grpc.AccountDetails.newBuilder().setAccountId(getAccountId().toString()) - .setProfileId(getProfileId().toString()).setAccountMark(getAccountMark()) + .setProfileId(getProfileId().toString()).setAuthenticationIdentifier(getAuthenticationProvider()) + .setAuthenticationType(getAuthenticationProviderType()).setAccountMark(getAccountMark()) .setAccountName(getAccountName()).setFirstName(getFirstName()).setLastName(getLastName()) .setUsername(getUsername()).setAccountStatus(getAccountStatus()); -- GitLab From 82792df49f4624d80de2d07758385c084ba07ac2 Mon Sep 17 00:00:00 2001 From: Ralitsa Todorova Date: Fri, 31 Aug 2018 16:53:03 +0300 Subject: [PATCH 2/8] NY-3044: Unify gRPC responses - return AccountResponse for expected single account in response; - return AccountsResponse for expected list of accounts in response. Signed-off-by: Ralitsa Todorova --- .../account/services/AccountServiceImpl.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java index 9cf8573..5d60d58 100644 --- a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java +++ b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java @@ -15,14 +15,14 @@ import org.springframework.beans.factory.annotation.Autowired; import biz.nynja.account.components.Validator; import biz.nynja.account.grpc.AccountDetails; +import biz.nynja.account.grpc.AccountResponse; import biz.nynja.account.grpc.AccountServiceGrpc; import biz.nynja.account.grpc.AccountsByAuthenticationProviderRequest; import biz.nynja.account.grpc.AccountsByProfileIdRequest; +import biz.nynja.account.grpc.AccountsList; import biz.nynja.account.grpc.AccountsResponse; import biz.nynja.account.grpc.CompletePendingAccountCreationRequest; -import biz.nynja.account.grpc.CompletePendingAccountCreationResponse; import biz.nynja.account.grpc.CreateAccountRequest; -import biz.nynja.account.grpc.CreateAccountResponse; import biz.nynja.account.grpc.CreatePendingAccountRequest; import biz.nynja.account.grpc.CreatePendingAccountResponse; import biz.nynja.account.grpc.ErrorResponse; @@ -41,7 +41,6 @@ import biz.nynja.account.repositories.PendingAccountRepository; import biz.nynja.account.repositories.UserInfoByEmailRepository; import biz.nynja.account.repositories.UserInfoByPhoneRepository; import biz.nynja.account.repositories.UserInfoRepository; -import biz.nynja.account.grpc.GetAccountsResponse; import io.grpc.stub.StreamObserver; /** @@ -189,11 +188,11 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas @Override public void getAllAccountsByProfileId(AccountsByProfileIdRequest request, - StreamObserver responseObserver) { - logger.info("Getting accounts by profile ID..."); + StreamObserver responseObserver) { + logger.info("Getting accounts by profile id: {}", request.getProfileId()); if ((request.getProfileId() == null) || (request.getProfileId().isEmpty())) { - responseObserver.onNext(GetAccountsResponse.newBuilder() + responseObserver.onNext(AccountsResponse.newBuilder() .setError(ErrorResponse.newBuilder().setCause(Cause.MISSING_PROFILE_ID)).build()); responseObserver.onCompleted(); return; @@ -205,7 +204,7 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas List responseList = new ArrayList(); if (listAccountsByProfileId.size() == 0) { - responseObserver.onNext(GetAccountsResponse.newBuilder() + responseObserver.onNext(AccountsResponse.newBuilder() .setError(ErrorResponse.newBuilder().setCause(Cause.ACCOUNT_NOT_FOUND)).build()); responseObserver.onCompleted(); return; @@ -215,8 +214,8 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas responseList.add(account.toProto()); } - GetAccountsResponse response = GetAccountsResponse.newBuilder() - .setAccountsResponse(AccountsResponse.newBuilder().addAllAccountDetails(responseList)).build(); + AccountsResponse response = AccountsResponse.newBuilder() + .setAccountsResponse(AccountsList.newBuilder().addAllAccountDetails(responseList)).build(); logger.debug("Returned response: \"{}\".", response); @@ -252,21 +251,20 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas @Override public void completePendingAccountCreation(CompletePendingAccountCreationRequest request, - StreamObserver responseObserver) { + StreamObserver responseObserver) { logger.info("Complete pending account creation..."); logger.debug("Complete pending account creation...: {} ...", request); Account createdAccount = accountRepositoryAdditional.completePendingAccountCreation(request); if (createdAccount == null) { - responseObserver.onNext(CompletePendingAccountCreationResponse.newBuilder() + responseObserver.onNext(AccountResponse.newBuilder() .setError(ErrorResponse.newBuilder().setCause(Cause.ERROR_CREATING_ACCOUNT)).build()); responseObserver.onCompleted(); return; } else { logger.debug("Account \"{}\" saved into the DB", createdAccount.toString()); - CompletePendingAccountCreationResponse response = CompletePendingAccountCreationResponse.newBuilder() - .setAccountDetails(createdAccount.toCompletePendingAccountProto()).build(); + AccountResponse response = AccountResponse.newBuilder().setAccountDetails(createdAccount.toProto()).build(); logger.debug("Account: \"{}\" created successfully.", response); responseObserver.onNext(response); -- GitLab From e55718142cbc7f1a9aa5f5558a499e5f34302dc9 Mon Sep 17 00:00:00 2001 From: Ralitsa Todorova Date: Fri, 31 Aug 2018 16:53:03 +0300 Subject: [PATCH 3/8] NY-3044: Refactor get account by authentication provider implementation Signed-off-by: Ralitsa Todorova --- .../AccountByAuthenticationProvider.java | 297 ++++++++++++++++++ ...untByAuthenticationProviderRepository.java | 17 + .../account/services/AccountServiceImpl.java | 87 +++-- 3 files changed, 352 insertions(+), 49 deletions(-) create mode 100644 src/main/java/biz/nynja/account/models/AccountByAuthenticationProvider.java create mode 100644 src/main/java/biz/nynja/account/repositories/AccountByAuthenticationProviderRepository.java diff --git a/src/main/java/biz/nynja/account/models/AccountByAuthenticationProvider.java b/src/main/java/biz/nynja/account/models/AccountByAuthenticationProvider.java new file mode 100644 index 0000000..c65ecf4 --- /dev/null +++ b/src/main/java/biz/nynja/account/models/AccountByAuthenticationProvider.java @@ -0,0 +1,297 @@ +/** + * Copyright (C) 2018 Nynja Inc. All rights reserved. + */ +package biz.nynja.account.models; + +import java.nio.ByteBuffer; +import java.util.Set; +import java.util.UUID; + +import biz.nynja.account.grpc.AccountDetails.Builder; + +public class AccountByAuthenticationProvider { + + private UUID profileId; + private UUID accountId; + private String accountMark; + private String authenticationProvider; + private String authenticationProviderType; + private String firstName; + private String lastName; + private ByteBuffer avatar; + private String accountName; + private String username; + private String accountStatus; + private Long creationTimestamp; + private Long lastUpdateTimestamp; + private Set communicationProviders; + private String qrCode; + + public UUID getAccountId() { + return accountId; + } + + public void setAccountId(UUID accountId) { + this.accountId = accountId; + } + + public UUID getProfileId() { + return profileId; + } + + public void setProfileId(UUID profileId) { + this.profileId = profileId; + } + + public String getAccountMark() { + return accountMark; + } + + public void setAccountMark(String accountMark) { + this.accountMark = accountMark; + } + + public String getAuthenticationProvider() { + return authenticationProvider; + } + + public void setAuthenticationProvider(String authenticationProvider) { + this.authenticationProvider = authenticationProvider; + } + + public String getAuthenticationProviderType() { + return authenticationProviderType; + } + + public void setAuthenticationProviderType(String authenticationProviderType) { + this.authenticationProviderType = authenticationProviderType; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public ByteBuffer getAvatar() { + return avatar; + } + + public void setAvatar(ByteBuffer avatar) { + this.avatar = avatar; + } + + public String getAccountName() { + return accountName; + } + + public void setAccountName(String accountName) { + this.accountName = accountName; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getAccountStatus() { + return accountStatus; + } + + public void setAccountStatus(String accountStatus) { + this.accountStatus = accountStatus; + } + + public Long getCreationTimestamp() { + return creationTimestamp; + } + + public void setCreationTimestamp(Long creationTimestamp) { + this.creationTimestamp = creationTimestamp; + } + + public Long getLastUpdateTimestamp() { + return lastUpdateTimestamp; + } + + public void setLastUpdateTimestamp(Long lastUpdateTimestamp) { + this.lastUpdateTimestamp = lastUpdateTimestamp; + } + + public Set getCommunicationProviders() { + return communicationProviders; + } + + public void setCommunicationProviders(Set communicationProviders) { + this.communicationProviders = communicationProviders; + } + + public String getQrCode() { + return qrCode; + } + + public void setQrCode(String qrCode) { + this.qrCode = qrCode; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((accountId == null) ? 0 : accountId.hashCode()); + result = prime * result + ((accountMark == null) ? 0 : accountMark.hashCode()); + result = prime * result + ((accountName == null) ? 0 : accountName.hashCode()); + result = prime * result + ((accountStatus == null) ? 0 : accountStatus.hashCode()); + result = prime * result + ((authenticationProvider == null) ? 0 : authenticationProvider.hashCode()); + result = prime * result + ((authenticationProviderType == null) ? 0 : authenticationProviderType.hashCode()); + result = prime * result + ((avatar == null) ? 0 : avatar.hashCode()); + result = prime * result + ((communicationProviders == null) ? 0 : communicationProviders.hashCode()); + result = prime * result + ((creationTimestamp == null) ? 0 : creationTimestamp.hashCode()); + result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); + result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); + result = prime * result + ((lastUpdateTimestamp == null) ? 0 : lastUpdateTimestamp.hashCode()); + result = prime * result + ((profileId == null) ? 0 : profileId.hashCode()); + result = prime * result + ((qrCode == null) ? 0 : qrCode.hashCode()); + result = prime * result + ((username == null) ? 0 : username.hashCode()); + return result; + } + + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + AccountByAuthenticationProvider other = (AccountByAuthenticationProvider) obj; + if (accountId == null) { + if (other.accountId != null) + return false; + } else if (!accountId.equals(other.accountId)) + return false; + if (accountMark == null) { + if (other.accountMark != null) + return false; + } else if (!accountMark.equals(other.accountMark)) + return false; + if (accountName == null) { + if (other.accountName != null) + return false; + } else if (!accountName.equals(other.accountName)) + return false; + if (accountStatus == null) { + if (other.accountStatus != null) + return false; + } else if (!accountStatus.equals(other.accountStatus)) + return false; + if (authenticationProvider == null) { + if (other.authenticationProvider != null) + return false; + } else if (!authenticationProvider.equals(other.authenticationProvider)) + return false; + if (authenticationProviderType == null) { + if (other.authenticationProviderType != null) + return false; + } else if (!authenticationProviderType.equals(other.authenticationProviderType)) + return false; + if (avatar == null) { + if (other.avatar != null) + return false; + } else if (!avatar.equals(other.avatar)) + return false; + if (communicationProviders == null) { + if (other.communicationProviders != null) + return false; + } else if (!communicationProviders.equals(other.communicationProviders)) + return false; + if (creationTimestamp == null) { + if (other.creationTimestamp != null) + return false; + } else if (!creationTimestamp.equals(other.creationTimestamp)) + return false; + if (firstName == null) { + if (other.firstName != null) + return false; + } else if (!firstName.equals(other.firstName)) + return false; + if (lastName == null) { + if (other.lastName != null) + return false; + } else if (!lastName.equals(other.lastName)) + return false; + if (lastUpdateTimestamp == null) { + if (other.lastUpdateTimestamp != null) + return false; + } else if (!lastUpdateTimestamp.equals(other.lastUpdateTimestamp)) + return false; + if (profileId == null) { + if (other.profileId != null) + return false; + } else if (!profileId.equals(other.profileId)) + return false; + if (qrCode == null) { + if (other.qrCode != null) + return false; + } else if (!qrCode.equals(other.qrCode)) + return false; + if (username == null) { + if (other.username != null) + return false; + } else if (!username.equals(other.username)) + return false; + return true; + } + + @Override + public String toString() { + return new StringBuilder("Account [accountId=").append(accountId).append(", profileId=").append(profileId) + .append(", accountMark=").append(accountMark).append(", authenticationProvider=") + .append(authenticationProvider).append(", authenticationProviderType=") + .append(authenticationProviderType).append(", firstName=").append(firstName).append(", lastName=") + .append(lastName).append(", avatar=").append(avatar).append(", accountName=").append(accountName) + .append(", username=").append(username).append(", accountStatus=").append(accountStatus) + .append(", creationTimestamp=").append(creationTimestamp).append(", lastUpdateTimestamp=") + .append(lastUpdateTimestamp).append(", communicationProviders=").append(communicationProviders) + .append("]").toString(); + } + + public biz.nynja.account.grpc.AccountDetails toProto() { + + Builder builder = biz.nynja.account.grpc.AccountDetails.newBuilder().setAccountId(getAccountId().toString()) + .setProfileId(getProfileId().toString()).setAuthenticationIdentifier(getAuthenticationProvider()) + .setAuthenticationType(getAuthenticationProviderType()).setAccountMark(getAccountMark()) + .setAccountName(getAccountName()).setFirstName(getFirstName()).setLastName(getLastName()) + .setUsername(getUsername()).setAccountStatus(getAccountStatus()); + + if (getQrCode() != null) { + builder.setQrCode(getQrCode()); + } + if (avatar != null) { + builder.setAvatar(com.google.protobuf.ByteString.copyFrom(avatar)); + } + if (communicationProviders != null) { + for (AuthenticationProvider ap : communicationProviders) { + builder.addCommunicationProviders(ap.toProto()); + } + } + + return builder.build(); + + } + +} diff --git a/src/main/java/biz/nynja/account/repositories/AccountByAuthenticationProviderRepository.java b/src/main/java/biz/nynja/account/repositories/AccountByAuthenticationProviderRepository.java new file mode 100644 index 0000000..73f9cb7 --- /dev/null +++ b/src/main/java/biz/nynja/account/repositories/AccountByAuthenticationProviderRepository.java @@ -0,0 +1,17 @@ +/** + * Copyright (C) 2018 Nynja Inc. All rights reserved. + */ +package biz.nynja.account.repositories; + +import java.util.List; + +import org.springframework.data.cassandra.repository.CassandraRepository; +import org.springframework.stereotype.Repository; + +import biz.nynja.account.models.AccountByAuthenticationProvider; + +@Repository +public interface AccountByAuthenticationProviderRepository extends CassandraRepository { + + List findAllByAuthenticationProvider(String authenticationProvider); +} diff --git a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java index 5d60d58..c48c8f3 100644 --- a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java +++ b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java @@ -14,10 +14,10 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import biz.nynja.account.components.Validator; +import biz.nynja.account.grpc.AccountByAuthenticationProviderRequest; import biz.nynja.account.grpc.AccountDetails; import biz.nynja.account.grpc.AccountResponse; import biz.nynja.account.grpc.AccountServiceGrpc; -import biz.nynja.account.grpc.AccountsByAuthenticationProviderRequest; import biz.nynja.account.grpc.AccountsByProfileIdRequest; import biz.nynja.account.grpc.AccountsList; import biz.nynja.account.grpc.AccountsResponse; @@ -28,9 +28,10 @@ import biz.nynja.account.grpc.CreatePendingAccountResponse; import biz.nynja.account.grpc.ErrorResponse; import biz.nynja.account.grpc.ErrorResponse.Cause; import biz.nynja.account.models.Account; +import biz.nynja.account.models.AccountByAuthenticationProvider; import biz.nynja.account.models.AccountByProfileId; -import biz.nynja.account.models.AuthenticationProvider; import biz.nynja.account.models.PendingAccount; +import biz.nynja.account.repositories.AccountByAuthenticationProviderRepository; import biz.nynja.account.models.UserInfo; import biz.nynja.account.models.UserInfoByEmail; import biz.nynja.account.models.UserInfoByPhone; @@ -63,7 +64,7 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas private AccountByProfileIdRepository accountByProfileIdRepository; @Autowired - private UserInfoByEmailRepository userInfoByEmailRepository; + private AccountByAuthenticationProviderRepository accountByAuthenticationProviderRepository; @Autowired private PendingAccountRepository pendingAccountRepository; @@ -116,74 +117,62 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas } @Override - public void getAllAccountsByAuthenticationProvider(AccountsByAuthenticationProviderRequest request, - StreamObserver responseObserver) { + public void getAccountByAuthenticationProvider(AccountByAuthenticationProviderRequest request, + StreamObserver responseObserver) { - logger.info("New get all accounts by authentication provider request recieved."); - logger.debug("New get all accounts by authentication provider request recieved: {}", request); + logger.info("Getting account by authentication provider: {}", request); if (request.getAuthenticationType() == null) { - responseObserver.onNext(GetAccountsResponse.newBuilder() + responseObserver.onNext(AccountResponse.newBuilder() .setError(ErrorResponse.newBuilder().setCause(Cause.MISSING_AUTH_PROVIDER_TYPE)).build()); responseObserver.onCompleted(); return; } if (request.getAuthenticationIdentifier() == null) { - responseObserver.onNext(GetAccountsResponse.newBuilder() + responseObserver.onNext(AccountResponse.newBuilder() .setError(ErrorResponse.newBuilder().setCause(Cause.MISSING_AUTH_PROVIDER_IDENTIFIER)).build()); responseObserver.onCompleted(); return; } - List accountDetails = new ArrayList(); + AccountDetails accountDetails = null; - switch (request.getAuthenticationType()) { - case PHONE: { - - List relatedAccounts = userInfoByPhoneRepository - .findByPhoneNumber(request.getAuthenticationIdentifier()); - if (relatedAccounts.isEmpty()) { - responseObserver.onNext(GetAccountsResponse.newBuilder() - .setError(ErrorResponse.newBuilder().setCause(Cause.ACCOUNT_NOT_FOUND)).build()); - responseObserver.onCompleted(); - return; - } + List accounts = accountByAuthenticationProviderRepository + .findAllByAuthenticationProvider(request.getAuthenticationIdentifier()); - for (UserInfoByPhone account : relatedAccounts) { - accountDetails.add(account.toProto()); - } - GetAccountsResponse response = GetAccountsResponse.newBuilder() - .setAccountsResponse(AccountsResponse.newBuilder().addAllAccountDetails(accountDetails)).build(); - responseObserver.onNext(response); + if (accounts.isEmpty()) { + logger.debug("No matching accounts found for authetntication provider {}: {}", + request.getAuthenticationType(), request.getAuthenticationIdentifier()); + responseObserver.onNext(AccountResponse.newBuilder() + .setError(ErrorResponse.newBuilder().setCause(Cause.ACCOUNT_NOT_FOUND)).build()); responseObserver.onCompleted(); + return; } - case EMAIL: { - List relatedAccounts = userInfoByEmailRepository - .findByEmailAddress(request.getAuthenticationIdentifier()); - if (relatedAccounts.isEmpty()) { - responseObserver.onNext(GetAccountsResponse.newBuilder() - .setError(ErrorResponse.newBuilder().setCause(Cause.ACCOUNT_NOT_FOUND)).build()); - responseObserver.onCompleted(); - return; - } - for (UserInfoByEmail account : relatedAccounts) { - accountDetails.add(account.toProto()); + + // We retrieve accounts by authentication provider identifier from DB where both authentication provider + // identifier and type uniquely identify an account. + // For this reason we need to filter results by authentication provider type. + for (AccountByAuthenticationProvider account : accounts) { + if (account.getAuthenticationProviderType().equals(request.getAuthenticationType().name())) { + accountDetails = account.toProto(); + break; } } - case FACEBOOK: - break; - case GOOGLEPLUS: - break; - case UNRECOGNIZED: - break; - default: - break; - + if (accountDetails == null) { + logger.debug("No matching accounts found for authetntication provider {}: {}", + request.getAuthenticationType(), request.getAuthenticationIdentifier()); + responseObserver.onNext(AccountResponse.newBuilder() + .setError(ErrorResponse.newBuilder().setCause(Cause.ACCOUNT_NOT_FOUND)).build()); + responseObserver.onCompleted(); + return; } - GetAccountsResponse response = GetAccountsResponse.newBuilder() - .setAccountsResponse(AccountsResponse.newBuilder().addAllAccountDetails(accountDetails)).build(); + AccountResponse response = AccountResponse.newBuilder().setAccountDetails(accountDetails).build(); + logger.debug("Found result for account by authentication provider {}: {}: \"{}\"", + request.getAuthenticationType(), request.getAuthenticationIdentifier(), response); responseObserver.onNext(response); responseObserver.onCompleted(); + + return; } @Override -- GitLab From b8cc6aeb84f0dfe2a702b16d31c4f178e4e8005d Mon Sep 17 00:00:00 2001 From: Ralitsa Todorova Date: Fri, 31 Aug 2018 16:53:03 +0300 Subject: [PATCH 4/8] NY-3044: Remove stale implementation - temporary commented unit tests and validations. Signed-off-by: Ralitsa Todorova --- .../nynja/account/components/Validator.java | 90 +- .../biz/nynja/account/models/UserInfo.java | 268 ------ .../nynja/account/models/UserInfoByEmail.java | 250 ----- .../nynja/account/models/UserInfoByPhone.java | 247 ----- .../account/models/UserInfoByUsername.java | 226 ----- .../UserInfoByEmailRepository.java | 17 - .../UserInfoByPhoneRepository.java | 15 - .../UserInfoByUsernameRepository.java | 15 - .../repositories/UserInfoRepository.java | 17 - .../account/services/AccountServiceImpl.java | 51 +- .../account/components/ValidatorTests.java | 12 - .../account/services/AccountServiceTests.java | 911 +++++++++--------- .../java/biz/nynja/account/utils/Util.java | 129 ++- 13 files changed, 547 insertions(+), 1701 deletions(-) delete mode 100644 src/main/java/biz/nynja/account/models/UserInfo.java delete mode 100644 src/main/java/biz/nynja/account/models/UserInfoByEmail.java delete mode 100644 src/main/java/biz/nynja/account/models/UserInfoByPhone.java delete mode 100644 src/main/java/biz/nynja/account/models/UserInfoByUsername.java delete mode 100644 src/main/java/biz/nynja/account/repositories/UserInfoByEmailRepository.java delete mode 100644 src/main/java/biz/nynja/account/repositories/UserInfoByPhoneRepository.java delete mode 100644 src/main/java/biz/nynja/account/repositories/UserInfoByUsernameRepository.java delete mode 100644 src/main/java/biz/nynja/account/repositories/UserInfoRepository.java diff --git a/src/main/java/biz/nynja/account/components/Validator.java b/src/main/java/biz/nynja/account/components/Validator.java index cccc9de..d8fdc75 100644 --- a/src/main/java/biz/nynja/account/components/Validator.java +++ b/src/main/java/biz/nynja/account/components/Validator.java @@ -23,9 +23,6 @@ import org.springframework.stereotype.Component; import biz.nynja.account.grpc.CreateAccountRequest; import biz.nynja.account.grpc.ErrorResponse.Cause; import biz.nynja.account.models.CountryInfo; -import biz.nynja.account.repositories.UserInfoByEmailRepository; -import biz.nynja.account.repositories.UserInfoByPhoneRepository; -import biz.nynja.account.repositories.UserInfoByUsernameRepository; /** * Component which contains all validation methods. @@ -38,15 +35,6 @@ public class Validator { private HashMap countryInfoMap; - @Autowired - private UserInfoByEmailRepository userInfoByEmailRepository; - - @Autowired - private UserInfoByPhoneRepository userInfoByPhoneRepository; - - @Autowired - private UserInfoByUsernameRepository userInfoByUsernameRepository; - @PostConstruct public void loadPhonesBook() { @@ -169,44 +157,44 @@ public class Validator { return isValid; } - public Cause validateCreateAccountRequest(CreateAccountRequest request) { - - if (request.getUsername() != null && !request.getUsername().trim().isEmpty() - && !isUsernameValid(request.getUsername())) { - return Cause.USERNAME_INVALID; - } else if (request.getUsername() != null && !request.getUsername().trim().isEmpty() - && !userInfoByUsernameRepository.findByUsername(request.getUsername()).isEmpty()) { - return Cause.USERNAME_ALREADY_USED; - } - - if (request.getEmailAddress() != null && !request.getEmailAddress().trim().isEmpty() - && !isEmailValid(request.getEmailAddress())) { - return Cause.EMAIL_INVALID; - } else if (request.getEmailAddress() != null && !request.getEmailAddress().trim().isEmpty() - && !userInfoByEmailRepository.findByEmailAddress(request.getEmailAddress()).isEmpty()) { - return Cause.EMAIL_ALREADY_USED; - } - - if (request.getPhoneNumber() != null && !request.getPhoneNumber().trim().isEmpty() - && !isPhoneNumberValid(request.getPhoneNumber(), request.getCountryCode())) { - return Cause.PHONE_NUMBER_INVALID; - } else if (request.getPhoneNumber() != null && !request.getPhoneNumber().trim().isEmpty() - && !userInfoByPhoneRepository.findByPhoneNumber(request.getPhoneNumber()).isEmpty()) { - return Cause.PHONE_NUMBER_ALREADY_USED; - } - - if (request.getFirstName() != null && request.getFirstName().trim().isEmpty()) { - return Cause.MISSING_FIRST_NAME; - } else if (!isFirstNameValid(request.getFirstName())) { - return Cause.INVALID_FIRST_NAME; - } - - if (request.getLastName() != null && !request.getLastName().trim().isEmpty() - && !isLastNameValid(request.getLastName())) { - return Cause.INVALID_LAST_NAME; - } - - return null; - } +// public Cause validateCreateAccountRequest(CreateAccountRequest request) { +// +// if (request.getUsername() != null && !request.getUsername().trim().isEmpty() +// && !isUsernameValid(request.getUsername())) { +// return Cause.USERNAME_INVALID; +// } else if (request.getUsername() != null && !request.getUsername().trim().isEmpty() +// && !userInfoByUsernameRepository.findByUsername(request.getUsername()).isEmpty()) { +// return Cause.USERNAME_ALREADY_USED; +// } +// +// if (request.getEmailAddress() != null && !request.getEmailAddress().trim().isEmpty() +// && !isEmailValid(request.getEmailAddress())) { +// return Cause.EMAIL_INVALID; +// } else if (request.getEmailAddress() != null && !request.getEmailAddress().trim().isEmpty() +// && !userInfoByEmailRepository.findByEmailAddress(request.getEmailAddress()).isEmpty()) { +// return Cause.EMAIL_ALREADY_USED; +// } +// +// if (request.getPhoneNumber() != null && !request.getPhoneNumber().trim().isEmpty() +// && !isPhoneNumberValid(request.getPhoneNumber(), request.getCountryCode())) { +// return Cause.PHONE_NUMBER_INVALID; +// } else if (request.getPhoneNumber() != null && !request.getPhoneNumber().trim().isEmpty() +// && !userInfoByPhoneRepository.findByPhoneNumber(request.getPhoneNumber()).isEmpty()) { +// return Cause.PHONE_NUMBER_ALREADY_USED; +// } +// +// if (request.getFirstName() != null && request.getFirstName().trim().isEmpty()) { +// return Cause.MISSING_FIRST_NAME; +// } else if (!isFirstNameValid(request.getFirstName())) { +// return Cause.INVALID_FIRST_NAME; +// } +// +// if (request.getLastName() != null && !request.getLastName().trim().isEmpty() +// && !isLastNameValid(request.getLastName())) { +// return Cause.INVALID_LAST_NAME; +// } +// +// return null; +// } } diff --git a/src/main/java/biz/nynja/account/models/UserInfo.java b/src/main/java/biz/nynja/account/models/UserInfo.java deleted file mode 100644 index b5337df..0000000 --- a/src/main/java/biz/nynja/account/models/UserInfo.java +++ /dev/null @@ -1,268 +0,0 @@ -/** - * Copyright (C) 2018 Nynja Inc. All rights reserved. - */ -package biz.nynja.account.models; - -import java.util.UUID; - -import org.springframework.data.cassandra.core.cql.PrimaryKeyType; -import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; -import org.springframework.data.cassandra.core.mapping.Table; - -import biz.nynja.account.grpc.AuthenticationType; -import biz.nynja.account.grpc.CreateAccountRequest; -import biz.nynja.account.grpc.Status; - -@Table -public class UserInfo { - - @PrimaryKeyColumn(name = "profile_id", ordinal = 0, type = PrimaryKeyType.PARTITIONED) - private UUID profileId; - @PrimaryKeyColumn(name = "account_id", ordinal = 1, type = PrimaryKeyType.CLUSTERED) - private UUID accountId; - private String firstName; - private String lastName; - private String middleName; - @PrimaryKeyColumn(name = "username", ordinal = 2, type = PrimaryKeyType.CLUSTERED) - private String username; - private String phoneNumber; - private String emailAddress; - private String password; - private Status status; - @PrimaryKeyColumn(name = "authentication_type", ordinal = 3, type = PrimaryKeyType.CLUSTERED) - private AuthenticationType authenticationType; - @PrimaryKeyColumn(name = "authnetication_provider_id", ordinal = 4, type = PrimaryKeyType.CLUSTERED) - private String authenticationProviderId; - private String communicationProcviderId; - - public UserInfo() { - } - - public UUID getProfileId() { - return profileId; - } - - public void setProfileId(UUID profileId) { - this.profileId = profileId; - } - - public UUID getAccountId() { - return accountId; - } - - public void setAccountId(UUID accountId) { - this.accountId = accountId; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getMiddleName() { - return middleName; - } - - public void setMiddleName(String middleName) { - this.middleName = middleName; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPhoneNumber() { - return phoneNumber; - } - - public void setPhoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - } - - public String getEmailAddress() { - return emailAddress; - } - - public void setEmailAddress(String emailAddress) { - this.emailAddress = emailAddress; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } - - public AuthenticationType getAuthenticationType() { - return authenticationType; - } - - public void setAuthenticationType(AuthenticationType authenticationType) { - this.authenticationType = authenticationType; - } - - public String getAuthenticationProviderId() { - return authenticationProviderId; - } - - public void setAuthenticationProviderId(String authenticationProviderId) { - this.authenticationProviderId = authenticationProviderId; - } - - public String getCommunicationProcviderId() { - return communicationProcviderId; - } - - public void setCommunicationProcviderId(String communicationProcviderId) { - this.communicationProcviderId = communicationProcviderId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((accountId == null) ? 0 : accountId.hashCode()); - result = prime * result + ((authenticationProviderId == null) ? 0 : authenticationProviderId.hashCode()); - result = prime * result + ((authenticationType == null) ? 0 : authenticationType.hashCode()); - result = prime * result + ((communicationProcviderId == null) ? 0 : communicationProcviderId.hashCode()); - result = prime * result + ((emailAddress == null) ? 0 : emailAddress.hashCode()); - result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); - result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); - result = prime * result + ((middleName == null) ? 0 : middleName.hashCode()); - result = prime * result + ((phoneNumber == null) ? 0 : phoneNumber.hashCode()); - result = prime * result + ((profileId == null) ? 0 : profileId.hashCode()); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - result = prime * result + ((username == null) ? 0 : username.hashCode()); - result = prime * result + ((password == null) ? 0 : password.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - UserInfo other = (UserInfo) obj; - if (accountId == null) { - if (other.accountId != null) - return false; - } else if (!accountId.equals(other.accountId)) - return false; - if (authenticationProviderId == null) { - if (other.authenticationProviderId != null) - return false; - } else if (!authenticationProviderId.equals(other.authenticationProviderId)) - return false; - if (authenticationType != other.authenticationType) - return false; - if (communicationProcviderId == null) { - if (other.communicationProcviderId != null) - return false; - } else if (!communicationProcviderId.equals(other.communicationProcviderId)) - return false; - if (emailAddress == null) { - if (other.emailAddress != null) - return false; - } else if (!emailAddress.equals(other.emailAddress)) - return false; - if (firstName == null) { - if (other.firstName != null) - return false; - } else if (!firstName.equals(other.firstName)) - return false; - if (lastName == null) { - if (other.lastName != null) - return false; - } else if (!lastName.equals(other.lastName)) - return false; - if (middleName == null) { - if (other.middleName != null) - return false; - } else if (!middleName.equals(other.middleName)) - return false; - if (phoneNumber == null) { - if (other.phoneNumber != null) - return false; - } else if (!phoneNumber.equals(other.phoneNumber)) - return false; - if (profileId == null) { - if (other.profileId != null) - return false; - } else if (!profileId.equals(other.profileId)) - return false; - if (status != other.status) - return false; - if (username == null) { - if (other.username != null) - return false; - } else if (!username.equals(other.username)) - return false; - if (password == null) { - if (other.password != null) - return false; - } else if (!password.equals(other.password)) - return false; - return true; - } - - @Override - public String toString() { - return new StringBuilder("UserInfo [profileId=").append(profileId).append(", accountId=").append(accountId) - .append(", firstName=").append(firstName).append(", lastName=").append(lastName).append(", middleName=") - .append(middleName).append(", username=").append(username).append(", password=").append(password) - .append(", phoneNumber=").append(phoneNumber).append(", emailAddress=").append(emailAddress) - .append(", status=").append(status).append(", authenticationType=").append(authenticationType) - .append(", authenticationProviderId=").append(authenticationProviderId).append(", avatar=[]") - .append(", communicationProcviderId=").append(communicationProcviderId).append("]").toString(); - } - - public static UserInfo fromProto(CreateAccountRequest proto) { - UserInfo userInfo = new UserInfo(); - userInfo.setUsername(proto.getUsername()); - userInfo.setEmailAddress(proto.getEmailAddress()); - userInfo.setFirstName(proto.getFirstName()); - userInfo.setLastName(proto.getLastName()); - userInfo.setMiddleName(proto.getMiddleName()); - userInfo.setPhoneNumber(proto.getPhoneNumber()); - userInfo.setAuthenticationType(proto.getAuthenticationType()); - userInfo.setStatus(proto.getStatus()); - userInfo.setPassword(proto.getPassword()); - return userInfo; - } - - public biz.nynja.account.grpc.AccountDetails toProto() { - return biz.nynja.account.grpc.AccountDetails.newBuilder().setAccountId(getAccountId().toString()) - .setProfileId(getProfileId().toString()).setUsername(getUsername()) - .setAuthenticationType(getAuthenticationType()).setEmailAddress(getEmailAddress()) - .setFirstName(getFirstName()).setLastName(getLastName()).setMiddleName(getMiddleName()) - .setPhoneNumber(getPhoneNumber()).setStatus(getStatus()).build(); - } -} diff --git a/src/main/java/biz/nynja/account/models/UserInfoByEmail.java b/src/main/java/biz/nynja/account/models/UserInfoByEmail.java deleted file mode 100644 index 9a2a9b0..0000000 --- a/src/main/java/biz/nynja/account/models/UserInfoByEmail.java +++ /dev/null @@ -1,250 +0,0 @@ -/** - * Copyright (C) 2018 Nynja Inc. All rights reserved. - */ -package biz.nynja.account.models; - -import java.util.UUID; - -import org.springframework.data.cassandra.core.cql.PrimaryKeyType; -import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; -import org.springframework.data.cassandra.core.mapping.Table; - -import biz.nynja.account.grpc.AuthenticationType; -import biz.nynja.account.grpc.CreateAccountRequest; -import biz.nynja.account.grpc.Status; - -@Table("userinfo_by_email") -public class UserInfoByEmail { - - @PrimaryKeyColumn(name = "emailaddress", ordinal = 0, type = PrimaryKeyType.PARTITIONED) - private String emailAddress; - @PrimaryKeyColumn(name = "profile_id", ordinal = 1, type = PrimaryKeyType.CLUSTERED) - private UUID profileId; - @PrimaryKeyColumn(name = "account_id", ordinal = 2, type = PrimaryKeyType.CLUSTERED) - private UUID accountId; - @PrimaryKeyColumn(name = "username", ordinal = 3, type = PrimaryKeyType.CLUSTERED) - private String username; - @PrimaryKeyColumn(name = "authentication_type", ordinal = 4, type = PrimaryKeyType.CLUSTERED) - private AuthenticationType authenticationType; - @PrimaryKeyColumn(name = "authnetication_provider_id", ordinal = 5, type = PrimaryKeyType.CLUSTERED) - private String authenticationProviderId; - private String firstName; - private String lastName; - private String middleName; - private String phoneNumber; - private Status status; - private String communicationProcviderId; - - public String getEmailAddress() { - return emailAddress; - } - - public void setEmailAddress(String emailAddress) { - this.emailAddress = emailAddress; - } - - public UUID getProfileId() { - return profileId; - } - - public void setProfileId(UUID profileId) { - this.profileId = profileId; - } - - public UUID getAccountId() { - return accountId; - } - - public void setAccountId(UUID accountId) { - this.accountId = accountId; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public AuthenticationType getAuthenticationType() { - return authenticationType; - } - - public void setAuthenticationType(AuthenticationType authenticationType) { - this.authenticationType = authenticationType; - } - - public String getAuthenticationProviderId() { - return authenticationProviderId; - } - - public void setAuthenticationProviderId(String authenticationProviderId) { - this.authenticationProviderId = authenticationProviderId; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getMiddleName() { - return middleName; - } - - public void setMiddleName(String middleName) { - this.middleName = middleName; - } - - public String getPhoneNumber() { - return phoneNumber; - } - - public void setPhoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - } - - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } - - public String getCommunicationProcviderId() { - return communicationProcviderId; - } - - public void setCommunicationProcviderId(String communicationProcviderId) { - this.communicationProcviderId = communicationProcviderId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((accountId == null) ? 0 : accountId.hashCode()); - result = prime * result + ((authenticationProviderId == null) ? 0 : authenticationProviderId.hashCode()); - result = prime * result + ((authenticationType == null) ? 0 : authenticationType.hashCode()); - result = prime * result + ((communicationProcviderId == null) ? 0 : communicationProcviderId.hashCode()); - result = prime * result + ((emailAddress == null) ? 0 : emailAddress.hashCode()); - result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); - result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); - result = prime * result + ((middleName == null) ? 0 : middleName.hashCode()); - result = prime * result + ((phoneNumber == null) ? 0 : phoneNumber.hashCode()); - result = prime * result + ((profileId == null) ? 0 : profileId.hashCode()); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - result = prime * result + ((username == null) ? 0 : username.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - UserInfoByEmail other = (UserInfoByEmail) obj; - if (accountId == null) { - if (other.accountId != null) - return false; - } else if (!accountId.equals(other.accountId)) - return false; - if (authenticationProviderId == null) { - if (other.authenticationProviderId != null) - return false; - } else if (!authenticationProviderId.equals(other.authenticationProviderId)) - return false; - if (authenticationType != other.authenticationType) - return false; - if (communicationProcviderId == null) { - if (other.communicationProcviderId != null) - return false; - } else if (!communicationProcviderId.equals(other.communicationProcviderId)) - return false; - if (emailAddress == null) { - if (other.emailAddress != null) - return false; - } else if (!emailAddress.equals(other.emailAddress)) - return false; - if (firstName == null) { - if (other.firstName != null) - return false; - } else if (!firstName.equals(other.firstName)) - return false; - if (lastName == null) { - if (other.lastName != null) - return false; - } else if (!lastName.equals(other.lastName)) - return false; - if (middleName == null) { - if (other.middleName != null) - return false; - } else if (!middleName.equals(other.middleName)) - return false; - if (phoneNumber == null) { - if (other.phoneNumber != null) - return false; - } else if (!phoneNumber.equals(other.phoneNumber)) - return false; - if (profileId == null) { - if (other.profileId != null) - return false; - } else if (!profileId.equals(other.profileId)) - return false; - if (status != other.status) - return false; - if (username == null) { - if (other.username != null) - return false; - } else if (!username.equals(other.username)) - return false; - return true; - } - - @Override - public String toString() { - return new StringBuilder("UserInfoByEmail [emailAddress=").append(emailAddress).append(", profileId=") - .append(profileId).append(", accountId=").append(accountId).append(", username=").append(username) - .append(", authenticationType=").append(authenticationType).append(", authenticationProviderId=") - .append(authenticationProviderId).append(", firstName=").append(firstName).append(", lastName=") - .append(lastName).append(", middleName=").append(middleName).append(", phoneNumber=") - .append(phoneNumber).append(", status=").append(status).append(", communicationProcviderId=") - .append(communicationProcviderId).append("]").toString(); - } - - public static UserInfoByEmail fromProto(CreateAccountRequest proto) { - UserInfoByEmail userInfo = new UserInfoByEmail(); - userInfo.setUsername(proto.getUsername()); - userInfo.setEmailAddress(proto.getEmailAddress()); - userInfo.setFirstName(proto.getFirstName()); - userInfo.setLastName(proto.getLastName()); - userInfo.setMiddleName(proto.getMiddleName()); - userInfo.setPhoneNumber(proto.getPhoneNumber()); - userInfo.setAuthenticationType(proto.getAuthenticationType()); - userInfo.setStatus(proto.getStatus()); - return userInfo; - } - - public biz.nynja.account.grpc.AccountDetails toProto() { - return biz.nynja.account.grpc.AccountDetails.newBuilder().setAccountId(getAccountId().toString()) - .setProfileId(getProfileId().toString()).setUsername(getUsername()) - .setAuthenticationType(getAuthenticationType()).setEmailAddress(getEmailAddress()) - .setFirstName(getFirstName()).setLastName(getLastName()).setMiddleName(getMiddleName()) - .setPhoneNumber(getPhoneNumber()).setStatus(getStatus()).build(); - } -} diff --git a/src/main/java/biz/nynja/account/models/UserInfoByPhone.java b/src/main/java/biz/nynja/account/models/UserInfoByPhone.java deleted file mode 100644 index 0fefda5..0000000 --- a/src/main/java/biz/nynja/account/models/UserInfoByPhone.java +++ /dev/null @@ -1,247 +0,0 @@ -package biz.nynja.account.models; - -import java.util.UUID; - -import org.springframework.data.cassandra.core.cql.PrimaryKeyType; -import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; -import org.springframework.data.cassandra.core.mapping.Table; - -import biz.nynja.account.grpc.AuthenticationType; -import biz.nynja.account.grpc.CreateAccountRequest; -import biz.nynja.account.grpc.Status; - -@Table("userinfo_by_phone") -public class UserInfoByPhone { - - @PrimaryKeyColumn(name = "phonenumber", ordinal = 0, type = PrimaryKeyType.PARTITIONED) - private String phoneNumber; - @PrimaryKeyColumn(name = "profile_id", ordinal = 1, type = PrimaryKeyType.CLUSTERED) - private UUID profileId; - @PrimaryKeyColumn(name = "account_id", ordinal = 2, type = PrimaryKeyType.CLUSTERED) - private UUID accountId; - @PrimaryKeyColumn(name = "username", ordinal = 3, type = PrimaryKeyType.CLUSTERED) - private String username; - @PrimaryKeyColumn(name = "authentication_type", ordinal = 4, type = PrimaryKeyType.CLUSTERED) - private AuthenticationType authenticationType; - @PrimaryKeyColumn(name = "authnetication_provider_id", ordinal = 5, type = PrimaryKeyType.CLUSTERED) - private String authenticationProviderId; - private String firstName; - private String lastName; - private String middleName; - private String emailAddress; - private Status status; - private String communicationProcviderId; - - public String getPhoneNumber() { - return phoneNumber; - } - - public void setPhoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - } - - public UUID getProfileId() { - return profileId; - } - - public void setProfileId(UUID profileId) { - this.profileId = profileId; - } - - public UUID getAccountId() { - return accountId; - } - - public void setAccountId(UUID accountId) { - this.accountId = accountId; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public AuthenticationType getAuthenticationType() { - return authenticationType; - } - - public void setAuthenticationType(AuthenticationType authenticationType) { - this.authenticationType = authenticationType; - } - - public String getAuthenticationProviderId() { - return authenticationProviderId; - } - - public void setAuthenticationProviderId(String authenticationProviderId) { - this.authenticationProviderId = authenticationProviderId; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getMiddleName() { - return middleName; - } - - public void setMiddleName(String middleName) { - this.middleName = middleName; - } - - public String getEmailAddress() { - return emailAddress; - } - - public void setEmailAddress(String emailAddress) { - this.emailAddress = emailAddress; - } - - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } - - public String getCommunicationProcviderId() { - return communicationProcviderId; - } - - public void setCommunicationProcviderId(String communicationProcviderId) { - this.communicationProcviderId = communicationProcviderId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((accountId == null) ? 0 : accountId.hashCode()); - result = prime * result + ((authenticationProviderId == null) ? 0 : authenticationProviderId.hashCode()); - result = prime * result + ((authenticationType == null) ? 0 : authenticationType.hashCode()); - result = prime * result + ((communicationProcviderId == null) ? 0 : communicationProcviderId.hashCode()); - result = prime * result + ((emailAddress == null) ? 0 : emailAddress.hashCode()); - result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); - result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); - result = prime * result + ((middleName == null) ? 0 : middleName.hashCode()); - result = prime * result + ((phoneNumber == null) ? 0 : phoneNumber.hashCode()); - result = prime * result + ((profileId == null) ? 0 : profileId.hashCode()); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - result = prime * result + ((username == null) ? 0 : username.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - UserInfoByPhone other = (UserInfoByPhone) obj; - if (accountId == null) { - if (other.accountId != null) - return false; - } else if (!accountId.equals(other.accountId)) - return false; - if (authenticationProviderId == null) { - if (other.authenticationProviderId != null) - return false; - } else if (!authenticationProviderId.equals(other.authenticationProviderId)) - return false; - if (authenticationType != other.authenticationType) - return false; - if (communicationProcviderId == null) { - if (other.communicationProcviderId != null) - return false; - } else if (!communicationProcviderId.equals(other.communicationProcviderId)) - return false; - if (emailAddress == null) { - if (other.emailAddress != null) - return false; - } else if (!emailAddress.equals(other.emailAddress)) - return false; - if (firstName == null) { - if (other.firstName != null) - return false; - } else if (!firstName.equals(other.firstName)) - return false; - if (lastName == null) { - if (other.lastName != null) - return false; - } else if (!lastName.equals(other.lastName)) - return false; - if (middleName == null) { - if (other.middleName != null) - return false; - } else if (!middleName.equals(other.middleName)) - return false; - if (phoneNumber == null) { - if (other.phoneNumber != null) - return false; - } else if (!phoneNumber.equals(other.phoneNumber)) - return false; - if (profileId == null) { - if (other.profileId != null) - return false; - } else if (!profileId.equals(other.profileId)) - return false; - if (status != other.status) - return false; - if (username == null) { - if (other.username != null) - return false; - } else if (!username.equals(other.username)) - return false; - return true; - } - - @Override - public String toString() { - return new StringBuilder("UserInfoByEmail [emailAddress=").append(emailAddress).append(", profileId=") - .append(profileId).append(", accountId=").append(accountId).append(", username=").append(username) - .append(", authenticationType=").append(authenticationType).append(", authenticationProviderId=") - .append(authenticationProviderId).append(", firstName=").append(firstName).append(", lastName=") - .append(lastName).append(", middleName=").append(middleName).append(", phoneNumber=") - .append(phoneNumber).append(", status=").append(status).append(", communicationProcviderId=") - .append(communicationProcviderId).append("]").toString(); - } - - public static UserInfoByPhone fromProto(CreateAccountRequest proto) { - UserInfoByPhone userInfo = new UserInfoByPhone(); - userInfo.setUsername(proto.getUsername()); - userInfo.setEmailAddress(proto.getEmailAddress()); - userInfo.setFirstName(proto.getFirstName()); - userInfo.setLastName(proto.getLastName()); - userInfo.setMiddleName(proto.getMiddleName()); - userInfo.setPhoneNumber(proto.getPhoneNumber()); - userInfo.setAuthenticationType(proto.getAuthenticationType()); - userInfo.setStatus(proto.getStatus()); - return userInfo; - } - - public biz.nynja.account.grpc.AccountDetails toProto() { - return biz.nynja.account.grpc.AccountDetails.newBuilder().setAccountId(getAccountId().toString()) - .setProfileId(getProfileId().toString()).setUsername(getUsername()) - .setAuthenticationType(getAuthenticationType()).setEmailAddress(getEmailAddress()) - .setFirstName(getFirstName()).setLastName(getLastName()).setMiddleName(getMiddleName()) - .setPhoneNumber(getPhoneNumber()).setStatus(getStatus()).build(); - } -} diff --git a/src/main/java/biz/nynja/account/models/UserInfoByUsername.java b/src/main/java/biz/nynja/account/models/UserInfoByUsername.java deleted file mode 100644 index 726ee30..0000000 --- a/src/main/java/biz/nynja/account/models/UserInfoByUsername.java +++ /dev/null @@ -1,226 +0,0 @@ -package biz.nynja.account.models; - -import java.util.UUID; - -import org.springframework.data.cassandra.core.cql.PrimaryKeyType; -import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; -import org.springframework.data.cassandra.core.mapping.Table; - -import biz.nynja.account.grpc.AuthenticationType; -import biz.nynja.account.grpc.Status; - -@Table("userinfo_by_username") -public class UserInfoByUsername { - - @PrimaryKeyColumn(name = "username", ordinal = 0, type = PrimaryKeyType.PARTITIONED) - private String username; - @PrimaryKeyColumn(name = "profile_id", ordinal = 1, type = PrimaryKeyType.CLUSTERED) - private UUID profileId; - @PrimaryKeyColumn(name = "account_id", ordinal = 2, type = PrimaryKeyType.CLUSTERED) - private UUID accountId; - @PrimaryKeyColumn(name = "phonenumber", ordinal = 3, type = PrimaryKeyType.CLUSTERED) - private String phoneNumber; - @PrimaryKeyColumn(name = "authentication_type", ordinal = 4, type = PrimaryKeyType.CLUSTERED) - private AuthenticationType authenticationType; - @PrimaryKeyColumn(name = "authnetication_provider_id", ordinal = 5, type = PrimaryKeyType.CLUSTERED) - private String authenticationProviderId; - private String firstName; - private String lastName; - private String middleName; - private String emailAddress; - private Status status; - private String communicationProcviderId; - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public UUID getProfileId() { - return profileId; - } - - public void setProfileId(UUID profileId) { - this.profileId = profileId; - } - - public UUID getAccountId() { - return accountId; - } - - public void setAccountId(UUID accountId) { - this.accountId = accountId; - } - - public String getPhoneNumber() { - return phoneNumber; - } - - public void setPhoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - } - - public AuthenticationType getAuthenticationType() { - return authenticationType; - } - - public void setAuthenticationType(AuthenticationType authenticationType) { - this.authenticationType = authenticationType; - } - - public String getAuthenticationProviderId() { - return authenticationProviderId; - } - - public void setAuthenticationProviderId(String authenticationProviderId) { - this.authenticationProviderId = authenticationProviderId; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getMiddleName() { - return middleName; - } - - public void setMiddleName(String middleName) { - this.middleName = middleName; - } - - public String getEmailAddress() { - return emailAddress; - } - - public void setEmailAddress(String emailAddress) { - this.emailAddress = emailAddress; - } - - public Status getStatus() { - return status; - } - - public void setStatus(Status status) { - this.status = status; - } - - public String getCommunicationProcviderId() { - return communicationProcviderId; - } - - public void setCommunicationProcviderId(String communicationProcviderId) { - this.communicationProcviderId = communicationProcviderId; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((accountId == null) ? 0 : accountId.hashCode()); - result = prime * result + ((authenticationProviderId == null) ? 0 : authenticationProviderId.hashCode()); - result = prime * result + ((authenticationType == null) ? 0 : authenticationType.hashCode()); - result = prime * result + ((communicationProcviderId == null) ? 0 : communicationProcviderId.hashCode()); - result = prime * result + ((emailAddress == null) ? 0 : emailAddress.hashCode()); - result = prime * result + ((firstName == null) ? 0 : firstName.hashCode()); - result = prime * result + ((lastName == null) ? 0 : lastName.hashCode()); - result = prime * result + ((middleName == null) ? 0 : middleName.hashCode()); - result = prime * result + ((phoneNumber == null) ? 0 : phoneNumber.hashCode()); - result = prime * result + ((profileId == null) ? 0 : profileId.hashCode()); - result = prime * result + ((status == null) ? 0 : status.hashCode()); - result = prime * result + ((username == null) ? 0 : username.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - UserInfoByUsername other = (UserInfoByUsername) obj; - if (accountId == null) { - if (other.accountId != null) - return false; - } else if (!accountId.equals(other.accountId)) - return false; - if (authenticationProviderId == null) { - if (other.authenticationProviderId != null) - return false; - } else if (!authenticationProviderId.equals(other.authenticationProviderId)) - return false; - if (authenticationType != other.authenticationType) - return false; - if (communicationProcviderId == null) { - if (other.communicationProcviderId != null) - return false; - } else if (!communicationProcviderId.equals(other.communicationProcviderId)) - return false; - if (emailAddress == null) { - if (other.emailAddress != null) - return false; - } else if (!emailAddress.equals(other.emailAddress)) - return false; - if (firstName == null) { - if (other.firstName != null) - return false; - } else if (!firstName.equals(other.firstName)) - return false; - if (lastName == null) { - if (other.lastName != null) - return false; - } else if (!lastName.equals(other.lastName)) - return false; - if (middleName == null) { - if (other.middleName != null) - return false; - } else if (!middleName.equals(other.middleName)) - return false; - if (phoneNumber == null) { - if (other.phoneNumber != null) - return false; - } else if (!phoneNumber.equals(other.phoneNumber)) - return false; - if (profileId == null) { - if (other.profileId != null) - return false; - } else if (!profileId.equals(other.profileId)) - return false; - if (status != other.status) - return false; - if (username == null) { - if (other.username != null) - return false; - } else if (!username.equals(other.username)) - return false; - return true; - } - - @Override - public String toString() { - return new StringBuilder("UserInfoByEmail [emailAddress=").append(emailAddress).append(", profileId=") - .append(profileId).append(", accountId=").append(accountId).append(", username=").append(username) - .append(", authenticationType=").append(authenticationType).append(", authenticationProviderId=") - .append(authenticationProviderId).append(", firstName=").append(firstName).append(", lastName=") - .append(lastName).append(", middleName=").append(middleName).append(", phoneNumber=") - .append(phoneNumber).append(", status=").append(status).append(", communicationProcviderId=") - .append(communicationProcviderId).append("]").toString(); - } - -} \ No newline at end of file diff --git a/src/main/java/biz/nynja/account/repositories/UserInfoByEmailRepository.java b/src/main/java/biz/nynja/account/repositories/UserInfoByEmailRepository.java deleted file mode 100644 index 92630e6..0000000 --- a/src/main/java/biz/nynja/account/repositories/UserInfoByEmailRepository.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (C) 2018 Nynja Inc. All rights reserved. - */ -package biz.nynja.account.repositories; - -import java.util.List; - -import org.springframework.data.cassandra.repository.CassandraRepository; -import org.springframework.stereotype.Repository; - -import biz.nynja.account.models.UserInfoByEmail; - -@Repository -public interface UserInfoByEmailRepository extends CassandraRepository { - - List findByEmailAddress(String email); -} diff --git a/src/main/java/biz/nynja/account/repositories/UserInfoByPhoneRepository.java b/src/main/java/biz/nynja/account/repositories/UserInfoByPhoneRepository.java deleted file mode 100644 index 172f5ce..0000000 --- a/src/main/java/biz/nynja/account/repositories/UserInfoByPhoneRepository.java +++ /dev/null @@ -1,15 +0,0 @@ -package biz.nynja.account.repositories; - -import java.util.List; - -import org.springframework.data.cassandra.repository.CassandraRepository; -import org.springframework.stereotype.Repository; - -import biz.nynja.account.models.UserInfoByPhone; - -@Repository -public interface UserInfoByPhoneRepository extends CassandraRepository{ - - List findByPhoneNumber(String phoneNumber); - -} diff --git a/src/main/java/biz/nynja/account/repositories/UserInfoByUsernameRepository.java b/src/main/java/biz/nynja/account/repositories/UserInfoByUsernameRepository.java deleted file mode 100644 index 6abe3ef..0000000 --- a/src/main/java/biz/nynja/account/repositories/UserInfoByUsernameRepository.java +++ /dev/null @@ -1,15 +0,0 @@ -package biz.nynja.account.repositories; - -import java.util.List; - -import org.springframework.data.cassandra.repository.CassandraRepository; -import org.springframework.stereotype.Repository; - -import biz.nynja.account.models.UserInfoByUsername; - -@Repository -public interface UserInfoByUsernameRepository extends CassandraRepository { - - List findByUsername(String username); - -} diff --git a/src/main/java/biz/nynja/account/repositories/UserInfoRepository.java b/src/main/java/biz/nynja/account/repositories/UserInfoRepository.java deleted file mode 100644 index a089409..0000000 --- a/src/main/java/biz/nynja/account/repositories/UserInfoRepository.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (C) 2018 Nynja Inc. All rights reserved. - */ -package biz.nynja.account.repositories; - -import java.util.List; -import java.util.UUID; - -import org.springframework.data.cassandra.repository.CassandraRepository; - -import biz.nynja.account.models.UserInfo; - -public interface UserInfoRepository extends CassandraRepository { - - public List findAllByProfileId(UUID profileId); - -} diff --git a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java index c48c8f3..b16d83b 100644 --- a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java +++ b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java @@ -32,16 +32,9 @@ import biz.nynja.account.models.AccountByAuthenticationProvider; import biz.nynja.account.models.AccountByProfileId; import biz.nynja.account.models.PendingAccount; import biz.nynja.account.repositories.AccountByAuthenticationProviderRepository; -import biz.nynja.account.models.UserInfo; -import biz.nynja.account.models.UserInfoByEmail; -import biz.nynja.account.models.UserInfoByPhone; import biz.nynja.account.repositories.AccountByProfileIdRepository; -import biz.nynja.account.repositories.AccountRepository; import biz.nynja.account.repositories.AccountRepositoryAdditional; import biz.nynja.account.repositories.PendingAccountRepository; -import biz.nynja.account.repositories.UserInfoByEmailRepository; -import biz.nynja.account.repositories.UserInfoByPhoneRepository; -import biz.nynja.account.repositories.UserInfoRepository; import io.grpc.stub.StreamObserver; /** @@ -54,12 +47,6 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas private static final Logger logger = LoggerFactory.getLogger(AccountServiceImpl.class); - @Autowired - private UserInfoRepository userInfoRepository; - - @Autowired - private AccountRepository accountRepository; - @Autowired private AccountByProfileIdRepository accountByProfileIdRepository; @@ -72,48 +59,14 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas @Autowired private AccountRepositoryAdditional accountRepositoryAdditional; - @Autowired - private UserInfoByPhoneRepository userInfoByPhoneRepository; - @Autowired private Validator validator; @Override - public void createAccount(CreateAccountRequest request, StreamObserver responseObserver) { - - logger.info("Creating account..."); - logger.debug("Creating account: {} ...", request); + public void createAccount(CreateAccountRequest request, StreamObserver responseObserver) { - Cause validationCause = validator.validateCreateAccountRequest(request); - if (validationCause != null) { - responseObserver.onNext(CreateAccountResponse.newBuilder() - .setError(ErrorResponse.newBuilder().setCause(validationCause)).build()); - responseObserver.onCompleted(); - return; - } + // TODO: add method implementation - UserInfo userInfo = UserInfo.fromProto(request); - if (request.getProfileId() == null || request.getProfileId().isEmpty()) { - userInfo.setProfileId(UUID.randomUUID()); - } else { - userInfo.setProfileId(UUID.fromString(request.getProfileId())); - } - userInfo.setAccountId(UUID.randomUUID()); - // TODO set authentication provider - userInfo.setAuthenticationProviderId("id"); - - UserInfo savedAccount = userInfoRepository.save(userInfo); - logger.debug("Account \"{}\" saved into the DB", savedAccount.toString()); - - CreateAccountResponse response = CreateAccountResponse.newBuilder().setAccountDetails(savedAccount.toProto()) - .build(); - logger.info("Account created successfully."); - logger.debug("Account: \"{}\" created successfully.", response); - - responseObserver.onNext(response); - responseObserver.onCompleted(); - - return; } @Override diff --git a/src/test/java/biz/nynja/account/components/ValidatorTests.java b/src/test/java/biz/nynja/account/components/ValidatorTests.java index 522a0ba..f65f3d4 100644 --- a/src/test/java/biz/nynja/account/components/ValidatorTests.java +++ b/src/test/java/biz/nynja/account/components/ValidatorTests.java @@ -15,9 +15,6 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; import biz.nynja.account.components.Validator; -import biz.nynja.account.repositories.UserInfoByEmailRepository; -import biz.nynja.account.repositories.UserInfoByPhoneRepository; -import biz.nynja.account.repositories.UserInfoByUsernameRepository; /** * Components unit tests. @@ -30,15 +27,6 @@ public class ValidatorTests { @Autowired private Validator validator; - @MockBean - private UserInfoByEmailRepository userInfoByEmailRepository; - - @MockBean - private UserInfoByPhoneRepository userInfoByPhoneRepository; - - @MockBean - private UserInfoByUsernameRepository userInfoByUsernameRepository; - @Test public void validPhoneNumberTest() { diff --git a/src/test/java/biz/nynja/account/services/AccountServiceTests.java b/src/test/java/biz/nynja/account/services/AccountServiceTests.java index 5b231fe..2075fa0 100644 --- a/src/test/java/biz/nynja/account/services/AccountServiceTests.java +++ b/src/test/java/biz/nynja/account/services/AccountServiceTests.java @@ -26,23 +26,16 @@ import org.springframework.test.context.junit4.SpringRunner; import com.datastax.driver.core.Session; +import biz.nynja.account.grpc.AccountByAuthenticationProviderRequest; +import biz.nynja.account.grpc.AccountResponse; import biz.nynja.account.grpc.AccountServiceGrpc; -import biz.nynja.account.grpc.AccountsByAuthenticationProviderRequest; import biz.nynja.account.grpc.AccountsByProfileIdRequest; +import biz.nynja.account.grpc.AccountsResponse; import biz.nynja.account.grpc.AuthenticationType; import biz.nynja.account.grpc.CreateAccountRequest; -import biz.nynja.account.grpc.CreateAccountResponse; import biz.nynja.account.grpc.ErrorResponse.Cause; -import biz.nynja.account.grpc.GetAccountsResponse; import biz.nynja.account.grpc.Status; -import biz.nynja.account.models.UserInfo; -import biz.nynja.account.models.UserInfoByEmail; -import biz.nynja.account.models.UserInfoByPhone; -import biz.nynja.account.models.UserInfoByUsername; -import biz.nynja.account.repositories.UserInfoByEmailRepository; -import biz.nynja.account.repositories.UserInfoByPhoneRepository; -import biz.nynja.account.repositories.UserInfoByUsernameRepository; -import biz.nynja.account.repositories.UserInfoRepository; +import biz.nynja.account.models.Account; import biz.nynja.account.utils.GrpcServerTestBase; import biz.nynja.account.utils.Util; @@ -50,7 +43,7 @@ import biz.nynja.account.utils.Util; * AccountService unit tests. */ -@RunWith(SpringRunner.class) +//@RunWith(SpringRunner.class) @SpringBootTest(classes = Util.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = { @@ -59,469 +52,451 @@ import biz.nynja.account.utils.Util; @ActiveProfiles("dev") public class AccountServiceTests extends GrpcServerTestBase { - @MockBean - private UserInfoRepository userInfoRepository; - - @MockBean - private UserInfoByEmailRepository userInfoByEmailRepository; - - @MockBean - private UserInfoByPhoneRepository userInfoByPhoneRepository; - @MockBean private Session session; - @MockBean - private UserInfoByUsernameRepository userInfoByUsernameRepository; - @Autowired @Qualifier("newAccount") - private UserInfo newAccount; + private Account newAccount; @Autowired @Qualifier("savedAccount") - private UserInfo savedAccount; - - @Autowired - private UserInfoByEmail userInfoByEmail; - - @Autowired - private UserInfoByPhone userInfoByPhone; - - @Test - public void testCreateAccountByEmail() throws ExecutionException, InterruptedException { - final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName(Util.FIRST_NAME) - .setLastName(Util.LAST_NAME).setMiddleName(Util.MIDDLE_NAME) - .setAuthenticationType(AuthenticationType.EMAIL).setUsername(Util.USERNAME).setPassword(Util.PASSWORD) - .setEmailAddress(Util.EMAIL).setStatus(Status.SUSPENDED).build(); - - List usersByPhone = new ArrayList<>(); - List usersByEmail = new ArrayList<>(); - List usersByUsername = new ArrayList<>(); - given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); - given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); - given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); - given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); - - final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc - .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); - - final CreateAccountResponse reply = accountServiceBlockingStub.createAccount(request); - - assertNotNull("Reply should not be null", reply); - assertTrue(String.format("Reply should contain email '%s'", Util.EMAIL), - reply.getAccountDetails().getEmailAddress().equals(Util.EMAIL)); - } - - @Test - public void testCreateAccountExistEmail() throws ExecutionException, InterruptedException { - final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName(Util.FIRST_NAME) - .setLastName(Util.LAST_NAME).setMiddleName(Util.MIDDLE_NAME) - .setAuthenticationType(AuthenticationType.EMAIL).setUsername(Util.USERNAME).setPassword(Util.PASSWORD) - .setEmailAddress(Util.EMAIL).setPhoneNumber(Util.PHONE_NUMBER).setCountryCode("BG") - .setStatus(Status.SUSPENDED).build(); - - List usersByPhone = new ArrayList<>(); - List usersByEmail = new ArrayList<>(); - usersByEmail.add(new UserInfoByEmail()); - List usersByUsername = new ArrayList<>(); - given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); - given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); - given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); - given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); - - final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc - .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); - - final CreateAccountResponse reply = accountServiceBlockingStub.createAccount(request); - - assertNotNull("Reply should not be null", reply); - assertTrue(String.format("Reply should contain cause '%s'", Cause.EMAIL_ALREADY_USED), - reply.getError().getCause().equals(Cause.EMAIL_ALREADY_USED)); - } - - @Test - public void testCreateAccountByPhone() throws ExecutionException, InterruptedException { - final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName(Util.FIRST_NAME) - .setLastName(Util.LAST_NAME).setMiddleName(Util.MIDDLE_NAME) - .setAuthenticationType(AuthenticationType.PHONE).setUsername(Util.USERNAME).setPassword(Util.PASSWORD) - .setPhoneNumber(Util.PHONE_NUMBER).setCountryCode("BG").setStatus(Status.SUSPENDED).build(); - - List usersByPhone = new ArrayList<>(); - List usersByEmail = new ArrayList<>(); - List usersByUsername = new ArrayList<>(); - given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); - given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); - given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); - given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); - - final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc - .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); - - final CreateAccountResponse reply = accountServiceBlockingStub.createAccount(request); - - assertNotNull("Reply should not be null", reply); - assertTrue(String.format("Reply should contain phone '%s'", Util.PHONE_NUMBER), - reply.getAccountDetails().getPhoneNumber().equals(Util.PHONE_NUMBER)); - } - - @Test - public void testCreateAccountExistPhone() throws ExecutionException, InterruptedException { - final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName(Util.FIRST_NAME) - .setLastName(Util.LAST_NAME).setMiddleName(Util.MIDDLE_NAME) - .setAuthenticationType(AuthenticationType.PHONE).setUsername(Util.USERNAME).setPassword(Util.PASSWORD) - .setPhoneNumber(Util.PHONE_NUMBER).setCountryCode("BG").setStatus(Status.SUSPENDED).build(); - - List usersByPhone = new ArrayList<>(); - usersByPhone.add(new UserInfoByPhone()); - List usersByEmail = new ArrayList<>(); - List usersByUsername = new ArrayList<>(); - given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); - given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); - given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); - given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); - - final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc - .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); - - final CreateAccountResponse reply = accountServiceBlockingStub.createAccount(request); - - assertNotNull("Reply should not be null", reply); - assertTrue(String.format("Reply should contain cause '%s'", Cause.PHONE_NUMBER_ALREADY_USED), - reply.getError().getCause().equals(Cause.PHONE_NUMBER_ALREADY_USED)); - } - - @Test - public void testCreateAccountExistUsername() throws ExecutionException, InterruptedException { - final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName(Util.FIRST_NAME) - .setLastName(Util.LAST_NAME).setMiddleName(Util.MIDDLE_NAME) - .setAuthenticationType(AuthenticationType.PHONE).setUsername(Util.USERNAME).setPassword(Util.PASSWORD) - .setPhoneNumber(Util.PHONE_NUMBER).setCountryCode("BG").setStatus(Status.SUSPENDED).build(); - - List usersByPhone = new ArrayList<>(); - List usersByEmail = new ArrayList<>(); - List usersByUsername = new ArrayList<>(); - usersByUsername.add(new UserInfoByUsername()); - given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); - given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); - given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); - given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); - - final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc - .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); - - final CreateAccountResponse reply = accountServiceBlockingStub.createAccount(request); - - assertNotNull("Reply should not be null", reply); - assertTrue(String.format("Reply should contain cause '%s'", Cause.USERNAME_ALREADY_USED), - reply.getError().getCause().equals(Cause.USERNAME_ALREADY_USED)); - } - - @Test - public void testCreateAccountInvalidUsername() throws ExecutionException, InterruptedException { - final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName(Util.FIRST_NAME) - .setLastName(Util.LAST_NAME).setMiddleName(Util.MIDDLE_NAME) - .setAuthenticationType(AuthenticationType.PHONE).setUsername(".Invalid-Username.") - .setPassword(Util.PASSWORD).setPhoneNumber(Util.PHONE_NUMBER).setCountryCode("BG") - .setStatus(Status.SUSPENDED).build(); - - List usersByPhone = new ArrayList<>(); - List usersByEmail = new ArrayList<>(); - List usersByUsername = new ArrayList<>(); - given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); - given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); - given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); - given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); - - final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc - .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); - - final CreateAccountResponse reply = accountServiceBlockingStub.createAccount(request); - - assertNotNull("Reply should not be null", reply); - assertTrue(String.format("Reply should contain cause '%s'", Cause.USERNAME_INVALID), - reply.getError().getCause().equals(Cause.USERNAME_INVALID)); - } - - @Test - public void testCreateAccountMissingFirstName() throws ExecutionException, InterruptedException { - final CreateAccountRequest request = CreateAccountRequest.newBuilder().setLastName(Util.LAST_NAME) - .setMiddleName(Util.MIDDLE_NAME).setAuthenticationType(AuthenticationType.PHONE) - .setUsername(Util.USERNAME).setPassword(Util.PASSWORD).setPhoneNumber(Util.PHONE_NUMBER) - .setCountryCode("BG").setStatus(Status.SUSPENDED).build(); - - List usersByPhone = new ArrayList<>(); - List usersByEmail = new ArrayList<>(); - List usersByUsername = new ArrayList<>(); - given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); - given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); - given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); - given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); - - final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc - .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); - - final CreateAccountResponse reply = accountServiceBlockingStub.createAccount(request); - - assertNotNull("Reply should not be null", reply); - assertTrue(String.format("Reply should contain cause '%s'", Cause.MISSING_FIRST_NAME), - reply.getError().getCause().equals(Cause.MISSING_FIRST_NAME)); - } - - @Test - public void testCreateAccountInvalidFirstName() throws ExecutionException, InterruptedException { - final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName("n") - .setLastName(Util.LAST_NAME).setMiddleName(Util.MIDDLE_NAME) - .setAuthenticationType(AuthenticationType.PHONE).setUsername(Util.USERNAME).setPassword(Util.PASSWORD) - .setPhoneNumber(Util.PHONE_NUMBER).setCountryCode("BG").setStatus(Status.SUSPENDED).build(); - - List usersByPhone = new ArrayList<>(); - List usersByEmail = new ArrayList<>(); - List usersByUsername = new ArrayList<>(); - given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); - given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); - given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); - given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); - - final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc - .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); - - final CreateAccountResponse reply = accountServiceBlockingStub.createAccount(request); - - assertNotNull("Reply should not be null", reply); - assertTrue(String.format("Reply should contain cause '%s'", Cause.INVALID_FIRST_NAME), - reply.getError().getCause().equals(Cause.INVALID_FIRST_NAME)); - } - - @Test - public void testCreateAccountInvalidLastName() throws ExecutionException, InterruptedException { - final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName(Util.FIRST_NAME) - .setLastName("ThisIsNotaValidLastNameIndeedAndItIsNotReal").setMiddleName(Util.MIDDLE_NAME) - .setAuthenticationType(AuthenticationType.PHONE).setUsername(Util.USERNAME).setPassword(Util.PASSWORD) - .setPhoneNumber(Util.PHONE_NUMBER).setCountryCode("BG").setStatus(Status.SUSPENDED).build(); - - List usersByPhone = new ArrayList<>(); - List usersByEmail = new ArrayList<>(); - List usersByUsername = new ArrayList<>(); - given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); - given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); - given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); - given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); - - final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc - .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); - - final CreateAccountResponse reply = accountServiceBlockingStub.createAccount(request); - - assertNotNull("Reply should not be null", reply); - assertTrue(String.format("Reply should contain cause '%s'", Cause.INVALID_LAST_NAME), - reply.getError().getCause().equals(Cause.INVALID_LAST_NAME)); - } - - @Test - public void testCreateAccountInvalidEmail() throws ExecutionException, InterruptedException { - final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName(Util.FIRST_NAME) - .setLastName(Util.LAST_NAME).setMiddleName(Util.MIDDLE_NAME) - .setAuthenticationType(AuthenticationType.EMAIL).setUsername(Util.USERNAME).setPassword(Util.PASSWORD) - .setEmailAddress(".invalid@email-.com").setStatus(Status.SUSPENDED).build(); - - List usersByPhone = new ArrayList<>(); - List usersByEmail = new ArrayList<>(); - List usersByUsername = new ArrayList<>(); - given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); - given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); - given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); - given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); - - final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc - .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); - - final CreateAccountResponse reply = accountServiceBlockingStub.createAccount(request); - - assertNotNull("Reply should not be null", reply); - assertTrue(String.format("Reply should contain cause '%s'", Cause.EMAIL_INVALID), - reply.getError().getCause().equals(Cause.EMAIL_INVALID)); - } - - @Test - public void testCreateAccountInvalidPhone() throws ExecutionException, InterruptedException { - final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName(Util.FIRST_NAME) - .setLastName(Util.LAST_NAME).setMiddleName(Util.MIDDLE_NAME) - .setAuthenticationType(AuthenticationType.PHONE).setUsername(Util.USERNAME).setPassword(Util.PASSWORD) - .setPhoneNumber("+45955588833648946512957").setCountryCode("BG").setStatus(Status.SUSPENDED).build(); - - List usersByPhone = new ArrayList<>(); - List usersByEmail = new ArrayList<>(); - List usersByUsername = new ArrayList<>(); - given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); - given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); - given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); - given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); - - final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc - .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); - - final CreateAccountResponse reply = accountServiceBlockingStub.createAccount(request); - - assertNotNull("Reply should not be null", reply); - assertTrue(String.format("Reply should contain cause '%s'", Cause.PHONE_NUMBER_INVALID), - reply.getError().getCause().equals(Cause.PHONE_NUMBER_INVALID)); - } - - @Test - public void testGetAccountsByEmail() throws ExecutionException, InterruptedException { - final AccountsByAuthenticationProviderRequest request = AccountsByAuthenticationProviderRequest.newBuilder() - .setAuthenticationType(AuthenticationType.EMAIL).setAuthenticationIdentifier(Util.EMAIL).build(); - - List usersByEmail = new ArrayList<>(); - usersByEmail.add(userInfoByEmail); - given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); - - final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc - .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); - - final GetAccountsResponse reply = accountServiceBlockingStub.getAllAccountsByAuthenticationProvider(request); - - assertNotNull("Reply should not be null", reply); - assertTrue(String.format("Reply should contain email '%s'", Util.EMAIL), - reply.getAccountsResponse().getAccountDetails(0).getEmailAddress().equals(Util.EMAIL)); - } - - @Test - public void testGetAccountsByEmailNotFound() throws ExecutionException, InterruptedException { - final AccountsByAuthenticationProviderRequest request = AccountsByAuthenticationProviderRequest.newBuilder() - .setAuthenticationType(AuthenticationType.EMAIL).setAuthenticationIdentifier(Util.EMAIL).build(); - - List usersByEmail = new ArrayList<>(); - given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); - - final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc - .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); - - final GetAccountsResponse reply = accountServiceBlockingStub.getAllAccountsByAuthenticationProvider(request); - - assertNotNull("Reply should not be null", reply); - assertTrue(String.format("Reply should contain cause '%s'", Cause.ACCOUNT_NOT_FOUND), - reply.getError().getCause().equals(Cause.ACCOUNT_NOT_FOUND)); - } - - @Test - public void testGetAccountsByEmailBadRequest() throws ExecutionException, InterruptedException { - final AccountsByAuthenticationProviderRequest request = AccountsByAuthenticationProviderRequest.newBuilder() - .setAuthenticationType(AuthenticationType.EMAIL).build(); - - final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc - .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); - - final GetAccountsResponse reply = accountServiceBlockingStub.getAllAccountsByAuthenticationProvider(request); - - assertNotNull("Reply should not be null", reply); - assertTrue(String.format("Reply should contain cause '%s'", Cause.ACCOUNT_NOT_FOUND), - reply.getError().getCause().equals(Cause.ACCOUNT_NOT_FOUND)); - } - - @Test - public void testGetAccountsByPhone() throws ExecutionException, InterruptedException { - final AccountsByAuthenticationProviderRequest request = AccountsByAuthenticationProviderRequest.newBuilder() - .setAuthenticationType(AuthenticationType.PHONE).setAuthenticationIdentifier(Util.PHONE_NUMBER).build(); - - List usersByPhone = new ArrayList<>(); - usersByPhone.add(userInfoByPhone); - given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); - - final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc - .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); - - final GetAccountsResponse reply = accountServiceBlockingStub.getAllAccountsByAuthenticationProvider(request); - - assertNotNull("Reply should not be null", reply); - assertTrue(String.format("Reply should contain phone '%s'", Util.PHONE_NUMBER), - reply.getAccountsResponse().getAccountDetails(0).getPhoneNumber().equals(Util.PHONE_NUMBER)); - } - - @Test - public void testGetAccountsByPhoneNotFound() throws ExecutionException, InterruptedException { - final AccountsByAuthenticationProviderRequest request = AccountsByAuthenticationProviderRequest.newBuilder() - .setAuthenticationType(AuthenticationType.PHONE).setAuthenticationIdentifier(Util.PHONE_NUMBER).build(); - - List usersByPhone = new ArrayList<>(); - given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); - - final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc - .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); - - final GetAccountsResponse reply = accountServiceBlockingStub.getAllAccountsByAuthenticationProvider(request); - - assertNotNull("Reply should not be null", reply); - assertTrue(String.format("Reply should contain cause '%s'", Cause.ACCOUNT_NOT_FOUND), - reply.getError().getCause().equals(Cause.ACCOUNT_NOT_FOUND)); - } - - @Test - public void testGetAccountsByPhoneBadRequest() throws ExecutionException, InterruptedException { - final AccountsByAuthenticationProviderRequest request = AccountsByAuthenticationProviderRequest.newBuilder() - .setAuthenticationType(AuthenticationType.PHONE).build(); - - final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc - .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); - - final GetAccountsResponse reply = accountServiceBlockingStub.getAllAccountsByAuthenticationProvider(request); - - assertNotNull("Reply should not be null", reply); - assertTrue(String.format("Reply should contain cause '%s'", Cause.ACCOUNT_NOT_FOUND), - reply.getError().getCause().equals(Cause.ACCOUNT_NOT_FOUND)); - } - - @Test - public void testGetAccountsByProfileId() throws ExecutionException, InterruptedException { - final AccountsByProfileIdRequest request = AccountsByProfileIdRequest.newBuilder() - .setProfileId(Util.PROFILE_ID.toString()).build(); - - List usersInfo = new ArrayList<>(); - usersInfo.add(savedAccount); - given(userInfoRepository.findAllByProfileId(UUID.fromString(request.getProfileId()))).willReturn(usersInfo); - - final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc - .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); - - final GetAccountsResponse reply = accountServiceBlockingStub.getAllAccountsByProfileId(request); - - assertNotNull("Reply should not be null", reply); - assertTrue(String.format("Reply should contain profile ID '%s'", Util.PROFILE_ID.toString()), - reply.getAccountsResponse().getAccountDetails(0).getProfileId().equals(Util.PROFILE_ID.toString())); - } - - @Test - public void testGetAccountsByProfileIdNotFound() throws ExecutionException, InterruptedException { - final AccountsByProfileIdRequest request = AccountsByProfileIdRequest.newBuilder() - .setProfileId(Util.PROFILE_ID.toString()).build(); - - List usersInfo = new ArrayList<>(); - - given(userInfoRepository.findAllByProfileId(Util.PROFILE_ID)).willReturn(usersInfo); - - final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc - .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); - - final GetAccountsResponse reply = accountServiceBlockingStub.getAllAccountsByProfileId(request); - - assertNotNull("Reply should not be null", reply); - assertTrue(String.format("Reply should contain cause '%s'", Cause.ACCOUNT_NOT_FOUND), - reply.getError().getCause().equals(Cause.ACCOUNT_NOT_FOUND)); - } - - @Test - public void testGetAccountsByProfileIdBadRequest() throws ExecutionException, InterruptedException { - final AccountsByProfileIdRequest request = AccountsByProfileIdRequest.newBuilder().build(); - - final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc - .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); - - final GetAccountsResponse reply = accountServiceBlockingStub.getAllAccountsByProfileId(request); - - assertNotNull("Reply should not be null", reply); - assertTrue(String.format("Reply should contain cause '%s'", Cause.MISSING_PROFILE_ID), - reply.getError().getCause().equals(Cause.MISSING_PROFILE_ID)); - } + private Account savedAccount; + +// @Test +// public void testCreateAccountByEmail() throws ExecutionException, InterruptedException { +// final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName(Util.FIRST_NAME) +// .setLastName(Util.LAST_NAME).setMiddleName(Util.MIDDLE_NAME) +// .setAuthenticationType(AuthenticationType.EMAIL).setUsername(Util.USERNAME).setPassword(Util.PASSWORD) +// .setEmailAddress(Util.EMAIL).setStatus(Status.SUSPENDED).build(); +// +// List usersByPhone = new ArrayList<>(); +// List usersByEmail = new ArrayList<>(); +// List usersByUsername = new ArrayList<>(); +// given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); +// given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); +// given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); +// given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); +// +// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc +// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); +// +// final AccountResponse reply = accountServiceBlockingStub.createAccount(request); +// +// assertNotNull("Reply should not be null", reply); +// assertTrue(String.format("Reply should contain email '%s'", Util.EMAIL), +// reply.getAccountDetails().getEmailAddress().equals(Util.EMAIL)); +// } +// +// @Test +// public void testCreateAccountExistEmail() throws ExecutionException, InterruptedException { +// final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName(Util.FIRST_NAME) +// .setLastName(Util.LAST_NAME).setMiddleName(Util.MIDDLE_NAME) +// .setAuthenticationType(AuthenticationType.EMAIL).setUsername(Util.USERNAME).setPassword(Util.PASSWORD) +// .setEmailAddress(Util.EMAIL).setPhoneNumber(Util.PHONE_NUMBER).setCountryCode("BG") +// .setStatus(Status.SUSPENDED).build(); +// +// List usersByPhone = new ArrayList<>(); +// List usersByEmail = new ArrayList<>(); +// usersByEmail.add(new UserInfoByEmail()); +// List usersByUsername = new ArrayList<>(); +// given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); +// given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); +// given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); +// given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); +// +// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc +// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); +// +// final AccountResponse reply = accountServiceBlockingStub.createAccount(request); +// +// assertNotNull("Reply should not be null", reply); +// assertTrue(String.format("Reply should contain cause '%s'", Cause.EMAIL_ALREADY_USED), +// reply.getError().getCause().equals(Cause.EMAIL_ALREADY_USED)); +// } +// +// @Test +// public void testCreateAccountByPhone() throws ExecutionException, InterruptedException { +// final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName(Util.FIRST_NAME) +// .setLastName(Util.LAST_NAME).setMiddleName(Util.MIDDLE_NAME) +// .setAuthenticationType(AuthenticationType.PHONE).setUsername(Util.USERNAME).setPassword(Util.PASSWORD) +// .setPhoneNumber(Util.PHONE_NUMBER).setCountryCode("BG").setStatus(Status.SUSPENDED).build(); +// +// List usersByPhone = new ArrayList<>(); +// List usersByEmail = new ArrayList<>(); +// List usersByUsername = new ArrayList<>(); +// given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); +// given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); +// given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); +// given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); +// +// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc +// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); +// +// final AccountResponse reply = accountServiceBlockingStub.createAccount(request); +// +// assertNotNull("Reply should not be null", reply); +// assertTrue(String.format("Reply should contain phone '%s'", Util.PHONE_NUMBER), +// reply.getAccountDetails().getAuthenticationIdentifier().equals(Util.PHONE_NUMBER)); +// } +// +// @Test +// public void testCreateAccountExistPhone() throws ExecutionException, InterruptedException { +// final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName(Util.FIRST_NAME) +// .setLastName(Util.LAST_NAME).setMiddleName(Util.MIDDLE_NAME) +// .setAuthenticationType(AuthenticationType.PHONE).setUsername(Util.USERNAME).setPassword(Util.PASSWORD) +// .setPhoneNumber(Util.PHONE_NUMBER).setCountryCode("BG").setStatus(Status.SUSPENDED).build(); +// +// List usersByPhone = new ArrayList<>(); +// usersByPhone.add(new UserInfoByPhone()); +// List usersByEmail = new ArrayList<>(); +// List usersByUsername = new ArrayList<>(); +// given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); +// given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); +// given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); +// given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); +// +// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc +// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); +// +// final AccountResponse reply = accountServiceBlockingStub.createAccount(request); +// +// assertNotNull("Reply should not be null", reply); +// assertTrue(String.format("Reply should contain cause '%s'", Cause.PHONE_NUMBER_ALREADY_USED), +// reply.getError().getCause().equals(Cause.PHONE_NUMBER_ALREADY_USED)); +// } +// +// @Test +// public void testCreateAccountExistUsername() throws ExecutionException, InterruptedException { +// final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName(Util.FIRST_NAME) +// .setLastName(Util.LAST_NAME).setMiddleName(Util.MIDDLE_NAME) +// .setAuthenticationType(AuthenticationType.PHONE).setUsername(Util.USERNAME).setPassword(Util.PASSWORD) +// .setPhoneNumber(Util.PHONE_NUMBER).setCountryCode("BG").setStatus(Status.SUSPENDED).build(); +// +// List usersByPhone = new ArrayList<>(); +// List usersByEmail = new ArrayList<>(); +// List usersByUsername = new ArrayList<>(); +// usersByUsername.add(new UserInfoByUsername()); +// given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); +// given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); +// given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); +// given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); +// +// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc +// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); +// +// final AccountResponse reply = accountServiceBlockingStub.createAccount(request); +// +// assertNotNull("Reply should not be null", reply); +// assertTrue(String.format("Reply should contain cause '%s'", Cause.USERNAME_ALREADY_USED), +// reply.getError().getCause().equals(Cause.USERNAME_ALREADY_USED)); +// } +// +// @Test +// public void testCreateAccountInvalidUsername() throws ExecutionException, InterruptedException { +// final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName(Util.FIRST_NAME) +// .setLastName(Util.LAST_NAME).setMiddleName(Util.MIDDLE_NAME) +// .setAuthenticationType(AuthenticationType.PHONE).setUsername(".Invalid-Username.") +// .setPassword(Util.PASSWORD).setPhoneNumber(Util.PHONE_NUMBER).setCountryCode("BG") +// .setStatus(Status.SUSPENDED).build(); +// +// List usersByPhone = new ArrayList<>(); +// List usersByEmail = new ArrayList<>(); +// List usersByUsername = new ArrayList<>(); +// given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); +// given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); +// given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); +// given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); +// +// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc +// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); +// +// final AccountResponse reply = accountServiceBlockingStub.createAccount(request); +// +// assertNotNull("Reply should not be null", reply); +// assertTrue(String.format("Reply should contain cause '%s'", Cause.USERNAME_INVALID), +// reply.getError().getCause().equals(Cause.USERNAME_INVALID)); +// } +// +// @Test +// public void testCreateAccountMissingFirstName() throws ExecutionException, InterruptedException { +// final CreateAccountRequest request = CreateAccountRequest.newBuilder().setLastName(Util.LAST_NAME) +// .setMiddleName(Util.MIDDLE_NAME).setAuthenticationType(AuthenticationType.PHONE) +// .setUsername(Util.USERNAME).setPassword(Util.PASSWORD).setPhoneNumber(Util.PHONE_NUMBER) +// .setCountryCode("BG").setStatus(Status.SUSPENDED).build(); +// +// List usersByPhone = new ArrayList<>(); +// List usersByEmail = new ArrayList<>(); +// List usersByUsername = new ArrayList<>(); +// given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); +// given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); +// given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); +// given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); +// +// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc +// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); +// +// final AccountResponse reply = accountServiceBlockingStub.createAccount(request); +// +// assertNotNull("Reply should not be null", reply); +// assertTrue(String.format("Reply should contain cause '%s'", Cause.MISSING_FIRST_NAME), +// reply.getError().getCause().equals(Cause.MISSING_FIRST_NAME)); +// } +// +// @Test +// public void testCreateAccountInvalidFirstName() throws ExecutionException, InterruptedException { +// final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName("n") +// .setLastName(Util.LAST_NAME).setMiddleName(Util.MIDDLE_NAME) +// .setAuthenticationType(AuthenticationType.PHONE).setUsername(Util.USERNAME).setPassword(Util.PASSWORD) +// .setPhoneNumber(Util.PHONE_NUMBER).setCountryCode("BG").setStatus(Status.SUSPENDED).build(); +// +// List usersByPhone = new ArrayList<>(); +// List usersByEmail = new ArrayList<>(); +// List usersByUsername = new ArrayList<>(); +// given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); +// given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); +// given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); +// given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); +// +// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc +// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); +// +// final AccountResponse reply = accountServiceBlockingStub.createAccount(request); +// +// assertNotNull("Reply should not be null", reply); +// assertTrue(String.format("Reply should contain cause '%s'", Cause.INVALID_FIRST_NAME), +// reply.getError().getCause().equals(Cause.INVALID_FIRST_NAME)); +// } +// +// @Test +// public void testCreateAccountInvalidLastName() throws ExecutionException, InterruptedException { +// final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName(Util.FIRST_NAME) +// .setLastName("ThisIsNotaValidLastNameIndeedAndItIsNotReal").setMiddleName(Util.MIDDLE_NAME) +// .setAuthenticationType(AuthenticationType.PHONE).setUsername(Util.USERNAME).setPassword(Util.PASSWORD) +// .setPhoneNumber(Util.PHONE_NUMBER).setCountryCode("BG").setStatus(Status.SUSPENDED).build(); +// +// List usersByPhone = new ArrayList<>(); +// List usersByEmail = new ArrayList<>(); +// List usersByUsername = new ArrayList<>(); +// given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); +// given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); +// given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); +// given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); +// +// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc +// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); +// +// final AccountResponse reply = accountServiceBlockingStub.createAccount(request); +// +// assertNotNull("Reply should not be null", reply); +// assertTrue(String.format("Reply should contain cause '%s'", Cause.INVALID_LAST_NAME), +// reply.getError().getCause().equals(Cause.INVALID_LAST_NAME)); +// } +// +// @Test +// public void testCreateAccountInvalidEmail() throws ExecutionException, InterruptedException { +// final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName(Util.FIRST_NAME) +// .setLastName(Util.LAST_NAME).setMiddleName(Util.MIDDLE_NAME) +// .setAuthenticationType(AuthenticationType.EMAIL).setUsername(Util.USERNAME).setPassword(Util.PASSWORD) +// .setEmailAddress(".invalid@email-.com").setStatus(Status.SUSPENDED).build(); +// +// List usersByPhone = new ArrayList<>(); +// List usersByEmail = new ArrayList<>(); +// List usersByUsername = new ArrayList<>(); +// given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); +// given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); +// given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); +// given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); +// +// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc +// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); +// +// final AccountResponse reply = accountServiceBlockingStub.createAccount(request); +// +// assertNotNull("Reply should not be null", reply); +// assertTrue(String.format("Reply should contain cause '%s'", Cause.EMAIL_INVALID), +// reply.getError().getCause().equals(Cause.EMAIL_INVALID)); +// } +// +// @Test +// public void testCreateAccountInvalidPhone() throws ExecutionException, InterruptedException { +// final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName(Util.FIRST_NAME) +// .setLastName(Util.LAST_NAME).setMiddleName(Util.MIDDLE_NAME) +// .setAuthenticationType(AuthenticationType.PHONE).setUsername(Util.USERNAME).setPassword(Util.PASSWORD) +// .setPhoneNumber("+45955588833648946512957").setCountryCode("BG").setStatus(Status.SUSPENDED).build(); +// +// List usersByPhone = new ArrayList<>(); +// List usersByEmail = new ArrayList<>(); +// List usersByUsername = new ArrayList<>(); +// given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); +// given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); +// given(userInfoByUsernameRepository.findByUsername(Util.USERNAME)).willReturn(usersByUsername); +// given(userInfoRepository.save(any(UserInfo.class))).willReturn(savedAccount); +// +// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc +// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); +// +// final AccountResponse reply = accountServiceBlockingStub.createAccount(request); +// +// assertNotNull("Reply should not be null", reply); +// assertTrue(String.format("Reply should contain cause '%s'", Cause.PHONE_NUMBER_INVALID), +// reply.getError().getCause().equals(Cause.PHONE_NUMBER_INVALID)); +// } +// +// @Test +// public void testGetAccountsByEmail() throws ExecutionException, InterruptedException { +// final AccountByAuthenticationProviderRequest request = AccountByAuthenticationProviderRequest.newBuilder() +// .setAuthenticationType(AuthenticationType.EMAIL).setAuthenticationIdentifier(Util.EMAIL).build(); +// +// List usersByEmail = new ArrayList<>(); +// usersByEmail.add(userInfoByEmail); +// given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); +// +// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc +// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); +// +// final AccountResponse reply = accountServiceBlockingStub.getAccountByAuthenticationProvider(request); +// +// assertNotNull("Reply should not be null", reply); +// assertTrue(String.format("Reply should contain email '%s'", Util.EMAIL), +// reply.getAccountDetails().getAuthenticationIdentifier().equals(Util.EMAIL)); +// } +// +// @Test +// public void testGetAccountsByEmailNotFound() throws ExecutionException, InterruptedException { +// final AccountByAuthenticationProviderRequest request = AccountByAuthenticationProviderRequest.newBuilder() +// .setAuthenticationType(AuthenticationType.EMAIL).setAuthenticationIdentifier(Util.EMAIL).build(); +// +// List usersByEmail = new ArrayList<>(); +// given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); +// +// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc +// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); +// +// final AccountResponse reply = accountServiceBlockingStub.getAccountByAuthenticationProvider(request); +// +// assertNotNull("Reply should not be null", reply); +// assertTrue(String.format("Reply should contain cause '%s'", Cause.ACCOUNT_NOT_FOUND), +// reply.getError().getCause().equals(Cause.ACCOUNT_NOT_FOUND)); +// } +// +// @Test +// public void testGetAccountsByEmailBadRequest() throws ExecutionException, InterruptedException { +// final AccountByAuthenticationProviderRequest request = AccountByAuthenticationProviderRequest.newBuilder() +// .setAuthenticationType(AuthenticationType.EMAIL).build(); +// +// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc +// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); +// +// final AccountResponse reply = accountServiceBlockingStub.getAccountByAuthenticationProvider(request); +// +// assertNotNull("Reply should not be null", reply); +// assertTrue(String.format("Reply should contain cause '%s'", Cause.ACCOUNT_NOT_FOUND), +// reply.getError().getCause().equals(Cause.ACCOUNT_NOT_FOUND)); +// } +// +// @Test +// public void testGetAccountsByPhone() throws ExecutionException, InterruptedException { +// final AccountByAuthenticationProviderRequest request = AccountByAuthenticationProviderRequest.newBuilder() +// .setAuthenticationType(AuthenticationType.PHONE).setAuthenticationIdentifier(Util.PHONE_NUMBER).build(); +// +// List usersByPhone = new ArrayList<>(); +// usersByPhone.add(userInfoByPhone); +// given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); +// +// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc +// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); +// +// final AccountResponse reply = accountServiceBlockingStub.getAccountByAuthenticationProvider(request); +// +// assertNotNull("Reply should not be null", reply); +// assertTrue(String.format("Reply should contain phone '%s'", Util.PHONE_NUMBER), +// reply.getAccountDetails().getAuthenticationIdentifier().equals(Util.PHONE_NUMBER)); +// } +// +// @Test +// public void testGetAccountsByPhoneNotFound() throws ExecutionException, InterruptedException { +// final AccountByAuthenticationProviderRequest request = AccountByAuthenticationProviderRequest.newBuilder() +// .setAuthenticationType(AuthenticationType.PHONE).setAuthenticationIdentifier(Util.PHONE_NUMBER).build(); +// +// List usersByPhone = new ArrayList<>(); +// given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); +// +// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc +// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); +// +// final AccountResponse reply = accountServiceBlockingStub.getAccountByAuthenticationProvider(request); +// +// assertNotNull("Reply should not be null", reply); +// assertTrue(String.format("Reply should contain cause '%s'", Cause.ACCOUNT_NOT_FOUND), +// reply.getError().getCause().equals(Cause.ACCOUNT_NOT_FOUND)); +// } +// +// @Test +// public void testGetAccountsByPhoneBadRequest() throws ExecutionException, InterruptedException { +// final AccountByAuthenticationProviderRequest request = AccountByAuthenticationProviderRequest.newBuilder() +// .setAuthenticationType(AuthenticationType.PHONE).build(); +// +// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc +// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); +// +// final AccountResponse reply = accountServiceBlockingStub.getAccountByAuthenticationProvider(request); +// +// assertNotNull("Reply should not be null", reply); +// assertTrue(String.format("Reply should contain cause '%s'", Cause.ACCOUNT_NOT_FOUND), +// reply.getError().getCause().equals(Cause.ACCOUNT_NOT_FOUND)); +// } +// +// @Test +// public void testGetAccountsByProfileId() throws ExecutionException, InterruptedException { +// final AccountsByProfileIdRequest request = AccountsByProfileIdRequest.newBuilder() +// .setProfileId(Util.PROFILE_ID.toString()).build(); +// +// List usersInfo = new ArrayList<>(); +// usersInfo.add(savedAccount); +// given(userInfoRepository.findAllByProfileId(UUID.fromString(request.getProfileId()))).willReturn(usersInfo); +// +// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc +// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); +// +// final AccountsResponse reply = accountServiceBlockingStub.getAllAccountsByProfileId(request); +// +// assertNotNull("Reply should not be null", reply); +// assertTrue(String.format("Reply should contain profile ID '%s'", Util.PROFILE_ID.toString()), +// reply.getAccountsResponse().getAccountDetails(0).getProfileId().equals(Util.PROFILE_ID.toString())); +// } +// +// @Test +// public void testGetAccountsByProfileIdNotFound() throws ExecutionException, InterruptedException { +// final AccountsByProfileIdRequest request = AccountsByProfileIdRequest.newBuilder() +// .setProfileId(Util.PROFILE_ID.toString()).build(); +// +// List usersInfo = new ArrayList<>(); +// +// given(userInfoRepository.findAllByProfileId(Util.PROFILE_ID)).willReturn(usersInfo); +// +// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc +// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); +// +// final AccountsResponse reply = accountServiceBlockingStub.getAllAccountsByProfileId(request); +// +// assertNotNull("Reply should not be null", reply); +// assertTrue(String.format("Reply should contain cause '%s'", Cause.ACCOUNT_NOT_FOUND), +// reply.getError().getCause().equals(Cause.ACCOUNT_NOT_FOUND)); +// } +// +// @Test +// public void testGetAccountsByProfileIdBadRequest() throws ExecutionException, InterruptedException { +// final AccountsByProfileIdRequest request = AccountsByProfileIdRequest.newBuilder().build(); +// +// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc +// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); +// +// final AccountsResponse reply = accountServiceBlockingStub.getAllAccountsByProfileId(request); +// +// assertNotNull("Reply should not be null", reply); +// assertTrue(String.format("Reply should contain cause '%s'", Cause.MISSING_PROFILE_ID), +// reply.getError().getCause().equals(Cause.MISSING_PROFILE_ID)); +// } } diff --git a/src/test/java/biz/nynja/account/utils/Util.java b/src/test/java/biz/nynja/account/utils/Util.java index 6254fa3..97b4377 100644 --- a/src/test/java/biz/nynja/account/utils/Util.java +++ b/src/test/java/biz/nynja/account/utils/Util.java @@ -11,9 +11,6 @@ import org.springframework.context.annotation.Bean; import biz.nynja.account.grpc.AuthenticationType; import biz.nynja.account.grpc.Status; -import biz.nynja.account.models.UserInfo; -import biz.nynja.account.models.UserInfoByEmail; -import biz.nynja.account.models.UserInfoByPhone;; /** * Unit tests variables, beans and help methods. @@ -32,68 +29,68 @@ public class Util { public static final String MIDDLE_NAME = "Kass"; public static final String PHONE_NUMBER = "+359887434646"; - @Bean - public UserInfo newAccount() { - UserInfo userInfo = new UserInfo(); - userInfo.setUsername(USERNAME); - userInfo.setPassword(PASSWORD); - userInfo.setEmailAddress(EMAIL); - userInfo.setFirstName(FIRST_NAME); - userInfo.setLastName(LAST_NAME); - userInfo.setMiddleName(MIDDLE_NAME); - userInfo.setPhoneNumber(PHONE_NUMBER); - userInfo.setAuthenticationType(AuthenticationType.EMAIL); - userInfo.setStatus(Status.SUSPENDED); - return userInfo; - } - - @Bean - public UserInfo savedAccount() { - UserInfo userInfo = new UserInfo(); - userInfo.setAccountId(ACCOUNT_ID); - userInfo.setProfileId(PROFILE_ID); - userInfo.setEmailAddress(EMAIL); - userInfo.setUsername(USERNAME); - userInfo.setPassword(PASSWORD); - userInfo.setFirstName(FIRST_NAME); - userInfo.setLastName(LAST_NAME); - userInfo.setMiddleName(MIDDLE_NAME); - userInfo.setPhoneNumber(PHONE_NUMBER); - userInfo.setAuthenticationType(AuthenticationType.EMAIL); - userInfo.setStatus(Status.SUSPENDED); - return userInfo; - } - - @Bean - public UserInfoByEmail accountByEmail() { - UserInfoByEmail userInfoByEmail = new UserInfoByEmail(); - userInfoByEmail.setEmailAddress(EMAIL); - userInfoByEmail.setAccountId(ACCOUNT_ID); - userInfoByEmail.setProfileId(PROFILE_ID); - userInfoByEmail.setUsername(USERNAME); - userInfoByEmail.setFirstName(FIRST_NAME); - userInfoByEmail.setLastName(LAST_NAME); - userInfoByEmail.setMiddleName(MIDDLE_NAME); - userInfoByEmail.setPhoneNumber(PHONE_NUMBER); - userInfoByEmail.setAuthenticationType(AuthenticationType.EMAIL); - userInfoByEmail.setStatus(Status.SUSPENDED); - return userInfoByEmail; - } - - @Bean - public UserInfoByPhone accountByPhone() { - UserInfoByPhone userInfoByPhone = new UserInfoByPhone(); - userInfoByPhone.setPhoneNumber(PHONE_NUMBER); - userInfoByPhone.setEmailAddress(EMAIL); - userInfoByPhone.setAccountId(ACCOUNT_ID); - userInfoByPhone.setProfileId(PROFILE_ID); - userInfoByPhone.setUsername(USERNAME); - userInfoByPhone.setFirstName(FIRST_NAME); - userInfoByPhone.setLastName(LAST_NAME); - userInfoByPhone.setMiddleName(MIDDLE_NAME); - userInfoByPhone.setAuthenticationType(AuthenticationType.EMAIL); - userInfoByPhone.setStatus(Status.SUSPENDED); - return userInfoByPhone; - } +// @Bean +// public UserInfo newAccount() { +// UserInfo userInfo = new UserInfo(); +// userInfo.setUsername(USERNAME); +// userInfo.setPassword(PASSWORD); +// userInfo.setEmailAddress(EMAIL); +// userInfo.setFirstName(FIRST_NAME); +// userInfo.setLastName(LAST_NAME); +// userInfo.setMiddleName(MIDDLE_NAME); +// userInfo.setPhoneNumber(PHONE_NUMBER); +// userInfo.setAuthenticationType(AuthenticationType.EMAIL); +// userInfo.setStatus(Status.SUSPENDED); +// return userInfo; +// } +// +// @Bean +// public UserInfo savedAccount() { +// UserInfo userInfo = new UserInfo(); +// userInfo.setAccountId(ACCOUNT_ID); +// userInfo.setProfileId(PROFILE_ID); +// userInfo.setEmailAddress(EMAIL); +// userInfo.setUsername(USERNAME); +// userInfo.setPassword(PASSWORD); +// userInfo.setFirstName(FIRST_NAME); +// userInfo.setLastName(LAST_NAME); +// userInfo.setMiddleName(MIDDLE_NAME); +// userInfo.setPhoneNumber(PHONE_NUMBER); +// userInfo.setAuthenticationType(AuthenticationType.EMAIL); +// userInfo.setStatus(Status.SUSPENDED); +// return userInfo; +// } +// +// @Bean +// public UserInfoByEmail accountByEmail() { +// UserInfoByEmail userInfoByEmail = new UserInfoByEmail(); +// userInfoByEmail.setEmailAddress(EMAIL); +// userInfoByEmail.setAccountId(ACCOUNT_ID); +// userInfoByEmail.setProfileId(PROFILE_ID); +// userInfoByEmail.setUsername(USERNAME); +// userInfoByEmail.setFirstName(FIRST_NAME); +// userInfoByEmail.setLastName(LAST_NAME); +// userInfoByEmail.setMiddleName(MIDDLE_NAME); +// userInfoByEmail.setPhoneNumber(PHONE_NUMBER); +// userInfoByEmail.setAuthenticationType(AuthenticationType.EMAIL); +// userInfoByEmail.setStatus(Status.SUSPENDED); +// return userInfoByEmail; +// } +// +// @Bean +// public UserInfoByPhone accountByPhone() { +// UserInfoByPhone userInfoByPhone = new UserInfoByPhone(); +// userInfoByPhone.setPhoneNumber(PHONE_NUMBER); +// userInfoByPhone.setEmailAddress(EMAIL); +// userInfoByPhone.setAccountId(ACCOUNT_ID); +// userInfoByPhone.setProfileId(PROFILE_ID); +// userInfoByPhone.setUsername(USERNAME); +// userInfoByPhone.setFirstName(FIRST_NAME); +// userInfoByPhone.setLastName(LAST_NAME); +// userInfoByPhone.setMiddleName(MIDDLE_NAME); +// userInfoByPhone.setAuthenticationType(AuthenticationType.EMAIL); +// userInfoByPhone.setStatus(Status.SUSPENDED); +// return userInfoByPhone; +// } } -- GitLab From b0d663b4051a972ed31b2c88bbd1e5e75d194b54 Mon Sep 17 00:00:00 2001 From: abotev-intracol Date: Mon, 3 Sep 2018 16:15:15 +0300 Subject: [PATCH 5/8] NY-3231 [Unit tests] Cassandra configuration issue - add additional mocked configuration for cassandra; Signed-off-by: abotev-intracol --- pom.xml | 2 +- .../biz/nynja/account/ApplicationTests.java | 2 +- .../account/components/ValidatorTests.java | 1 - .../configurations/CassandraTestsConfig.java | 48 +++++++ .../account/services/AccountServiceTests.java | 37 +++--- .../java/biz/nynja/account/utils/Util.java | 117 ++++++++---------- 6 files changed, 119 insertions(+), 88 deletions(-) create mode 100644 src/test/java/biz/nynja/account/configurations/CassandraTestsConfig.java diff --git a/pom.xml b/pom.xml index b28a877..e1015ce 100644 --- a/pom.xml +++ b/pom.xml @@ -101,7 +101,7 @@ libs-snapshot-local.biz.nynja.protos - account-service-intracoldev + account-service-ny-3044-account-retrieval 1.0-SNAPSHOT diff --git a/src/test/java/biz/nynja/account/ApplicationTests.java b/src/test/java/biz/nynja/account/ApplicationTests.java index 23ac7df..45f00f1 100644 --- a/src/test/java/biz/nynja/account/ApplicationTests.java +++ b/src/test/java/biz/nynja/account/ApplicationTests.java @@ -14,7 +14,7 @@ import org.springframework.test.context.junit4.SpringRunner; */ @RunWith(SpringRunner.class) -@ContextConfiguration(classes = { ApplicationTests.class }) +@ContextConfiguration public class ApplicationTests { @Test diff --git a/src/test/java/biz/nynja/account/components/ValidatorTests.java b/src/test/java/biz/nynja/account/components/ValidatorTests.java index f65f3d4..6715678 100644 --- a/src/test/java/biz/nynja/account/components/ValidatorTests.java +++ b/src/test/java/biz/nynja/account/components/ValidatorTests.java @@ -10,7 +10,6 @@ import static org.junit.Assert.assertTrue; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringRunner; diff --git a/src/test/java/biz/nynja/account/configurations/CassandraTestsConfig.java b/src/test/java/biz/nynja/account/configurations/CassandraTestsConfig.java new file mode 100644 index 0000000..f57d3f5 --- /dev/null +++ b/src/test/java/biz/nynja/account/configurations/CassandraTestsConfig.java @@ -0,0 +1,48 @@ +package biz.nynja.account.configurations; + +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.context.annotation.Bean; +import org.springframework.data.cassandra.config.CassandraClusterFactoryBean; +import org.springframework.data.cassandra.core.CassandraOperations; +import org.springframework.data.cassandra.core.CassandraTemplate; +import org.springframework.data.cassandra.core.convert.CassandraConverter; +import org.springframework.data.cassandra.core.convert.MappingCassandraConverter; +import org.springframework.data.cassandra.core.mapping.CassandraMappingContext; +import org.springframework.data.cassandra.core.mapping.SimpleUserTypeResolver; + +import com.datastax.driver.core.Session; + +@TestConfiguration +public class CassandraTestsConfig { + + @MockBean + private Session session; + + @Bean + public CassandraClusterFactoryBean cluster() { + + CassandraClusterFactoryBean cluster = new CassandraClusterFactoryBean(); + cluster.setContactPoints("127.0.0.1"); + cluster.setPort(1); + + return cluster; + } + + @Bean + public CassandraMappingContext mappingContext() { + CassandraMappingContext mappingContext = new CassandraMappingContext(); + mappingContext.setUserTypeResolver(new SimpleUserTypeResolver(cluster().getObject(), "AuthenticationProvider")); + return mappingContext; + } + + @Bean + public CassandraConverter converter() { + return new MappingCassandraConverter(mappingContext()); + } + + @Bean + public CassandraOperations cassandraTemplate() throws Exception { + return new CassandraTemplate(session, converter()); + } +} diff --git a/src/test/java/biz/nynja/account/services/AccountServiceTests.java b/src/test/java/biz/nynja/account/services/AccountServiceTests.java index 2075fa0..1d1714b 100644 --- a/src/test/java/biz/nynja/account/services/AccountServiceTests.java +++ b/src/test/java/biz/nynja/account/services/AccountServiceTests.java @@ -17,6 +17,7 @@ import java.util.concurrent.ExecutionException; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.context.TestConfiguration; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; @@ -26,8 +27,7 @@ import org.springframework.test.context.junit4.SpringRunner; import com.datastax.driver.core.Session; -import biz.nynja.account.grpc.AccountByAuthenticationProviderRequest; -import biz.nynja.account.grpc.AccountResponse; +import biz.nynja.account.configurations.CassandraTestsConfig; import biz.nynja.account.grpc.AccountServiceGrpc; import biz.nynja.account.grpc.AccountsByProfileIdRequest; import biz.nynja.account.grpc.AccountsResponse; @@ -43,8 +43,8 @@ import biz.nynja.account.utils.Util; * AccountService unit tests. */ -//@RunWith(SpringRunner.class) -@SpringBootTest(classes = Util.class, +@RunWith(SpringRunner.class) +@SpringBootTest(classes = { Util.class, CassandraTestsConfig.class }, webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration", @@ -52,9 +52,6 @@ import biz.nynja.account.utils.Util; @ActiveProfiles("dev") public class AccountServiceTests extends GrpcServerTestBase { - @MockBean - private Session session; - @Autowired @Qualifier("newAccount") private Account newAccount; @@ -485,18 +482,18 @@ public class AccountServiceTests extends GrpcServerTestBase { // reply.getError().getCause().equals(Cause.ACCOUNT_NOT_FOUND)); // } // -// @Test -// public void testGetAccountsByProfileIdBadRequest() throws ExecutionException, InterruptedException { -// final AccountsByProfileIdRequest request = AccountsByProfileIdRequest.newBuilder().build(); -// -// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc -// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); -// -// final AccountsResponse reply = accountServiceBlockingStub.getAllAccountsByProfileId(request); -// -// assertNotNull("Reply should not be null", reply); -// assertTrue(String.format("Reply should contain cause '%s'", Cause.MISSING_PROFILE_ID), -// reply.getError().getCause().equals(Cause.MISSING_PROFILE_ID)); -// } + @Test + public void testGetAccountsByProfileIdBadRequest() throws ExecutionException, InterruptedException { + final AccountsByProfileIdRequest request = AccountsByProfileIdRequest.newBuilder().build(); + + final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc + .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); + + final AccountsResponse reply = accountServiceBlockingStub.getAllAccountsByProfileId(request); + + assertNotNull("Reply should not be null", reply); + assertTrue(String.format("Reply should contain cause '%s'", Cause.MISSING_PROFILE_ID), + reply.getError().getCause().equals(Cause.MISSING_PROFILE_ID)); + } } diff --git a/src/test/java/biz/nynja/account/utils/Util.java b/src/test/java/biz/nynja/account/utils/Util.java index 97b4377..0745825 100644 --- a/src/test/java/biz/nynja/account/utils/Util.java +++ b/src/test/java/biz/nynja/account/utils/Util.java @@ -9,8 +9,7 @@ import java.util.UUID; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; -import biz.nynja.account.grpc.AuthenticationType; -import biz.nynja.account.grpc.Status; +import biz.nynja.account.models.Account; /** * Unit tests variables, beans and help methods. @@ -29,68 +28,56 @@ public class Util { public static final String MIDDLE_NAME = "Kass"; public static final String PHONE_NUMBER = "+359887434646"; -// @Bean -// public UserInfo newAccount() { -// UserInfo userInfo = new UserInfo(); -// userInfo.setUsername(USERNAME); -// userInfo.setPassword(PASSWORD); -// userInfo.setEmailAddress(EMAIL); -// userInfo.setFirstName(FIRST_NAME); -// userInfo.setLastName(LAST_NAME); -// userInfo.setMiddleName(MIDDLE_NAME); -// userInfo.setPhoneNumber(PHONE_NUMBER); -// userInfo.setAuthenticationType(AuthenticationType.EMAIL); -// userInfo.setStatus(Status.SUSPENDED); -// return userInfo; -// } -// -// @Bean -// public UserInfo savedAccount() { -// UserInfo userInfo = new UserInfo(); -// userInfo.setAccountId(ACCOUNT_ID); -// userInfo.setProfileId(PROFILE_ID); -// userInfo.setEmailAddress(EMAIL); -// userInfo.setUsername(USERNAME); -// userInfo.setPassword(PASSWORD); -// userInfo.setFirstName(FIRST_NAME); -// userInfo.setLastName(LAST_NAME); -// userInfo.setMiddleName(MIDDLE_NAME); -// userInfo.setPhoneNumber(PHONE_NUMBER); -// userInfo.setAuthenticationType(AuthenticationType.EMAIL); -// userInfo.setStatus(Status.SUSPENDED); -// return userInfo; -// } -// -// @Bean -// public UserInfoByEmail accountByEmail() { -// UserInfoByEmail userInfoByEmail = new UserInfoByEmail(); -// userInfoByEmail.setEmailAddress(EMAIL); -// userInfoByEmail.setAccountId(ACCOUNT_ID); -// userInfoByEmail.setProfileId(PROFILE_ID); -// userInfoByEmail.setUsername(USERNAME); -// userInfoByEmail.setFirstName(FIRST_NAME); -// userInfoByEmail.setLastName(LAST_NAME); -// userInfoByEmail.setMiddleName(MIDDLE_NAME); -// userInfoByEmail.setPhoneNumber(PHONE_NUMBER); -// userInfoByEmail.setAuthenticationType(AuthenticationType.EMAIL); -// userInfoByEmail.setStatus(Status.SUSPENDED); -// return userInfoByEmail; -// } -// -// @Bean -// public UserInfoByPhone accountByPhone() { -// UserInfoByPhone userInfoByPhone = new UserInfoByPhone(); -// userInfoByPhone.setPhoneNumber(PHONE_NUMBER); -// userInfoByPhone.setEmailAddress(EMAIL); -// userInfoByPhone.setAccountId(ACCOUNT_ID); -// userInfoByPhone.setProfileId(PROFILE_ID); -// userInfoByPhone.setUsername(USERNAME); -// userInfoByPhone.setFirstName(FIRST_NAME); -// userInfoByPhone.setLastName(LAST_NAME); -// userInfoByPhone.setMiddleName(MIDDLE_NAME); -// userInfoByPhone.setAuthenticationType(AuthenticationType.EMAIL); -// userInfoByPhone.setStatus(Status.SUSPENDED); -// return userInfoByPhone; -// } + @Bean + public Account newAccount() { + Account userInfo = new Account(); + userInfo.setUsername(USERNAME); + userInfo.setFirstName(FIRST_NAME); + userInfo.setLastName(LAST_NAME); + return userInfo; + } + + @Bean + public Account savedAccount() { + Account userInfo = new Account(); + userInfo.setAccountId(ACCOUNT_ID); + userInfo.setProfileId(PROFILE_ID); + userInfo.setUsername(USERNAME); + userInfo.setFirstName(FIRST_NAME); + userInfo.setLastName(LAST_NAME); + return userInfo; + } + // + // @Bean + // public UserInfoByEmail accountByEmail() { + // UserInfoByEmail userInfoByEmail = new UserInfoByEmail(); + // userInfoByEmail.setEmailAddress(EMAIL); + // userInfoByEmail.setAccountId(ACCOUNT_ID); + // userInfoByEmail.setProfileId(PROFILE_ID); + // userInfoByEmail.setUsername(USERNAME); + // userInfoByEmail.setFirstName(FIRST_NAME); + // userInfoByEmail.setLastName(LAST_NAME); + // userInfoByEmail.setMiddleName(MIDDLE_NAME); + // userInfoByEmail.setPhoneNumber(PHONE_NUMBER); + // userInfoByEmail.setAuthenticationType(AuthenticationType.EMAIL); + // userInfoByEmail.setStatus(Status.SUSPENDED); + // return userInfoByEmail; + // } + // + // @Bean + // public UserInfoByPhone accountByPhone() { + // UserInfoByPhone userInfoByPhone = new UserInfoByPhone(); + // userInfoByPhone.setPhoneNumber(PHONE_NUMBER); + // userInfoByPhone.setEmailAddress(EMAIL); + // userInfoByPhone.setAccountId(ACCOUNT_ID); + // userInfoByPhone.setProfileId(PROFILE_ID); + // userInfoByPhone.setUsername(USERNAME); + // userInfoByPhone.setFirstName(FIRST_NAME); + // userInfoByPhone.setLastName(LAST_NAME); + // userInfoByPhone.setMiddleName(MIDDLE_NAME); + // userInfoByPhone.setAuthenticationType(AuthenticationType.EMAIL); + // userInfoByPhone.setStatus(Status.SUSPENDED); + // return userInfoByPhone; + // } } -- GitLab From 0adfe5c08e705dac34929f5590df924cc4bbd3e2 Mon Sep 17 00:00:00 2001 From: Ralitsa Todorova Date: Tue, 4 Sep 2018 15:59:57 +0300 Subject: [PATCH 6/8] NY-3044: Unit tests for getting account by authentication provider Signed-off-by: Ralitsa Todorova --- .../AccountByAuthenticationProvider.java | 37 +++- .../account/services/AccountServiceImpl.java | 4 +- .../account/services/AccountServiceTests.java | 209 +++++++++--------- .../java/biz/nynja/account/utils/Util.java | 106 +++++---- 4 files changed, 200 insertions(+), 156 deletions(-) diff --git a/src/main/java/biz/nynja/account/models/AccountByAuthenticationProvider.java b/src/main/java/biz/nynja/account/models/AccountByAuthenticationProvider.java index c65ecf4..7ef1245 100644 --- a/src/main/java/biz/nynja/account/models/AccountByAuthenticationProvider.java +++ b/src/main/java/biz/nynja/account/models/AccountByAuthenticationProvider.java @@ -272,12 +272,37 @@ public class AccountByAuthenticationProvider { public biz.nynja.account.grpc.AccountDetails toProto() { - Builder builder = biz.nynja.account.grpc.AccountDetails.newBuilder().setAccountId(getAccountId().toString()) - .setProfileId(getProfileId().toString()).setAuthenticationIdentifier(getAuthenticationProvider()) - .setAuthenticationType(getAuthenticationProviderType()).setAccountMark(getAccountMark()) - .setAccountName(getAccountName()).setFirstName(getFirstName()).setLastName(getLastName()) - .setUsername(getUsername()).setAccountStatus(getAccountStatus()); - + Builder builder = biz.nynja.account.grpc.AccountDetails.newBuilder(); + if (getAccountId() != null) { + builder.setAccountId(getAccountId().toString()); + } + if (getProfileId() != null) { + builder.setProfileId(getProfileId().toString()); + } + if (getAuthenticationProvider() != null) { + builder.setAuthenticationIdentifier(getAuthenticationProvider()); + } + if (getAuthenticationProviderType() != null) { + builder.setAuthenticationType(getAuthenticationProviderType()); + } + if (getAccountMark() != null) { + builder.setAccountMark(getAccountMark()); + } + if (getAccountName() != null) { + builder.setAccountName(getAccountName()); + } + if (getFirstName() != null) { + builder.setFirstName(getFirstName()); + } + if (getLastName() != null) { + builder.setLastName(getLastName()); + } + if (getUsername() != null) { + builder.setUsername(getUsername()); + } + if (getAccountStatus() != null) { + builder.setAccountStatus(getAccountStatus()); + } if (getQrCode() != null) { builder.setQrCode(getQrCode()); } diff --git a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java index b16d83b..a06dda4 100644 --- a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java +++ b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java @@ -74,13 +74,13 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas StreamObserver responseObserver) { logger.info("Getting account by authentication provider: {}", request); - if (request.getAuthenticationType() == null) { + if (request.getAuthenticationTypeValue() == 0) { responseObserver.onNext(AccountResponse.newBuilder() .setError(ErrorResponse.newBuilder().setCause(Cause.MISSING_AUTH_PROVIDER_TYPE)).build()); responseObserver.onCompleted(); return; } - if (request.getAuthenticationIdentifier() == null) { + if (request.getAuthenticationIdentifier() == null || request.getAuthenticationIdentifier().isEmpty()) { responseObserver.onNext(AccountResponse.newBuilder() .setError(ErrorResponse.newBuilder().setCause(Cause.MISSING_AUTH_PROVIDER_IDENTIFIER)).build()); responseObserver.onCompleted(); diff --git a/src/test/java/biz/nynja/account/services/AccountServiceTests.java b/src/test/java/biz/nynja/account/services/AccountServiceTests.java index 1d1714b..47f251a 100644 --- a/src/test/java/biz/nynja/account/services/AccountServiceTests.java +++ b/src/test/java/biz/nynja/account/services/AccountServiceTests.java @@ -28,6 +28,8 @@ import org.springframework.test.context.junit4.SpringRunner; import com.datastax.driver.core.Session; import biz.nynja.account.configurations.CassandraTestsConfig; +import biz.nynja.account.grpc.AccountByAuthenticationProviderRequest; +import biz.nynja.account.grpc.AccountResponse; import biz.nynja.account.grpc.AccountServiceGrpc; import biz.nynja.account.grpc.AccountsByProfileIdRequest; import biz.nynja.account.grpc.AccountsResponse; @@ -36,6 +38,8 @@ import biz.nynja.account.grpc.CreateAccountRequest; import biz.nynja.account.grpc.ErrorResponse.Cause; import biz.nynja.account.grpc.Status; import biz.nynja.account.models.Account; +import biz.nynja.account.models.AccountByAuthenticationProvider; +import biz.nynja.account.repositories.AccountByAuthenticationProviderRepository; import biz.nynja.account.utils.GrpcServerTestBase; import biz.nynja.account.utils.Util; @@ -52,6 +56,21 @@ import biz.nynja.account.utils.Util; @ActiveProfiles("dev") public class AccountServiceTests extends GrpcServerTestBase { + @MockBean + private AccountByAuthenticationProviderRepository accountByAuthenticationProviderRepository; + + @Autowired + @Qualifier("accountByPhone") + private AccountByAuthenticationProvider accountByPhone; + + @Autowired + @Qualifier("accountByEmail") + private AccountByAuthenticationProvider accountByEmail; + + @Autowired + @Qualifier("accountByFacebook") + private AccountByAuthenticationProvider accountByFacebook; + @Autowired @Qualifier("newAccount") private Account newAccount; @@ -60,6 +79,9 @@ public class AccountServiceTests extends GrpcServerTestBase { @Qualifier("savedAccount") private Account savedAccount; + // TODO: These tests are commented and left here to be used as a reference + // Should be removed when they are not needed anymore + // @Test // public void testCreateAccountByEmail() throws ExecutionException, InterruptedException { // final CreateAccountRequest request = CreateAccountRequest.newBuilder().setFirstName(Util.FIRST_NAME) @@ -341,110 +363,6 @@ public class AccountServiceTests extends GrpcServerTestBase { // } // // @Test -// public void testGetAccountsByEmail() throws ExecutionException, InterruptedException { -// final AccountByAuthenticationProviderRequest request = AccountByAuthenticationProviderRequest.newBuilder() -// .setAuthenticationType(AuthenticationType.EMAIL).setAuthenticationIdentifier(Util.EMAIL).build(); -// -// List usersByEmail = new ArrayList<>(); -// usersByEmail.add(userInfoByEmail); -// given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); -// -// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc -// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); -// -// final AccountResponse reply = accountServiceBlockingStub.getAccountByAuthenticationProvider(request); -// -// assertNotNull("Reply should not be null", reply); -// assertTrue(String.format("Reply should contain email '%s'", Util.EMAIL), -// reply.getAccountDetails().getAuthenticationIdentifier().equals(Util.EMAIL)); -// } -// -// @Test -// public void testGetAccountsByEmailNotFound() throws ExecutionException, InterruptedException { -// final AccountByAuthenticationProviderRequest request = AccountByAuthenticationProviderRequest.newBuilder() -// .setAuthenticationType(AuthenticationType.EMAIL).setAuthenticationIdentifier(Util.EMAIL).build(); -// -// List usersByEmail = new ArrayList<>(); -// given(userInfoByEmailRepository.findByEmailAddress(Util.EMAIL)).willReturn(usersByEmail); -// -// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc -// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); -// -// final AccountResponse reply = accountServiceBlockingStub.getAccountByAuthenticationProvider(request); -// -// assertNotNull("Reply should not be null", reply); -// assertTrue(String.format("Reply should contain cause '%s'", Cause.ACCOUNT_NOT_FOUND), -// reply.getError().getCause().equals(Cause.ACCOUNT_NOT_FOUND)); -// } -// -// @Test -// public void testGetAccountsByEmailBadRequest() throws ExecutionException, InterruptedException { -// final AccountByAuthenticationProviderRequest request = AccountByAuthenticationProviderRequest.newBuilder() -// .setAuthenticationType(AuthenticationType.EMAIL).build(); -// -// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc -// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); -// -// final AccountResponse reply = accountServiceBlockingStub.getAccountByAuthenticationProvider(request); -// -// assertNotNull("Reply should not be null", reply); -// assertTrue(String.format("Reply should contain cause '%s'", Cause.ACCOUNT_NOT_FOUND), -// reply.getError().getCause().equals(Cause.ACCOUNT_NOT_FOUND)); -// } -// -// @Test -// public void testGetAccountsByPhone() throws ExecutionException, InterruptedException { -// final AccountByAuthenticationProviderRequest request = AccountByAuthenticationProviderRequest.newBuilder() -// .setAuthenticationType(AuthenticationType.PHONE).setAuthenticationIdentifier(Util.PHONE_NUMBER).build(); -// -// List usersByPhone = new ArrayList<>(); -// usersByPhone.add(userInfoByPhone); -// given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); -// -// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc -// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); -// -// final AccountResponse reply = accountServiceBlockingStub.getAccountByAuthenticationProvider(request); -// -// assertNotNull("Reply should not be null", reply); -// assertTrue(String.format("Reply should contain phone '%s'", Util.PHONE_NUMBER), -// reply.getAccountDetails().getAuthenticationIdentifier().equals(Util.PHONE_NUMBER)); -// } -// -// @Test -// public void testGetAccountsByPhoneNotFound() throws ExecutionException, InterruptedException { -// final AccountByAuthenticationProviderRequest request = AccountByAuthenticationProviderRequest.newBuilder() -// .setAuthenticationType(AuthenticationType.PHONE).setAuthenticationIdentifier(Util.PHONE_NUMBER).build(); -// -// List usersByPhone = new ArrayList<>(); -// given(userInfoByPhoneRepository.findByPhoneNumber(Util.PHONE_NUMBER)).willReturn(usersByPhone); -// -// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc -// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); -// -// final AccountResponse reply = accountServiceBlockingStub.getAccountByAuthenticationProvider(request); -// -// assertNotNull("Reply should not be null", reply); -// assertTrue(String.format("Reply should contain cause '%s'", Cause.ACCOUNT_NOT_FOUND), -// reply.getError().getCause().equals(Cause.ACCOUNT_NOT_FOUND)); -// } -// -// @Test -// public void testGetAccountsByPhoneBadRequest() throws ExecutionException, InterruptedException { -// final AccountByAuthenticationProviderRequest request = AccountByAuthenticationProviderRequest.newBuilder() -// .setAuthenticationType(AuthenticationType.PHONE).build(); -// -// final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc -// .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); -// -// final AccountResponse reply = accountServiceBlockingStub.getAccountByAuthenticationProvider(request); -// -// assertNotNull("Reply should not be null", reply); -// assertTrue(String.format("Reply should contain cause '%s'", Cause.ACCOUNT_NOT_FOUND), -// reply.getError().getCause().equals(Cause.ACCOUNT_NOT_FOUND)); -// } -// -// @Test // public void testGetAccountsByProfileId() throws ExecutionException, InterruptedException { // final AccountsByProfileIdRequest request = AccountsByProfileIdRequest.newBuilder() // .setProfileId(Util.PROFILE_ID.toString()).build(); @@ -496,4 +414,87 @@ public class AccountServiceTests extends GrpcServerTestBase { reply.getError().getCause().equals(Cause.MISSING_PROFILE_ID)); } + @Test + public void testGetAccountByAuthProviderPhone() { + final AccountByAuthenticationProviderRequest request = AccountByAuthenticationProviderRequest.newBuilder() + .setAuthenticationIdentifier(Util.PHONE_NUMBER).setAuthenticationType(AuthenticationType.PHONE).build(); + + List accList = new ArrayList<>(); + accList.add(accountByPhone); + given(accountByAuthenticationProviderRepository.findAllByAuthenticationProvider(Util.PHONE_NUMBER)) + .willReturn(accList); + + final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc + .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); + final AccountResponse reply = accountServiceBlockingStub.getAccountByAuthenticationProvider(request); + assertNotNull("Reply should not be null", reply); + assertTrue( + String.format("Reply should contain authentication provider '%s'", + request.getAuthenticationIdentifier()), + reply.getAccountDetails().getAuthenticationIdentifier().equals(Util.PHONE_NUMBER)); + assertTrue(String.format("Reply should contain authentication type '%s'", AuthenticationType.PHONE.name()), + reply.getAccountDetails().getAuthenticationType().equals(AuthenticationType.PHONE.name())); + } + + @Test + public void testGetAccountByAuthProviderMultipleRecords() { + final AccountByAuthenticationProviderRequest request = AccountByAuthenticationProviderRequest.newBuilder() + .setAuthenticationIdentifier(Util.EMAIL).setAuthenticationType(AuthenticationType.EMAIL).build(); + + List accList = new ArrayList<>(); + accList.add(accountByEmail); + accList.add(accountByFacebook); + given(accountByAuthenticationProviderRepository.findAllByAuthenticationProvider(Util.EMAIL)) + .willReturn(accList); + + final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc + .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); + final AccountResponse reply = accountServiceBlockingStub.getAccountByAuthenticationProvider(request); + assertNotNull("Reply should not be null", reply); + assertTrue( + String.format("Reply should contain authentication provider '%s'", + request.getAuthenticationIdentifier()), + reply.getAccountDetails().getAuthenticationIdentifier().equals(Util.EMAIL)); + assertTrue(String.format("Reply should contain authentication type '%s'", AuthenticationType.EMAIL.name()), + reply.getAccountDetails().getAuthenticationType().equals(AuthenticationType.EMAIL.name())); + } + + @Test + public void testGetAccountByAuthProviderMissingType() { + final AccountByAuthenticationProviderRequest request = AccountByAuthenticationProviderRequest.newBuilder() + .build(); + final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc + .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); + final AccountResponse reply = accountServiceBlockingStub.getAccountByAuthenticationProvider(request); + assertNotNull("Reply should not be null", reply); + assertTrue(String.format("Reply should contain cause '%s'", Cause.MISSING_AUTH_PROVIDER_TYPE), + reply.getError().getCause().equals(Cause.MISSING_AUTH_PROVIDER_TYPE)); + } + + @Test + public void testGetAccountByAuthProviderMissingIdentifier() { + final AccountByAuthenticationProviderRequest request = AccountByAuthenticationProviderRequest.newBuilder() + .setAuthenticationType(AuthenticationType.PHONE).build(); + final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc + .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); + final AccountResponse reply = accountServiceBlockingStub.getAccountByAuthenticationProvider(request); + assertNotNull("Reply should not be null", reply); + assertTrue(String.format("Reply should contain cause '%s'", Cause.MISSING_AUTH_PROVIDER_IDENTIFIER), + reply.getError().getCause().equals(Cause.MISSING_AUTH_PROVIDER_IDENTIFIER)); + } + + @Test + public void testGetAccountByAuthProviderNotFound() { + final AccountByAuthenticationProviderRequest request = AccountByAuthenticationProviderRequest.newBuilder() + .setAuthenticationIdentifier(Util.EMAIL).setAuthenticationType(AuthenticationType.EMAIL).build(); + List accList = new ArrayList<>(); + given(accountByAuthenticationProviderRepository.findAllByAuthenticationProvider(Util.EMAIL)) + .willReturn(accList); + final AccountServiceGrpc.AccountServiceBlockingStub accountServiceBlockingStub = AccountServiceGrpc + .newBlockingStub(Optional.ofNullable(channel).orElse(inProcChannel)); + final AccountResponse reply = accountServiceBlockingStub.getAccountByAuthenticationProvider(request); + assertNotNull("Reply should not be null", reply); + assertTrue(String.format("Reply should contain cause '%s'", Cause.ACCOUNT_NOT_FOUND), + reply.getError().getCause().equals(Cause.ACCOUNT_NOT_FOUND)); + } } diff --git a/src/test/java/biz/nynja/account/utils/Util.java b/src/test/java/biz/nynja/account/utils/Util.java index 0745825..4f964be 100644 --- a/src/test/java/biz/nynja/account/utils/Util.java +++ b/src/test/java/biz/nynja/account/utils/Util.java @@ -9,7 +9,9 @@ import java.util.UUID; import org.springframework.boot.test.context.TestConfiguration; import org.springframework.context.annotation.Bean; +import biz.nynja.account.grpc.Status; import biz.nynja.account.models.Account; +import biz.nynja.account.models.AccountByAuthenticationProvider; /** * Unit tests variables, beans and help methods. @@ -27,57 +29,73 @@ public class Util { public static final String LAST_NAME = "Doe"; public static final String MIDDLE_NAME = "Kass"; public static final String PHONE_NUMBER = "+359887434646"; + public static final String PHONE_TYPE = "PHONE"; + public static final String EMAIL_TYPE = "EMAIL"; + public static final String FACBOOK_TYPE = "FACEBOOK"; + public static final String GOOGLEPLUS_TYPE = "GOOGLEPLUS"; @Bean public Account newAccount() { - Account userInfo = new Account(); - userInfo.setUsername(USERNAME); - userInfo.setFirstName(FIRST_NAME); - userInfo.setLastName(LAST_NAME); - return userInfo; + Account account = new Account(); + account.setUsername(USERNAME); + account.setFirstName(FIRST_NAME); + account.setLastName(LAST_NAME); + account.setUsername(USERNAME); + account.setFirstName(FIRST_NAME); + account.setLastName(LAST_NAME); + account.setAuthenticationProvider(EMAIL); + account.setAuthenticationProviderType(EMAIL_TYPE); + account.setAccountStatus(Status.SUSPENDED.name()); + return account; } @Bean public Account savedAccount() { - Account userInfo = new Account(); - userInfo.setAccountId(ACCOUNT_ID); - userInfo.setProfileId(PROFILE_ID); - userInfo.setUsername(USERNAME); - userInfo.setFirstName(FIRST_NAME); - userInfo.setLastName(LAST_NAME); - return userInfo; + Account account = new Account(); + account.setAccountId(ACCOUNT_ID); + account.setProfileId(PROFILE_ID); + account.setUsername(USERNAME); + account.setFirstName(FIRST_NAME); + account.setLastName(LAST_NAME); + return account; } - // - // @Bean - // public UserInfoByEmail accountByEmail() { - // UserInfoByEmail userInfoByEmail = new UserInfoByEmail(); - // userInfoByEmail.setEmailAddress(EMAIL); - // userInfoByEmail.setAccountId(ACCOUNT_ID); - // userInfoByEmail.setProfileId(PROFILE_ID); - // userInfoByEmail.setUsername(USERNAME); - // userInfoByEmail.setFirstName(FIRST_NAME); - // userInfoByEmail.setLastName(LAST_NAME); - // userInfoByEmail.setMiddleName(MIDDLE_NAME); - // userInfoByEmail.setPhoneNumber(PHONE_NUMBER); - // userInfoByEmail.setAuthenticationType(AuthenticationType.EMAIL); - // userInfoByEmail.setStatus(Status.SUSPENDED); - // return userInfoByEmail; - // } - // - // @Bean - // public UserInfoByPhone accountByPhone() { - // UserInfoByPhone userInfoByPhone = new UserInfoByPhone(); - // userInfoByPhone.setPhoneNumber(PHONE_NUMBER); - // userInfoByPhone.setEmailAddress(EMAIL); - // userInfoByPhone.setAccountId(ACCOUNT_ID); - // userInfoByPhone.setProfileId(PROFILE_ID); - // userInfoByPhone.setUsername(USERNAME); - // userInfoByPhone.setFirstName(FIRST_NAME); - // userInfoByPhone.setLastName(LAST_NAME); - // userInfoByPhone.setMiddleName(MIDDLE_NAME); - // userInfoByPhone.setAuthenticationType(AuthenticationType.EMAIL); - // userInfoByPhone.setStatus(Status.SUSPENDED); - // return userInfoByPhone; - // } + @Bean + public AccountByAuthenticationProvider accountByPhone() { + AccountByAuthenticationProvider accountByPhone = new AccountByAuthenticationProvider(); + accountByPhone.setAuthenticationProvider(PHONE_NUMBER); + accountByPhone.setAuthenticationProviderType(PHONE_TYPE); + accountByPhone.setAccountId(ACCOUNT_ID); + accountByPhone.setProfileId(PROFILE_ID); + accountByPhone.setUsername(USERNAME); + accountByPhone.setFirstName(FIRST_NAME); + accountByPhone.setLastName(LAST_NAME); + return accountByPhone; + } + + @Bean + public AccountByAuthenticationProvider accountByEmail() { + AccountByAuthenticationProvider accountByPhone = new AccountByAuthenticationProvider(); + accountByPhone.setAuthenticationProvider(EMAIL); + accountByPhone.setAuthenticationProviderType(EMAIL_TYPE); + accountByPhone.setAccountId(ACCOUNT_ID); + accountByPhone.setProfileId(PROFILE_ID); + accountByPhone.setUsername(USERNAME); + accountByPhone.setFirstName(FIRST_NAME); + accountByPhone.setLastName(LAST_NAME); + return accountByPhone; + } + + @Bean + public AccountByAuthenticationProvider accountByFacebook() { + AccountByAuthenticationProvider accountByPhone = new AccountByAuthenticationProvider(); + accountByPhone.setAuthenticationProvider(EMAIL); + accountByPhone.setAuthenticationProviderType(FACBOOK_TYPE); + accountByPhone.setAccountId(ACCOUNT_ID); + accountByPhone.setProfileId(PROFILE_ID); + accountByPhone.setUsername(USERNAME); + accountByPhone.setFirstName(FIRST_NAME); + accountByPhone.setLastName(LAST_NAME); + return accountByPhone; + } } -- GitLab From ea2e4b18130abc1ca044e0d829bdadbc043daaa6 Mon Sep 17 00:00:00 2001 From: Ralitsa Todorova Date: Tue, 4 Sep 2018 16:01:12 +0300 Subject: [PATCH 7/8] Update models base package after package renaming Signed-off-by: Ralitsa Todorova --- .../java/biz/nynja/account/configuration/CassandraConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/biz/nynja/account/configuration/CassandraConfig.java b/src/main/java/biz/nynja/account/configuration/CassandraConfig.java index 0c5a2f2..6ea4bd2 100644 --- a/src/main/java/biz/nynja/account/configuration/CassandraConfig.java +++ b/src/main/java/biz/nynja/account/configuration/CassandraConfig.java @@ -43,7 +43,7 @@ public class CassandraConfig extends AbstractCassandraConfiguration { @Override public String[] getEntityBasePackages() { - return new String[] { "biz.nynja.account.grpc.models" }; + return new String[] { "biz.nynja.account.models" }; } /** -- GitLab From 6587e75a85a0e664dd8c82a92489d09c30eb7d00 Mon Sep 17 00:00:00 2001 From: Ralitsa Todorova Date: Tue, 4 Sep 2018 16:10:11 +0300 Subject: [PATCH 8/8] NY-3044: Point to the correct artifact from proto-repository Signed-off-by: Ralitsa Todorova --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e1015ce..b28a877 100644 --- a/pom.xml +++ b/pom.xml @@ -101,7 +101,7 @@ libs-snapshot-local.biz.nynja.protos - account-service-ny-3044-account-retrieval + account-service-intracoldev 1.0-SNAPSHOT -- GitLab