### Question:
BranchLoader { boolean saveBranch(Branch branch) { File branchDir = loadBranchDirectory(branch.getBranchId()); if (!branchDir.exists()) { branchDir.mkdir(); File branchFile = new File(branchDir, BRANCH_FILE); try (FileOutputStream outputStream = new FileOutputStream(branchFile)) { byte[] branchJson = branch.getJson().toString().getBytes(); outputStream.write(branchJson); return true; } catch (IOException e) { log.error(e.getMessage()); } } return false; } BranchLoader(String branchPath); Optional<GenesisBlock> getGenesisBlock(BranchId branchId); List<GenesisBlock> getGenesisBlockList(); static final String BRANCH_FILE; }### Answer:
@Test public void saveBranchTest() throws IOException { String branchPath = new DefaultConfig().getBranchPath(); BranchLoader loader = new BranchLoader(branchPath); Assert.assertTrue(loader.saveBranch(branch)); Path targetBranch = Paths.get(branchPath, branch.getBranchId().toString(), BranchLoader.BRANCH_FILE); String reloadBranch = FileUtil.readFileToString(targetBranch.toFile(), FileUtil.DEFAULT_CHARSET); JsonObject branchJson = new JsonParser().parse(reloadBranch).getAsJsonObject(); Assert.assertEquals(Branch.of(branchJson).getBranchId(), branch.getBranchId()); }