@Test
  public void testAddWordUnknown() throws SpellCheckerInvalidParameterException {
    LanguageRepository languageRepositoryMock = Mockito.mock(LanguageRepository.class);
    Mockito.when(languageRepositoryMock.findByShortCode(KNOWN_LANGUAGE)).thenReturn(enLanguage);
    spellCheckerService.setLanguageRepository(languageRepositoryMock);

    WordRepository wordRepositoryMock = Mockito.mock(WordRepository.class);
    Mockito.when(wordRepositoryMock.findByLanguageAndName(enLanguage, UNKNOWN_WORD))
        .thenReturn(null);
    spellCheckerService.setWordRepository(wordRepositoryMock);

    Boolean isAdded = spellCheckerService.addWord(KNOWN_LANGUAGE, UNKNOWN_WORD);

    assertThat(isAdded).isEqualTo(true);
  }
  @Test
  public void testAddWordWithNullName() {
    SpellCheckerInvalidParameterException exception = null;
    LanguageRepository languageRepositoryMock = Mockito.mock(LanguageRepository.class);
    Mockito.when(languageRepositoryMock.findByShortCode(KNOWN_LANGUAGE)).thenReturn(enLanguage);

    spellCheckerService.setLanguageRepository(languageRepositoryMock);

    try {
      spellCheckerService.addWord(KNOWN_LANGUAGE, null);
    } catch (SpellCheckerInvalidParameterException e) {
      exception = e;
    }
    Assert.assertNotNull(exception);
    Assert.assertEquals(
        SpellCheckerExceptionStatus.INVALID_WORD.toString(), exception.getMessage());
  }
  @Test
  public void testCheckWithUnknownWord() throws SpellCheckerInvalidParameterException {

    LanguageRepository languageRepositoryMock = Mockito.mock(LanguageRepository.class);
    Mockito.when(languageRepositoryMock.findByShortCode(KNOWN_LANGUAGE)).thenReturn(enLanguage);
    spellCheckerService.setLanguageRepository(languageRepositoryMock);

    WordRepository wordRepositoryMock = Mockito.mock(WordRepository.class);
    Mockito.when(wordRepositoryMock.findByLanguageAndName(enLanguage, UNKNOWN_WORD))
        .thenReturn(null);
    spellCheckerService.setWordRepository(wordRepositoryMock);

    Boolean wasFound = spellCheckerService.check(KNOWN_LANGUAGE, UNKNOWN_WORD);

    Assert.assertNotNull(wasFound);
    Assert.assertEquals(false, wasFound);
  }
  // Must return SpellCheckerInvalidParameterException with reason
  // INVALID_LANGUAGE
  @Test
  public void testCheckWithUnknownLanguage() {
    // SpellCheckerInvalidParameterException exception = null;
    SpellCheckerUnknownLanguageException exception = null;
    try {
      LanguageRepository languageRepositoryMock = Mockito.mock(LanguageRepository.class);
      Mockito.when(languageRepositoryMock.findByShortCode(UNKNOWN_LANGUAGE)).thenReturn(null);
      spellCheckerService.setLanguageRepository(languageRepositoryMock);

      spellCheckerService.check(UNKNOWN_LANGUAGE, KNOWN_WORD);

      // } catch (SpellCheckerInvalidParameterException e) {
    } catch (SpellCheckerUnknownLanguageException e) {
      exception = e;
    }

    Assert.assertNotNull(exception);
    // Assert.assertEquals(
    // SpellCheckerExceptionStatus.UNKNOWN_LANGUAGE.toString(),
    // exception.getMessage());
  }
  @Test
  public void testCheckWithNullWord() {
    SpellCheckerInvalidParameterException exception = null;
    try {
      spellCheckerService.check(KNOWN_LANGUAGE, null);

    } catch (SpellCheckerInvalidParameterException e) {
      exception = e;
    }
    Assert.assertNotNull(exception);
    Assert.assertEquals(
        SpellCheckerExceptionStatus.INVALID_WORD.toString(), exception.getMessage());
  }
  @Test
  public void testAddWordWithNewLanguage() {
    Language newLanguage = new Language(UNKNOWN_LANGUAGE);
    Word word = new Word(KNOWN_WORD, newLanguage);

    LanguageRepository languageRepositoryMock = Mockito.mock(LanguageRepository.class);
    Mockito.when(languageRepositoryMock.findByShortCode(UNKNOWN_LANGUAGE)).thenReturn(null);
    spellCheckerService.setLanguageRepository(languageRepositoryMock);

    WordRepository wordRepositoryMock = Mockito.mock(WordRepository.class);
    Mockito.when(wordRepositoryMock.findByLanguageAndName(newLanguage, KNOWN_WORD))
        .thenReturn(word);
    spellCheckerService.setWordRepository(wordRepositoryMock);

    Boolean isAdded = spellCheckerService.addWord(UNKNOWN_LANGUAGE, UNKNOWN_WORD);

    assertThat(isAdded).isNotNull();
    assertThat(isAdded).isEqualTo(true);

    verify(languageRepositoryMock, times(1)).save(Mockito.any(Language.class));
    verify(wordRepositoryMock, times(1)).save(Mockito.any(Word.class));
  }