@Test public void testPaging() { Page<Institusi> hasilQuery = institusiDao.findAll(new PageRequest(0, 10)); Assert.assertNotNull(hasilQuery); Assert.assertEquals(1, hasilQuery.getTotalPages()); Assert.assertEquals(2, hasilQuery.getTotalElements()); Assert.assertEquals(2, hasilQuery.getNumberOfElements()); Assert.assertEquals(0, institusiDao.findAll(new PageRequest(1, 10)).getNumberOfElements()); }
@Test public void testCariById() { Institusi x = institusiDao.findOne("artivisi"); // harusnya ada record dengan id artivisi Assert.assertNotNull(x); // kalau id tersebut tidak ada di database, harusnya null Assert.assertNull(institusiDao.findOne("xyz")); }
@Test public void testSimpan() { Institusi i = new Institusi(); i.setKode("T-001"); i.setNama("Institusi Test"); Assert.assertNull(i.getId()); institusiDao.save(i); Assert.assertNotNull(i.getId()); }
@Test public void testFindAll() { Institusi i = institusiDao.findAll().iterator().next(); Assert.assertEquals("ArtiVisi Intermedia", i.getNama()); Assert.assertEquals("123", i.getNpwp()); }
@Test public void testHitungRecord() { Assert.assertEquals(2L, institusiDao.count()); }