Skip to content

Commit

Permalink
conflict resolved with master
Browse files Browse the repository at this point in the history
  • Loading branch information
“sayali-salunkhe” authored and “sayali-salunkhe” committed Nov 9, 2021
2 parents bd902a0 + dbe4092 commit d61cff3
Show file tree
Hide file tree
Showing 104 changed files with 2,654 additions and 582 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ gov-pay-client/out/
model/out/
reference-data/out/
/.apt_generated/
/api/pacts/
10 changes: 8 additions & 2 deletions Jenkinsfile_CNP
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ def product = "payment"

def app = "api"

// Configure branches to sync with master branch
def branchesToSync = ['demo', 'ithc', 'perftest']

def vaultOverrides = [
'preview': 'aat',
'hmctsdemo': 'aat',
Expand All @@ -26,7 +29,8 @@ def secrets = [
secret('citizen-oauth-client-secret', 'OAUTH2_CLIENT_SECRET'),
secret('freg-idam-generated-user-email-pattern', 'GENERATED_USER_EMAIL_PATTERN'),
secret('freg-idam-test-user-password', 'TEST_USER_PASSWORD'),
secret('gov-pay-keys-cmc', 'GOV_PAY_AUTH_KEY_CMC')
secret('gov-pay-keys-cmc', 'GOV_PAY_AUTH_KEY_CMC'),
secret('pci-pal-antenna-client-secret', 'PCI_PAL_ANTENNA_CLIENT_SECRET')
]
]

Expand All @@ -50,7 +54,6 @@ withPipeline(type, product, app) {
//installCharts()
enableSlackNotifications('#cc-payments-tech')
disableLegacyDeployment()

onMaster() {
enablePactAs([
AppPipelineDsl.PactRoles.CONSUMER,
Expand All @@ -63,4 +66,7 @@ withPipeline(type, product, app) {
AppPipelineDsl.PactRoles.PROVIDER
])
}

//Sync demo,ithc and perftest with master branch
syncBranchesWithMaster(branchesToSync)
}
5 changes: 5 additions & 0 deletions Jenkinsfile_nightly
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ withNightlyPipeline("java", product, component) {
loadVaultSecrets(secrets)
enableSecurityScan()
enableMutationTest()
enableFortifyScan('ccpay-aat')
enableFullFunctionalTest()
enableSlackNotifications('#cc-payments-tech')

after('fortify-scan') {
steps.archiveArtifacts allowEmptyArchive: true, artifacts: '**/Fortify Scan/**/*'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package uk.gov.hmcts.payment.api.contract;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.UUID;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CasePaymentOrderDto {
private UUID id;
private LocalDateTime createdTimestamp;
private Long caseId;
private String action;
private String responsibleParty;
private String orderReference;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package uk.gov.hmcts.payment.api.contract;

import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class CasePaymentOrdersDto {
private List<CasePaymentOrderDto> content;
private Integer number;
private Integer size;
private Long totalElements;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import lombok.NoArgsConstructor;
import lombok.With;
import uk.gov.hmcts.payment.api.contract.util.CurrencyCode;

import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Digits;
import javax.validation.constraints.NotBlank;
Expand All @@ -20,6 +19,7 @@
import javax.validation.constraints.Positive;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.util.List;

import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void testValidateSiteIdForIac(){
@Test
public void testValidateSiteIdForFpl() {
CreditAccountPaymentRequest request = new CreditAccountPaymentRequest();
request.setService("IAC");
request.setService("FPL");
request.setSiteId("invalid-site-id");
Set<ConstraintViolation<CreditAccountPaymentRequest>> violations = validator.validate(request);
violations.stream().forEach(v->{
Expand Down
2 changes: 2 additions & 0 deletions api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ dependencies {
compile project(':payment-api-contract')
compile project(':payment-model')
compile project(':payment-reference-data')
compile project(':case-payment-orders-client')
compile group: 'uk.gov.hmcts.reform', name: 'logging', version: javaLoggingVersion
compile group: 'uk.gov.hmcts.reform', name: 'logging-appinsights', version: javaLoggingVersion
compile group: 'uk.gov.hmcts.reform', name: 'logging-spring', version: javaLoggingVersion
Expand Down Expand Up @@ -196,6 +197,7 @@ task providerContractTest(type: Test) {
testClassesDirs = sourceSets.contractTest.output.classesDirs
classpath = sourceSets.contractTest.runtimeClasspath
systemProperty 'pact.rootDir', "pacts"
systemProperty 'pact.verifier.publishResults', System.getProperty('pact.verifier.publishResults')
systemProperty 'pact.provider.version', project.pactVersion

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ void pactVerificationTestTemplate(PactVerificationContext context) {

@BeforeEach
void before(PactVerificationContext context) {
System.getProperties().setProperty("pact.verifier.publishResults", "true");
MockMvcTestTarget testTarget = new MockMvcTestTarget();
testTarget.setControllers(
new AccountController(accountServiceMock));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ void pactVerificationTestTemplate(PactVerificationContext context) {

@BeforeEach
void before(PactVerificationContext context) {
System.getProperties().setProperty("pact.verifier.publishResults", "true");
MockMvcTestTarget testTarget = new MockMvcTestTarget();
testTarget.setControllers(
new CardPaymentController(cardDelegatingPaymentService, paymentDtoMapper, cardDetailsService, pciPalPaymentService, ff4j,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Import;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import uk.gov.hmcts.payment.api.configuration.LaunchDarklyFeatureToggler;
import uk.gov.hmcts.payment.api.controllers.CreditAccountPaymentController;
import uk.gov.hmcts.payment.api.dto.AccountDto;
import uk.gov.hmcts.payment.api.dto.OrganisationalServiceDto;
import uk.gov.hmcts.payment.api.dto.mapper.CreditAccountDtoMapper;
import uk.gov.hmcts.payment.api.dto.mapper.PaymentDtoMapper;
import uk.gov.hmcts.payment.api.mapper.CreditAccountPaymentRequestMapper;
Expand Down Expand Up @@ -45,8 +48,11 @@

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Collections;
import java.util.Map;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.when;

Expand Down Expand Up @@ -128,7 +134,8 @@ void pactVerificationTestTemplate(PactVerificationContext context) {

@BeforeEach
void before(PactVerificationContext context) {
System.getProperties().setProperty("pact.verifier.publishResults", "true");
// Uncomment the line below in order to pubish verification to pact broker (not for PR pipeline!!!)
// System.getProperties().setProperty("pact.verifier.publishResults", "true");
MockMvcTestTarget testTarget = new MockMvcTestTarget();
testTarget.setControllers(
new CreditAccountPaymentController(creditAccountPaymentService, creditAccountDtoMapper, accountServiceMock, paymentValidator,
Expand Down Expand Up @@ -183,6 +190,14 @@ private void setUpMockInteractions(Map<String, Object> paymentMap, String s, Str
.availableBalance(new BigDecimal(availableBalance))
.status(accountStatus)
.build());

OrganisationalServiceDto organisationalServiceDto = OrganisationalServiceDto.orgServiceDtoWith()
.serviceCode("AAD7")
.serviceDescription("Divorce")
.ccdCaseTypes(Collections.singletonList("DIVORCE"))
.build();

when(referenceDataService.getOrganisationalDetail(anyString(), any())).thenReturn(organisationalServiceDto);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@

@RunWith(SpringRunner.class)
@ContextConfiguration(classes = TestContextConfiguration.class)
public class PaymentBarPerformanceLiberataTest {
public class BarPaymentFunctionalTest {

private static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
private static final Logger LOG = LoggerFactory.getLogger(PaymentBarPerformanceLiberataTest.class);
private static final Logger LOG = LoggerFactory.getLogger(BarPaymentFunctionalTest.class);
private static String USER_TOKEN;
private static String SERVICE_TOKEN;
private static boolean TOKENS_INITIALIZED = false;
Expand Down Expand Up @@ -81,33 +81,14 @@ public void createPaymentRecordAndValidateSearchResults() throws Exception {

String endDate = formatter.format(LocalDateTime.now(zoneUTC).toDate());

PaymentsResponse liberataResponseOld = dsl.given().userToken(USER_TOKEN)
.s2sToken(SERVICE_TOKEN)
.when().searchPaymentsBetweenDatesPaymentMethodServiceName(startDate, endDate, "cash")
.then().getPayments();

PaymentsResponse liberataResponseApproach1 = dsl.given().userToken(USER_TOKEN)
.s2sToken(SERVICE_TOKEN)
.when().searchPaymentsBetweenDatesPaymentMethodServiceNameApproach1(startDate, endDate, "cash")
.then().getPayments();

//Comparing the response size of old and new approach
Java6Assertions.assertThat(liberataResponseOld.getPayments().size()).
isEqualTo(liberataResponseApproach1.getPayments().size());

//Comparing the response of old and new approach
Boolean compareResult = new HashSet<>(liberataResponseOld.getPayments()).equals(new HashSet<>(liberataResponseApproach1.getPayments()));
Java6Assertions.assertThat(compareResult).isEqualTo(true);
LOG.info("Comparison of old and new api end point response BAR Cash payment is same");

dsl.given().userToken(USER_TOKEN)
.s2sToken(SERVICE_TOKEN)
.when().searchPaymentsBetweenDatesPaymentMethodServiceName(startDate, endDate, "cash")
.when().searchPaymentsBetweenDatesPaymentMethodServiceNameApproach1(startDate, endDate, "cash")
.then().getPayments((paymentsResponse -> {
LOG.info("paymentsResponse: {}", paymentsResponse.getPayments().size());
assertThat(paymentsResponse.getPayments().size()).isGreaterThanOrEqualTo(1);
assertThat(paymentsResponse.getPayments().get(0).getMethod()).isEqualTo("cash");
assertThat(paymentsResponse.getPayments().get(0).getAmount()).isEqualTo(new BigDecimal("550.00"));
assertThat(paymentsResponse.getPayments().get(0).getAmount()).isIn(new BigDecimal("1.01"), new BigDecimal("0.10"), new BigDecimal("0.01"), new BigDecimal("100.00"), new BigDecimal("550.00"));
assertThat(paymentsResponse.getPayments().get(0).getChannel()).isEqualTo("digital bar");
assertThat(paymentsResponse.getPayments().get(0).getStatus()).isEqualTo("success");
assertThat(paymentsResponse.getPayments().get(0).getServiceName()).isEqualTo("Digital Bar");
Expand All @@ -120,10 +101,10 @@ public void createPaymentRecordAndValidateSearchResults() throws Exception {
assertThat(paymentsResponse.getPayments().get(0).getSiteId()).isNotNull();
assertThat(paymentsResponse.getPayments().get(0).getPaymentGroupReference()).isNotNull();
assertThat(paymentsResponse.getPayments().get(0).getReportedDateOffline()).isNotNull();
assertThat(paymentsResponse.getPayments().get(0).getGiroSlipNo()).isEqualTo("312131");
assertThat(paymentsResponse.getPayments().get(0).getGiroSlipNo()).isEqualTo("12345");
FeeDto feeDto = paymentsResponse.getPayments().get(0).getFees().get(0);
assertThat(feeDto.getCode()).isEqualTo("FEE0002");
assertThat(feeDto.getVersion()).isEqualTo("4");
assertThat(feeDto.getCode()).isEqualTo("FEE0333");
assertThat(feeDto.getVersion()).isEqualTo("1");
assertThat(feeDto.getCalculatedAmount()).isEqualTo(new BigDecimal("550.00"));
assertThat(feeDto.getReference()).isNotNull();
assertThat(feeDto.getReference()).isEqualTo("REF_123");
Expand All @@ -140,15 +121,15 @@ private PaymentRecordRequest getPaymentRecordRequest() {
.externalProvider("middle office provider")
.service("DIGITAL_BAR")
.currency(CurrencyCode.GBP)
.giroSlipNo("312131")
.giroSlipNo("12345")
.reportedDateOffline(DateTime.now(zoneUTC).toString())
.siteId("AA01")
.fees(
Arrays.asList(
FeeDto.feeDtoWith()
.calculatedAmount(new BigDecimal("550.00"))
.code("FEE0002")
.version("4")
.code("FEE0333")
.version("1")
.volume(1)
.reference("REF_123")
.build()
Expand All @@ -166,10 +147,10 @@ public void createBarPostalOrderPaymentRecordAndValidateSearchResults() throws E
.s2sToken(SERVICE_TOKEN)
.when().createTelephonyPayment(getPaymentRecordRequestForPostalOrder())
.then().created(paymentDto -> {
LOG.info(paymentDto.getReference());
assertNotNull(paymentDto.getReference());
});


try {
Thread.sleep(5000);
} catch (InterruptedException e) {
Expand All @@ -191,7 +172,7 @@ public void createBarPostalOrderPaymentRecordAndValidateSearchResults() throws E
//Comparing the response size of old and new approach
Java6Assertions.assertThat(liberataResponseOld.getPayments().size()).
isEqualTo(liberataResponseApproach1.getPayments().size());

LOG.info(""+liberataResponseApproach1.getPayments().size());
//Comparing the response of old and new approach
Boolean compareResult = new HashSet<>(liberataResponseOld.getPayments()).equals(new HashSet<>(liberataResponseApproach1.getPayments()));
Java6Assertions.assertThat(compareResult).isEqualTo(true);
Expand Down Expand Up @@ -280,25 +261,6 @@ public void createBarChequePaymentRecordAndValidateSearchResults() throws Except

String endDate = formatter.format(LocalDateTime.now(zoneUTC).toDate());

PaymentsResponse liberataResponseOld = dsl.given().userToken(USER_TOKEN)
.s2sToken(SERVICE_TOKEN)
.when().searchPaymentsBetweenDatesPaymentMethodServiceName(startDate, endDate, "cheque")
.then().getPayments();

PaymentsResponse liberataResponseApproach1 = dsl.given().userToken(USER_TOKEN)
.s2sToken(SERVICE_TOKEN)
.when().searchPaymentsBetweenDatesPaymentMethodServiceNameApproach1(startDate, endDate, "cheque")
.then().getPayments();

//Comparing the response size of old and new approach
Java6Assertions.assertThat(liberataResponseOld.getPayments().size()).
isEqualTo(liberataResponseApproach1.getPayments().size());

//Comparing the response of old and new approach
Boolean compareResult = new HashSet<>(liberataResponseOld.getPayments()).equals(new HashSet<>(liberataResponseApproach1.getPayments()));
Java6Assertions.assertThat(compareResult).isEqualTo(true);
LOG.info("Comparison of old and new api end point response BAR Cheque payment is same");

// search payment and assert the result
dsl.given().userToken(USER_TOKEN)
.s2sToken(SERVICE_TOKEN)
Expand All @@ -307,8 +269,8 @@ public void createBarChequePaymentRecordAndValidateSearchResults() throws Except
LOG.info("paymentsResponse: {}", paymentsResponse.getPayments().size());
assertThat(paymentsResponse.getPayments().size()).isGreaterThanOrEqualTo(1);
assertThat(paymentsResponse.getPayments().get(0).getMethod()).isEqualTo("cheque");
assertThat(paymentsResponse.getPayments().get(0).getAmount()).isEqualTo(new BigDecimal("550.00"));
assertThat(paymentsResponse.getPayments().get(0).getChannel()).isEqualTo("digital bar");
assertThat(paymentsResponse.getPayments().get(0).getAmount()).isIn(new BigDecimal("0.10"), new BigDecimal("0.01"), new BigDecimal("100.00"), new BigDecimal("550.00"));
assertThat(paymentsResponse.getPayments().get(0).getChannel()).isIn("digital bar", "bulk scan");
assertThat(paymentsResponse.getPayments().get(0).getStatus()).isEqualTo("pending");
assertThat(paymentsResponse.getPayments().get(0).getServiceName()).isEqualTo("Digital Bar");
assertThat(paymentsResponse.getPayments().get(0).getDateCreated()).isNotNull();
Expand Down Expand Up @@ -380,24 +342,6 @@ public void createBarCardPaymentRecordAndValidateSearchResults() throws Exceptio
e.printStackTrace();
}
String endDate = formatter.format(LocalDateTime.now(zoneUTC).toDate());
PaymentsResponse liberataResponseOld = dsl.given().userToken(USER_TOKEN)
.s2sToken(SERVICE_TOKEN)
.when().searchPaymentsBetweenDatesPaymentMethodServiceName(startDate, endDate, "card")
.then().getPayments();

PaymentsResponse liberataResponseApproach1 = dsl.given().userToken(USER_TOKEN)
.s2sToken(SERVICE_TOKEN)
.when().searchPaymentsBetweenDatesPaymentMethodServiceNameApproach1(startDate, endDate, "card")
.then().getPayments();

//Comparing the response size of old and new approach
Java6Assertions.assertThat(liberataResponseOld.getPayments().size()).
isEqualTo(liberataResponseApproach1.getPayments().size());

//Comparing the response of old and new approach
Boolean compareResult = new HashSet<>(liberataResponseOld.getPayments()).equals(new HashSet<>(liberataResponseApproach1.getPayments()));
Java6Assertions.assertThat(compareResult).isEqualTo(true);
LOG.info("Comparison of old and new api end point response BAR Card payment is same");

// search payment and assert the result
dsl.given().userToken(USER_TOKEN)
Expand Down
Loading

0 comments on commit d61cff3

Please sign in to comment.