Skip to content
This repository was archived by the owner on Oct 14, 2023. It is now read-only.

Commit 97f9664

Browse files
authored
fix: replace get("model") with translationPb.getModel() (#242)
Fixes #240
1 parent 44df12e commit 97f9664

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

google-cloud-translate/src/main/java/com/google/cloud/translate/Translation.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,9 @@ public final boolean equals(Object obj) {
104104
}
105105

106106
static Translation fromPb(TranslationsResource translationPb) {
107-
// TODO remove get("model") as soon as REST apiary supports model
108107
return new Translation(
109108
translationPb.getTranslatedText(),
110109
translationPb.getDetectedSourceLanguage(),
111-
(String) translationPb.get("model"));
110+
translationPb.getModel());
112111
}
113112
}

google-cloud-translate/src/test/java/com/google/cloud/translate/TranslationTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,27 @@ public class TranslationTest {
2525

2626
private static final String TRANSLATED_TEXT = "Hello world";
2727
private static final String SOURCE_LANGUAGE = "en";
28+
private static final String MODEL = "nmt";
2829
private static final TranslationsResource TRANSLATION_PB =
2930
new TranslationsResource()
3031
.setTranslatedText(TRANSLATED_TEXT)
31-
.setDetectedSourceLanguage(SOURCE_LANGUAGE);
32+
.setDetectedSourceLanguage(SOURCE_LANGUAGE)
33+
.setModel(MODEL);
3234
private static final Translation TRANSLATION = Translation.fromPb(TRANSLATION_PB);
3335

3436
@Test
3537
public void testFromPb() {
3638
assertEquals(TRANSLATED_TEXT, TRANSLATION.getTranslatedText());
3739
assertEquals(SOURCE_LANGUAGE, TRANSLATION.getSourceLanguage());
40+
assertEquals(MODEL, TRANSLATION.getModel());
3841
compareTranslation(TRANSLATION, Translation.fromPb(TRANSLATION_PB));
3942
}
4043

4144
private void compareTranslation(Translation expected, Translation value) {
4245
assertEquals(expected, value);
4346
assertEquals(expected.getTranslatedText(), value.getTranslatedText());
4447
assertEquals(expected.getSourceLanguage(), value.getSourceLanguage());
48+
assertEquals(expected.getModel(), value.getModel());
4549
assertEquals(expected.hashCode(), value.hashCode());
4650
assertEquals(expected.toString(), value.toString());
4751
}

0 commit comments

Comments
 (0)