-
Notifications
You must be signed in to change notification settings - Fork 3
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
9427fef
commit 8b062ec
Showing
1 changed file
with
102 additions
and
0 deletions.
There are no files selected for viewing
102 changes: 102 additions & 0 deletions
102
src/test/java/com/github/brenoepics/at4j/data/request/TranslateParamsTest.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,102 @@ | ||
package com.github.brenoepics.at4j.data.request; | ||
|
||
import com.github.brenoepics.at4j.data.request.optional.ProfanityAction; | ||
import com.github.brenoepics.at4j.data.request.optional.ProfanityMarker; | ||
import com.github.brenoepics.at4j.data.request.optional.TextType; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class TranslateParamsTest { | ||
|
||
@Test | ||
void shouldSetAndGetText() { | ||
TranslateParams params = new TranslateParams("Hello", List.of("fr")); | ||
params.setText("Bonjour"); | ||
assertEquals("Bonjour", params.getText()); | ||
} | ||
|
||
@Test | ||
void shouldSetAndGetTextType() { | ||
TranslateParams params = new TranslateParams("Hello", List.of("fr")); | ||
params.setTextType(TextType.HTML); | ||
assertEquals(TextType.HTML, params.getTextType()); | ||
} | ||
|
||
@Test | ||
void shouldSetAndGetProfanityAction() { | ||
TranslateParams params = new TranslateParams("Hello", List.of("fr")); | ||
params.setProfanityAction(ProfanityAction.MARKED); | ||
assertEquals(ProfanityAction.MARKED, params.getProfanityAction()); | ||
} | ||
|
||
@Test | ||
void shouldSetAndGetProfanityMarker() { | ||
TranslateParams params = new TranslateParams("Hello", List.of("fr")); | ||
params.setProfanityMarker(ProfanityMarker.TAG); | ||
assertEquals(ProfanityMarker.TAG, params.getProfanityMarker()); | ||
} | ||
|
||
@Test | ||
void shouldSetAndGetIncludeAlignment() { | ||
TranslateParams params = new TranslateParams("Hello", List.of("fr")); | ||
params.setIncludeAlignment(true); | ||
assertTrue(params.getIncludeAlignment()); | ||
} | ||
|
||
@Test | ||
void shouldSetAndGetIncludeSentenceLength() { | ||
TranslateParams params = new TranslateParams("Hello", List.of("fr")); | ||
params.setIncludeSentenceLength(true); | ||
assertTrue(params.getIncludeSentenceLength()); | ||
} | ||
|
||
@Test | ||
void shouldSetAndGetSourceLanguage() { | ||
TranslateParams params = new TranslateParams("Hello", List.of("fr")); | ||
params.setSourceLanguage("en"); | ||
assertEquals("en", params.getSourceLanguage()); | ||
} | ||
|
||
@Test | ||
void shouldSetAndGetTargetLanguages() { | ||
TranslateParams params = new TranslateParams("Hello", List.of("fr")); | ||
params.setTargetLanguages("de", "it"); | ||
assertTrue(params.getTargetLanguages().containsAll(Arrays.asList("de", "it"))); | ||
} | ||
|
||
@Test | ||
void shouldSetAndGetSuggestedFromLanguage() { | ||
TranslateParams params = new TranslateParams("Hello", List.of("fr")); | ||
params.setSuggestedFromLanguage("en"); | ||
assertEquals("en", params.getSuggestedFromLanguage()); | ||
} | ||
|
||
@Test | ||
void shouldGetQueryParameters() { | ||
TranslateParams params = new TranslateParams("Hello", List.of("fr")); | ||
params.setSourceLanguage("en"); | ||
params.setTextType(TextType.HTML); | ||
params.setProfanityAction(ProfanityAction.MARKED); | ||
params.setProfanityMarker(ProfanityMarker.TAG); | ||
params.setIncludeAlignment(true); | ||
params.setIncludeSentenceLength(true); | ||
params.setSuggestedFromLanguage("en"); | ||
|
||
Map<String, String> expectedParams = new HashMap<>(); | ||
expectedParams.put("from", "en"); | ||
expectedParams.put("textType", "html"); | ||
expectedParams.put("profanityAction", "Marked"); | ||
expectedParams.put("profanityMarker", "Tag"); | ||
expectedParams.put("includeAlignment", "true"); | ||
expectedParams.put("includeSentenceLength", "true"); | ||
expectedParams.put("suggestedFrom", "en"); | ||
|
||
assertEquals(expectedParams, params.getQueryParameters()); | ||
} | ||
} |