Skip to content

Conversation

@Lemeri123
Copy link
Contributor

I created a new test file and added the necessary tests needed. #109

@Ndacyayisenga-droid
Copy link
Member

@Lemeri123 you didn't sign off your commit.

That you now pushed a commit already, you can run these commands to get them signed off

  1. In your local branch, run: git rebase HEAD~1 --signoff
  2. Force push your changes to overwrite the branch: git push --force-with-lease origin main

Signed-off-by: Lemeri123 <132246079+Lemeri123@users.noreply.github.com>
@Lemeri123
Copy link
Contributor Author

Okay thank you @Ndacyayisenga-droid

@Ndacyayisenga-droid
Copy link
Member

Okay thank you @Ndacyayisenga-droid

Thanks for your contribution @Lemeri123 . I added a few comments

Copy link
Member

@hendrikebbers hendrikebbers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some changes are needed


@NonNull
@Override
public Hbar getAccountBalance(@NonNull AccountId account) throws HieroException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change do not make sense to me. Can you please revert it.

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version> 5.11.0</version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We define the versions for all dependencies in the root pom. Please remove the version at this place and add it to the root pom.xml

@Test
public void testGetAccountBalance_ValidPositiveBalance() throws HieroException {
// Fully qualify AccountId to ensure no ambiguity
com.hedera.hashgraph.sdk.AccountId accountId = com.hedera.hashgraph.sdk.AccountId.fromString("0.0.12345");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is only one AccountId on the classpath. Based on that I would favor to do a regular import instead of a full qualified class in code.

@hendrikebbers
Copy link
Member

@Lemeri123 please have a look at my review

Signed-off-by: Lemeri123 <132246079+Lemeri123@users.noreply.github.com>
@hendrikebbers hendrikebbers merged commit 8ed92d1 into OpenElements:main Dec 14, 2024
3 of 4 checks passed
@hendrikebbers
Copy link
Member

@Lemeri123 thank you for your contribution!

import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatchers;

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the asterisk wildcard

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if I remove it then I get errors since they set up the testing framework and mocking utilities for the test method


import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the asterisk wildcard

@Test
public void testGetAccountBalance_ValidPositiveBalance() throws HieroException {
// Fully qualify AccountId to ensure no ambiguity
com.hedera.hashgraph.sdk.AccountId accountId = com.hedera.hashgraph.sdk.AccountId.fromString("0.0.12345");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Lemeri123 I recommend importing AccountId directly to simplify the code and enhance readability by eliminating the need for full qualifications. You can change the above line to something like
AccountId accountId = AccountId.fromString("0.0.12345");


@Test
public void testGetAccountBalance_ZeroBalance() throws HieroException {
com.hedera.hashgraph.sdk.AccountId accountId = com.hedera.hashgraph.sdk.AccountId.fromString("0.0.67890");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend importing AccountId directly to simplify the code and enhance readability by eliminating the need for full qualifications. You can change the above line to something like
AccountId accountId = AccountId.fromString("0.0.67890");

@Test
public void testGetAccountBalance_InvalidAccount_ThrowsException() throws HieroException {
// Use a valid but non-existing account ID to simulate invalid behavior
com.hedera.hashgraph.sdk.AccountId invalidAccountId = com.hedera.hashgraph.sdk.AccountId.fromString("0.0.9999999"); // Simulate invalid or non-existing account

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same review as the above

@Test
public void testGetAccountBalance_NullThrowsException() {
assertThrows(NullPointerException.class, () -> {
accountClientImpl.getAccountBalance((com.hedera.hashgraph.sdk.AccountId) null);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pass in the AccountId not com.hedera.hashgraph.sdk.AccountId


@Test
public void testGetAccountBalance_ProtocolLayerClientFails() throws HieroException {
com.hedera.hashgraph.sdk.AccountId accountId = com.hedera.hashgraph.sdk.AccountId.fromString("0.0.12345");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use AccountId accountId = AccountId.fromString("0.0.12345"); not com.hedera.hashgraph.sdk.AccountId accountId = com.hedera.hashgraph.sdk.AccountId.fromString("0.0.12345");

@@ -1,6 +1,4 @@
package com.openelements.hiero.base.implementation;

import com.hedera.hashgraph.sdk.AccountId;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this change

@NonNull
@Override
public Hbar getAccountBalance(@NonNull AccountId account) throws HieroException {
public Hbar getAccountBalance(com.hedera.hashgraph.sdk.AccountId account) throws HieroException {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this change as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants