-
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.
- Loading branch information
1 parent
a728b13
commit 68f5289
Showing
5 changed files
with
334 additions
and
1 deletion.
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
70 changes: 70 additions & 0 deletions
70
src/test/java/io/imagineobjects/linguinai/BulkDetectionITCase.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,70 @@ | ||
package io.imagineobjects.linguinai; | ||
|
||
import org.hamcrest.MatcherAssert; | ||
import org.hamcrest.Matchers; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import java.util.Iterator; | ||
|
||
/** | ||
* RestLinguinAi can detect languages in bulk. | ||
* @author Mihai Andronache (amihaiemil@gmail.com) | ||
* @version $Id$ | ||
* @since 0.0.1 | ||
*/ | ||
public final class BulkDetectionITCase { | ||
|
||
/** | ||
* Linguin.ai API Token. | ||
* @checkstyle StaticVariableName (5 lines) | ||
*/ | ||
private static String TOKEN; | ||
|
||
/** | ||
* Read the API token from maven cmd param. | ||
*/ | ||
@BeforeClass | ||
public static void init() { | ||
String token = System.getProperty("linguin-api-token"); | ||
if(token == null || token.isBlank()) { | ||
throw new IllegalStateException( | ||
"Please specify the linguin-api-token parameter!" | ||
); | ||
} | ||
TOKEN = token; | ||
} | ||
|
||
|
||
/** | ||
* It can detect English, German, Romanian and French in bulk. | ||
*/ | ||
@Test | ||
public void detectsInBulk() { | ||
final LinguinAi linguinAi = new RestLinguinAi(TOKEN); | ||
final BulkDetection bulk = linguinAi.bulkDetect( | ||
"What's up??", | ||
"Woher kommst du?", | ||
"Eu vin din Romania.", | ||
"La langue Francaise..." | ||
); | ||
final Iterator<Languages> languages = bulk.iterator(); | ||
MatcherAssert.assertThat( | ||
languages.next().bestMatch().code(), | ||
Matchers.equalTo("en") | ||
); | ||
MatcherAssert.assertThat( | ||
languages.next().bestMatch().code(), | ||
Matchers.equalTo("de") | ||
); | ||
MatcherAssert.assertThat( | ||
languages.next().bestMatch().code(), | ||
Matchers.equalTo("ro") | ||
); | ||
MatcherAssert.assertThat( | ||
languages.next().bestMatch().code(), | ||
Matchers.equalTo("fr") | ||
); | ||
} | ||
|
||
} |
83 changes: 83 additions & 0 deletions
83
src/test/java/io/imagineobjects/linguinai/SingleDetectITCase.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,83 @@ | ||
package io.imagineobjects.linguinai; | ||
|
||
import org.hamcrest.MatcherAssert; | ||
import org.hamcrest.Matchers; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
/** | ||
* RestLinguinAi can detect a single language. | ||
* @author Mihai Andronache (amihaiemil@gmail.com) | ||
* @version $Id$ | ||
* @since 0.0.1 | ||
*/ | ||
public final class SingleDetectITCase { | ||
|
||
/** | ||
* Linguin.ai API Token. | ||
* @checkstyle StaticVariableName (5 lines) | ||
*/ | ||
private static String TOKEN; | ||
|
||
/** | ||
* Read the API token from maven cmd param. | ||
*/ | ||
@BeforeClass | ||
public static void init() { | ||
String token = System.getProperty("linguin-api-token"); | ||
if(token == null || token.isBlank()) { | ||
throw new IllegalStateException( | ||
"Please specify the linguin-api-token parameter!" | ||
); | ||
} | ||
TOKEN = token; | ||
} | ||
|
||
/** | ||
* It can detect English. | ||
*/ | ||
@Test | ||
public void detectsEnglish() { | ||
final LinguinAi linguinAi = new RestLinguinAi(TOKEN); | ||
MatcherAssert.assertThat( | ||
linguinAi.detect("What's up??").bestMatch().code(), | ||
Matchers.equalTo("en") | ||
); | ||
} | ||
|
||
/** | ||
* It can detect German. | ||
*/ | ||
@Test | ||
public void detectsGerman() { | ||
final LinguinAi linguinAi = new RestLinguinAi(TOKEN); | ||
MatcherAssert.assertThat( | ||
linguinAi.detect("Woher kommst du?").bestMatch().code(), | ||
Matchers.equalTo("de") | ||
); | ||
} | ||
|
||
/** | ||
* It can detect Romanian. | ||
*/ | ||
@Test | ||
public void detectsRomanian() { | ||
final LinguinAi linguinAi = new RestLinguinAi(TOKEN); | ||
MatcherAssert.assertThat( | ||
linguinAi.detect("Eu vin din Romania.").bestMatch().code(), | ||
Matchers.equalTo("ro") | ||
); | ||
} | ||
|
||
/** | ||
* It can detect French. | ||
*/ | ||
@Test | ||
public void detectsFrench() { | ||
final LinguinAi linguinAi = new RestLinguinAi(TOKEN); | ||
MatcherAssert.assertThat( | ||
linguinAi.detect("La langue Francaise...").bestMatch().code(), | ||
Matchers.equalTo("fr") | ||
); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/test/java/io/imagineobjects/linguinai/StatusITCase.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,49 @@ | ||
package io.imagineobjects.linguinai; | ||
|
||
import org.hamcrest.MatcherAssert; | ||
import org.hamcrest.Matchers; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
/** | ||
* RestLinguinAi can return the account status. | ||
* @author Mihai Andronache (amihaiemil@gmail.com) | ||
* @version $Id$ | ||
* @since 0.0.1 | ||
*/ | ||
public final class StatusITCase { | ||
|
||
/** | ||
* Linguin.ai API Token. | ||
* @checkstyle StaticVariableName (5 lines) | ||
*/ | ||
private static String TOKEN; | ||
|
||
/** | ||
* Read the API token from maven cmd param. | ||
*/ | ||
@BeforeClass | ||
public static void init() { | ||
String token = System.getProperty("linguin-api-token"); | ||
if(token == null || token.isBlank()) { | ||
throw new IllegalStateException( | ||
"Please specify the linguin-api-token parameter!" | ||
); | ||
} | ||
TOKEN = token; | ||
} | ||
|
||
/** | ||
* It can return the Status. | ||
*/ | ||
@Test | ||
public void returnsStatus() { | ||
final LinguinAi linguinAi = new RestLinguinAi(TOKEN); | ||
final Status status = linguinAi.status(); | ||
MatcherAssert.assertThat( | ||
status.dailyLimit(), | ||
Matchers.equalTo(100) | ||
); | ||
} | ||
|
||
} |
60 changes: 60 additions & 0 deletions
60
src/test/java/io/imagineobjects/linguinai/SupportedLanguagesITCase.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,60 @@ | ||
package io.imagineobjects.linguinai; | ||
|
||
import org.hamcrest.MatcherAssert; | ||
import org.hamcrest.Matchers; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import java.util.Arrays; | ||
|
||
/** | ||
* RestLinguinAi can return the SupportedLanguages. | ||
* @author Mihai Andronache (amihaiemil@gmail.com) | ||
* @version $Id$ | ||
* @since 0.0.1 | ||
*/ | ||
public final class SupportedLanguagesITCase { | ||
|
||
/** | ||
* Linguin.ai API Token. | ||
* @checkstyle StaticVariableName (5 lines) | ||
*/ | ||
private static String TOKEN; | ||
|
||
/** | ||
* Read the API token from maven cmd param. | ||
*/ | ||
@BeforeClass | ||
public static void init() { | ||
String token = System.getProperty("linguin-api-token"); | ||
if(token == null || token.isBlank()) { | ||
throw new IllegalStateException( | ||
"Please specify the linguin-api-token parameter!" | ||
); | ||
} | ||
TOKEN = token; | ||
} | ||
|
||
/** | ||
* Can return them. | ||
*/ | ||
@Test | ||
public void returnsSupportedLanguages() { | ||
final LinguinAi linguinAi = new RestLinguinAi(TOKEN); | ||
final SupportedLanguages languages = linguinAi.languages(); | ||
final SupportedLanguage first = languages.iterator().next(); | ||
MatcherAssert.assertThat( | ||
first.code(), | ||
Matchers.equalTo("ab") | ||
); | ||
MatcherAssert.assertThat( | ||
Arrays.toString(first.englishNames()), | ||
Matchers.equalTo("[Abkhazian]") | ||
); | ||
MatcherAssert.assertThat( | ||
Arrays.toString(first.nativeNames()), | ||
Matchers.equalTo("[аҧсуа бызшәа, аҧсшәа]") | ||
); | ||
} | ||
|
||
} |