Esempio n. 1
0
 @Test
 public void shouldGetSynonymsFromSavingSide() {
   wordRepository.save(earth);
   assertThat("earth's synonyms count", earth.getSynonymsCount(), is(0));
   wordRepository.save(globe);
   // as earth and globe both are under controll of springdata graph, no need to further call
   // earth.save()
   earth.synonymWith(globe, "the planet we live");
   assertThat("earth's synonyms count", earth.getSynonymsCount(), is(equalTo(1)));
   assertThat("earth's synonym contains globe", earth.getSynonyms(), hasItem(globe));
   Relationship relationship = earth.getSynonymRelationshipTo(globe);
   assertThat("relationship should work properly", relationship.getWord(), is(earth));
   assertThat("relationship should work properly", relationship.getAnotherWord(), is(globe));
   assertThat(
       "relationship should work properly", relationship.getOnEnglish(), is("the planet we live"));
 }
Esempio n. 2
0
  @Test
  public void shouldGetAntonymFromOtherSide() {
    wordRepository.save(happy);
    wordRepository.save(sad);
    wordRepository.save(earth);
    assertThat("sad's antonym count", sad.getAntonymsCount(), is(0));
    // as earth and sky both are under controll of springdata graph, no need to further call
    // earth.save()
    happy.antonymWith(sad, "feel good vs feel bad'");
    assertThat("sad's antonym count", sad.getAntonymsCount(), is(equalTo(1)));
    assertThat("sad's antonym contains happy", sad.getAntonyms(), hasItem(happy));
    Relationship relationship = happy.getSynonymRelationshipTo(sad);
    assertThat(
        "relationship should work properly", relationship, is(CoreMatchers.<Object>nullValue()));

    Set<Relationship> relationships = happy.getRelationshipsTo(earth);
    assertThat(relationships.size(), is(0));
  }