This is an automated email from the ASF dual-hosted git repository.
sergeykamov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/master by this push:
new 2ad2eba Tests minor refactoring.
2ad2eba is described below
commit 2ad2eba86acf834f10643dd63012d0e48873140e
Author: Sergey Kamov <[email protected]>
AuthorDate: Wed Aug 5 22:22:31 2020 +0300
Tests minor refactoring.
---
...SqlExampleTest.scala => NCSqlExampleSpec.scala} | 2 +-
.../model/conversation/ConversationTest.java | 69 ----------------------
.../NCConversationSpec.scala} | 33 +++++++----
.../dsl/{NCDslTest.scala => NCDslSpec.scala} | 2 +-
4 files changed, 24 insertions(+), 82 deletions(-)
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/examples/sql/NCSqlExampleTest.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/examples/sql/NCSqlExampleSpec.scala
similarity index 99%
rename from
nlpcraft/src/test/scala/org/apache/nlpcraft/examples/sql/NCSqlExampleTest.scala
rename to
nlpcraft/src/test/scala/org/apache/nlpcraft/examples/sql/NCSqlExampleSpec.scala
index 132a46b..0d00b07 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/examples/sql/NCSqlExampleTest.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/examples/sql/NCSqlExampleSpec.scala
@@ -37,7 +37,7 @@ import scala.compat.java8.OptionConverters._
*
* @see SqlModel
*/
-class NCSqlExampleTest {
+class NCSqlExampleSpec {
private val GSON = new Gson
private val TYPE_RESP = new TypeToken[util.Map[String, Object]]()
{}.getType
private val NORM = Seq("\n", "\r", "\t")
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/conversation/ConversationTest.java
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/conversation/ConversationTest.java
deleted file mode 100644
index 65e7527..0000000
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/conversation/ConversationTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-package org.apache.nlpcraft.model.conversation;
-
-import org.apache.nlpcraft.common.NCException;
-import org.apache.nlpcraft.examples.weather.WeatherModel;
-import org.apache.nlpcraft.model.tools.test.NCTestClient;
-import org.apache.nlpcraft.model.tools.test.NCTestClientBuilder;
-import org.apache.nlpcraft.probe.embedded.NCEmbeddedProbe;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-
-import java.io.IOException;
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-/**
- * @see WeatherModel
- */
-class ConversationTest {
- private NCTestClient cli;
-
- @BeforeEach
- void setUp() throws NCException, IOException {
- NCEmbeddedProbe.start(WeatherModel.class);
-
- cli = new NCTestClientBuilder().newBuilder().build();
-
- cli.open("nlpcraft.weather.ex"); // See weather_model.json
- }
-
- @AfterEach
- void tearDown() throws NCException, IOException {
- if (cli != null)
- cli.close();
-
- NCEmbeddedProbe.stop();
- }
-
- @Test
- void test() throws NCException, IOException {
- assertTrue(cli.ask("What's the weather in Moscow?").isOk());
-
- // Can be answered with conversation.
- assertTrue(cli.ask("Chance of snow?").isOk());
- assertTrue(cli.ask("Moscow").isOk());
-
- cli.clearConversation();
-
- // Cannot be answered without conversation.
- assertTrue(cli.ask("Moscow").isFailed());
- }
-}
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslTest.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/conversation/NCConversationSpec.scala
similarity index 66%
copy from
nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslTest.scala
copy to
nlpcraft/src/test/scala/org/apache/nlpcraft/model/conversation/NCConversationSpec.scala
index c061969..f727284 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslTest.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/conversation/NCConversationSpec.scala
@@ -15,38 +15,38 @@
* limitations under the License.
*/
-package org.apache.nlpcraft.model.intent.dsl
+package org.apache.nlpcraft.model.conversation
import java.io.IOException
import org.apache.nlpcraft.common.NCException
+import org.apache.nlpcraft.examples.weather.WeatherModel
import org.apache.nlpcraft.model.tools.test.{NCTestClient, NCTestClientBuilder}
import org.apache.nlpcraft.probe.embedded.NCEmbeddedProbe
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.{AfterEach, BeforeEach, Test}
/**
- * DSL test model test. Make sure to start up the NLPCraft server before
running this test.
- */
-class NCDslTest {
+ * @see WeatherModel
+ */
+class NCConversationSpec {
private var cli: NCTestClient = _
@BeforeEach
@throws[NCException]
@throws[IOException]
- private[dsl] def setUp(): Unit = {
- // Start embedded probe with the test model.
- NCEmbeddedProbe.start(classOf[NCDslTestModel])
+ private[conversation] def setUp(): Unit = {
+ NCEmbeddedProbe.start(classOf[WeatherModel])
cli = new NCTestClientBuilder().newBuilder.build
- cli.open("nlpcraft.dsl.test")
+ cli.open("nlpcraft.weather.ex") // See weather_model.json
}
@AfterEach
@throws[NCException]
@throws[IOException]
- private[dsl] def tearDown(): Unit = {
+ private[conversation] def tearDown(): Unit = {
if (cli != null)
cli.close()
@@ -56,5 +56,16 @@ class NCDslTest {
@Test
@throws[NCException]
@throws[IOException]
- private[dsl] def test(): Unit = assertTrue(cli.ask("aa").isOk)
-}
\ No newline at end of file
+ private[conversation] def test(): Unit = {
+ assertTrue(cli.ask("What's the weather in Moscow?").isOk)
+
+ // Can be answered with conversation.
+ assertTrue(cli.ask("Chance of snow?").isOk)
+ assertTrue(cli.ask("Moscow").isOk)
+
+ cli.clearConversation()
+
+ // Cannot be answered without conversation.
+ assertTrue(cli.ask("Moscow").isFailed)
+ }
+}
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslTest.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslSpec.scala
similarity index 99%
rename from
nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslTest.scala
rename to
nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslSpec.scala
index c061969..b7c4280 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslTest.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslSpec.scala
@@ -28,7 +28,7 @@ import org.junit.jupiter.api.{AfterEach, BeforeEach, Test}
/**
* DSL test model test. Make sure to start up the NLPCraft server before
running this test.
*/
-class NCDslTest {
+class NCDslSpec {
private var cli: NCTestClient = _
@BeforeEach