@Test(expected = SanskritException.class) public void moreThanOneHashFoundAfterBothHashesFound() throws Exception { HashChecker checker = new HashChecker("e", "f"); assertTrue(checker.check("a")); assertTrue(checker.check("b")); assertTrue(checker.check("e")); assertTrue(checker.check("f")); assertFalse(checker.check("c")); checker.check("d"); }
public boolean check(String hash) throws SanskritException { if (hashes.isEmpty()) { if (laterHash) { throw new SanskritException("Found hashes after the last recorded hash"); } laterHash = true; LOGGER.trace("check({}}): {}", hash, false); return false; } String removed = hashes.remove(hash); LOGGER.trace("check({}}): removed: {}", hash, removed); if (removed != null) { if (removedFirst == null) { removedFirst = removed; } } else { if (removedFirst != null) { throw new SanskritException("Found extra hash between final hashes: " + hash); } } LOGGER.trace("check({}}): {}", hash, true); return true; }
HashChecker { public boolean check(String hash) throws SanskritException { if (hashes.isEmpty()) { if (laterHash) { throw new SanskritException("Found hashes after the last recorded hash"); } laterHash = true; LOGGER.trace("check({}}): {}", hash, false); return false; } String removed = hashes.remove(hash); LOGGER.trace("check({}}): removed: {}", hash, removed); if (removed != null) { if (removedFirst == null) { removedFirst = removed; } } else { if (removedFirst != null) { throw new SanskritException("Found extra hash between final hashes: " + hash); } } LOGGER.trace("check({}}): {}", hash, true); return true; } }
HashChecker { public boolean check(String hash) throws SanskritException { if (hashes.isEmpty()) { if (laterHash) { throw new SanskritException("Found hashes after the last recorded hash"); } laterHash = true; LOGGER.trace("check({}}): {}", hash, false); return false; } String removed = hashes.remove(hash); LOGGER.trace("check({}}): removed: {}", hash, removed); if (removed != null) { if (removedFirst == null) { removedFirst = removed; } } else { if (removedFirst != null) { throw new SanskritException("Found extra hash between final hashes: " + hash); } } LOGGER.trace("check({}}): {}", hash, true); return true; } HashChecker(String hash0, String hash1); }
HashChecker { public boolean check(String hash) throws SanskritException { if (hashes.isEmpty()) { if (laterHash) { throw new SanskritException("Found hashes after the last recorded hash"); } laterHash = true; LOGGER.trace("check({}}): {}", hash, false); return false; } String removed = hashes.remove(hash); LOGGER.trace("check({}}): removed: {}", hash, removed); if (removed != null) { if (removedFirst == null) { removedFirst = removed; } } else { if (removedFirst != null) { throw new SanskritException("Found extra hash between final hashes: " + hash); } } LOGGER.trace("check({}}): {}", hash, true); return true; } HashChecker(String hash0, String hash1); boolean check(String hash); String done(); String nextHashFile(); }
HashChecker { public boolean check(String hash) throws SanskritException { if (hashes.isEmpty()) { if (laterHash) { throw new SanskritException("Found hashes after the last recorded hash"); } laterHash = true; LOGGER.trace("check({}}): {}", hash, false); return false; } String removed = hashes.remove(hash); LOGGER.trace("check({}}): removed: {}", hash, removed); if (removed != null) { if (removedFirst == null) { removedFirst = removed; } } else { if (removedFirst != null) { throw new SanskritException("Found extra hash between final hashes: " + hash); } } LOGGER.trace("check({}}): {}", hash, true); return true; } HashChecker(String hash0, String hash1); boolean check(String hash); String done(); String nextHashFile();  }