Skip to content

Commit

Permalink
EA-3717 address sonarq
Browse files Browse the repository at this point in the history
  • Loading branch information
SrishtiSingh-eu committed Feb 1, 2024
1 parent c399e6b commit 5202492
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void langDetection() throws Exception {
assertNotNull(result);
JSONObject json = new JSONObject(result);
JSONArray langs = json.getJSONArray(TranslationAppConstants.LANGS);
assertTrue(langs.length() == 3);
assertEquals(3,langs.length());
String serviceFieldValue = json.getString(TranslationAppConstants.SERVICE);
assertNotNull(serviceFieldValue);
}
Expand Down Expand Up @@ -106,7 +106,7 @@ void langDetectionGoogle() throws Exception {
assertNotNull(result);
JSONObject json = new JSONObject(result);
JSONArray langs = json.getJSONArray(TranslationAppConstants.LANGS);
assertTrue(langs.length() == 2);
assertEquals(2, langs.length());
String serviceFieldValue = json.getString(TranslationAppConstants.SERVICE);
assertNotNull(serviceFieldValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

import java.util.List;

/**
* Pre processing class for the Language detection flow
* @author srishti singh
* @since 31 Jan 2024
*/
public class LangDetectionPreProcessor implements LanguageDetectionService {

@Override
Expand All @@ -20,6 +25,7 @@ public String getServiceId() {

@Override
public void setServiceId(String serviceId) {
// leave empty

}

Expand All @@ -30,7 +36,7 @@ public List<String> detectLang(List<String> texts, String langHint) throws Langu

@Override
public void close() {

// leave empty, nothing to close
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ private List<String> accumulateLanguages(List<String> texts, List<String> langDe

List<String> languages = new ArrayList<>(texts.size());
int j =0;
for (int i = 0; i < texts.size(); i++) {
if (eligibleValues.contains(texts.get(i))) {
for (String text : texts) {
if (eligibleValues.contains(text)) {
languages.add(langDetected.get(j));
j++;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@

import java.util.List;

/**
* Pre processing class for the Translation flow
* @author srishti singh
* @since 31 Jan 2024
*/
public class TranslationPreProcessor implements TranslationService {

@Override
Expand All @@ -31,7 +36,7 @@ public void translate(List<TranslationObj> translationStrings) throws Translatio

@Override
public void close() {

// leave empty, nothing to close
}

@Override
Expand Down

0 comments on commit 5202492

Please sign in to comment.