remove @Nullable/@NotNull annotations (too noisy and better use Optional/Either instead to avoid null pointer exc.)

This commit is contained in:
Manfred Karrer 2014-07-01 15:09:23 +02:00
parent d9410f91a0
commit 4f26d76746
88 changed files with 1539 additions and 1122 deletions

View file

@ -1,6 +1,7 @@
package io.bitsquare;
import io.bitsquare.btc.BtcValidatorTest;
import io.bitsquare.currency.BitcoinTest;
import io.bitsquare.gui.util.BitSquareConverterTest;
import io.bitsquare.gui.util.BitSquareValidatorTest;
import org.junit.runner.RunWith;
@ -10,7 +11,8 @@ import org.junit.runners.Suite;
@Suite.SuiteClasses({
BtcValidatorTest.class,
BitSquareConverterTest.class,
BitSquareValidatorTest.class
BitSquareValidatorTest.class,
BitcoinTest.class
})
public class BitSquareTestSuite

View file

@ -2,7 +2,6 @@ package io.bitsquare.btc;
import com.google.bitcoin.core.Transaction;
import java.math.BigInteger;
import org.jetbrains.annotations.Nullable;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
@ -13,23 +12,23 @@ public class BtcValidatorTest
@Test
public void testIsMinSpendableAmount()
{
@Nullable BigInteger amount = null;
BigInteger amount = null;
//noinspection ConstantConditions
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
amount = BigInteger.ZERO;
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
amount = FeePolicy.TX_FEE;
amount = FeePolicy.TX_FEE_depr;
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
amount = Transaction.MIN_NONDUST_OUTPUT;
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
amount = FeePolicy.TX_FEE.add(Transaction.MIN_NONDUST_OUTPUT);
amount = FeePolicy.TX_FEE_depr.add(Transaction.MIN_NONDUST_OUTPUT);
assertFalse("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
amount = FeePolicy.TX_FEE.add(Transaction.MIN_NONDUST_OUTPUT).add(BigInteger.ONE);
amount = FeePolicy.TX_FEE_depr.add(Transaction.MIN_NONDUST_OUTPUT).add(BigInteger.ONE);
assertTrue("tx unfunded, pending", BtcValidator.isMinSpendableAmount(amount));
}
}

View file

@ -0,0 +1,50 @@
package io.bitsquare.currency;
import com.google.bitcoin.core.Transaction;
import java.math.BigInteger;
import org.junit.Test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class BitcoinTest
{
@Test
public void testBitcoin()
{
Bitcoin bitcoin;
Bitcoin compareValue;
bitcoin = new Bitcoin("0");
assertTrue(bitcoin.isZero());
bitcoin = new Bitcoin("0");
compareValue = new Bitcoin("1");
assertTrue(bitcoin.isLess(compareValue));
assertFalse(compareValue.isLess(bitcoin));
assertFalse(compareValue.isEqual(bitcoin));
bitcoin = new Bitcoin("1");
compareValue = new Bitcoin("0");
assertFalse(bitcoin.isLess(compareValue));
assertTrue(compareValue.isLess(bitcoin));
assertFalse(compareValue.isEqual(bitcoin));
bitcoin = new Bitcoin("1");
compareValue = new Bitcoin("1");
assertFalse(bitcoin.isLess(compareValue));
assertFalse(compareValue.isLess(bitcoin));
assertTrue(compareValue.isEqual(bitcoin));
bitcoin = new Bitcoin(Transaction.MIN_NONDUST_OUTPUT);
assertTrue(bitcoin.isMinValue());
bitcoin = new Bitcoin(Transaction.MIN_NONDUST_OUTPUT.subtract(BigInteger.ONE));
assertFalse(bitcoin.isMinValue());
bitcoin = new Bitcoin(Transaction.MIN_NONDUST_OUTPUT.add(BigInteger.ONE));
assertTrue(bitcoin.isMinValue());
}
}