Ejemplo n.º 1
0
  @Test
  public void shouldGetExtensionFromOtherSide() {
    wordRepository.save(earth);
    wordRepository.save(sky);
    assertThat("sky's extensions count", sky.getExtensionsCount(), is(0));

    // 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("sky's extensions count", sky.getExtensionsCount(), is(equalTo(1)));
    assertThat("sky's extensions contains sky", sky.getExtensions(), hasItem(earth));
  }
Ejemplo n.º 2
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.º 3
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"));
 }
Ejemplo n.º 4
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));
  }
Ejemplo n.º 5
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'"));
 }
Ejemplo n.º 6
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"));
 }
Ejemplo n.º 7
0
 @Test
 public void shouldGetSynonymsFromOtherSide() {
   wordRepository.save(earth);
   wordRepository.save(globe);
   assertThat("globe's synonyms count", globe.getSynonymsCount(), is(0));
   // 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("globe's synonyms count", globe.getSynonymsCount(), is(equalTo(1)));
   assertThat("globe's synonyms contain earth", globe.getSynonyms(), hasItem(earth));
 }
Ejemplo n.º 8
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));
  }
Ejemplo n.º 9
0
 @Test
 public void shouldRetrieveTheSameWordJustSaved() {
   Word retrievedWord = wordRepository.save(earth);
   assertEquals("retrieved word match persisted one", earth, retrievedWord);
   assertEquals("retrieved word name match ", "earth", retrievedWord.getName());
 }