Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…rosetta-java into refactor/RA-107-replace-rest-template

# Conflicts:
#	api/src/test/java/org/cardanofoundation/rosetta/api/data/account/AccountBalanceApiTest.java
#	api/src/test/java/org/cardanofoundation/rosetta/api/data/account/AccountCoinsApiTest.java
  • Loading branch information
shleger committed May 9, 2024
2 parents 48e2798 + 5ea5d8a commit d30d153
Show file tree
Hide file tree
Showing 23 changed files with 137 additions and 147 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ void fromEntity_Test() {
assertThat(to(into).getHash()).isEqualTo(got(from).getTxHash());
assertThat(to(into).getBlockHash()).isEqualTo(got(from).getBlock().getHash());
assertThat(to(into).getBlockNo()).isEqualTo(got(from).getBlock().getNumber());
assertThat(to(into).getSize()).isEqualTo(0L);
assertThat(to(into).getScriptSize()).isEqualTo(0L);
assertThat(to(into).getSize()).isZero();
assertThat(to(into).getScriptSize()).isZero();
assertThat(to(into).getInputs().size()).isEqualTo(got(from).getInputKeys().size());
assertThat(to(into).getOutputs().size()).isEqualTo(got(from).getOutputKeys().size());
assertThat(to(into).getFee()).isEqualTo(got(from).getFee().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ void fromEntity_Test() {
assertThat(into.getHash()).isEqualTo(from.getTxHash());
assertThat(into.getBlockHash()).isEqualTo(from.getBlock().getHash());
assertThat(into.getBlockNo()).isEqualTo(from.getBlock().getNumber());
assertThat(into.getSize()).isEqualTo(0L);
assertThat(into.getScriptSize()).isEqualTo(0L);
assertThat(into.getSize()).isZero();
assertThat(into.getScriptSize()).isZero();

assertThat(into.getInputs().size()).isEqualTo(from.getInputKeys().size());
assertThat(into.getInputs()).extracting("txHash")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void toDto_Test_empty_operations() {
assertThat(into.getMetadata().getSize()).isEqualTo(from.getSize());
assertThat(into.getMetadata().getScriptSize()).isEqualTo(from.getScriptSize());
assertThat(into.getTransactionIdentifier().getHash()).isEqualTo(from.getHash());
assertThat(into.getOperations().size()).isEqualTo(0);
assertThat(into.getOperations().size()).isZero();
}


Expand Down Expand Up @@ -287,7 +287,7 @@ void toDto_Test_getOutputsAsOperations() {
assertThat(token.getCurrency().getSymbol())
.isEqualTo(Hex.encodeHexString(
from.getOutputs().getFirst().getAmounts().getFirst().getAssetName().getBytes()));
assertThat(token.getCurrency().getDecimals()).isEqualTo(0);
assertThat(token.getCurrency().getDecimals()).isZero();
}


Expand All @@ -313,7 +313,7 @@ void toDto_Test_getInputsAsOperations() {
Utxo firstFrom = from.getInputs().getFirst();
assertThat(opInto.getType()).isEqualTo(Constants.INPUT);
assertThat(opInto.getStatus()).isEqualTo("success");
assertThat(opInto.getOperationIdentifier().getIndex()).isEqualTo(0); //index in array
assertThat(opInto.getOperationIdentifier().getIndex()).isZero(); //index in array
assertThat(opInto.getAccount().getAddress()).isEqualTo(firstFrom.getOwnerAddr());
assertThat(opInto.getAmount()).isEqualTo(amountActual("-10"));
assertThat(opInto.getMetadata().getDepositAmount()).isNull();
Expand All @@ -335,7 +335,7 @@ void toDto_Test_getInputsAsOperations() {
assertThat(token.getCurrency().getSymbol())
.isEqualTo(Hex.encodeHexString(
from.getInputs().getFirst().getAmounts().getFirst().getAssetName().getBytes()));
assertThat(token.getCurrency().getDecimals()).isEqualTo(0);
assertThat(token.getCurrency().getDecimals()).isZero();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

public class CombineApiTest extends IntegrationTest {
class CombineApiTest extends IntegrationTest {
@Autowired
private ConstructionApiService constructionApiService;

Expand All @@ -28,7 +28,7 @@ private ConstructionCombineRequest getCombineRequest(String fileName) throws IOE
}

@Test
public void combineWithMetadataTest() throws IOException, CborException {
void combineWithMetadataTest() throws IOException, CborException {
ConstructionCombineRequest combineRequest = getCombineRequest(
"testdata/construction/combine/combine_with_metadata.json");

Expand All @@ -39,7 +39,7 @@ public void combineWithMetadataTest() throws IOException, CborException {
}

@Test
public void combineWithByronAddressTest() throws IOException, CborException {
void combineWithByronAddressTest() throws IOException, CborException {
ConstructionCombineRequest combineRequest = getCombineRequest(
"testdata/construction/combine/combine_with_byron_addresses.json");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

public class DeriveApiTest extends IntegrationTest {
class DeriveApiTest extends IntegrationTest {

@Autowired
private ConstructionApiService constructionApiService;
Expand All @@ -28,7 +28,7 @@ private ConstructionDeriveRequest getDeriveRequest(String fileName) throws IOExc
}

@Test
public void deriveAddressTest() throws IOException, IllegalAccessException {
void deriveAddressTest() throws IOException, IllegalAccessException {
ConstructionDeriveRequest deriveRequest = getDeriveRequest(
"testdata/construction/derive/derive_request.json");
ConstructionDeriveResponse constructionDeriveResponse = constructionApiService.constructionDeriveService(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

public class HashApiTest extends IntegrationTest {
class HashApiTest extends IntegrationTest {

@Autowired
private ConstructionApiService constructionApiService;
Expand All @@ -28,7 +28,7 @@ private ConstructionHashRequest getHashRequest(String fileName) throws IOExcepti
}

@Test
public void hashTest() throws IOException {
void hashTest() throws IOException {
ConstructionHashRequest hashRequest = getHashRequest(
"testdata/construction/hash/hash_request.json");
TransactionIdentifierResponse transactionIdentifierResponse = constructionApiService.constructionHashService(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

public class ParseApiTest extends IntegrationTest {
class ParseApiTest extends IntegrationTest {

@Autowired
private ConstructionApiService constructionApiService;
Expand All @@ -28,7 +28,7 @@ private ConstructionParseRequest getParseRequest(String fileName) throws IOExcep
}

@Test
public void depositParseTest() throws IOException {
void depositParseTest() throws IOException {
ConstructionParseRequest parseRequest = getParseRequest(
"testdata/construction/parse/deposit_request.json");
ConstructionParseResponse parseResponse = constructionApiService.constructionParseService(
Expand All @@ -42,7 +42,7 @@ public void depositParseTest() throws IOException {
}

@Test
public void refundParseTest() throws IOException {
void refundParseTest() throws IOException {
ConstructionParseRequest parseRequest = getParseRequest(
"testdata/construction/parse/refund_request.json");
ConstructionParseResponse parseResponse = constructionApiService.constructionParseService(
Expand All @@ -56,7 +56,7 @@ public void refundParseTest() throws IOException {
}

@Test
public void signedMultiAssetTest() throws IOException {
void signedMultiAssetTest() throws IOException {
ConstructionParseRequest parseRequest = getParseRequest(
"testdata/construction/parse/signed_multiasset_request.json");
ConstructionParseResponse parseResponse = constructionApiService.constructionParseService(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;


public class PayloadsApiTest extends IntegrationTest {
class PayloadsApiTest extends IntegrationTest {

@Autowired
private ConstructionApiService constructionApiService;
Expand All @@ -29,7 +29,7 @@ private ConstructionPayloadsRequest getPayloadRequest(String fileName) throws IO
}

@Test
public void payloadsMultipleInputTests() throws Exception {
void payloadsMultipleInputTests() throws Exception {
ConstructionPayloadsRequest request = getPayloadRequest("testdata/construction/payloads/multiple_inputs.json");

ConstructionPayloadsResponse body = constructionApiService.constructionPayloadsService(
Expand All @@ -39,7 +39,7 @@ public void payloadsMultipleInputTests() throws Exception {
}

@Test
public void byronInputTest() throws Exception {
void byronInputTest() throws Exception {
ConstructionPayloadsRequest request = getPayloadRequest("testdata/construction/payloads/byronInput.json");

ConstructionPayloadsResponse body = constructionApiService.constructionPayloadsService(
Expand All @@ -49,7 +49,7 @@ public void byronInputTest() throws Exception {
}

@Test
public void depositTest() throws Exception {
void depositTest() throws Exception {
ConstructionPayloadsRequest request = getPayloadRequest("testdata/construction/payloads/deposit.json");

ConstructionPayloadsResponse body = constructionApiService.constructionPayloadsService(
Expand All @@ -59,7 +59,7 @@ public void depositTest() throws Exception {
}

@Test
public void simpeInputOutputTest() throws Exception {
void simpeInputOutputTest() throws Exception {
ConstructionPayloadsRequest request = getPayloadRequest("testdata/construction/payloads/simpleInputOutput.json");

ConstructionPayloadsResponse body = constructionApiService.constructionPayloadsService(
Expand All @@ -69,7 +69,7 @@ public void simpeInputOutputTest() throws Exception {
}

@Test
public void stakeKeyDeregistrationTest() throws Exception {
void stakeKeyDeregistrationTest() throws Exception {
ConstructionPayloadsRequest request = getPayloadRequest("testdata/construction/payloads/stakeKey_deregistration.json");

ConstructionPayloadsResponse body = constructionApiService.constructionPayloadsService(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

public class PreprocessApiTest extends IntegrationTest {
class PreprocessApiTest extends IntegrationTest {

@Autowired
private ConstructionApiService constructionApiService;
Expand All @@ -32,7 +32,7 @@ private ConstructionPreprocessRequest getPreprocessRequest(String fileName) thro
}

@Test
public void simplePreprocessTest()
void simplePreprocessTest()
throws IOException, CborException, AddressExcepion, CborSerializationException {
ConstructionPreprocessRequest preprocessRequest = getPreprocessRequest(
"testdata/construction/preprocess/simple_preprocess.json");
Expand All @@ -45,7 +45,7 @@ public void simplePreprocessTest()
}

@Test
public void twoWithdrawalsTest()
void twoWithdrawalsTest()
throws IOException, CborException, AddressExcepion, CborSerializationException {
ConstructionPreprocessRequest preprocessRequest = getPreprocessRequest(
"testdata/construction/preprocess/two_withdrawals.json");
Expand All @@ -58,7 +58,7 @@ public void twoWithdrawalsTest()
}

@Test
public void poolRegistrationTest()
void poolRegistrationTest()
throws IOException, CborException, AddressExcepion, CborSerializationException {
ConstructionPreprocessRequest preprocessRequest = getPreprocessRequest(
"testdata/construction/preprocess/pool_registration.json");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ class AccountBalanceApiTest extends BaseSpringMvcTest {
private final Long upToBlockNumber = generatedDataMap.get(
TestTransactionNames.SIMPLE_LOVELACE_FIRST_TRANSACTION.getName()).blockNumber();

private final String currentAdaBalance = "1635030";
private final String currentAdaBalance = "3636394";
private final String previousAdaBalance = "1636394";
private final String currentLovelaceBalance = "1939500";

@Test
void accountBalance2Ada_Test() {
Expand Down Expand Up @@ -214,7 +216,7 @@ void accountBalanceBetweenTwoBlocksWithMintedCoins_Test() {
// check the balance on the current block
assertNotNull(accountBalanceResponseWith3Tokens);
assertEquals(3, accountBalanceResponseWith3Tokens.getBalances().size());
assertEquals(currentAdaBalance,
assertEquals(previousAdaBalance,
accountBalanceResponseWith3Tokens.getBalances().getFirst().getValue());
assertEquals(TestConstants.ACCOUNT_BALANCE_MINTED_TOKENS_AMOUNT,
accountBalanceResponseWith3Tokens.getBalances().get(1).getValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@

class AccountCoinsApiTest extends BaseSpringMvcTest {

private final String myAssetPolicyId = "ae1ed1312d2e2e2e3e80e48e4485a9a0b1373ad71e28bde4764ca8c6";
private final String myAssetPolicyId = "55fb0efbf5721e95a05c3d9a13fa63421c83689b35de6247d9d371ef";
private final String latestTxHashOnZeroSlot = generatedDataMap.get(
TestTransactionNames.SIMPLE_NEW_EMPTY_NAME_COINS_TRANSACTION.getName()).txHash() + ":0";
private final String expectedTestAccountCoinAmount = "1635030";
private final String expectedTestAccountCoinAmount = "1636394";
private final Currency myAssetCurrency = getCurrency(TestConstants.MY_ASSET_SYMBOL,
myAssetPolicyId);
private final Currency ada = getCurrency(Constants.ADA, Constants.ADA_DECIMALS);
Expand All @@ -50,7 +51,7 @@ void accountCoins2Ada_Test() {
AccountCoinsResponse accountCoinsResponse = post(newAccCoinsRequest(TEST_ACCOUNT_ADDRESS));

assertNotNull(accountCoinsResponse);
assertEquals(1, accountCoinsResponse.getCoins().size());
assertEquals(2, accountCoinsResponse.getCoins().size());
List<CoinTokens> metadata = accountCoinsResponse.getCoins().getFirst().getMetadata()
.get(latestTxHashOnZeroSlot);
assertEquals(2, metadata.size());
Expand Down Expand Up @@ -105,7 +106,7 @@ void accountCoinsDifferentCoins_Test() {
AccountCoinsResponse accountCoinsResponse = post(newAccCoinsRequest(TEST_ACCOUNT_ADDRESS));

assertNotNull(accountCoinsResponse);
assertEquals(1, accountCoinsResponse.getCoins().size());
assertEquals(2, accountCoinsResponse.getCoins().size());
assertEquals(latestTxHashOnZeroSlot,
accountCoinsResponse.getCoins().getFirst().getCoinIdentifier().getIdentifier());
assertEquals(expectedTestAccountCoinAmount,
Expand All @@ -117,7 +118,7 @@ void accountCoinsDifferentCoins_Test() {
List<CoinTokens> metadata = accountCoinsResponse.getCoins().getFirst().getMetadata()
.get(latestTxHashOnZeroSlot);
assertEquals(2, metadata.size());
assertNotEquals(metadata.get(1).getPolicyId(), metadata.getFirst().getPolicyId());
assertEquals(metadata.get(1).getPolicyId(), metadata.getFirst().getPolicyId());
assertEquals(metadata.getFirst().getPolicyId(), metadata
.getFirst().getTokens().getFirst().getCurrency().getMetadata().getPolicyId());
assertEquals(metadata.get(1).getPolicyId(), metadata
Expand All @@ -136,17 +137,23 @@ void accountCoinsEmptyNameCoin_Test() {
AccountCoinsResponse accountCoinsResponse = post(
newAccCoinsRequestWithCurrencies(TEST_ACCOUNT_ADDRESS,
getCurrency("\\x", emptyNamePolicyId)));
ResponseEntity<AccountCoinsResponse> response = restTemplate.postForEntity(
getAccountCoinsUrl(),
getAccountCoinsRequestWithCurrencies(TestConstants.TEST_ACCOUNT_ADDRESS,
getCurrency("\\x", Constants.MULTI_ASSET_DECIMALS, myAssetPolicyId)),
AccountCoinsResponse.class);
AccountCoinsResponse accountCoinsResponse = response.getBody();

assertNotNull(accountCoinsResponse);
assertEquals(1, accountCoinsResponse.getCoins().size());
assertEquals(2, accountCoinsResponse.getCoins().size());
assertEquals(1, accountCoinsResponse.getCoins().getFirst().getMetadata().size());
assertEquals(latestTxHashOnZeroSlot,
accountCoinsResponse.getCoins().getFirst().getCoinIdentifier().getIdentifier());
assertEquals(Constants.ADA,
accountCoinsResponse.getCoins().getFirst().getAmount().getCurrency().getSymbol());
assertEquals(Constants.ADA_DECIMALS,
accountCoinsResponse.getCoins().getFirst().getAmount().getCurrency().getDecimals());
assertEquals(emptyNamePolicyId,
assertEquals(myAssetPolicyId,
accountCoinsResponse.getCoins().getFirst().getMetadata().get(latestTxHashOnZeroSlot)
.getFirst().getPolicyId());
assertEquals(TestConstants.ACCOUNT_BALANCE_MINTED_TOKENS_AMOUNT,
Expand All @@ -156,7 +163,7 @@ void accountCoinsEmptyNameCoin_Test() {
.get(latestTxHashOnZeroSlot).getFirst().getTokens().getFirst().getCurrency();
assertEquals("", mintedTokenCurrency.getSymbol());
assertEquals(Constants.MULTI_ASSET_DECIMALS, mintedTokenCurrency.getDecimals());
assertEquals(emptyNamePolicyId, mintedTokenCurrency.getMetadata().getPolicyId());
assertEquals(myAssetPolicyId, mintedTokenCurrency.getMetadata().getPolicyId());
}

@Test
Expand All @@ -180,14 +187,14 @@ void accountCoinsMultipleSpecifiedCurrencies_Test() {
post(newAccCoinsRequestWithCurrencies(TEST_ACCOUNT_ADDRESS, ada, myAssetCurrency));

assertNotNull(accountCoinsResponse);
assertEquals(1, accountCoinsResponse.getCoins().size());
assertEquals(2, accountCoinsResponse.getCoins().size());
Coin coins = accountCoinsResponse.getCoins().getFirst();
assertEquals(expectedTestAccountCoinAmount, coins.getAmount().getValue());
assertEquals(Constants.ADA, coins.getAmount().getCurrency().getSymbol());
assertEquals(Constants.ADA_DECIMALS, coins.getAmount().getCurrency().getDecimals());
List<CoinTokens> coinsMetadata = coins.getMetadata().values().iterator().next();
assertEquals(2, coinsMetadata.size());
assertNotEquals(coinsMetadata.getFirst().getPolicyId(), coinsMetadata.get(1).getPolicyId());
assertEquals(coinsMetadata.getFirst().getPolicyId(), coinsMetadata.get(1).getPolicyId());
assertEquals(TestConstants.ACCOUNT_BALANCE_MINTED_TOKENS_AMOUNT, coinsMetadata.getFirst()
.getTokens().getFirst().getValue());
assertEquals(coinsMetadata.getFirst().getPolicyId(),
Expand Down

0 comments on commit d30d153

Please sign in to comment.