Skip to content

Commit

Permalink
Fix #193
Browse files Browse the repository at this point in the history
  • Loading branch information
neutralleiter committed Jan 2, 2018
1 parent a938d93 commit 86fad4f
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package eu.bittrade.libs.steemj.plugins.apis.account.history.models;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.fail;

import java.security.InvalidParameterException;

import org.joou.UInteger;
import org.joou.ULong;
import org.junit.Test;

import eu.bittrade.libs.steemj.protocol.AccountName;

/**
* This class contains all test connected to the
* {@link eu.bittrade.libs.steemj.plugins.apis.account.history.models.GetAccountHistoryArgs
* GetAccountHistoryArgs} object.
*
* @author <a href="http://steemit.com/@dez1337">dez1337</a>
*/
public class GetAccountHistoryArgsTest {
/**
* Test if the {@link GetAccountHistoryArgs} fields are validated correctly.
*/
@Test
public void testFieldValidation() {
AccountName accountName = new AccountName("dez1337");
ULong start = ULong.valueOf(20);
UInteger limit = UInteger.valueOf(10);

GetAccountHistoryArgs getAccountHistoryArgs = new GetAccountHistoryArgs(accountName, start, limit);

assertThat(getAccountHistoryArgs.getAccount(), equalTo(accountName));
assertThat(getAccountHistoryArgs.getStart(), equalTo(start));
assertThat(getAccountHistoryArgs.getLimit(), equalTo(limit));

// Check if default values are applied correctly if <code>null</code>
// values are provided:
getAccountHistoryArgs.setLimit(null);
getAccountHistoryArgs.setStart(null);

assertThat(getAccountHistoryArgs.getStart(), equalTo(ULong.valueOf(-1)));
assertThat(getAccountHistoryArgs.getLimit(), equalTo(UInteger.valueOf(1000)));

// Verify that an exception is thrown if required fields are not
// provided:
try {
getAccountHistoryArgs.setAccount(null);
fail();
} catch (InvalidParameterException e) {
// Expected.
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package eu.bittrade.libs.steemj.plugins.apis.account.history.models;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.fail;

import java.security.InvalidParameterException;

import org.joou.UInteger;
import org.junit.Test;

/**
* This class contains all test connected to the
* {@link eu.bittrade.libs.steemj.plugins.apis.account.history.models.GetOpsInBlockArgs
* GetOpsInBlockArgs} object.
*
* @author <a href="http://steemit.com/@dez1337">dez1337</a>
*/
public class GetOpsInBlockArgsTest {
/**
* Test if the {@link GetOpsInBlockArgs} fields are validated correctly.
*/
@Test
public void testFieldValidation() {
UInteger blockNum = UInteger.valueOf(1345461);

GetOpsInBlockArgs getOpsInBlockArgs = new GetOpsInBlockArgs(blockNum, false);

assertThat(getOpsInBlockArgs.getBlockNum(), equalTo(blockNum));
assertThat(getOpsInBlockArgs.getOnlyVirtual(), equalTo(false));

// Verify that an exception is thrown if required fields are not
// provided:
try {
getOpsInBlockArgs.setBlockNum(null);
fail();
} catch (InvalidParameterException e) {
// Expected.
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package eu.bittrade.libs.steemj.plugins.apis.account.history.models;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.fail;

import java.security.InvalidParameterException;

import org.junit.Test;

import eu.bittrade.libs.steemj.protocol.TransactionId;

/**
* This class contains all test connected to the
* {@link eu.bittrade.libs.steemj.plugins.apis.account.history.models.GetTransactionArgs
* GetTransactionArgs} object.
*
* @author <a href="http://steemit.com/@dez1337">dez1337</a>
*/
public class GetTransactionArgsTest {
/**
* Test if the {@link GetTransactionArgs} fields are validated correctly.
*/
@Test
public void testFieldValidation() {
TransactionId transactionId = new TransactionId("bd8069e6544f658da560b72e93b605dfe2cb0aaf");

GetTransactionArgs getTransactionArgs = new GetTransactionArgs(transactionId);

assertThat(getTransactionArgs.getId(), equalTo(transactionId));

// Verify that an exception is thrown if required fields are not
// provided:
try {
getTransactionArgs.setId(null);
fail();
} catch (InvalidParameterException e) {
// Expected.
}
}
}

0 comments on commit 86fad4f

Please sign in to comment.