Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [MIR-3740] Notifications sent to Beneficiary must use the address email from the consumer and not from The beneficiary [BNA]
- ### Eclipse Workspace Patch 1.0
- #P batch-services
- Index: src/main/java/net/sxpbelux/mirage/service/batch/card/CardRequestDataProcessor.java
- ===================================================================
- --- src/main/java/net/sxpbelux/mirage/service/batch/card/CardRequestDataProcessor.java (revision 9266)
- +++ src/main/java/net/sxpbelux/mirage/service/batch/card/CardRequestDataProcessor.java (working copy)
- @@ -69,7 +69,7 @@
- }
- if (informBeneficiaries) {
- - mailSenderService.sendMailToInformBeneficiaryForBlockCard(card);
- + mailSenderService.sendMailToInformConsumerForBlockCard(card);
- }
- if (informClients) {
- @@ -90,7 +90,7 @@
- cardRequestItemRepository.add(cardRequestItem);
- if (informBeneficiaries) {
- - mailSenderService.sendMailToInformBeneficiaryForPinResend(card);
- + mailSenderService.sendMailToInformConsumerForPinResend(card);
- }
- if (informClients) {
- Index: src/test/java/net/sxpbelux/mirage/service/batch/card/CardRequestDataProcessorTest.java
- ===================================================================
- --- src/test/java/net/sxpbelux/mirage/service/batch/card/CardRequestDataProcessorTest.java (revision 8971)
- +++ src/test/java/net/sxpbelux/mirage/service/batch/card/CardRequestDataProcessorTest.java (working copy)
- @@ -102,7 +102,7 @@
- assertEquals(blockCardRequestData,item);
- assertEquals(item.getCardRequestDataState(), CardRequestDataState.IN_PROGRESS);
- - verify(mailSenderService, times(1)).sendMailToInformBeneficiaryForBlockCard(card);
- + verify(mailSenderService, times(1)).sendMailToInformConsumerForBlockCard(card);
- verify(mailSenderService, times(1)).sendMailToInformClientForBlockCard(card);
- }
- @@ -116,7 +116,7 @@
- assertEquals(item.getCardRequestDataState(), CardRequestDataState.IN_PROGRESS);
- assertEquals(item.getPinResendReason(), PinResendReason.NEVER_ARRIVED_PIN);
- - verify(mailSenderService, times(1)).sendMailToInformBeneficiaryForPinResend(card);
- + verify(mailSenderService, times(1)).sendMailToInformConsumerForPinResend(card);
- verify(mailSenderService, times(1)).sendMailToInformClientForPinResend(card);
- #P domain
- Index: src/main/java/net/sxpbelux/mirage/domain/EmailRecipientFactory.java
- ===================================================================
- --- src/main/java/net/sxpbelux/mirage/domain/EmailRecipientFactory.java (revision 9290)
- +++ src/main/java/net/sxpbelux/mirage/domain/EmailRecipientFactory.java (working copy)
- @@ -1,8 +1,11 @@
- package net.sxpbelux.mirage.domain;
- +import net.sxpbelux.mirage.domain.beneficiary.Beneficiary;
- +
- public interface EmailRecipientFactory {
- EmailRecipient createNewEmailRecipient(String emailAddress, Language language);
- EmailRecipient createNewEmailRecipient(EmailAddress emailAddress, Language language);
- + EmailRecipient createNewEmailRecipientBasedOnConsumerFirstAndBeneficiaryAfterwards(Beneficiary beneficiary);
- }
- \ No newline at end of file
- Index: src/main/java/net/sxpbelux/mirage/domain/EmailRecipientFactoryImpl.java
- ===================================================================
- --- src/main/java/net/sxpbelux/mirage/domain/EmailRecipientFactoryImpl.java (revision 9290)
- +++ src/main/java/net/sxpbelux/mirage/domain/EmailRecipientFactoryImpl.java (working copy)
- @@ -1,5 +1,8 @@
- package net.sxpbelux.mirage.domain;
- +import net.sxpbelux.mirage.domain.beneficiary.Beneficiary;
- +
- +import org.apache.commons.lang.StringUtils;
- import org.springframework.stereotype.Service;
- @Service
- @@ -15,4 +18,23 @@
- return new EmailRecipient(language, emailAddress);
- }
- + @Override
- + public EmailRecipient createNewEmailRecipientBasedOnConsumerFirstAndBeneficiaryAfterwards (Beneficiary beneficiary) {
- + EmailAddress emailAddress = null;
- + Language language = null;
- + if (beneficiary.getConsumer().getEmail() != null && !StringUtils.isEmpty(beneficiary.getConsumer().getEmail().toString())) {
- + emailAddress = beneficiary.getConsumer ().getEmail();
- + }
- + else {
- + emailAddress = beneficiary.getEmail();
- + }
- + if (beneficiary.getConsumer().getLanguage() != null && !StringUtils.isEmpty(beneficiary.getConsumer().getLanguage().toString())) {
- + language = beneficiary.getConsumer ().getLanguage();
- + }
- + else {
- + language = beneficiary.getLanguage();
- + }
- + return new EmailRecipient(language, emailAddress);
- +
- + }
- }
- \ No newline at end of file
- Index: src/main/java/net/sxpbelux/mirage/domain/notifications/NotificationFactoryImpl.java
- ===================================================================
- --- src/main/java/net/sxpbelux/mirage/domain/notifications/NotificationFactoryImpl.java (revision 9290)
- +++ src/main/java/net/sxpbelux/mirage/domain/notifications/NotificationFactoryImpl.java (working copy)
- @@ -45,7 +45,7 @@
- public static final String DATE_FORMAT_SUBJECT = "dd-MM-yyyy hh:mm:ss";
- - private EmailRecipientFactory emailRecipientFactory;
- + private final EmailRecipientFactory emailRecipientFactory;
- @Autowired public NotificationFactoryImpl(EmailRecipientFactory emailRecipientFactory){
- this.emailRecipientFactory = emailRecipientFactory;
- @@ -68,7 +68,7 @@
- public ProductDeliveryNotification createProductDeliveryNotification(OrderDeliveryEvent orderDeliveryEvent) {
- ConsumableProduct consumableProduct = orderDeliveryEvent.getProduct();
- Beneficiary beneficiary = consumableProduct.getBeneficiary();
- - EmailRecipient recipient = emailRecipientFactory.createNewEmailRecipient(beneficiary.getEmail(),beneficiary.getLanguage());
- + EmailRecipient recipient = emailRecipientFactory.createNewEmailRecipientBasedOnConsumerFirstAndBeneficiaryAfterwards(beneficiary);
- return new ProductDeliveryNotification(recipient, beneficiary.getConsumer(), orderDeliveryEvent);
- }
- Index: src/main/java/net/sxpbelux/mirage/service/MailSenderService.java
- ===================================================================
- --- src/main/java/net/sxpbelux/mirage/service/MailSenderService.java (revision 9266)
- +++ src/main/java/net/sxpbelux/mirage/service/MailSenderService.java (working copy)
- @@ -25,8 +25,8 @@
- void sendMailForAccountRetrieval(List<UserContext> userContexts, EmailAddress emailTo, Language language);
- void sendMailForPDFEmailToClient(InputStream pdfFile, List<EmailAddress> emailAddresses, AbstractBillingDocument document);
- void sendMailForPDFEmailToAffiliate(InputStream pdfFile, List<EmailAddress> emailAddresses, AbstractBillingDocument document);
- - void sendMailToInformBeneficiaryForBlockCard(Card card);
- + void sendMailToInformConsumerForBlockCard(Card card);
- void sendMailToInformClientForBlockCard(Card card);
- - void sendMailToInformBeneficiaryForPinResend(Card card);
- + void sendMailToInformConsumerForPinResend(Card card);
- void sendMailToInformClientForPinResend(Card card);
- }
- \ No newline at end of file
- Index: src/test/java/net/sxpbelux/mirage/domain/beneficiary/BeneficiaryMother.java
- ===================================================================
- --- src/test/java/net/sxpbelux/mirage/domain/beneficiary/BeneficiaryMother.java (revision 9290)
- +++ src/test/java/net/sxpbelux/mirage/domain/beneficiary/BeneficiaryMother.java (working copy)
- @@ -120,6 +120,11 @@
- public static Beneficiary createBeneficiary(Client client, Consumer consumer) {
- return createBeneficiary(client, consumer, FACEVALUE, new EmailAddress("test@test.be"));
- }
- +
- + public static Beneficiary createBeneficiaryWithoutEmailAddress(Client client, Consumer consumer) {
- + return createBeneficiary(client, consumer, FACEVALUE, null);
- + }
- +
- public static Beneficiary createBeneficiary(Client client, Consumer consumer, EmailAddress emailAddress) {
- return createBeneficiary(client, consumer, FACEVALUE, emailAddress);
- }
- Index: src/test/java/net/sxpbelux/mirage/domain/owner/ConsumerMother.java
- ===================================================================
- --- src/test/java/net/sxpbelux/mirage/domain/owner/ConsumerMother.java (revision 9266)
- +++ src/test/java/net/sxpbelux/mirage/domain/owner/ConsumerMother.java (working copy)
- @@ -21,6 +21,10 @@
- return createConsumer(Constants.DUMMY_INSZ);
- }
- + public static Consumer createConsumerWithoutEmailAddress(){
- + return new ConsumerFactoryTestImpl().createConsumer(PersonMother.createDefaultPerson(), null);
- + }
- +
- public static Consumer createConsumer(PersistedPersonIdentifier insz){
- return createConsumer(PersonMother.createPerson(insz));
- }
- Index: src/test/java/net/sxpbelux/mirage/domain/EmailRecipientFactoryTest.java
- ===================================================================
- --- src/test/java/net/sxpbelux/mirage/domain/EmailRecipientFactoryTest.java (revision 0)
- +++ src/test/java/net/sxpbelux/mirage/domain/EmailRecipientFactoryTest.java (revision 0)
- @@ -0,0 +1,68 @@
- +package net.sxpbelux.mirage.domain;
- +
- +import static org.junit.Assert.assertEquals;
- +import static org.junit.Assert.assertNotNull;
- +import static org.junit.Assert.assertNull;
- +import net.sxpbelux.mirage.domain.beneficiary.Beneficiary;
- +import net.sxpbelux.mirage.domain.beneficiary.BeneficiaryMother;
- +import net.sxpbelux.mirage.domain.organization.Client;
- +import net.sxpbelux.mirage.domain.organization.ClientMother;
- +import net.sxpbelux.mirage.domain.owner.Consumer;
- +import net.sxpbelux.mirage.domain.owner.ConsumerMother;
- +
- +import org.junit.Before;
- +import org.junit.Test;
- +
- +
- +public class EmailRecipientFactoryTest {
- +
- + private EmailRecipientFactory factory;
- + private Client client;
- +
- + @Before
- + public void setUp() {
- + factory = new EmailRecipientFactoryImpl ();
- + client = ClientMother.createClient();
- + }
- +
- + @Test
- + public void testCreateEmailForBeneficiaryWithConsumerAddressIdenticalToBeneficiaryAddress () {
- + Consumer consumer = ConsumerMother.createConsumer();
- + consumer.setEmail(new EmailAddress("johnny.cash@sodexo.com"));
- + Beneficiary beneficiary = BeneficiaryMother.createBeneficiary(client, consumer);
- + beneficiary.setEmail(new EmailAddress("johnny.cash@sodexo.com"));
- + beneficiary.setLanguage(Language.EN);
- + EmailRecipient email = factory.createNewEmailRecipientBasedOnConsumerFirstAndBeneficiaryAfterwards(beneficiary);
- + assertNotNull (email);
- + assertEquals (Language.EN, email.getLanguage());
- + assertEquals (new EmailAddress("johnny.cash@sodexo.com"), email.getEmailAddress());
- + }
- +
- + @Test
- + public void testCreateEmailForBeneficiaryWithConsumerAddressAndLanguageDifferentFromBeneficiaryAddressAndLanguage () {
- + Consumer consumer = ConsumerMother.createConsumer();
- + consumer.setEmail(new EmailAddress("johnny.cash@test.com"));
- + consumer.setLanguage(Language.FR);
- +
- + Beneficiary beneficiary = BeneficiaryMother.createBeneficiary(client, consumer);
- + beneficiary.setEmail(new EmailAddress("johnny.cash@sodexo.com"));
- + beneficiary.setLanguage(Language.EN);
- +
- + EmailRecipient email = factory.createNewEmailRecipientBasedOnConsumerFirstAndBeneficiaryAfterwards(beneficiary);
- + assertNotNull (email);
- + assertEquals (Language.FR, email.getLanguage());
- + assertEquals (new EmailAddress("johnny.cash@test.com"), email.getEmailAddress());
- +
- + }
- +
- + @Test
- + public void testCreateEmailForBeneficiaryWithConsumerAddressAndBeneficiaryAddressNull () {
- + Consumer consumer = ConsumerMother.createConsumerWithoutEmailAddress();
- + Beneficiary beneficiary = BeneficiaryMother.createBeneficiaryWithoutEmailAddress(client, consumer);
- +
- + EmailRecipient email = factory.createNewEmailRecipientBasedOnConsumerFirstAndBeneficiaryAfterwards(beneficiary);
- + assertNotNull (email);
- + assertEquals (Language.EN, email.getLanguage());
- + assertNull (email.getEmailAddress());
- + }
- +}
- #P common-services
- Index: src/main/java/net/sxpbelux/mirage/service/MailSenderServiceImpl.java
- ===================================================================
- --- src/main/java/net/sxpbelux/mirage/service/MailSenderServiceImpl.java (revision 9266)
- +++ src/main/java/net/sxpbelux/mirage/service/MailSenderServiceImpl.java (working copy)
- @@ -337,7 +337,7 @@
- }
- @Override
- - public void sendMailToInformBeneficiaryForBlockCard(Card card) {
- + public void sendMailToInformConsumerForBlockCard(Card card) {
- Map<String, Object> model = new HashMap<String, Object>();
- model.put("date", DateUtil.formatDateToDDMMYYY(DateUtil.getToday()));
- model.put("display_name", card.getConsumer().getDisplayName());
- @@ -349,7 +349,7 @@
- }
- @Override
- - public void sendMailToInformBeneficiaryForPinResend(Card card) {
- + public void sendMailToInformConsumerForPinResend(Card card) {
- Map<String, Object> model = new HashMap<String, Object>();
- List<EmailAddress> emailAddresses = new ArrayList<EmailAddress>();
- emailAddresses.add(card.getConsumer().getEmail());
Add Comment
Please, Sign In to add comment