Ejemplo n.º 1
0
  @Test
  public void shouldGetIdiomFromOtherSide() {
    wordRepository.save(earth);
    wordRepository.save(onEarth);
    assertThat("onEarth's idiom count", onEarth.getIdiomsCount(), is(0));

    // as earth and sky both are under controll of springdata graph, no need to further call
    // earth.save()
    earth.idiomWith(onEarth, "added a prefix 'on'");
    assertThat("onEarth's idiom count", onEarth.getIdiomsCount(), is(equalTo(1)));
    assertThat("onEarth's idiom contains earth", onEarth.getIdioms(), hasItem(earth));
  }
Ejemplo n.º 2
0
 @Test
 public void shouldGetIdiomFromSavingSide() {
   wordRepository.save(earth);
   assertThat("earth's idioms count", earth.getIdiomsCount(), is(0));
   wordRepository.save(onEarth);
   // as earth and sky both are under controll of springdata graph, no need to further call
   // earth.save()
   earth.idiomWith(onEarth, "added a prefix 'on'");
   assertThat("earth's idioms count", earth.getIdiomsCount(), is(equalTo(1)));
   assertThat("earth's idioms contains onEarth", earth.getIdioms(), hasItem(onEarth));
   Relationship relationship = earth.getIdiomRelationshipTo(onEarth);
   assertThat("relationship should work properly", relationship.getWord(), is(earth));
   assertThat("relationship should work properly", relationship.getAnotherWord(), is(onEarth));
   assertThat(
       "relationship should work properly",
       relationship.getOnEnglish(),
       is("added a prefix 'on'"));
 }