Search in sources :

Example 1 with OfferToCreate

use of io.bisq.api.model.OfferToCreate in project bisq-api by mrosseel.

the class OfferResourceIT method createOffer_notUseMarketBasePriceButNoFixedPrice_returns422status.

@InSequence(3)
@Test
public void createOffer_notUseMarketBasePriceButNoFixedPrice_returns422status() {
    final OfferToCreate offer = getOfferToCreateFixedBuy(tradeCurrency, alicePaymentAccount.id);
    offer.priceType = PriceType.FIXED;
    final JSONObject jsonOffer = toJsonObject(offer);
    jsonOffer.remove("fixedPrice");
    given().port(getAlicePort()).body(jsonOffer.toString()).contentType(ContentType.JSON).when().post("/api/v1/offers").then().statusCode(422);
}
Also used : JSONObject(org.json.simple.JSONObject) OfferToCreate(io.bisq.api.model.OfferToCreate) InSequence(org.jboss.arquillian.junit.InSequence) Test(org.junit.Test)

Example 2 with OfferToCreate

use of io.bisq.api.model.OfferToCreate in project bisq-api by mrosseel.

the class OfferResourceIT method createOffer_validPayloadButNoFunds_returns427status.

@InSequence(3)
@Test
public void createOffer_validPayloadButNoFunds_returns427status() {
    final OfferToCreate offer = getOfferToCreateFixedBuy(tradeCurrency, alicePaymentAccount.id);
    createOffer_template(offer, 427);
}
Also used : OfferToCreate(io.bisq.api.model.OfferToCreate) InSequence(org.jboss.arquillian.junit.InSequence) Test(org.junit.Test)

Example 3 with OfferToCreate

use of io.bisq.api.model.OfferToCreate in project bisq-api by mrosseel.

the class OfferResourceIT method createOffer_validPayloadAndHasFunds_returnsOffer.

@InSequence(5)
@Test
public void createOffer_validPayloadAndHasFunds_returnsOffer() throws Exception {
    final int alicePort = getAlicePort();
    final OfferToCreate offer = getOfferToCreateFixedBuy(tradeCurrency, alicePaymentAccount.id);
    createdOffer = given().port(alicePort).body(offer).contentType(ContentType.JSON).when().post("/api/v1/offers").then().statusCode(200).and().body("acceptedCountryCodes", equalTo(alicePaymentAccount.acceptedCountries)).and().body("amount", equalTo(1)).and().body("arbitratorNodeAddresses", equalTo(ApiTestHelper.getAcceptedArbitrators(alicePort))).and().body("baseCurrencyCode", equalTo("BTC")).and().body("bankId", equalTo(alicePaymentAccount.bic)).and().body("blockHeightAtOfferCreation", isA(Integer.class)).and().body("buyerSecurityDeposit", equalTo(offer.buyerSecurityDeposit.intValue())).and().body("counterCurrencyCode", equalTo(alicePaymentAccount.selectedTradeCurrency)).and().body("countryCode", equalTo(alicePaymentAccount.countryCode)).and().body("currencyCode", equalTo(alicePaymentAccount.selectedTradeCurrency)).and().body("date", isA(Long.class)).and().body("direction", equalTo(OfferPayload.Direction.BUY.name())).and().body("id", isA(String.class)).and().body("isCurrencyForMakerFeeBtc", equalTo(true)).and().body("isPrivateOffer", equalTo(false)).and().body("lowerClosePrice", equalTo(0)).and().body("makerFee", equalTo(5000)).and().body("makerPaymentAccountId", equalTo(alicePaymentAccount.id)).and().body("marketPriceMargin", equalTo(10f)).and().body("maxTradeLimit", equalTo(25000000)).and().body("maxTradePeriod", equalTo(518400000)).and().body("minAmount", equalTo(1)).and().body("offerFeePaymentTxId", isA(String.class)).and().body("ownerNodeAddress", equalTo(ApiTestHelper.getP2PNetworkStatus(alicePort).address)).and().body("paymentMethodId", equalTo(alicePaymentAccount.paymentMethod)).and().body("price", equalTo(10)).and().body("protocolVersion", equalTo(1)).and().body("sellerSecurityDeposit", equalTo(300000)).and().body("state", equalTo(Offer.State.OFFER_FEE_PAID.name())).and().body("txFee", equalTo(6000)).and().body("upperClosePrice", equalTo(0)).and().body("useAutoClose", equalTo(false)).and().body("useMarketBasedPrice", equalTo(false)).and().body("useReOpenAfterAutoClose", equalTo(false)).and().body("versionNr", isA(String.class)).extract().as(OfferDetail.class);
}
Also used : OfferToCreate(io.bisq.api.model.OfferToCreate) OfferDetail(io.bisq.api.model.OfferDetail) InSequence(org.jboss.arquillian.junit.InSequence) Test(org.junit.Test)

Example 4 with OfferToCreate

use of io.bisq.api.model.OfferToCreate in project bisq-api by mrosseel.

the class OfferResourceIT method getOfferToCreateFixedBuy.

@NotNull
private OfferToCreate getOfferToCreateFixedBuy(String tradeCurrency, String paymentAccountId) {
    final OfferToCreate offer = new OfferToCreate();
    offer.fundUsingBisqWallet = true;
    offer.amount = new BigDecimal(1);
    offer.minAmount = offer.amount;
    offer.direction = OfferPayload.Direction.BUY;
    offer.fixedPrice = 10L;
    offer.marketPair = "BTC_" + tradeCurrency;
    offer.priceType = PriceType.FIXED;
    offer.accountId = paymentAccountId;
    offer.percentageFromMarketPrice = 10.0;
    offer.buyerSecurityDeposit = 123456L;
    return offer;
}
Also used : OfferToCreate(io.bisq.api.model.OfferToCreate) BigDecimal(java.math.BigDecimal) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with OfferToCreate

use of io.bisq.api.model.OfferToCreate in project bisq-api by mrosseel.

the class OfferResourceIT method createOffer_useMarketBasePriceButNoMarginProvided_returns422status.

@InSequence(3)
@Test
public void createOffer_useMarketBasePriceButNoMarginProvided_returns422status() {
    final OfferToCreate offer = getOfferToCreateFixedBuy(tradeCurrency, alicePaymentAccount.id);
    offer.priceType = PriceType.PERCENTAGE;
    offer.percentageFromMarketPrice = null;
    createOffer_template(offer, 422);
}
Also used : OfferToCreate(io.bisq.api.model.OfferToCreate) InSequence(org.jboss.arquillian.junit.InSequence) Test(org.junit.Test)

Aggregations

OfferToCreate (io.bisq.api.model.OfferToCreate)8 InSequence (org.jboss.arquillian.junit.InSequence)7 Test (org.junit.Test)7 OfferDetail (io.bisq.api.model.OfferDetail)1 BigDecimal (java.math.BigDecimal)1 NotNull (org.jetbrains.annotations.NotNull)1 JSONObject (org.json.simple.JSONObject)1