Search in sources :

Example 61 with InSequence

use of org.jboss.arquillian.junit.InSequence in project bisq-api by mrosseel.

the class OfferResourceIT method takeOffer_validPaymentMethodAndHasFunds_returnsTrade.

@InSequence(10)
@Test
public void takeOffer_validPaymentMethodAndHasFunds_returnsTrade() throws Exception {
    final int alicePort = getAlicePort();
    final int bobPort = getBobPort();
    final TakeOffer payload = new TakeOffer();
    payload.amount = "1";
    payload.paymentAccountId = bobPaymentAccount.id;
    final String offerId = given().port(bobPort).when().get("/api/v1/offers").then().extract().body().jsonPath().getString("offers[0].id");
    final String arbitratorAddress = given().port(bobPort).when().get("/api/v1/offers").then().extract().body().jsonPath().getString("offers[0].arbitratorNodeAddresses[0]");
    final String aliceAddress = ApiTestHelper.getP2PNetworkStatus(alicePort).address;
    // TODO some of following properties change over time and we have no control over that timing so probably there's not much point in returning everything here
    given().port(bobPort).body(payload).contentType(ContentType.JSON).when().post("/api/v1/offers/" + offerId + "/take").then().statusCode(200).and().body("id", isA(String.class)).and().body("offer.id", equalTo(offerId)).and().body("offer.acceptedCountryCodes", equalTo(alicePaymentAccount.acceptedCountries)).and().body("offer.amount", equalTo(1)).and().body("offer.arbitratorNodeAddresses", equalTo(ApiTestHelper.getAcceptedArbitrators(alicePort))).and().body("offer.baseCurrencyCode", equalTo("BTC")).and().body("offer.bankId", equalTo(alicePaymentAccount.bic)).and().body("offer.blockHeightAtOfferCreation", isA(Integer.class)).and().body("offer.buyerSecurityDeposit", isA(Integer.class)).and().body("offer.counterCurrencyCode", equalTo(alicePaymentAccount.selectedTradeCurrency)).and().body("offer.countryCode", equalTo(alicePaymentAccount.countryCode)).and().body("offer.currencyCode", equalTo(alicePaymentAccount.selectedTradeCurrency)).and().body("offer.date", isA(Long.class)).and().body("offer.direction", equalTo(OfferPayload.Direction.BUY.name())).and().body("offer.id", isA(String.class)).and().body("offer.isCurrencyForMakerFeeBtc", equalTo(true)).and().body("offer.isPrivateOffer", equalTo(false)).and().body("offer.lowerClosePrice", equalTo(0)).and().body("offer.makerFee", equalTo(5000)).and().body("offer.makerPaymentAccountId", equalTo(alicePaymentAccount.id)).and().body("offer.marketPriceMargin", equalTo(10f)).and().body("offer.maxTradeLimit", equalTo(25000000)).and().body("offer.maxTradePeriod", equalTo(518400000)).and().body("offer.minAmount", equalTo(1)).and().body("offer.offerFeePaymentTxId", isA(String.class)).and().body("offer.ownerNodeAddress", equalTo(ApiTestHelper.getP2PNetworkStatus(alicePort).address)).and().body("offer.paymentMethodId", equalTo(alicePaymentAccount.paymentMethod)).and().body("offer.price", equalTo(10)).and().body("offer.protocolVersion", equalTo(1)).and().body("offer.sellerSecurityDeposit", equalTo(300000)).and().body("offer.state", equalTo(Offer.State.AVAILABLE.name())).and().body("offer.txFee", equalTo(6000)).and().body("offer.upperClosePrice", equalTo(0)).and().body("offer.useAutoClose", equalTo(false)).and().body("offer.useMarketBasedPrice", equalTo(false)).and().body("offer.useReOpenAfterAutoClose", equalTo(false)).and().body("offer.versionNr", isA(String.class)).and().body("isCurrencyForTakerFeeBtc", equalTo(true)).and().body("txFee", isA(Integer.class)).and().body("takerFee", isA(Integer.class)).and().body("takeOfferDate", isA(Long.class)).and().body("takerFeeTxId", isEmptyOrNullString()).and().body("payoutTxId", isEmptyOrNullString()).and().body("tradeAmount", equalTo(1)).and().body("tradePrice", equalTo(10)).and().body("state", isOneOf(ApiTestHelper.toString(Trade.State.values()))).and().body("disputeState", equalTo(Trade.DisputeState.NO_DISPUTE.name())).and().body("tradePeriodState", equalTo(Trade.TradePeriodState.FIRST_HALF.name())).and().body("arbitratorBtcPubKey", isA(String.class)).and().body("contractHash", isEmptyOrNullString()).and().body("mediatorNodeAddress", equalTo(arbitratorAddress)).and().body("takerContractSignature", isEmptyOrNullString()).and().body("makerContractSignature", isEmptyOrNullString()).and().body("arbitratorNodeAddress", equalTo(arbitratorAddress)).and().body("tradingPeerNodeAddress", equalTo(aliceAddress)).and().body("takerPaymentAccountId", equalTo(bobPaymentAccount.id)).and().body("counterCurrencyTxId", isEmptyOrNullString());
}
Also used : TakeOffer(io.bisq.api.model.TakeOffer) InSequence(org.jboss.arquillian.junit.InSequence) Test(org.junit.Test)

Example 62 with InSequence

use of org.jboss.arquillian.junit.InSequence 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 63 with InSequence

use of org.jboss.arquillian.junit.InSequence in project bisq-api by mrosseel.

the class OfferResourceIT method takeOffer_noOverlappingArbitrator_returnsXXX.

@Ignore("Bug in tradeManager.onTakeOffer which resolves instead of reject in this scenario")
@InSequence(7)
@Test
public void takeOffer_noOverlappingArbitrator_returnsXXX() throws Exception {
    final int bobPort = getBobPort();
    ApiTestHelper.registerArbitrator(getAlicePort());
    final OfferDetail offer = ApiTestHelper.getOfferById(bobPort, createdOffer.id);
    final List<String> arbitrators = ApiTestHelper.getAcceptedArbitrators(bobPort);
    arbitrators.removeAll(offer.arbitratorNodeAddresses);
    Assert.assertThat(arbitrators.size(), greaterThan(0));
    ApiTestHelper.deselectAllArbitrators(bobPort);
    ApiTestHelper.selectArbitrator(bobPort, arbitrators.get(0));
    final TakeOffer payload = new TakeOffer(bobPaymentAccount.id, "1");
    takeOffer_template(createdOffer.id, payload, 0);
    throw new UnsupportedOperationException("Not implemented yet");
}
Also used : TakeOffer(io.bisq.api.model.TakeOffer) OfferDetail(io.bisq.api.model.OfferDetail) Ignore(org.junit.Ignore) InSequence(org.jboss.arquillian.junit.InSequence) Test(org.junit.Test)

Example 64 with InSequence

use of org.jboss.arquillian.junit.InSequence in project bisq-api by mrosseel.

the class PaymentAccountIT method create_validFasterPayments_returnsCreatedAccount.

@InSequence(2)
@Test
public void create_validFasterPayments_returnsCreatedAccount() {
    final int alicePort = getAlicePort();
    final Faker faker = new Faker();
    final FasterPaymentsPaymentAccount accountToCreate = new FasterPaymentsPaymentAccount();
    ApiTestHelper.randomizeAccountPayload(accountToCreate);
    accountToCreate.accountNr = faker.finance().iban();
    accountToCreate.sortCode = faker.address().zipCode();
    final String expectedPaymentDetails = String.format("FasterPayments - UK Sort code: %s, Account number: %s", accountToCreate.sortCode, accountToCreate.accountNr);
    given().port(alicePort).contentType(ContentType.JSON).body(accountToCreate).when().post("/api/v1/payment-accounts").then().statusCode(200).and().body("id", isA(String.class)).and().body("paymentMethod", equalTo(accountToCreate.paymentMethod)).and().body("accountName", equalTo(accountToCreate.accountName)).and().body("paymentDetails", equalTo(expectedPaymentDetails)).and().body("selectedTradeCurrency", equalTo(accountToCreate.selectedTradeCurrency)).and().body("tradeCurrencies", equalTo(accountToCreate.tradeCurrencies)).and().body("accountNr", equalTo(accountToCreate.accountNr)).and().body("sortCode", equalTo(accountToCreate.sortCode)).and().body("size()", equalTo(8));
}
Also used : Faker(com.github.javafaker.Faker) InSequence(org.jboss.arquillian.junit.InSequence) Test(org.junit.Test)

Example 65 with InSequence

use of org.jboss.arquillian.junit.InSequence in project bisq-api by mrosseel.

the class PaymentAccountIT method create_validPopmoney_returnsCreatedAccount.

@InSequence(2)
@Test
public void create_validPopmoney_returnsCreatedAccount() {
    final int alicePort = getAlicePort();
    final Faker faker = new Faker();
    final PopmoneyPaymentAccount accountToCreate = new PopmoneyPaymentAccount();
    ApiTestHelper.randomizeAccountPayload(accountToCreate);
    accountToCreate.accountId = faker.idNumber().valid();
    accountToCreate.holderName = faker.name().fullName();
    final String expectedPaymentDetails = String.format("Popmoney - Holder name: %s, email or phone no.: %s", accountToCreate.holderName, accountToCreate.accountId);
    given().port(alicePort).contentType(ContentType.JSON).body(accountToCreate).when().post("/api/v1/payment-accounts").then().statusCode(200).and().body("id", isA(String.class)).and().body("paymentMethod", equalTo(accountToCreate.paymentMethod)).and().body("accountName", equalTo(accountToCreate.accountName)).and().body("paymentDetails", equalTo(expectedPaymentDetails)).and().body("selectedTradeCurrency", equalTo(accountToCreate.selectedTradeCurrency)).and().body("tradeCurrencies", equalTo(accountToCreate.tradeCurrencies)).and().body("accountId", equalTo(accountToCreate.accountId)).and().body("holderName", equalTo(accountToCreate.holderName)).and().body("size()", equalTo(8));
}
Also used : Faker(com.github.javafaker.Faker) InSequence(org.jboss.arquillian.junit.InSequence) Test(org.junit.Test)

Aggregations

InSequence (org.jboss.arquillian.junit.InSequence)157 Test (org.junit.Test)157 Faker (com.github.javafaker.Faker)21 Simple (org.apache.deltaspike.data.test.ee7.domain.Simple)18 ModelNode (org.jboss.dmr.ModelNode)14 URL (java.net.URL)13 HttpResponse (org.apache.http.HttpResponse)10 TakeOffer (io.bisq.api.model.TakeOffer)9 HttpGet (org.apache.http.client.methods.HttpGet)8 ModelControllerClient (org.jboss.as.controller.client.ModelControllerClient)8 OfferToCreate (io.bisq.api.model.OfferToCreate)7 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)7 PartitionManager (org.picketlink.idm.PartitionManager)7 Response (javax.ws.rs.core.Response)6 IdentityManager (org.picketlink.idm.IdentityManager)6 StringTokenizer (java.util.StringTokenizer)5 RouteBuilder (org.apache.camel.builder.RouteBuilder)5 House (org.apache.deltaspike.data.test.ee7.domain.House)5 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)5 ManagementClient (org.jboss.as.arquillian.container.ManagementClient)5