Skip to content

Commit 61b7110

Browse files
committed
Added test case for TransactionNotFoundException
1 parent 117052d commit 61b7110

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/test/java/com/bigchaindb/api/TransactionCreateApiTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.bigchaindb.api.TransactionsApi;
99
import com.bigchaindb.builders.BigchainDbTransactionBuilder;
1010
import com.bigchaindb.constants.Operations;
11+
import com.bigchaindb.exceptions.TransactionNotFoundException;
1112
import com.bigchaindb.json.strategy.MetaDataDeserializer;
1213
import com.bigchaindb.json.strategy.MetaDataSerializer;
1314
import com.bigchaindb.json.strategy.TransactionDeserializer;
@@ -41,6 +42,7 @@
4142
public class TransactionCreateApiTest extends AbstractApiTest {
4243

4344
public static String TRANSACTION_ID = "4957744b3ac54434b8270f2c854cc1040228c82ea4e72d66d2887a4d3e30b317";
45+
public static String NON_EXISTENT_TRANSACTION_ID = "4957744b3ac5434b8270f2c854cc1040228c8ea4e72d66d2887a4d3e30b317";
4446
public static String V1_GET_TRANSACTION_JSON = "{\n" +
4547
" \"asset\": {\n" +
4648
" \"data\": {\n" +
@@ -245,9 +247,25 @@ public void testGetTransaction() {
245247
assertTrue(transaction.getId().equals(TRANSACTION_ID));
246248
} catch (IOException e) {
247249
e.printStackTrace();
250+
} catch (TransactionNotFoundException e) {
251+
e.printStackTrace();
248252
}
249253
}
250254

255+
/**
256+
* Test get transaction when the transaction with supplied id is not present.
257+
*/
258+
@Test(expected = TransactionNotFoundException.class)
259+
public void testGetNonExistentTransaction() throws TransactionNotFoundException {
260+
try {
261+
TransactionsApi.getTransactionById(NON_EXISTENT_TRANSACTION_ID);
262+
} catch (IOException e) {
263+
e.printStackTrace();
264+
}
265+
}
266+
267+
268+
251269
/**
252270
* Test get transactions by assets id
253271
*/

0 commit comments

Comments
 (0)