Skip to content

Commit

Permalink
Merge pull request #2569 from alphagov/PP-7229_remove_joda-time
Browse files Browse the repository at this point in the history
PP-7229 Remove Joda-Time
  • Loading branch information
alexbishop1 authored Sep 29, 2020
2 parents 43ee19f + 0111a67 commit 8a1ae43
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 27 deletions.
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,6 @@
<artifactId>jackson-datatype-jdk8</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-base</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package uk.gov.pay.connector.gateway.worldpay;

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import uk.gov.pay.connector.gateway.*;
import uk.gov.pay.connector.gateway.CaptureHandler;
import uk.gov.pay.connector.gateway.CaptureResponse;
import uk.gov.pay.connector.gateway.GatewayClient;
import uk.gov.pay.connector.gateway.GatewayException;
import uk.gov.pay.connector.gateway.GatewayOrder;
import uk.gov.pay.connector.gateway.model.request.CaptureGatewayRequest;

import java.net.URI;
import java.time.LocalDate;
import java.time.ZoneOffset;
import java.util.Map;

import static uk.gov.pay.connector.gateway.CaptureResponse.ChargeState.PENDING;
Expand Down Expand Up @@ -40,10 +44,11 @@ public CaptureResponse capture(CaptureGatewayRequest request) {

private GatewayOrder buildCaptureOrder(CaptureGatewayRequest request) {
return aWorldpayCaptureOrderRequestBuilder()
.withDate(DateTime.now(DateTimeZone.UTC))
.withDate(LocalDate.now(ZoneOffset.UTC))
.withMerchantCode(request.getGatewayAccount().getCredentials().get(CREDENTIALS_MERCHANT_ID))
.withAmount(request.getAmountAsString())
.withTransactionId(request.getTransactionId())
.build();
}

}
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
package uk.gov.pay.connector.gateway.worldpay;

import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.gov.pay.connector.gateway.OrderRequestBuilder;
import uk.gov.pay.connector.gateway.model.AuthCardDetails;
import uk.gov.pay.connector.gateway.model.OrderRequestType;
import uk.gov.pay.connector.gateway.templates.PayloadBuilder;
import uk.gov.pay.connector.gateway.templates.TemplateBuilder;
import uk.gov.pay.connector.northamericaregion.CanadaPostalcodeToProvinceOrTerritoryMapper;
import uk.gov.pay.connector.northamericaregion.NorthAmericaRegion;
import uk.gov.pay.connector.northamericaregion.NorthAmericanRegionMapper;
import uk.gov.pay.connector.northamericaregion.UsZipCodeToStateMapper;
import uk.gov.pay.connector.wallets.WalletType;
import uk.gov.pay.connector.wallets.model.WalletAuthorisationData;

import javax.ws.rs.core.MediaType;
import java.util.Locale;
import java.time.LocalDate;
import java.util.Optional;

public class WorldpayOrderRequestBuilder extends OrderRequestBuilder {
Expand All @@ -26,7 +23,7 @@ public class WorldpayOrderRequestBuilder extends OrderRequestBuilder {
static public class WorldpayTemplateData extends TemplateData {
private String reference;
private String amount;
private DateTime captureDate;
private LocalDate captureDate;
private String sessionId;
private String acceptHeader;
private String userAgentHeader;
Expand All @@ -53,11 +50,11 @@ public void setAmount(String amount) {
this.amount = amount;
}

public DateTime getCaptureDate() {
public LocalDate getCaptureDate() {
return captureDate;
}

public void setCaptureDate(DateTime captureDate) {
public void setCaptureDate(LocalDate captureDate) {
this.captureDate = captureDate;
}

Expand Down Expand Up @@ -174,7 +171,7 @@ public WorldpayOrderRequestBuilder withAmount(String amount) {
return this;
}

public WorldpayOrderRequestBuilder withDate(DateTime date) {
public WorldpayOrderRequestBuilder withDate(LocalDate date) {
worldpayTemplateData.setCaptureDate(date);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package uk.gov.pay.connector.gateway.worldpay;

import io.dropwizard.setup.Environment;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.gov.pay.connector.app.ConnectorConfiguration;
Expand Down Expand Up @@ -219,8 +217,7 @@ private GatewayOrder buildAuthoriseOrder(CardAuthorisationGatewayRequest request

var builder = aWorldpayAuthoriseOrderRequestBuilder()
.withSessionId(WorldpayAuthoriseOrderSessionId.of(request.getChargeExternalId()))
.with3dsRequired(is3dsRequired)
.withDate(DateTime.now(DateTimeZone.UTC));
.with3dsRequired(is3dsRequired);

if (request.getGatewayAccount().isSendPayerIpAddressToGateway()) {
request.getAuthCardDetails().getIpAddress().ifPresent(builder::withPayerIpAddress);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modify>
<orderModification orderCode="${transactionId?xml}">
<capture>
<date dayOfMonth="${captureDate.dayOfMonth().get()?string('00')}" month="${captureDate.monthOfYear().get()?string('00')}" year="${captureDate.year().get()?string('0000')}"/>
<date dayOfMonth="${captureDate.getDayOfMonth()?string('00')}" month="${captureDate.getMonthValue()?string('00')}" year="${captureDate.getYear()?string('0000')}"/>
<amount currencyCode="GBP" exponent="2" value="${amount}"/>
</capture>
</orderModification>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package uk.gov.pay.connector.gateway.worldpay;

import org.joda.time.DateTime;
import org.junit.Test;
import uk.gov.pay.connector.common.model.domain.Address;
import uk.gov.pay.connector.gateway.GatewayOrder;
Expand All @@ -11,6 +10,8 @@
import uk.gov.pay.connector.wallets.WalletType;
import uk.gov.pay.connector.wallets.applepay.AppleDecryptedPaymentData;

import java.time.LocalDate;

import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.junit.Assert.assertEquals;
import static uk.gov.pay.connector.gateway.worldpay.WorldpayOrderRequestBuilder.aWorldpay3dsResponseAuthOrderRequestBuilder;
Expand Down Expand Up @@ -254,8 +255,7 @@ public void shouldGenerateValidAuthoriseApplePayOrderRequest_withMinData() throw

@Test
public void shouldGenerateValidCaptureOrderRequest() throws Exception {

DateTime date = new DateTime(2013, 2, 23, 0, 0);
var date = LocalDate.of(2013, 2, 23);

GatewayOrder actualRequest = aWorldpayCaptureOrderRequestBuilder()
.withDate(date)
Expand All @@ -270,8 +270,7 @@ public void shouldGenerateValidCaptureOrderRequest() throws Exception {

@Test
public void shouldGenerateValidCaptureOrderRequestWithSpecialCharactersInStrings() throws Exception {

DateTime date = new DateTime(2013, 2, 23, 0, 0);
var date = LocalDate.of(2013, 2, 23);

GatewayOrder actualRequest = aWorldpayCaptureOrderRequestBuilder()
.withDate(date)
Expand Down

0 comments on commit 8a1ae43

Please sign in to comment.