-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from europeana/EA-3587-stress-test
added dummy services for stress testing
- Loading branch information
Showing
13 changed files
with
303 additions
and
108 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
...le/src/main/java/eu/europeana/api/translation/service/google/DummyGLangDetectService.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,26 @@ | ||
package eu.europeana.api.translation.service.google; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.apache.commons.lang3.StringUtils; | ||
import eu.europeana.api.translation.definitions.service.exception.LanguageDetectionException; | ||
|
||
public class DummyGLangDetectService extends GoogleLangDetectService { | ||
|
||
public DummyGLangDetectService(String googleProjectId, | ||
GoogleTranslationServiceClientWrapper clientWrapperBean) { | ||
super(googleProjectId, clientWrapperBean); | ||
} | ||
|
||
@Override | ||
public List<String> detectLang(List<String> texts, String langHint) | ||
throws LanguageDetectionException { | ||
String value = StringUtils.isNotBlank(langHint) ? langHint : "en"; | ||
ArrayList<String> ret = new ArrayList<>(); | ||
|
||
for (int i = 0; i < texts.size(); i++) { | ||
ret.add(value); | ||
} | ||
return ret; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...gle/src/main/java/eu/europeana/api/translation/service/google/DummyGTranslateService.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,24 @@ | ||
package eu.europeana.api.translation.service.google; | ||
|
||
import java.util.List; | ||
import eu.europeana.api.translation.definitions.service.exception.TranslationException; | ||
|
||
public class DummyGTranslateService extends GoogleTranslationService { | ||
|
||
public DummyGTranslateService(String googleProjectId, | ||
GoogleTranslationServiceClientWrapper clientWrapperBean) { | ||
super(googleProjectId, clientWrapperBean); | ||
} | ||
|
||
@Override | ||
public List<String> translate(List<String> text, String targetLanguage, String sourceLanguage) | ||
throws TranslationException { | ||
return translate(text, null); | ||
} | ||
|
||
@Override | ||
public List<String> translate(List<String> text, String targetLanguage) | ||
throws TranslationException { | ||
return text; | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
.../main/java/eu/europeana/api/translation/service/pangeanic/DummyPangLangDetectService.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,25 @@ | ||
package eu.europeana.api.translation.service.pangeanic; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.apache.commons.lang3.StringUtils; | ||
import eu.europeana.api.translation.definitions.service.exception.LanguageDetectionException; | ||
|
||
public class DummyPangLangDetectService extends PangeanicLangDetectService { | ||
|
||
public DummyPangLangDetectService() { | ||
super(null); | ||
} | ||
|
||
@Override | ||
public List<String> detectLang(List<String> texts, String langHint) | ||
throws LanguageDetectionException { | ||
String value = StringUtils.isNotBlank(langHint) ? langHint : "en"; | ||
ArrayList<String> ret = new ArrayList<>(); | ||
|
||
for (int i = 0; i < texts.size(); i++) { | ||
ret.add(value); | ||
} | ||
return ret; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...main/java/eu/europeana/api/translation/service/pangeanic/DummyPangTranslationService.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,23 @@ | ||
package eu.europeana.api.translation.service.pangeanic; | ||
|
||
import java.util.List; | ||
import eu.europeana.api.translation.definitions.service.exception.TranslationException; | ||
|
||
public class DummyPangTranslationService extends PangeanicTranslationService{ | ||
|
||
public DummyPangTranslationService() { | ||
super(null, null); | ||
} | ||
|
||
@Override | ||
public List<String> translate(List<String> text, String targetLanguage, String sourceLanguage) | ||
throws TranslationException { | ||
return translate(text, null); | ||
} | ||
|
||
@Override | ||
public List<String> translate(List<String> text, String targetLanguage) | ||
throws TranslationException { | ||
return text; | ||
} | ||
} |
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
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
Oops, something went wrong.