@Test public void thatDeleteDelete() { Long id1 = repository.save(click(url1())).getId(); Long id2 = repository.save(click(url2())).getId(); repository.delete(id1); assertEquals(repository.count().intValue(), 1); repository.delete(id2); assertEquals(repository.count().intValue(), 0); }
@Test public void thatFindByKeyReturnsEmpty() { repository.save(click(url1())); repository.save(click(url2())); repository.save(click(url1())); repository.save(click(url2())); repository.save(click(url1())); assertEquals(repository.findByHash(badUrl().getHash()).size(), 0); }
@Test public void thatFindByKeyReturnsAURL() { repository.save(click(url1())); repository.save(click(url2())); repository.save(click(url1())); repository.save(click(url2())); repository.save(click(url1())); assertEquals(repository.findByHash(url1().getHash()).size(), 3); assertEquals(repository.findByHash(url2().getHash()).size(), 2); }
@Test public void thatSavePersistsTheClickURL() { Click click = repository.save(click(url1())); assertSame(jdbc.queryForObject("select count(*) from CLICK", Integer.class), 1); assertNotNull(click); assertNotNull(click.getId()); }
@Test public void thatErrorsInSaveReturnsNull() { assertNull(repository.save(click(badUrl()))); assertSame(jdbc.queryForObject("select count(*) from CLICK", Integer.class), 0); }