Skip to content

Commit

Permalink
Merge pull request #41 from paypal/release/4.9.0
Browse files Browse the repository at this point in the history
Release 4.9.0
  • Loading branch information
javierpoloe2y authored May 2, 2022
2 parents 1a5b69f + 5ea951a commit 2d66042
Show file tree
Hide file tree
Showing 121 changed files with 3,749 additions and 2,527 deletions.
6 changes: 1 addition & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,14 @@ subprojects {
apply plugin: 'java-library'
apply plugin: 'java'
apply plugin: 'io.spring.javaformat'
apply plugin: 'info.solidsoft.pitest'
apply plugin: 'jacoco'

java {
toolchain {
languageVersion = JavaLanguageVersion.of(15)
}
}

pitest {
junit5PluginVersion = '0.12'
}


ext {
set('springCloudVersion', "Hoxton.SR8")
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
springBoot = 2.6.6
dependencyManagement = 1.0.11.RELEASE
projectVersion = 4.8.0
projectVersion = 4.9.0
paypalHyperwalletDockerRepository = hyperwallet-mirakl-connector
org.gradle.jvmargs = -XX:PermSize=1024M -XX:MaxPermSize=1024M
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
package com.paypal.infrastructure;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;

@Slf4j
@SpringBootApplication
@ComponentScan
public class InfrastructureConnectorApplication {

public static void main(final String[] args) {
SpringApplication.run(InfrastructureConnectorApplication.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.paypal.infrastructure.batchjob;

import org.quartz.Job;

/**
* Marker interface for Batch Jobs
*/
public interface BatchJob extends Job {

}
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
package com.paypal.infrastructure.batchjob;

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

import java.io.Serializable;

/**
* Data class for item id and type.
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BatchJobFailedItemId implements Serializable {

private final String id;
private String id;

private final String type;
private String type;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.paypal.infrastructure.exceptions;

import com.hyperwallet.clientsdk.HyperwalletException;

/**
* Base exception for all Hyperwallet Connector exceptions.
*/
public class HMCHyperwalletAPIException extends HMCException {

protected static final String DEFAULT_MSG = "An error has occurred while invoking Hyperwallet API";

private final HyperwalletException hyperwalletException;

public HMCHyperwalletAPIException(final String message, final HyperwalletException e) {
super(message, e);
hyperwalletException = e;
}

public HMCHyperwalletAPIException(HyperwalletException e) {
super(DEFAULT_MSG, e);
hyperwalletException = e;
}

public HyperwalletException getHyperwalletException() {
return hyperwalletException;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.paypal.infrastructure.exceptions;

import com.mirakl.client.core.exception.MiraklException;

/**
* Base exception for all Mirakl Connector exceptions.
*/
public class HMCMiraklAPIException extends HMCException {

protected static final String DEFAULT_MSG = "An error has occurred while invoking Mirakl API";

private final MiraklException miraklException;

public HMCMiraklAPIException(final String message, final MiraklException e) {
super(message, e);
miraklException = e;
}

public HMCMiraklAPIException(MiraklException e) {
super(DEFAULT_MSG, e);
miraklException = e;
}

public MiraklException getMiraklException() {
return miraklException;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.paypal.infrastructure.service;

/**
* Service for ensure the tokens in hypewallet and mirakl ar in sync
*
* @param <T>
*/
public interface TokenSynchronizationService<T> {

/**
* Synchronize the tokens in hypewallet and mirakl for a specific item
* @param model that contains the item to synchronize
* @return the updated model item with the token in case there was a synchronization
*/
T synchronizeToken(T model);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.paypal.infrastructure.exceptions;

import com.hyperwallet.clientsdk.HyperwalletException;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import static com.paypal.infrastructure.exceptions.HMCHyperwalletAPIException.DEFAULT_MSG;
import static org.assertj.core.api.Assertions.assertThat;

@ExtendWith(MockitoExtension.class)
class HMCHyperwalletAPIExceptionTest {

private static final String HMC_HYPERWALLET_EXCEPTION_MESSAGE = "HMC Mirakl exception message";

private static final String HYPERWALLET_EXCEPTION_FIELD = "hyperwalletException";

private static final String DETAIL_MESSAGE_FIELD = "detailMessage";

@Mock
private HyperwalletException hyperwalletExceptionMock;

@Test
void hMCHyperwalletAPIException_ShouldPopulateMessageAndException() {

final HMCHyperwalletAPIException hmcHyperwalletAPIException = new HMCHyperwalletAPIException(
HMC_HYPERWALLET_EXCEPTION_MESSAGE, hyperwalletExceptionMock);

assertThat(hmcHyperwalletAPIException)
.hasFieldOrPropertyWithValue(HYPERWALLET_EXCEPTION_FIELD, hyperwalletExceptionMock)
.hasFieldOrPropertyWithValue(DETAIL_MESSAGE_FIELD, HMC_HYPERWALLET_EXCEPTION_MESSAGE);
}

@Test
void hMCHyperwalletAPIException_ShouldPopulateDefaultMessageAndException() {

final HMCHyperwalletAPIException hmcHyperwalletAPIException = new HMCHyperwalletAPIException(
hyperwalletExceptionMock);

assertThat(hmcHyperwalletAPIException)
.hasFieldOrPropertyWithValue(HYPERWALLET_EXCEPTION_FIELD, hyperwalletExceptionMock)
.hasFieldOrPropertyWithValue(DETAIL_MESSAGE_FIELD, DEFAULT_MSG);
}

@Test
void hMCHyperwalletAPIException_ShouldReturnException() {

final HMCHyperwalletAPIException hmcHyperwalletAPIException = new HMCHyperwalletAPIException(
hyperwalletExceptionMock);

assertThat(hmcHyperwalletAPIException.getHyperwalletException()).isEqualTo(hyperwalletExceptionMock);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.paypal.infrastructure.exceptions;

import com.mirakl.client.core.exception.MiraklException;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import static com.paypal.infrastructure.exceptions.HMCMiraklAPIException.DEFAULT_MSG;
import static org.assertj.core.api.Assertions.assertThat;

@ExtendWith(MockitoExtension.class)
class HMCMiraklAPIExceptionTest {

private static final String HMC_MIRAKL_EXCEPTION_MESSAGE = "HMC Mirakl exception message";

private static final String MIRAKL_EXCEPTION_FIELD = "miraklException";

private static final String DETAIL_MESSAGE_FIELD = "detailMessage";

@Mock
private MiraklException miraklExceptionMock;

@Test
void hMCMiraklAPIException_ShouldPopulateMessageAndException() {

final HMCMiraklAPIException hmcMiraklAPIException = new HMCMiraklAPIException(HMC_MIRAKL_EXCEPTION_MESSAGE,
miraklExceptionMock);

assertThat(hmcMiraklAPIException).hasFieldOrPropertyWithValue(MIRAKL_EXCEPTION_FIELD, miraklExceptionMock)
.hasFieldOrPropertyWithValue(DETAIL_MESSAGE_FIELD, HMC_MIRAKL_EXCEPTION_MESSAGE);
}

@Test
void hMCMiraklAPIException_ShouldPopulateDefaultMessageAndException() {

final HMCMiraklAPIException hmcMiraklAPIException = new HMCMiraklAPIException(miraklExceptionMock);

assertThat(hmcMiraklAPIException).hasFieldOrPropertyWithValue(MIRAKL_EXCEPTION_FIELD, miraklExceptionMock)
.hasFieldOrPropertyWithValue(DETAIL_MESSAGE_FIELD, DEFAULT_MSG);
}

@Test
void hMCMiraklAPIException_ShouldReturnException() {

final HMCMiraklAPIException hmcMiraklAPIException = new HMCMiraklAPIException(miraklExceptionMock);

assertThat(hmcMiraklAPIException.getMiraklException()).isEqualTo(miraklExceptionMock);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@
import com.paypal.infrastructure.InfrastructureConnectorApplication;
import com.paypal.invoices.infraestructure.configuration.InvoicesHyperwalletApiConfig;
import com.paypal.invoices.infraestructure.configuration.InvoicesMiraklApiConfig;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;

@SpringBootApplication
@ComponentScan
@EnableConfigurationProperties({ InvoicesMiraklApiConfig.class, InvoicesHyperwalletApiConfig.class })
@ImportAutoConfiguration({ InfrastructureConnectorApplication.class })
public class InvoicesSpringContextConfiguration {

public static void main(final String[] args) {
SpringApplication.run(InvoicesSpringContextConfiguration.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package com.paypal.invoices.batchjobs.creditnotes;

import com.paypal.infrastructure.batchjob.AbstractBatchJob;
import com.paypal.infrastructure.batchjob.BatchJobContext;
import com.paypal.infrastructure.batchjob.BatchJobItemProcessor;
import com.paypal.infrastructure.batchjob.BatchJobItemsExtractor;
import com.paypal.infrastructure.batchjob.*;
import org.springframework.stereotype.Service;

/**
* Extract invoices job for extracting Mirakl invoices data and populate it on
* HyperWallet.
*/
@Service
public class CreditNotesExtractBatchJob extends AbstractBatchJob<BatchJobContext, CreditNoteExtractJobItem> {
public class CreditNotesExtractBatchJob extends AbstractBatchJob<BatchJobContext, CreditNoteExtractJobItem>
implements BatchJob {

private final CreditNotesExtractBatchJobItemsExtractor creditNotesExtractBatchJobItemsExtractor;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
package com.paypal.invoices.batchjobs.invoices;

import com.paypal.infrastructure.batchjob.AbstractBatchJob;
import com.paypal.infrastructure.batchjob.BatchJobContext;
import com.paypal.infrastructure.batchjob.BatchJobItemProcessor;
import com.paypal.infrastructure.batchjob.BatchJobItemsExtractor;
import com.paypal.infrastructure.batchjob.*;
import org.springframework.stereotype.Service;

/**
* Extract invoices job for extracting Mirakl invoices data and populate it on
* HyperWallet.
*/
@Service
public class InvoicesExtractBatchJob extends AbstractBatchJob<BatchJobContext, InvoiceExtractJobItem> {
public class InvoicesExtractBatchJob extends AbstractBatchJob<BatchJobContext, InvoiceExtractJobItem>
implements BatchJob {

private final InvoicesExtractBatchJobItemsExtractor invoicesExtractBatchJobItemsExtractor;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.paypal.invoices.invoicesextract.service.hmc;

import com.hyperwallet.clientsdk.model.HyperwalletPayment;
import com.paypal.invoices.invoicesextract.model.InvoiceModel;

/**
Expand All @@ -11,8 +10,7 @@ public interface InvoiceProcessService {
/**
* Execute pay invoice operator in HW for the given invoice.
* @param invoice a {@link InvoiceModel}.
* @return a {@link HyperwalletPayment}.
*/
HyperwalletPayment payOperator(final InvoiceModel invoice);
void payOperator(final InvoiceModel invoice);

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,10 @@ protected InvoiceProcessServiceImpl(final HyperWalletPaymentExtractService hyper
/**
* {@inheritDoc}
*/
public HyperwalletPayment payOperator(final InvoiceModel invoice) {

HyperwalletPayment operatorPayment = null;
public void payOperator(final InvoiceModel invoice) {
if (invoicesOperatorCommissionsConfig.isEnabled()) {
operatorPayment = super.hyperWalletPaymentExtractService.payInvoiceOperator(invoice);
super.hyperWalletPaymentExtractService.payInvoiceOperator(invoice);
}
return operatorPayment;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ protected InvoiceProcessServiceMock(final HyperWalletPaymentExtractService hyper
/**
* {@inheritDoc}
*/
public HyperwalletPayment payOperator(InvoiceModel invoice) {
public void payOperator(InvoiceModel invoice) {

HyperwalletPayment operatorPayment = null;
if (testingInvoicesSessionDataHelper.isOperatorCommissionsEnabled()) {
operatorPayment = super.hyperWalletPaymentExtractService.payInvoiceOperator(invoice);
super.hyperWalletPaymentExtractService.payInvoiceOperator(invoice);
}
return operatorPayment;
}

}
Loading

0 comments on commit 2d66042

Please sign in to comment.