Beispiel #1
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));
  }
Beispiel #2
0
  @Test
  public void shouldGetAntonymFromSavingSide() {
    wordRepository.save(happy);
    assertThat("happy's antonym count", happy.getAntonymsCount(), is(0));
    wordRepository.save(sad);
    // 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("happy's antonym count", happy.getAntonymsCount(), is(equalTo(1)));
    assertThat("happy's antonym contains sad", happy.getAntonyms(), hasItem(sad));
    Relationship relationship = happy.getAntonymRelationshipTo(sad);
    assertThat("relationship should work properly", relationship.getWord(), is(happy));
    assertThat("relationship should work properly", relationship.getAnotherWord(), is(sad));
    assertThat(
        "relationship should work properly",
        relationship.getOnEnglish(),
        is("feel good vs feel bad"));

    Set<Relationship> relationships = happy.getRelationshipsTo(sad);
    assertThat(relationships.size(), is(1));
    assertThat(relationships, hasItem(relationship));
  }