-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
204 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.mangopay.entities; | ||
|
||
import com.google.gson.annotations.SerializedName; | ||
import com.mangopay.core.EntityBase; | ||
import com.mangopay.core.Money; | ||
|
||
public class ConversionQuote extends EntityBase { | ||
|
||
@SerializedName("ExpirationDate") | ||
private int expirationDate; | ||
@SerializedName("Status") | ||
private String status; | ||
@SerializedName("Duration") | ||
private int duration; | ||
@SerializedName("DebitedFunds") | ||
private Money debitedFunds; | ||
@SerializedName("CreditedFunds") | ||
private Money creditedFunds; | ||
@SerializedName("ConversionRateResponse") | ||
private ConversionRate conversionRateResponse; | ||
|
||
public int getExpirationDate() { | ||
return expirationDate; | ||
} | ||
|
||
public void setExpirationDate(int expirationDate) { | ||
this.expirationDate = expirationDate; | ||
} | ||
|
||
public String getStatus() { | ||
return status; | ||
} | ||
|
||
public void setStatus(String status) { | ||
this.status = status; | ||
} | ||
|
||
public int getDuration() { | ||
return duration; | ||
} | ||
|
||
public void setDuration(int duration) { | ||
this.duration = duration; | ||
} | ||
|
||
public Money getDebitedFunds() { | ||
return debitedFunds; | ||
} | ||
|
||
public void setDebitedFunds(Money debitedFunds) { | ||
this.debitedFunds = debitedFunds; | ||
} | ||
|
||
public Money getCreditedFunds() { | ||
return creditedFunds; | ||
} | ||
|
||
public void setCreditedFunds(Money creditedFunds) { | ||
this.creditedFunds = creditedFunds; | ||
} | ||
|
||
public ConversionRate getConversionRateResponse() { | ||
return conversionRateResponse; | ||
} | ||
|
||
public void setConversionRateResponse(ConversionRate conversionRateResponse) { | ||
this.conversionRateResponse = conversionRateResponse; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package com.mangopay.core; | ||
|
||
import com.mangopay.core.enumerations.CurrencyIso; | ||
import com.mangopay.core.enumerations.TransactionStatus; | ||
import com.mangopay.core.enumerations.TransactionType; | ||
import com.mangopay.entities.ConversionQuote; | ||
import com.mangopay.entities.ConversionRate; | ||
import com.mangopay.entities.InstantConversion; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
|
||
public class ConversionsImplTest extends BaseTest { | ||
|
||
@Test | ||
public void getConversionRateTest() throws Exception { | ||
ConversionRate conversionRate = getConversionRate(); | ||
|
||
assertNotNull(conversionRate); | ||
assertNotNull(conversionRate.clientRate); | ||
assertNotNull(conversionRate.marketRate); | ||
} | ||
|
||
@Test | ||
public void createInstantConversionTest() throws Exception { | ||
InstantConversion instantConversion = createInstantConversion(); | ||
|
||
assertNotNull(instantConversion); | ||
assertNotNull(instantConversion.creditedFunds.getAmount()); | ||
assertNotNull(instantConversion.debitedFunds.getAmount()); | ||
assertEquals(instantConversion.status, TransactionStatus.SUCCEEDED); | ||
assertEquals(instantConversion.type, TransactionType.CONVERSION); | ||
} | ||
|
||
@Test | ||
public void getInstantConversionTest() throws Exception { | ||
InstantConversion instantConversion = getInstantConversion(); | ||
|
||
assertNotNull(instantConversion); | ||
assertNotNull(instantConversion.creditedFunds.getAmount()); | ||
assertNotNull(instantConversion.debitedFunds.getAmount()); | ||
assertEquals(instantConversion.status, TransactionStatus.SUCCEEDED); | ||
assertEquals(instantConversion.type, TransactionType.CONVERSION); | ||
|
||
} | ||
|
||
@Test | ||
public void createConversionQuoteTest() throws Exception { | ||
ConversionQuote conversionQuote = createConversionQuote(); | ||
|
||
assertNotNull(conversionQuote); | ||
assertNotNull(conversionQuote.getDebitedFunds()); | ||
assertNotNull(conversionQuote.getCreditedFunds()); | ||
assertNotNull(conversionQuote.getConversionRateResponse()); | ||
assertEquals("ACTIVE", conversionQuote.getStatus()); | ||
|
||
} | ||
|
||
@Test | ||
public void getConversionQuoteTest() throws Exception { | ||
ConversionQuote createdConversionQuote = createConversionQuote(); | ||
ConversionQuote conversionQuote = this.api.getConversionsApi().getConversionQuote(createdConversionQuote.getId()); | ||
|
||
assertNotNull(conversionQuote); | ||
assertNotNull(conversionQuote.getDebitedFunds()); | ||
assertNotNull(conversionQuote.getCreditedFunds()); | ||
assertNotNull(conversionQuote.getConversionRateResponse()); | ||
assertEquals("ACTIVE", conversionQuote.getStatus()); | ||
} | ||
|
||
private ConversionQuote createConversionQuote() throws Exception { | ||
ConversionQuote conversionQuote = new ConversionQuote(); | ||
|
||
Money creditedFunds = new Money(); | ||
creditedFunds.setCurrency(CurrencyIso.USD); | ||
conversionQuote.setCreditedFunds(creditedFunds); | ||
|
||
Money debitedFunds = new Money(); | ||
debitedFunds.setCurrency(CurrencyIso.GBP); | ||
debitedFunds.setAmount(100); | ||
conversionQuote.setDebitedFunds(debitedFunds); | ||
|
||
conversionQuote.setDuration(90); | ||
conversionQuote.setTag("Created using the Mangopay PHP SDK"); | ||
|
||
return this.api.getConversionsApi().createConversionQuote(conversionQuote, null); | ||
} | ||
} |
44 changes: 0 additions & 44 deletions
44
src/test/java/com/mangopay/core/InstantConversionImplTest.java
This file was deleted.
Oops, something went wrong.