@Test public void deleteAll() { RiakUtil.deleteAllDefineBucket(); Collection<String> keys = MusicBand.findKeys("Musicband"); assertEquals(0, keys.size()); assertEquals(0, Year.findKeys("Year").size()); assertEquals(0, Album.findKeys("AlbumTest").size()); }
@Test public void saveAndFind() { // Delete all Collection<String> keys = MusicBand.findKeys("MusicBand"); for (String key : keys) { MusicBand.delete("MusicBand", key); } Collection<String> keysAfter = MusicBand.findKeys("MusicBand"); assertEquals(0, keysAfter.size()); // Save MusicBand mu = new MusicBand("SonicYouth", "Best band ever"); assertTrue(mu.save()); MusicBand mu2 = new MusicBand("Dillinger_escape", "Insane"); assertTrue(mu2.save()); Collection<String> keysAfter2 = MusicBand.findKeys("MusicBand"); assertEquals(2, keysAfter2.size()); // Find MusicBand mu3 = MusicBand.find("MusicBand", "SonicYouth"); assertNotNull(mu3); assertEquals("SonicYouth", mu3.name); assertEquals("Best band ever", mu3.description); assertNotNull(mu3.getUserMeta()); assertEquals(0, mu3.getUserMeta().size()); // Edit mu3.description = "Sonic Youth is an American rock band from New York City, formed in 1981."; assertTrue(mu3.save()); // Refind and check MusicBand mu4 = MusicBand.find("MusicBand", "SonicYouth"); assertEquals( "Sonic Youth is an American rock band from New York City, formed in 1981.", mu4.description); List<MusicBand> list = MusicBand.findAll("MusicBand"); assertNotNull(list); assertEquals(2, list.size()); }