### Question:
BranchGroup { public Map<String, List<String>> addTransaction(Transaction tx) { String version = !tx.getBody().getBody().has("contractVersion") || (!tx.getBody().getBody().get("contractVersion").isJsonPrimitive() || !tx.getBody().getBody().get("contractVersion").getAsJsonPrimitive().isString()) ? "" : tx.getBody().getBody().get("contractVersion").getAsString(); int verifyResult = verify(tx.getBranchId(), version); if (verifyResult == SystemError.VALID.toValue()) { return branches.get(tx.getBranchId()).addTransaction(tx); } return SystemError.getErrorLogsMap(verifyResult); }  void addBranch(BlockChain blockChain); BlockChain getBranch(BranchId branchId); boolean isFullSynced(BranchId branchId); int verify(BranchId branchId, String contractVersion); Collection<BlockChain> getAllBranch(); Map<String, List<String>> addTransaction(Transaction tx); long getLastIndex(BranchId branchId); boolean isBranchExist(BranchId branchId); Collection<Transaction> getRecentTxs(BranchId branchId); Transaction getTxByHash(BranchId branchId, String id); void addBlock(ConsensusBlock block, boolean broadcast); ConsensusBlock getBlockByIndex(BranchId branchId, long index); ConsensusBlock getBlockByHash(BranchId branchId, String hash); Receipt getReceipt(BranchId branchId, String key); List<Transaction> getUnconfirmedTxs(BranchId branchId); Object query(BranchId branchId, String contractVersion, String method, JsonObject params);  }### Answer:
@Test public void addVersioningTransaction() { Transaction tx = BlockChainTestUtils.createContractProposeTx( "8c65bc05e107aab9ceaa872bbbb2d96d57811de4", "activate"); Map<String, List<String>> errLogs = branchGroup.addTransaction(tx); Assert.assertEquals(1, errLogs.size()); }
@Test public void addTransaction() { int contractSize = branchGroup.getBranch(tx.getBranchId()).getBranchContracts().size(); assertThat(branchGroup.getRecentTxs(tx.getBranchId()).size()).isEqualTo(contractSize); Map<String, List<String>> errLogs = branchGroup.addTransaction(tx); if (getBalance(tx.getAddress().toString()).equals(BigInteger.ZERO)) { Assert.assertEquals(1, errLogs.size()); } else { Assert.assertEquals(0, errLogs.size()); Transaction foundTxBySha3 = branchGroup.getTxByHash(tx.getBranchId(), tx.getHash()); assertThat(foundTxBySha3.getHash()).isEqualTo(tx.getHash()); Transaction foundTxByString = branchGroup.getTxByHash(tx.getBranchId(), tx.getHash().toString()); assertThat(foundTxByString.getHash()).isEqualTo(tx.getHash()); assertThat(branchGroup.getUnconfirmedTxs(tx.getBranchId()).size()).isEqualTo(1); log.debug("Add valid tx to branchGroup. ErrorLog = {}", errLogs); } Transaction invalidTx1 = BlockChainTestUtils .createInvalidTransferTx(BranchId.of("696e76616c6964"), ContractVersion.of("696e76616c696420")); errLogs = branchGroup.addTransaction(invalidTx1); Assert.assertEquals(1, errLogs.size()); Assert.assertTrue(errLogs.containsKey("SystemError")); Assert.assertTrue(errLogs.get("SystemError").contains("Branch doesn't exist")); log.debug("Add invalid tx to branchGroup. ErrorLog = {}", errLogs); Transaction invalidTx2 = BlockChainTestUtils .createInvalidTransferTx(ContractVersion.of("696e76616c696420")); errLogs = branchGroup.addTransaction(invalidTx2); Assert.assertEquals(1, errLogs.size()); Assert.assertTrue(errLogs.containsKey("SystemError")); Assert.assertTrue(errLogs.get("SystemError").contains("ContractVersion doesn't exist")); log.debug("Add invalid tx to branchGroup. ErrorLog = {}", errLogs); }