WSMicrosoftMTAdapterV3 extends WSBaseMTAdapter { @Override protected WSLanguagePair[] composeLanguagePairs(WSLanguage[] languages) { ArrayList<WSLanguagePair> pairs = new ArrayList<>(); HashSet supportedLangs = new HashSet(Arrays.asList("af", "ar", "bg", "bn", "bs", "ca", "cs", "cy", "da", "de", "el", "en", "es", "et", "fa", "fi", "fil", "fj", "fr", "he", "hi", "hr", "ht", "hu", "id", "is", "it", "ja", "ko", "lt", "lv", "mg", "ms", "mt", "mww", "nb", "nl", "otq", "pl", "pt", "ro", "ru", "sk", "sl", "sm", "sr", "sv", "sw", "ta", "te", "th", "tlh", "to", "tr", "ty", "uk", "ur", "vi", "yua", "yue", "zh")); for (int i = 0; i < languages.length; i++) { for (int j = 0; j < languages.length; j++) { String sourceLang = languages[i].getLocale().getLanguage(); String targetLang = languages[j].getLocale().getLanguage(); boolean sourceLangValid = supportedLangs.contains(sourceLang); boolean targetLangValid = supportedLangs.contains(targetLang); if (i != j && sourceLangValid && targetLangValid) { pairs.add(new WSLanguagePair(languages[i], languages[j])); } } } return pairs.toArray(new WSLanguagePair[pairs.size()]); }  @Override String getName(); @Override String getDescription(); @Override String getVersion(); @Override WSComponentConfigurationUI getConfigurationUI(); @Override void translate(WSContext context, WSMTRequest[] requests, WSLanguage source, WSLanguage target); String getSourceString(List<WSMTRequest> requests);  }
@Test public void testSupportedLanguages() { WSMicrosoftMTAdapterV3 connector = new WSMicrosoftMTAdapterV3(); WSLanguage english = mock(WSLanguage.class); when(english.getLocale()).thenReturn(Locale.ENGLISH); WSLanguage french = mock(WSLanguage.class); when(french.getLocale()).thenReturn(Locale.FRENCH); WSLanguage afarNotSupported = mock(WSLanguage.class); Locale afarLocale = new Locale("aa"); when(afarNotSupported.getLocale()).thenReturn(afarLocale); WSLanguage[] languages = {english, french, afarNotSupported}; WSLanguagePair[] langPairs = connector.composeLanguagePairs(languages); assertEquals(2, langPairs.length); }