WSMicrosoftMTAdapter extends WSBaseMTAdapter { @Override protected BaseConnector getMTConnector() { MicrosoftMTConnector connector = new MicrosoftMTConnector(); WSMTAdapterConfigurationData configurationData = getConfigurationData(); connector.getParameters().setAzureKey(configurationData.getAzureKey()); connector.getParameters().setCategory(configurationData.getCategory()); logger.info("Using configuration: category={}", configurationData.getCategory()); return connector; }  String getName(); String getDescription(); @Override String getVersion(); @Override WSComponentConfigurationUI getConfigurationUI();  }
@Test public void testSomeFilteredResponses() { WSMicrosoftMTAdapter mtAdapter = spy(new WSMicrosoftMTAdapter()); doReturn(mtConnector).when(mtAdapter).getMTConnector(); when(mtConnector.getParameters()).thenReturn(parameters); when(wsLanguage.getLocale()).thenReturn(Locale.ENGLISH); when(mtConnector.batchQueryText(anyList())).thenReturn(getBatchQueryResults( "First segment", "Third segment" )); WSMTRequest[] requests = getWSMTRequestStabs("First segment", "Second segment", "Third segment"); mtAdapter.translate(wsContext, requests, wsLanguage, wsLanguage); assertEquals(1, requests[0].getMTResults().length); assertEquals(0, requests[1].getMTResults().length); assertEquals(1, requests[2].getMTResults().length); assertEquals(requests[0].getMTResults()[0].getTranslation(), "First segment"); assertEquals(requests[2].getMTResults()[0].getTranslation(), "Third segment"); }
@Test public void testWSResultsAreSetOnWSRequest() { WSMicrosoftMTAdapter mtAdapter = spy(new WSMicrosoftMTAdapter()); doReturn(mtConnector).when(mtAdapter).getMTConnector(); when(mtConnector.getParameters()).thenReturn(parameters); when(wsLanguage.getLocale()).thenReturn(Locale.ENGLISH); when(mtConnector.batchQueryText(anyList())).thenReturn(getBatchQueryResults( "First segment", "Second segment", "Third segment" )); WSMTRequest[] requests = getWSMTRequestStabs("First segment", "Second segment", "Third segment"); mtAdapter.translate(wsContext, requests, wsLanguage, wsLanguage); for (WSMTRequest request : requests) { assertEquals(request.getMTResults().length, 1); } assertEquals(requests[0].getMTResults()[0].getTranslation(), "First segment"); assertEquals(requests[1].getMTResults()[0].getTranslation(), "Second segment"); assertEquals(requests[2].getMTResults()[0].getTranslation(), "Third segment"); }