Пример #1
0
  @Test
  public void pathTest() {

    // Check content of path map
    assertEquals(3, RiakPlugin.bucketMap.size());

    RiakKey key1 = RiakPlugin.bucketMap.get("NIMPORTEQUOI");
    assertNull(key1);

    RiakKey key2 = RiakPlugin.bucketMap.get("models.riak.MusicBand");
    assertNotNull(key2);

    assertEquals("MusicBand", key2.getBucket());
    assertEquals("name", key2.getKey());

    RiakKey key3 = RiakPlugin.bucketMap.get("models.riak.Album");
    assertNotNull(key3);

    RiakKey key4 = RiakPlugin.bucketMap.get("models.riak.Year");
    assertNotNull(key4);

    // Resolve path
    Album a = new Album("Daydream_Nation", 1988);
    RiakPath path = a.getPath();

    assertNotNull(path);
    assertEquals("AlbumTest", path.getBucket());
    assertEquals("Daydream_Nation", path.getValue());
  }
Пример #2
0
  @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());
  }
Пример #3
0
  @Test
  public void resave() {
    Album.delete("AlbumTest", "DaydreamNation");

    Album a = new Album("DaydreamNation", 1988);
    assertTrue(a.save());

    a.addLink("MusicBand", "SonicYouth", "author");
    assertTrue(a.save());

    Album aa = Album.find("AlbumTest", "DaydreamNation");
    assertNotNull(aa);

    RiakObject o = aa.getObj();
    assertNotNull(o);

    assertEquals(1, o.getLinks().size());

    assertEquals(1, aa.getRawLink().size());
    assertEquals(1, aa.getRawLinksByTag("author").size());
    assertEquals(0, aa.getRawLinksByTag("NIMP").size());

    List<RiakModel> list = aa.getLink();

    assertEquals(1, list.size());

    MusicBand mb = (MusicBand) list.get(0);
    assertNotNull(mb);
    assertEquals("SonicYouth", mb.name);

    assertEquals(1, aa.getLinksByTag("author").size());
    assertEquals(0, aa.getLinksByTag("NIMP").size());
  }