Skip to content

Commit

Permalink
refactor: fixed more code smells. Mostly public modifier at tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kammerlo committed May 8, 2024
1 parent 22bce84 commit 46e0048
Show file tree
Hide file tree
Showing 16 changed files with 60 additions and 83 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 @@ -23,7 +23,7 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class CardanoAddressUtilTest {
class CardanoAddressUtilTest {

private final String testMnemonic = "clog book honey force cricket stamp until seed minimum margin denial kind volume undo simple federal then jealous solid legal crucial crazy acoustic thank";

Expand All @@ -37,7 +37,7 @@ public void isStakeAddressTest() {
}

@Test
public void getAddressTest() {
void getAddressTest() {
Account account = new Account(testMnemonic);
HdKeyPair stakeHdKeyPair = account.stakeHdKeyPair();
HdKeyPair paymentHdKeyPair = account.hdKeyPair();
Expand All @@ -50,7 +50,7 @@ public void getAddressTest() {
}

@Test
public void isKeyValidTest() {
void isKeyValidTest() {
Account account = new Account(testMnemonic);
HdKeyPair paymentKeyPair = account.hdKeyPair();
// key data will result in a valid Key
Expand All @@ -62,7 +62,7 @@ public void isKeyValidTest() {
}

@Test
public void generateSpecificRelayTest() {
void generateSpecificRelayTest() {
Relay relay = new Relay("127.0.0.1", "2001:0db8:3c4d:0015:0000:0000:1a2f:1a2b", "relay.io", 3001, Constants.SINGLE_HOST_ADDR);
SingleHostAddr singleHostAddr = (SingleHostAddr) CardanoAddressUtils.generateSpecificRelay(
relay);
Expand All @@ -80,15 +80,15 @@ public void generateSpecificRelayTest() {
}

@Test
public void generateAddressTest() {
void generateAddressTest() {
Account account = new Account(testMnemonic);
Address address = (Address) CardanoAddressUtils.generateAddress(
account.getBaseAddress().getAddress());
assertEquals(account.getBaseAddress().getAddress(), address.getAddress());
}

@Test
public void getEraAddressTypeTest() {
void getEraAddressTypeTest() {
Account account = new Account(Networks.preprod(), testMnemonic);
String address = account.getBaseAddress().getAddress();
System.out.println(address);
Expand All @@ -98,7 +98,7 @@ public void getEraAddressTypeTest() {
}

@Test
public void isPolicyIdValidTest() {
void isPolicyIdValidTest() {
String validPolicyID = "5d16cc1a177b5d9ba9cfa9793b07e60f1fb70fea1f8aef064415d114";
assertTrue(CardanoAddressUtils.isPolicyIdValid(validPolicyID));

Expand All @@ -107,50 +107,50 @@ public void isPolicyIdValidTest() {
}

@Test
public void isTokenNameValidTest() {
void isTokenNameValidTest() {
String validTokenName = "5d16cc1a177b5d9ba9cfa9793b07e60f1fb70fea1f8aef064415d1149307a4b6";
assertTrue(CardanoAddressUtils.isTokenNameValid(validTokenName));
}

@Test
public void isEmptyHexStringTest() {
void isEmptyHexStringTest() {
String emptyHex = "\\x";
assertTrue(CardanoAddressUtils.isEmptyHexString(emptyHex));
String notEmptyHEx = "1234abcd";
assertFalse(CardanoAddressUtils.isEmptyHexString(notEmptyHEx));
}

@Test
public void generateRewardAddress() {
void generateRewardAddress() {
Account account = new Account(testMnemonic);
String rewardAddress = CardanoAddressUtils.generateRewardAddress(NetworkIdentifierType.CARDANO_MAINNET_NETWORK, account.hdKeyPair().getPublicKey());
assertEquals("stake1ux5t8wq55e09usmh07ymxry8atzwxwt2nwwzfngg6esffxgfvzpaw", rewardAddress);
}

@Test
public void generateBaseAddressTest() {
void generateBaseAddressTest() {
Account account = new Account(testMnemonic);
String baseAddress = CardanoAddressUtils.generateBaseAddress(NetworkIdentifierType.CARDANO_MAINNET_NETWORK, account.hdKeyPair().getPublicKey(), account.stakeHdKeyPair().getPublicKey());
assertEquals(account.baseAddress(), baseAddress);
}

@Test
public void generateEnterpriseAddressTest() {
void generateEnterpriseAddressTest() {
Account account = new Account(testMnemonic);
String enterpriseAddress = CardanoAddressUtils.generateEnterpriseAddress(NetworkIdentifierType.CARDANO_MAINNET_NETWORK, account.hdKeyPair().getPublicKey());
assertEquals(account.enterpriseAddress(), enterpriseAddress);
}

@Test
public void isEd25519KeyHashTest() {
void isEd25519KeyHashTest() {
String validKeyHash = "5d16cc1a177b5d9ba9cfa9793b07e60f1fb70fea1f8aef064415d114";
assertTrue(CardanoAddressUtils.isEd25519KeyHash(validKeyHash));
String invalidKeyHash = "5d16cc1a177b5d9ba9cfa9793b07e60f1fb70fea1f8aef06441gg";
assertFalse(CardanoAddressUtils.isEd25519KeyHash(invalidKeyHash));
}

@Test
public void getStakingCredentialFromStakeKeyTest() {
void getStakingCredentialFromStakeKeyTest() {
Account account = new Account(testMnemonic);
PublicKey publicKey = PublicKey.builder()
.hexBytes(HexUtil.encodeHexString(account.stakeHdKeyPair().getPublicKey().getKeyData())).curveType(
Expand Down

0 comments on commit 46e0048

Please sign in to comment.