use of uk.gov.pay.adminusers.persistence.entity.MerchantDetailsEntity in project pay-adminusers by alphagov.
the class ServiceUpdaterTest method shouldUpdateMerchantDetailsAddressLine1Successfully_WhenExistingMerchantDetails.
@Test
public void shouldUpdateMerchantDetailsAddressLine1Successfully_WhenExistingMerchantDetails() {
String updatedAddressLine1 = "1 Spider Lane";
ServiceUpdateRequest request = serviceUpdateRequest("replace", "merchant_details/address_line1", updatedAddressLine1);
MerchantDetailsEntity merchantDetails = aMerchantDetailsEntity().build();
ServiceEntity serviceEntity = aServiceEntity().withMerchantDetailsEntity(merchantDetails).build();
when(serviceDao.findByExternalId(SERVICE_ID)).thenReturn(of(serviceEntity));
Optional<Service> maybeService = updater.doUpdate(SERVICE_ID, request);
assertThat(maybeService.isPresent(), is(true));
verify(serviceDao).merge(serviceEntity);
assertThat(maybeService.get().getMerchantDetails().getName(), is("test-name"));
assertThat(maybeService.get().getMerchantDetails().getAddressLine1(), is(updatedAddressLine1));
}
use of uk.gov.pay.adminusers.persistence.entity.MerchantDetailsEntity in project pay-adminusers by alphagov.
the class ServiceUpdaterTest method shouldSuccess_updateMerchantDetails.
@Test
public void shouldSuccess_updateMerchantDetails() throws ServiceNotFoundException {
String name = "name";
String telephoneNumber = "03069990000";
String addressLine1 = "something";
String addressLine2 = "something";
String addressCity = "something";
String addressPostcode = "something";
String addressCountry = "something";
String email = "dd-merchant@example.com";
String url = "https://merchant.example.com";
MerchantDetailsEntity toUpdate = new MerchantDetailsEntity(name, telephoneNumber, addressLine1, addressLine2, addressCity, addressPostcode, addressCountry, email, url);
UpdateMerchantDetailsRequest request = new UpdateMerchantDetailsRequest(name, telephoneNumber, addressLine1, addressLine2, addressCity, addressPostcode, addressCountry, email, url);
ServiceEntity serviceEntity = mock(ServiceEntity.class);
when(serviceDao.findByExternalId(SERVICE_ID)).thenReturn(of(serviceEntity));
when(serviceEntity.toService()).thenReturn(Service.from());
Service service = updater.doUpdateMerchantDetails(SERVICE_ID, request);
assertNotNull(service);
verify(serviceEntity).setMerchantDetailsEntity(toUpdate);
verify(serviceDao).merge(serviceEntity);
}
use of uk.gov.pay.adminusers.persistence.entity.MerchantDetailsEntity in project pay-adminusers by alphagov.
the class EmailServiceTest method shouldSendAnEmailForPaymentFailed.
@Test
public void shouldSendAnEmailForPaymentFailed() throws InvalidMerchantDetailsException {
EmailTemplate template = EmailTemplate.PAYMENT_FAILED;
Map<String, String> personalisation = Map.of("field 1", "theValueOfField1", "field 2", "theValueOfField2");
MerchantDetailsEntity merchantDetails = new MerchantDetailsEntity(MERCHANT_NAME, TELEPHONE_NUMBER, ADDRESS_LINE_1, null, CITY, POSTCODE, ADDRESS_COUNTRY_CODE, MERCHANT_EMAIL, null);
given(mockServiceEntity.getMerchantDetailsEntity()).willReturn(merchantDetails);
ArgumentCaptor<Map<String, String>> personalisationCaptor = forClass(Map.class);
emailService.sendEmail(EMAIL_ADDRESS, GATEWAY_ACCOUNT_ID, template, personalisation);
verify(mockNotificationService).sendEmail(eq("NOTIFY_PAYMENT_FAILED_EMAIL_TEMPLATE_ID_VALUE"), eq(EMAIL_ADDRESS), personalisationCaptor.capture());
Map<String, String> allContent = personalisationCaptor.getValue();
assertThat(allContent.get("field 1"), is("theValueOfField1"));
assertThat(allContent.get("field 2"), is("theValueOfField2"));
assertThat(allContent.get("organisation name"), is(MERCHANT_NAME));
assertThat(allContent.get("organisation phone number"), is(TELEPHONE_NUMBER));
}
use of uk.gov.pay.adminusers.persistence.entity.MerchantDetailsEntity in project pay-adminusers by alphagov.
the class EmailServiceTest method shouldNotDisplayCountryNameForInvalidCountryCode.
@Test
public void shouldNotDisplayCountryNameForInvalidCountryCode() throws InvalidMerchantDetailsException {
EmailTemplate template = EmailTemplate.ONE_OFF_PAYMENT_CONFIRMED;
Map<String, String> personalisation = Map.of("field 1", "theValueOfField1", "field 2", "theValueOfField2");
MerchantDetailsEntity merchantDetails = new MerchantDetailsEntity(MERCHANT_NAME, TELEPHONE_NUMBER, ADDRESS_LINE_1, null, CITY, POSTCODE, ADDRESS_COUNTRY_CODE, MERCHANT_EMAIL, null);
given(mockServiceEntity.getMerchantDetailsEntity()).willReturn(merchantDetails);
given(mockCountryConverter.getCountryNameFrom(ADDRESS_COUNTRY_CODE)).willReturn(Optional.empty());
ArgumentCaptor<Map<String, String>> personalisationCaptor = forClass(Map.class);
emailService.sendEmail(EMAIL_ADDRESS, GATEWAY_ACCOUNT_ID, template, personalisation);
verify(mockNotificationService).sendEmail(eq("NOTIFY_ONE_OFF_MANDATE_AND_PAYMENT_CREATED_EMAIL_TEMPLATE_ID_VALUE"), eq(EMAIL_ADDRESS), personalisationCaptor.capture());
Map<String, String> allContent = personalisationCaptor.getValue();
assertThat(allContent.get("field 1"), is("theValueOfField1"));
assertThat(allContent.get("field 2"), is("theValueOfField2"));
assertThat(allContent.get("service name"), is("a service"));
assertThat(allContent.get("organisation name"), is(MERCHANT_NAME));
assertThat(allContent.get("organisation address"), is("address line 1, city, postcode"));
assertThat(allContent.get("organisation phone number"), is(TELEPHONE_NUMBER));
assertThat(allContent.get("organisation email address"), is(MERCHANT_EMAIL));
}
use of uk.gov.pay.adminusers.persistence.entity.MerchantDetailsEntity in project pay-adminusers by alphagov.
the class EmailServiceTest method shouldSendAnEmailForOneOffPaymentConfirmed.
@Test
public void shouldSendAnEmailForOneOffPaymentConfirmed() throws InvalidMerchantDetailsException {
EmailTemplate template = EmailTemplate.ONE_OFF_PAYMENT_CONFIRMED;
Map<String, String> personalisation = Map.of("field 1", "theValueOfField1", "field 2", "theValueOfField2");
MerchantDetailsEntity merchantDetails = new MerchantDetailsEntity(MERCHANT_NAME, TELEPHONE_NUMBER, ADDRESS_LINE_1, null, CITY, POSTCODE, ADDRESS_COUNTRY_CODE, MERCHANT_EMAIL, null);
given(mockServiceEntity.getMerchantDetailsEntity()).willReturn(merchantDetails);
ArgumentCaptor<Map<String, String>> personalisationCaptor = forClass(Map.class);
emailService.sendEmail(EMAIL_ADDRESS, GATEWAY_ACCOUNT_ID, template, personalisation);
verify(mockNotificationService).sendEmail(eq("NOTIFY_ONE_OFF_MANDATE_AND_PAYMENT_CREATED_EMAIL_TEMPLATE_ID_VALUE"), eq(EMAIL_ADDRESS), personalisationCaptor.capture());
Map<String, String> allContent = personalisationCaptor.getValue();
assertThat(allContent.get("field 1"), is("theValueOfField1"));
assertThat(allContent.get("field 2"), is("theValueOfField2"));
assertThat(allContent.get("service name"), is("a service"));
assertThat(allContent.get("organisation name"), is(MERCHANT_NAME));
assertThat(allContent.get("organisation address"), is("address line 1, city, postcode, Cake Land"));
assertThat(allContent.get("organisation phone number"), is(TELEPHONE_NUMBER));
assertThat(allContent.get("organisation email address"), is(MERCHANT_EMAIL));
}
Aggregations