Search in sources :

Example 1 with MerchantDetails

use of uk.gov.pay.adminusers.model.MerchantDetails in project pay-adminusers by alphagov.

the class ServiceResourceUpdateIT method shouldUpdateMerchantUrlField.

@Test
public void shouldUpdateMerchantUrlField() {
    String serviceExternalId = serviceDbFixture(databaseHelper).withMerchantDetails(new MerchantDetails("name", null, "line1", null, "city", "postcode", "country", null, "https://www.example.com")).insertService().getExternalId();
    JsonNode payload = mapper.valueToTree(List.of(patchRequest("replace", "merchant_details/url", "https://merchant.example.com")));
    givenSetup().when().contentType(JSON).body(payload).patch(format(SERVICE_RESOURCE, serviceExternalId)).then().statusCode(200).body("merchant_details.url", is("https://merchant.example.com"));
}
Also used : MerchantDetails(uk.gov.pay.adminusers.model.MerchantDetails) JsonNode(com.fasterxml.jackson.databind.JsonNode) Test(org.junit.jupiter.api.Test)

Example 2 with MerchantDetails

use of uk.gov.pay.adminusers.model.MerchantDetails in project pay-adminusers by alphagov.

the class DatabaseTestHelper method addService.

public DatabaseTestHelper addService(Service service, String... gatewayAccountIds) {
    jdbi.withHandle(handle -> {
        PGobject customBranding = service.getCustomBranding() == null ? null : new CustomBrandingConverter().convertToDatabaseColumn(service.getCustomBranding());
        MerchantDetails merchantDetails = service.getMerchantDetails();
        if (merchantDetails == null) {
            merchantDetails = new MerchantDetails();
        }
        return handle.createUpdate("INSERT INTO services(" + "id, custom_branding, " + "merchant_name, merchant_telephone_number, merchant_address_line1, merchant_address_line2, merchant_address_city, " + "merchant_address_postcode, merchant_address_country, merchant_email, merchant_url, external_id, experimental_features_enabled) " + "VALUES (:id, :customBranding, :merchantName, :merchantTelephoneNumber, :merchantAddressLine1, :merchantAddressLine2, " + ":merchantAddressCity, :merchantAddressPostcode, :merchantAddressCountry, :merchantEmail, :merchantUrl, :externalId, :experimentalFeaturesEnabled)").bind("id", service.getId()).bindBySqlType("customBranding", customBranding, OTHER).bind("merchantName", merchantDetails.getName()).bind("merchantTelephoneNumber", merchantDetails.getTelephoneNumber()).bind("merchantAddressLine1", merchantDetails.getAddressLine1()).bind("merchantAddressLine2", merchantDetails.getAddressLine2()).bind("merchantAddressCity", merchantDetails.getAddressCity()).bind("merchantAddressPostcode", merchantDetails.getAddressPostcode()).bind("merchantAddressCountry", merchantDetails.getAddressCountry()).bind("merchantEmail", merchantDetails.getEmail()).bind("merchantUrl", merchantDetails.getUrl()).bind("externalId", service.getExternalId()).bind("experimentalFeaturesEnabled", service.isExperimentalFeaturesEnabled()).execute();
    });
    addServiceName(ServiceNameEntity.from(SupportedLanguage.ENGLISH, service.getName()), service.getId());
    for (String gatewayAccountId : gatewayAccountIds) {
        jdbi.withHandle(handle -> handle.createUpdate("INSERT INTO service_gateway_accounts(service_id, gateway_account_id) VALUES (:serviceId, :gatewayAccountId)").bind("serviceId", service.getId()).bind("gatewayAccountId", gatewayAccountId).execute());
    }
    return this;
}
Also used : MerchantDetails(uk.gov.pay.adminusers.model.MerchantDetails) CustomBrandingConverter(uk.gov.pay.adminusers.persistence.entity.CustomBrandingConverter) PGobject(org.postgresql.util.PGobject)

Example 3 with MerchantDetails

use of uk.gov.pay.adminusers.model.MerchantDetails in project pay-adminusers by alphagov.

the class DatabaseTestHelper method insertServiceEntity.

public DatabaseTestHelper insertServiceEntity(ServiceEntity serviceEntity) {
    jdbi.withHandle(handle -> {
        PGobject customBranding = serviceEntity.getCustomBranding() == null ? null : new CustomBrandingConverter().convertToDatabaseColumn(serviceEntity.getCustomBranding());
        MerchantDetailsEntity merchantDetails = serviceEntity.getMerchantDetailsEntity();
        return handle.createUpdate("INSERT INTO services(" + "id, custom_branding, " + "merchant_name, merchant_telephone_number, merchant_address_line1, merchant_address_line2, merchant_address_city, " + "merchant_address_postcode, merchant_address_country, merchant_email, merchant_url, external_id, redirect_to_service_immediately_on_terminal_state, " + "current_go_live_stage, experimental_features_enabled, current_psp_test_account_stage, created_date) " + "VALUES (:id, :customBranding, :merchantName, :merchantTelephoneNumber, :merchantAddressLine1, :merchantAddressLine2, " + ":merchantAddressCity, :merchantAddressPostcode, :merchantAddressCountry, :merchantEmail, :merchantUrl, :externalId, :redirectToServiceImmediatelyOnTerminalState, " + ":currentGoLiveStage, :experimentalFeaturesEnabled, :pspTestAccountStage, :createdDate)").bind("id", serviceEntity.getId()).bindBySqlType("customBranding", customBranding, OTHER).bind("merchantName", merchantDetails.getName()).bind("merchantTelephoneNumber", merchantDetails.getTelephoneNumber()).bind("merchantAddressLine1", merchantDetails.getAddressLine1()).bind("merchantAddressLine2", merchantDetails.getAddressLine2()).bind("merchantAddressCity", merchantDetails.getAddressCity()).bind("merchantAddressPostcode", merchantDetails.getAddressPostcode()).bind("merchantAddressCountry", merchantDetails.getAddressCountryCode()).bind("merchantEmail", merchantDetails.getEmail()).bind("merchantUrl", merchantDetails.getUrl()).bind("externalId", serviceEntity.getExternalId()).bind("redirectToServiceImmediatelyOnTerminalState", serviceEntity.isRedirectToServiceImmediatelyOnTerminalState()).bind("currentGoLiveStage", serviceEntity.getCurrentGoLiveStage()).bind("experimentalFeaturesEnabled", serviceEntity.isExperimentalFeaturesEnabled()).bind("pspTestAccountStage", serviceEntity.getCurrentPspTestAccountStage()).bind("createdDate", serviceEntity.getCreatedDate()).execute();
    });
    serviceEntity.getGatewayAccountIds().forEach(gatewayAccount -> jdbi.withHandle(handle -> handle.createUpdate("INSERT INTO service_gateway_accounts(service_id, gateway_account_id) VALUES (:serviceId, :gatewayAccountId)").bind("serviceId", serviceEntity.getId()).bind("gatewayAccountId", gatewayAccount.getGatewayAccountId()).execute()));
    serviceEntity.getServiceNames().values().forEach((name) -> addServiceName(name, serviceEntity.getId()));
    return this;
}
Also used : Jdbi(org.jdbi.v3.core.Jdbi) MerchantDetailsEntity(uk.gov.pay.adminusers.persistence.entity.MerchantDetailsEntity) User(uk.gov.pay.adminusers.model.User) ServiceEntity(uk.gov.pay.adminusers.persistence.entity.ServiceEntity) Timestamp(java.sql.Timestamp) ZonedDateTime(java.time.ZonedDateTime) Permission(uk.gov.pay.adminusers.model.Permission) Role(uk.gov.pay.adminusers.model.Role) ZoneId(java.time.ZoneId) OTHER(java.sql.Types.OTHER) PGobject(org.postgresql.util.PGobject) List(java.util.List) ForgottenPassword(uk.gov.pay.adminusers.model.ForgottenPassword) ServiceNameEntity(uk.gov.pay.adminusers.persistence.entity.service.ServiceNameEntity) Map(java.util.Map) Service(uk.gov.pay.adminusers.model.Service) SupportedLanguage(uk.gov.service.payments.commons.model.SupportedLanguage) CustomBrandingConverter(uk.gov.pay.adminusers.persistence.entity.CustomBrandingConverter) Timestamp.from(java.sql.Timestamp.from) MerchantDetails(uk.gov.pay.adminusers.model.MerchantDetails) MerchantDetailsEntity(uk.gov.pay.adminusers.persistence.entity.MerchantDetailsEntity) CustomBrandingConverter(uk.gov.pay.adminusers.persistence.entity.CustomBrandingConverter) PGobject(org.postgresql.util.PGobject)

Aggregations

MerchantDetails (uk.gov.pay.adminusers.model.MerchantDetails)3 PGobject (org.postgresql.util.PGobject)2 CustomBrandingConverter (uk.gov.pay.adminusers.persistence.entity.CustomBrandingConverter)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Timestamp (java.sql.Timestamp)1 Timestamp.from (java.sql.Timestamp.from)1 OTHER (java.sql.Types.OTHER)1 ZoneId (java.time.ZoneId)1 ZonedDateTime (java.time.ZonedDateTime)1 List (java.util.List)1 Map (java.util.Map)1 Jdbi (org.jdbi.v3.core.Jdbi)1 Test (org.junit.jupiter.api.Test)1 ForgottenPassword (uk.gov.pay.adminusers.model.ForgottenPassword)1 Permission (uk.gov.pay.adminusers.model.Permission)1 Role (uk.gov.pay.adminusers.model.Role)1 Service (uk.gov.pay.adminusers.model.Service)1 User (uk.gov.pay.adminusers.model.User)1 MerchantDetailsEntity (uk.gov.pay.adminusers.persistence.entity.MerchantDetailsEntity)1 ServiceEntity (uk.gov.pay.adminusers.persistence.entity.ServiceEntity)1