-
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
ec2e9a9
commit 76d0948
Showing
6 changed files
with
77 additions
and
4 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
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
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
49 changes: 49 additions & 0 deletions
49
src/test/java/io/github/brenoepics/at4j/data/TranslationTest.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.github.brenoepics.at4j.data; | ||
|
||
import com.fasterxml.jackson.databind.node.JsonNodeFactory; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class TranslationTest { | ||
|
||
@Test | ||
void from_createsTranslationWithGivenParameters() { | ||
Translation translation = Translation.from("en", "Hello"); | ||
|
||
assertEquals("en", translation.getLanguageCode()); | ||
assertEquals("Hello", translation.getText()); | ||
} | ||
|
||
@Test | ||
void ofJSON_createsTranslationFromValidNode() { | ||
ObjectNode node = JsonNodeFactory.instance.objectNode(); | ||
node.put("to", "en"); | ||
node.put("text", "Hello"); | ||
|
||
Translation translation = Translation.ofJSON(node); | ||
|
||
assertNotNull(translation); | ||
assertEquals("en", translation.getLanguageCode()); | ||
assertEquals("Hello", translation.getText()); | ||
} | ||
|
||
@Test | ||
void ofJSON_returnsNullForInvalidNode() { | ||
ObjectNode node = JsonNodeFactory.instance.objectNode(); | ||
node.put("invalid", "data"); | ||
|
||
Translation translation = Translation.ofJSON(node); | ||
|
||
assertNull(translation); | ||
} | ||
|
||
@Test | ||
void toString_returnsCorrectFormat() { | ||
Translation translation = Translation.from("en", "Hello"); | ||
|
||
String expected = "Translation{key='en', value='Hello'}"; | ||
assertEquals(expected, translation.toString()); | ||
} | ||
} |
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
9 changes: 8 additions & 1 deletion
9
src/test/java/io/github/brenoepics/at4j/util/rest/RestRequestResultErrorCodeTest.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