BisectRepository { public boolean exists(long buildId) { String value = storage.getValue(String.valueOf(buildId)); return tryParse(value) != null; } BisectRepository(CustomDataStorage storage); boolean exists(long buildId); void create(long buildId); Bisect[] getAllNotFinished(); Bisect get(long buildId); void save(Bisect bisect);  }
@Test public void Exists_StorageReturnsNull_ReturnsFalse() throws Exception { stub(storage.getValue("1")).toReturn(null); boolean actual = sut.exists(1); assertFalse(actual); }
@Test public void Exists_StorageReturnsEmptyString_ReturnsFalse() throws Exception { stub(storage.getValue("1")).toReturn(""); boolean actual = sut.exists(1); assertFalse(actual); }
@Test public void Exists_StorageReturnsInvalidJson_ReturnsFalse() throws Exception { stub(storage.getValue("1")).toReturn("{\"foo:1}"); boolean actual = sut.exists(1); assertFalse(actual); }
@Test public void Exists_StorageReturnsBisect_ReturnsTrue() throws Exception { stub(storage.getValue("1")).toReturn("{\"buildId\":1}"); boolean actual = sut.exists(1); assertTrue(actual); }