public void test_should_store_transaction_in_the_database() {
   Transaction t = new Transaction();
   t.fromAccountId = 1;
   t.fromAmount = 1000;
   t.categoryId = 5;
   t.accuracy = 6.0f;
   t.latitude = -11.0;
   t.isCCardPayment = 1;
   t.note = "My note";
   t.status = TransactionStatus.RS;
   long id = db.saveOrUpdate(t);
   assertTrue(id > 0);
   Transaction restored = db.load(Transaction.class, id);
   assertEquals(t.fromAccountId, restored.fromAccountId);
   assertEquals(t.fromAmount, restored.fromAmount);
   assertEquals(t.categoryId, restored.categoryId);
   assertEquals(t.note, restored.note);
   assertEquals(t.status, restored.status);
   assertEquals(t.accuracy, restored.accuracy);
   assertEquals(t.latitude, restored.latitude);
   assertEquals(t.isCCardPayment, restored.isCCardPayment);
 }
 public void test_should_restore_split_from_intent() {
   Transaction split = new Transaction();
   split.id = -2;
   split.fromAccountId = 3;
   split.toAccountId = 5;
   split.categoryId = 7;
   split.fromAmount = -10000;
   split.toAmount = 4000;
   split.unsplitAmount = 300000;
   split.note = "My note";
   Intent intent = new Intent();
   split.toIntentAsSplit(intent);
   Transaction restored = Transaction.fromIntentAsSplit(intent);
   assertEquals(split.id, restored.id);
   assertEquals(split.fromAccountId, restored.fromAccountId);
   assertEquals(split.toAccountId, restored.toAccountId);
   assertEquals(split.categoryId, restored.categoryId);
   assertEquals(split.fromAmount, restored.fromAmount);
   assertEquals(split.toAmount, restored.toAmount);
   assertEquals(split.unsplitAmount, restored.unsplitAmount);
   assertEquals(split.note, restored.note);
 }
 public void test_should_update_splits() {
   Transaction t =
       TransactionBuilder.withDb(db)
           .account(a1)
           .amount(-150)
           .category(Category.splitCategory(context))
           .withSplit(categories.get("A1"), -60)
           .withSplit(categories.get("A2"), -40)
           .withTransferSplit(a2, -50, 40)
           .create();
   List<Transaction> splits = db.getSplitsForTransaction(t.id);
   assertEquals(3, splits.size());
   t.fromAmount = -250;
   splits.get(0).fromAmount = -70;
   splits.get(1).fromAmount = -50;
   splits.get(2).fromAmount = -130;
   splits.get(2).toAmount = 70;
   t.splits = splits;
   db.insertOrUpdate(t);
   splits = db.getSplitsForTransaction(t.id);
   assertEquals(3, splits.size());
 }