Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GA tests + port over classes removed from connector-common #6

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/contrib/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<username>mb-gatesprojects</username>
<password>ModusBox</password>
<id>modusbox-release-local</id>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots><enabled>false</enabled></snapshots>
</repository>
<repository>
<snapshots><enabled>false</enabled></snapshots>
<id>modusbox-release-local</id>
<name>libs-release</name>
<url>https://modusbox.jfrog.io/modusbox/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots><enabled>false</enabled></snapshots>
<releases><updatePolicy>never</updatePolicy></releases>
</pluginRepository>
<pluginRepository>
<snapshots><enabled>false</enabled></snapshots>
<id>modusbox-plugin-release</id>
<name>plugins-release</name>
<url>https://modusbox.jfrog.io/modusbox/plugins-release</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
</settings>

29 changes: 29 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test
on: [push, pull_request]
jobs:
Assemble:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v2

- name: Check out ph-ee-connector-common repository code
uses: actions/checkout@master
with:
repository: openMF/ph-ee-connector-common
ref: 'refs/heads/master'
path: 'ph-ee-connector-common'

- name: Install ph-ee-connector-common
working-directory: ph-ee-connector-common
run: ./gradlew clean install
# run: mvn clean install

- name: Copy settings.xml
run: cp -v .github/contrib/settings.xml $HOME/.m2/

- name: Package project
run: mvn -U clean test package

- name: Build Docker image
run: docker build . -t paymenthubee.mifos.io/phee/connector-mojaloop-java
32 changes: 30 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,21 @@
<artifactId>ph-ee-connector-mojaloop-java</artifactId>
<version>1.0.0-SNAPSHOT</version>

<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>modusbox-release-local</id>
<name>libs-release</name>
<url>https://modusbox.jfrog.io/modusbox/libs-release</url>
</repository>
</repositories>

<properties>
<camel.version>3.4.0</camel.version>
<ilp.version>1.3</ilp.version>
<zeebe.version>1.1.0</zeebe.version>
<compiler-plugin.version>3.8.1</compiler-plugin.version>

<maven.compiler.parameters>true</maven.compiler.parameters>
Expand Down Expand Up @@ -46,9 +59,24 @@
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>io.zeebe</groupId>
<groupId>io.camunda</groupId>
<artifactId>zeebe-client-java</artifactId>
<version>0.26.0</version>
<version>${zeebe.version}</version>
</dependency>
<dependency>
<groupId>com.interop.ilp.conditions</groupId>
<artifactId>interop-ilp-conditions</artifactId>
<version>${ilp.version}</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20190722</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.10.1</version>
</dependency>

<!-- test deps -->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* This Source Code Form is subject to the terms of the Mozilla
* Public License, v. 2.0. If a copy of the MPL was not distributed
* with this file, You can obtain one at
*
* https://mozilla.org/MPL/2.0/.
*/

package org.mifos.connector.mojaloop.ilp;

import org.interledger.Condition;
import org.interledger.InterledgerAddress;
import org.interledger.codecs.CodecContext;
import org.interledger.codecs.oer.*;
import org.interledger.codecs.oer.ilp.ConditionOerCodec;
import org.interledger.codecs.oer.ilp.InterledgerAddressOerCodec;
import org.interledger.codecs.oer.ilp.InterledgerPacketTypeOerCodec;
import org.interledger.codecs.oer.ilqp.*;
import org.interledger.codecs.oer.ipr.InterledgerPaymentRequestOerCodec;
import org.interledger.codecs.packettypes.InterledgerPacketType;
import org.interledger.codecs.psk.PskMessageBinaryCodec;
import org.interledger.ilqp.*;
import org.interledger.ipr.InterledgerPaymentRequest;
import org.interledger.psk.PskMessage;

public class CodecContextFactory {

public static CodecContext interledger() {
return (new CodecContext())
.register(OerUint8Codec.OerUint8.class, new OerUint8Codec())
.register(OerUint32Codec.OerUint32.class, new OerUint32Codec())
.register(OerUint64Codec.OerUint64.class, new OerUint64Codec())
.register(OerUint256Codec.OerUint256.class, new OerUint256Codec())
.register(OerLengthPrefixCodec.OerLengthPrefix.class, new OerLengthPrefixCodec())
.register(OerIA5StringCodec.OerIA5String.class, new OerIA5StringCodec())
.register(OerOctetStringCodec.OerOctetString.class, new OerOctetStringCodec())
.register(OerGeneralizedTimeCodec.OerGeneralizedTime.class, new OerGeneralizedTimeCodec())
.register(InterledgerAddress.class, new InterledgerAddressOerCodec())
.register(InterledgerPacketType.class, new InterledgerPacketTypeOerCodec())
.register(org.interledger.ilp.InterledgerPayment.class, new org.interledger.codecs.oer.ilp.InterledgerPaymentOerCodec())
.register(InterledgerPaymentRequest.class, new InterledgerPaymentRequestOerCodec())
.register(Condition.class, new ConditionOerCodec())
.register(QuoteByDestinationAmountRequest.class, new QuoteByDestinationAmountRequestOerCodec())
.register(QuoteByDestinationAmountResponse.class, new QuoteByDestinationAmountResponseOerCodec())
.register(QuoteBySourceAmountRequest.class, new QuoteBySourceAmountRequestOerCodec())
.register(QuoteBySourceAmountResponse.class, new QuoteBySourceAmountResponseOerCodec())
.register(QuoteLiquidityRequest.class, new QuoteLiquidityRequestOerCodec())
.register(QuoteLiquidityResponse.class, new QuoteLiquidityResponseOerCodec())
.register(PskMessage.class, new PskMessageBinaryCodec())
.register(InterledgerPayment.class, new InterledgerPaymentOerCodec());
}

public static CodecContext interledgerJson() {
throw new RuntimeException("Not yet implemented!");
}

public static CodecContext interledgerProtobuf() {
throw new RuntimeException("Not yet implemented!");
}
}
68 changes: 68 additions & 0 deletions src/main/java/org/mifos/connector/mojaloop/ilp/Ilp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package org.mifos.connector.mojaloop.ilp;

/*
* This Source Code Form is subject to the terms of the Mozilla
* Public License, v. 2.0. If a copy of the MPL was not distributed
* with this file, You can obtain one at
*
* https://mozilla.org/MPL/2.0/.
*/


import com.ilp.conditions.models.pdp.Transaction;

public class Ilp {

private final String packet; // mandatory
private final String condition; // mandatory
private final String fulfilment; // optional
private final Transaction transaction; // mandatory

public Ilp(String packet, String condition, String fulfilment, Transaction transaction) {
this.packet = packet;
this.condition = condition;
this.fulfilment = fulfilment;
this.transaction = transaction;
}

public Ilp(String packet, String condition, Transaction transaction) {
this(packet, condition, null, transaction);
}

public String getPacket() {
return packet;
}

public String getCondition() {
return condition;
}

public String getFulfilment() {
return fulfilment;
}

public Transaction getTransaction() {
return transaction;
}

void update(Ilp oIlp) {
if (oIlp == null)
return;
if (!packet.equals(oIlp.getPacket()))
throw new RuntimeException("Ilp packet is not valid " + packet + " vs." + oIlp.getPacket());
if (!condition.equals(oIlp.getCondition()))
throw new RuntimeException("Ilp condition is not valid " + packet + " vs." + oIlp.getPacket());
if (fulfilment != null && oIlp.getFulfilment() != null && !fulfilment.equals(oIlp.getFulfilment()))
throw new RuntimeException("Ilp fulfilment is not valid " + fulfilment + " vs." + oIlp.getFulfilment());

}

@Override
public String toString() {
return "Ilp{" +
"packet:'" + packet + '\'' +
", condition:'" + condition + '\'' +
", fulfilment:'" + fulfilment + '\'' +
'}';
}
}
42 changes: 36 additions & 6 deletions src/main/java/org/mifos/connector/mojaloop/ilp/IlpBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
*/
package org.mifos.connector.mojaloop.ilp;

import com.ilp.conditions.models.pdp.Money;
import com.ilp.conditions.models.pdp.PartyIdInfo;
import com.ilp.conditions.models.pdp.Transaction;
import com.ilp.conditions.models.pdp.*;
import org.mifos.connector.common.mojaloop.dto.ComplexName;
import org.mifos.connector.common.mojaloop.dto.Party;
import org.mifos.connector.common.mojaloop.ilp.Ilp;
import org.mifos.connector.common.mojaloop.dto.PersonalInfo;
import org.mifos.connector.common.util.ContextUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.beans.Transient;
import java.io.IOException;
import java.math.BigDecimal;

Expand Down Expand Up @@ -74,9 +74,39 @@ private Transaction mapToTransaction(String transactionId, String quoteId, Money
transaction.setTransactionId(transactionId);
transaction.setQuoteId(quoteId);
transaction.setAmount(transactionAmount);
transaction.setPayer(payer.getIlpParty());
transaction.setPayee(payee.getIlpParty());
transaction.setPayer(getIlpPartyFromParty(payer));
transaction.setPayee(getIlpPartyFromParty(payee));

return transaction;
}

@Transient
public com.ilp.conditions.models.pdp.Party getIlpPartyFromParty(Party party) {
com.ilp.conditions.models.pdp.Party ilpParty = new com.ilp.conditions.models.pdp.Party();
ilpParty.setMerchantClassificationCode(party.getMerchantClassificationCode());
ilpParty.setName(party.getName());

org.mifos.connector.common.mojaloop.dto.PartyIdInfo partyIdInfo = party.getPartyIdInfo();
com.ilp.conditions.models.pdp.PartyIdInfo ilpPartyIdInfo = new com.ilp.conditions.models.pdp.PartyIdInfo();
ilpPartyIdInfo.setFspId(partyIdInfo.getFspId());
ilpPartyIdInfo.setPartyIdentifier(partyIdInfo.getPartyIdentifier());
ilpPartyIdInfo.setPartyIdType(partyIdInfo.getPartyIdType().name());
ilpPartyIdInfo.setPartySubIdOrType(partyIdInfo.getPartySubIdOrType());
ilpParty.setPartyIdInfo(ilpPartyIdInfo);

PersonalInfo personalInfo = party.getPersonalInfo();
if (personalInfo != null) {
PartyPersonalInfo ilpPersonalInfo = new PartyPersonalInfo();
ilpPersonalInfo.setDateOfBirth(personalInfo.getDateOfBirth());
PartyComplexName payerComplexName = new PartyComplexName();
ComplexName complexName = personalInfo.getComplexName();
payerComplexName.setFirstName(complexName.getFirstName());
payerComplexName.setLastName(complexName.getLastName());
payerComplexName.setMiddleName(complexName.getMiddleName());
ilpPersonalInfo.setComplexName(payerComplexName);
ilpParty.setPersonalInfo(ilpPersonalInfo);
}

return ilpParty;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import org.interledger.Fulfillment;
import org.interledger.InterledgerAddress;
import org.interledger.codecs.CodecContext;
import org.mifos.connector.common.mojaloop.ilp.CodecContextFactory;
import org.mifos.connector.common.mojaloop.ilp.InterledgerPayment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Loading