Пример #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"));
 }
Пример #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'"));
 }
Пример #3
0
 @Test
 public void shouldGetExtensionFromSavingSide() {
   wordRepository.save(earth);
   assertThat("earth's extensions count", earth.getExtensionsCount(), is(0));
   wordRepository.save(sky);
   // as earth and sky both are under controll of springdata graph, no need to further call
   // earth.save()
   earth.extendWith(sky, "earth and sky just intuitive");
   assertThat("earth's extensions count", earth.getExtensionsCount(), is(equalTo(1)));
   assertThat("earth's extensions contains sky", earth.getExtensions(), hasItem(sky));
   Relationship relationship = earth.getExtensionRelationshipTo(sky);
   assertThat("relationship should work properly", relationship.getWord(), is(earth));
   assertThat("relationship should work properly", relationship.getAnotherWord(), is(sky));
   assertThat(
       "relationship should work properly",
       relationship.getOnEnglish(),
       is("earth and sky just intuitive"));
 }
Пример #4
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));
  }