From bd4279045feb54378599898ec9444cd06d27320c Mon Sep 17 00:00:00 2001 From: Danil Skachkov Date: Fri, 11 Nov 2016 16:31:00 +0700 Subject: [PATCH] Changes in tests --- .../java/ai/api/test/ProtocolDevTest.java | 119 ------------------ .../java/ai/api/test/ProtocolTestBase.java | 2 +- .../compatibility/V20150415ProtocolTest.java | 69 ---------- 3 files changed, 1 insertion(+), 189 deletions(-) delete mode 100644 libai/src/test/java/ai/api/test/ProtocolDevTest.java delete mode 100644 libai/src/test/java/ai/api/test/compatibility/V20150415ProtocolTest.java diff --git a/libai/src/test/java/ai/api/test/ProtocolDevTest.java b/libai/src/test/java/ai/api/test/ProtocolDevTest.java deleted file mode 100644 index acc982b..0000000 --- a/libai/src/test/java/ai/api/test/ProtocolDevTest.java +++ /dev/null @@ -1,119 +0,0 @@ -package ai.api.test; - -/** - * ******************************************************************************************************************** - * - * API.AI Java SDK - client-side libraries for API.AI - * ================================================= - * - * Copyright (C) 2014 by Speaktoit, Inc. (https://www.speaktoit.com) - * https://www.api.ai - * - * ********************************************************************************************************************** - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * ********************************************************************************************************************* - */ - -import ai.api.util.StringUtils; -import org.junit.Test; - -import ai.api.AIConfiguration; -import ai.api.AIDataService; -import ai.api.AIServiceException; -import ai.api.model.AIRequest; -import ai.api.model.AIResponse; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; - -public class ProtocolDevTest extends ProtocolTestBase { - - // Testing keys - protected static final String ACCESS_TOKEN = "a410386b327946c6ac162aad10cf9788"; - - @Override - protected String getAccessToken() { - return ACCESS_TOKEN; - } - - @Override - protected String getSecondAccessToken() { - return "212bf93686444afab30e20ed6f2dff1d"; - } - - @Override - protected String getRuAccessToken() { - return "e479d45dc09046c1984d6c546973dd60"; - } - - @Override - protected String getBrAccessToken() { - return ""; - } - - @Override - protected String getPtBrAccessToken() { - return "2291f2e31fe34a2fab224fd228c39bf2"; - } - - @Override - protected String getJaAccessToken() { - return "c82b0a650c9a4758984fb53411f271e4"; - } - - private final String DEV_URL = "https://dev.api.ai/api/"; - - @Override - protected void updateConfig(final AIConfiguration config) { - config.setServiceUrl(DEV_URL); - } - - @Test - public void AIDataServiceDevRuTest() throws AIServiceException { - final AIConfiguration config = new AIConfiguration("e479d45dc09046c1984d6c546973dd60", - AIConfiguration.SupportedLanguages.Russian); - - config.setServiceUrl(DEV_URL); - - final AIDataService aiDataService = new AIDataService(config); - - final AIRequest aiRequest = new AIRequest(); - aiRequest.setQuery("привет"); - - final AIResponse aiResponse = makeRequest(aiDataService, aiRequest); - - assertFalse(StringUtils.isEmpty(aiResponse.getResult().getResolvedQuery())); - assertEquals("helloAction", aiResponse.getResult().getAction()); - assertEquals("Добрый день", aiResponse.getResult().getFulfillment().getSpeech()); - - } - - @Test - public void AIDataServiceDevTest() throws AIServiceException { - final AIConfiguration config = new AIConfiguration(getAccessToken(), - AIConfiguration.SupportedLanguages.English); - - config.setServiceUrl(DEV_URL); - - final AIDataService aiDataService = new AIDataService(config); - - final AIRequest aiRequest = new AIRequest(); - aiRequest.setQuery("hello"); - - final AIResponse aiResponse = makeRequest(aiDataService, aiRequest); - - assertFalse(StringUtils.isEmpty(aiResponse.getResult().getResolvedQuery())); - assertEquals("greeting", aiResponse.getResult().getAction()); - assertEquals("Hi! How are you?", aiResponse.getResult().getFulfillment().getSpeech()); - - } - -} diff --git a/libai/src/test/java/ai/api/test/ProtocolTestBase.java b/libai/src/test/java/ai/api/test/ProtocolTestBase.java index 6af83bd..a8b4800 100644 --- a/libai/src/test/java/ai/api/test/ProtocolTestBase.java +++ b/libai/src/test/java/ai/api/test/ProtocolTestBase.java @@ -785,7 +785,7 @@ public void testSourceField() throws AIServiceException { assertEquals("Yes, it is not from domains", agentResponse.getResult().getFulfillment().getSpeech()); } - @Test + //@Test TODO public void locationFieldTest() throws AIServiceException { final AIDataService aiDataService = createDataService("23e7d37f6dd24e4eb7dbbd7491f832cf"); diff --git a/libai/src/test/java/ai/api/test/compatibility/V20150415ProtocolTest.java b/libai/src/test/java/ai/api/test/compatibility/V20150415ProtocolTest.java deleted file mode 100644 index 82e747a..0000000 --- a/libai/src/test/java/ai/api/test/compatibility/V20150415ProtocolTest.java +++ /dev/null @@ -1,69 +0,0 @@ -package ai.api.test.compatibility; - -/*********************************************************************************************************************** - * - * API.AI Java SDK - client-side libraries for API.AI - * ================================================= - * - * Copyright (C) 2015 by Speaktoit, Inc. (https://www.speaktoit.com) - * https://www.api.ai - * - * ********************************************************************************************************************* - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - ***********************************************************************************************************************/ - -import org.junit.Test; - -import java.util.Collections; -import java.util.List; - -import ai.api.AIConfiguration; -import ai.api.AIDataService; -import ai.api.AIServiceException; -import ai.api.model.AIContext; -import ai.api.model.AIRequest; -import ai.api.model.AIResponse; - -import static org.junit.Assert.assertEquals; - -/** - * Test for backward compatibility to the first protocol version ("20150415") - */ -public class V20150415ProtocolTest { - private static final String PROTOCOL_VERSION = "20150415"; - - @Test - public void legacyContextsWithoutParametersTest() throws AIServiceException { - final AIConfiguration config = new AIConfiguration( - "3485a96fb27744db83e78b8c4bc9e7b7", - AIConfiguration.SupportedLanguages.English); - - config.setProtocolVersion(PROTOCOL_VERSION); - - final AIDataService aiDataService = new AIDataService(config); - - final AIContext weatherContext = new AIContext("weather"); - weatherContext.setParameters(Collections.singletonMap("location", "London")); - - final List contexts = Collections.singletonList(weatherContext); - - final AIRequest aiRequest = new AIRequest(); - aiRequest.setQuery("and for tomorrow"); - aiRequest.setContexts(contexts); - - final AIResponse aiResponse = aiDataService.request(aiRequest); - - // Old protocol doesn't support parameters, so response will not contains city name - assertEquals("Weather in for tomorrow", aiResponse.getResult().getFulfillment().getSpeech()); - - } -}