use of io.restassured.http.ContentType in project bisq-api by mrosseel.
the class PaymentAccountIT method create_validSpecificBanks_returnsCreatedAccount.
@InSequence(2)
@Test
public void create_validSpecificBanks_returnsCreatedAccount() {
final int alicePort = getAlicePort();
final Faker faker = new Faker();
final SpecificBanksAccountPaymentAccount accountToCreate = new SpecificBanksAccountPaymentAccount();
ApiTestHelper.randomizeAccountPayload(accountToCreate);
accountToCreate.accountNr = faker.finance().iban();
accountToCreate.accountType = faker.options().option("savings", "avista");
accountToCreate.bankId = faker.finance().bic();
accountToCreate.bankName = faker.company().name();
accountToCreate.branchId = faker.company().buzzword();
accountToCreate.countryCode = faker.address().countryCode();
accountToCreate.holderName = faker.name().fullName();
accountToCreate.holderTaxId = faker.finance().creditCard();
accountToCreate.acceptedBanks = Arrays.asList(faker.finance().bic(), faker.finance().bic());
final String acceptedBanks = accountToCreate.acceptedBanks.stream().reduce((i, a) -> a.length() > 0 ? i + ", " + a : i).orElse("");
final String expectedPaymentDetails = String.format("Transfers with specific banks - Holder name: %s, Bank name: %s, Bank ID (BIC/SWIFT): %s, Branch no.: %s, Account no. (IBAN): %s, Country of bank: %s, Accepted banks: %s", accountToCreate.holderName, accountToCreate.bankName, accountToCreate.bankId, accountToCreate.branchId, accountToCreate.accountNr, CountryUtil.getNameByCode(accountToCreate.countryCode), acceptedBanks);
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("accountType", equalTo(accountToCreate.accountType)).and().body("bankId", equalTo(accountToCreate.bankId)).and().body("bankName", equalTo(accountToCreate.bankName)).and().body("branchId", equalTo(accountToCreate.branchId)).and().body("countryCode", equalTo(accountToCreate.countryCode)).and().body("holderName", equalTo(accountToCreate.holderName)).and().body("holderTaxId", equalTo(accountToCreate.holderTaxId)).and().body("acceptedBanks", equalTo(accountToCreate.acceptedBanks)).and().body("size()", equalTo(15));
}
use of io.restassured.http.ContentType in project rest-assured by rest-assured.
the class EncoderRegistry method getAt.
/**
* Retrieve a encoder for the given content-type. This
* is called by HTTPBuilder to retrieve the correct encoder for a given
* content-type. The encoder is then used to serialize the request data
* in the request body.
*
* @param contentType
* @return encoder that can interpret the given content type,
* or null.
*/
public Closure getAt(Object contentType) {
String ct = contentType.toString();
int idx = ct.indexOf(';');
if (idx > 0)
ct = ct.substring(0, idx);
Closure closure = registeredEncoders.get(ct);
if (closure == null) {
final ContentType foundCt = ContentType.fromContentType(ct);
if (foundCt != null) {
closure = registeredEncoders.get(foundCt.toString());
}
}
// We couldn't find an explicit encoder for the given content-type so try to find a match
if (closure == null) {
closure = tryToFindMatchingEncoder(ct);
}
// If no encoder could be found then use binary
if (closure == null) {
return getAt(ContentType.BINARY.toString());
}
return closure;
}
use of io.restassured.http.ContentType in project bisq-api by mrosseel.
the class PaymentAccountIT method create_validSpecificBanks_returnsCreatedAccount.
@InSequence(2)
@Test
public void create_validSpecificBanks_returnsCreatedAccount() {
final int alicePort = getAlicePort();
final Faker faker = new Faker();
final SpecificBanksAccountPaymentAccount accountToCreate = new SpecificBanksAccountPaymentAccount();
ApiTestHelper.randomizeAccountPayload(accountToCreate);
accountToCreate.accountNr = faker.finance().iban();
accountToCreate.accountType = faker.options().option("savings", "avista");
accountToCreate.bankId = faker.finance().bic();
accountToCreate.bankName = faker.company().name();
accountToCreate.branchId = faker.company().buzzword();
accountToCreate.countryCode = "AT";
accountToCreate.holderName = faker.name().fullName();
accountToCreate.holderTaxId = faker.finance().creditCard();
accountToCreate.acceptedBanks = Arrays.asList(faker.finance().bic(), faker.finance().bic());
final String acceptedBanks = accountToCreate.acceptedBanks.stream().reduce((i, a) -> a.length() > 0 ? i + ", " + a : i).orElse("");
final String expectedPaymentDetails = String.format("Transfers with specific banks - Holder name: %s, Bank name: %s, Bank ID (BIC/SWIFT): %s, Branch no.: %s, Account no. (IBAN): %s, Country of bank: %s, Accepted banks: %s", accountToCreate.holderName, accountToCreate.bankName, accountToCreate.bankId, accountToCreate.branchId, accountToCreate.accountNr, CountryUtil.getNameByCode(accountToCreate.countryCode), acceptedBanks);
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("accountType", equalTo(accountToCreate.accountType)).and().body("bankId", equalTo(accountToCreate.bankId)).and().body("bankName", equalTo(accountToCreate.bankName)).and().body("branchId", equalTo(accountToCreate.branchId)).and().body("countryCode", equalTo(accountToCreate.countryCode)).and().body("holderName", equalTo(accountToCreate.holderName)).and().body("holderTaxId", equalTo(accountToCreate.holderTaxId)).and().body("acceptedBanks", equalTo(accountToCreate.acceptedBanks)).and().body("size()", equalTo(15));
}
Aggregations