From 76114c5bb88760414af1f3cf64a27641966aa96d Mon Sep 17 00:00:00 2001 From: Stoyan Tzenkov Date: Tue, 9 Oct 2018 13:14:14 +0300 Subject: [PATCH 1/3] AccountServiceHelperTests restored --- .../biz/nynja/account/components/AccountServiceHelperTests.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/biz/nynja/account/components/AccountServiceHelperTests.java b/src/test/java/biz/nynja/account/components/AccountServiceHelperTests.java index fcfcb5d..ef41016 100644 --- a/src/test/java/biz/nynja/account/components/AccountServiceHelperTests.java +++ b/src/test/java/biz/nynja/account/components/AccountServiceHelperTests.java @@ -27,6 +27,7 @@ import biz.nynja.account.utils.Util; @SpringBootTest(classes = { Util.class, CassandraTestsConfig.class }, webEnvironment = WebEnvironment.RANDOM_PORT, properties = { + "grpc.port=${grpc.unitTest.port.accountServiceTest}", "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration", "spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration" }) @ActiveProfiles("dev") -- GitLab From 619ff88b4489a4a3a419743b01f10a0ff7a4d08a Mon Sep 17 00:00:00 2001 From: Stoyan Tzenkov Date: Fri, 12 Oct 2018 12:11:47 +0300 Subject: [PATCH 2/3] LibphoneNormalizationParameterizedTest restored after refactoring Signed-off-by: Stoyan Tzenkov --- .../LibphoneNormalizationParameterizedTest.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/test/java/biz/nynja/account/components/LibphoneNormalizationParameterizedTest.java b/src/test/java/biz/nynja/account/components/LibphoneNormalizationParameterizedTest.java index 19a76cd..71e74d3 100644 --- a/src/test/java/biz/nynja/account/components/LibphoneNormalizationParameterizedTest.java +++ b/src/test/java/biz/nynja/account/components/LibphoneNormalizationParameterizedTest.java @@ -13,6 +13,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Configurable; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestContextManager; import org.springframework.test.context.TestExecutionListeners; @@ -30,11 +31,10 @@ import biz.nynja.account.services.AccountServiceImpl; @RunWith(Parameterized.class) @TestExecutionListeners({}) -@ContextConfiguration(classes = { AccountServiceImpl.class }) +@ContextConfiguration(classes = { Validator.class }) public class LibphoneNormalizationParameterizedTest { - @Autowired - private Validator validator; + private Validator validator = new Validator(); private String expectedPhoneNumber; private String inputPhoneNumber; @@ -52,12 +52,11 @@ public class LibphoneNormalizationParameterizedTest { @Parameterized.Parameters public static Collection phoneNumbers() { - return Arrays.asList(new Object[][] { { "359887345234", "BG:+359887345234" }, + return Arrays.asList(new Object[][] { + { "359887345234", "BG:+359887345234" }, { "359887345234", "BG:00359887345234" }, - { "359887345234", "BG:359 887 345 234" }, - { "359887345234", "BG:359887345234567" }, - { "359887345234", "BG:359 887 345" }, - { "359887345234", "BG:359-887-345-234" } }); + { "359887345234", "BG:359 887 345 234" }, + { "359887345234", "BG:359-887-345-234" } }); } @Test -- GitLab From a4e39e293d030d6cbe36c8afc1cf8fc59a7e757c Mon Sep 17 00:00:00 2001 From: Stoyan Tzenkov Date: Tue, 16 Oct 2018 14:21:36 +0300 Subject: [PATCH 3/3] NY_3610: phone normalization mived up in createPendingAccount() Signed-off-by: Stoyan Tzenkov --- .../account/services/AccountServiceImpl.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java index fff5366..6f298cc 100644 --- a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java +++ b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java @@ -234,6 +234,14 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas return; } + if (request.getAuthenticationType() == AuthenticationType.PHONE) { + // Get the normalized phone number from libphone + CreatePendingAccountRequest newRequest = CreatePendingAccountRequest.newBuilder() + .setAuthenticationType(request.getAuthenticationType()) + .setAuthenticationProvider(validator.getNormalizedPhoneNumber(request.getAuthenticationProvider())).build(); + request = newRequest; + } + PendingAccountByAuthenticationProvider foundExistingPendingAccount = accountRepositoryAdditional .findSameAuthenticationProviderInPendingAccount( AuthenticationProvider.createAuthenticationProviderFromStrings( @@ -268,11 +276,6 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas PendingAccount pendingAccount = PendingAccount.fromProto(request); - if (request.getAuthenticationType() == AuthenticationType.PHONE) { - // Get the normalized phone number from libphone - pendingAccount.setAuthenticationProvider(validator.getNormalizedPhoneNumber(request.getAuthenticationProvider())); - } - pendingAccount.setAccountId(UUID.randomUUID()); pendingAccount.setProfileId(UUID.randomUUID()); pendingAccount.setCreationTimestamp(new Date().getTime()); @@ -494,7 +497,7 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas responseObserver.onCompleted(); return; } - + if (request.getAuthenticationProvider().getAuthenticationType() == AuthenticationType.PHONE) { // Get the normalized phone number from libphone AuthProviderDetails newAuthProviderDetails = AuthProviderDetails.newBuilder() @@ -507,7 +510,6 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas request = newRequest; } - // Make sure that the requested profile id for update exists in DB. Profile profile = profileRepository.findByProfileId(UUID.fromString(request.getProfileId())); if (profile == null) { -- GitLab