-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#10 ListedLanguages finished and tested
- Loading branch information
1 parent
b981ca9
commit b27a0e1
Showing
2 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/test/java/io/imagineobjects/linguinai/ListedLanguagesTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package io.imagineobjects.linguinai; | ||
|
||
import org.hamcrest.MatcherAssert; | ||
import org.hamcrest.Matchers; | ||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Unit tests for {@link ListedLanguages}. | ||
* @author Mihai Andronache (amihaiemil@gmail.com) | ||
* @version $Id$ | ||
* @since 0.0.1 | ||
*/ | ||
public final class ListedLanguagesTestCase { | ||
|
||
/** | ||
* ListedLanguages can be iterated. | ||
*/ | ||
@Test | ||
public void canBeIterated() { | ||
final Languages languages = new ListedLanguages( | ||
List.of( | ||
Mockito.mock(Language.class), | ||
Mockito.mock(Language.class), | ||
Mockito.mock(Language.class) | ||
) | ||
); | ||
MatcherAssert.assertThat( | ||
languages, | ||
Matchers.iterableWithSize(3) | ||
); | ||
} | ||
|
||
/** | ||
* ListedLanguages can return the best match. | ||
*/ | ||
@Test | ||
public void returnsBestMatch() { | ||
final Language first = Mockito.mock(Language.class); | ||
Mockito.when(first.confidence()).thenReturn(0.5); | ||
final Language second = Mockito.mock(Language.class); | ||
Mockito.when(second.confidence()).thenReturn(0.7); | ||
final Language third = Mockito.mock(Language.class); | ||
Mockito.when(third.confidence()).thenReturn(0.4); | ||
final Languages languages = new ListedLanguages( | ||
List.of(first, second, third) | ||
); | ||
MatcherAssert.assertThat( | ||
languages.bestMatch(), | ||
Matchers.is(second) | ||
); | ||
} | ||
|
||
} |
b27a0e1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amihaiemil I've closed the Issues [#10] since their to-dos disappeared from the code.
The to-dos may have been removed in an earlier commit, but I've found it just now.