You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by ar...@apache.org on 2020/04/11 18:50:59 UTC

[incubator-nlpcraft] branch master updated: Fix for NLPCRAFT-35.

This is an automated email from the ASF dual-hosted git repository.

aradzinski 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 914c3c4  Fix for NLPCRAFT-35.
914c3c4 is described below

commit 914c3c403423a25c082526c2a22d32f0697b3661
Author: Aaron Radzinzski <ar...@datalingvo.com>
AuthorDate: Sat Apr 11 11:50:55 2020 -0700

    Fix for NLPCRAFT-35.
---
 .../intent/dsl/{NCDslTest.java => NCDslTest.scala} | 48 ++++++------
 .../nlpcraft/models/stm/NCStmTestModelSpec.java    | 85 ----------------------
 .../nlpcraft/models/stm/NCStmTestModelSpec.scala   | 83 +++++++++++++++++++++
 3 files changed, 107 insertions(+), 109 deletions(-)

diff --git a/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslTest.java b/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslTest.scala
similarity index 53%
rename from src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslTest.java
rename to src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslTest.scala
index 48192f2..c061969 100644
--- a/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslTest.java
+++ b/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslTest.scala
@@ -15,46 +15,46 @@
  * limitations under the License.
  */
 
-package org.apache.nlpcraft.model.intent.dsl;
+package org.apache.nlpcraft.model.intent.dsl
 
-import org.apache.nlpcraft.common.NCException;
-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 java.io.IOException;
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.apache.nlpcraft.common.NCException
+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 {
-    private NCTestClient cli;
+    private var cli: NCTestClient = _
 
     @BeforeEach
-    void setUp() throws NCException, IOException {
+    @throws[NCException]
+    @throws[IOException]
+    private[dsl] def setUp(): Unit = {
         // Start embedded probe with the test model.
-        NCEmbeddedProbe.start(NCDslTestModel.class);
+        NCEmbeddedProbe.start(classOf[NCDslTestModel])
 
-        cli = new NCTestClientBuilder().newBuilder().build();
+        cli = new NCTestClientBuilder().newBuilder.build
 
-        cli.open("nlpcraft.dsl.test");
+        cli.open("nlpcraft.dsl.test")
     }
 
     @AfterEach
-    void tearDown() throws NCException, IOException {
+    @throws[NCException]
+    @throws[IOException]
+    private[dsl] def tearDown(): Unit = {
         if (cli != null)
-            cli.close();
-    
-        NCEmbeddedProbe.stop();
+            cli.close()
+
+        NCEmbeddedProbe.stop()
     }
 
     @Test
-    void test() throws NCException, IOException {
-        assertTrue(cli.ask("aa").isOk());
-    }
-}
+    @throws[NCException]
+    @throws[IOException]
+    private[dsl] def test(): Unit = assertTrue(cli.ask("aa").isOk)
+}
\ No newline at end of file
diff --git a/src/test/scala/org/apache/nlpcraft/models/stm/NCStmTestModelSpec.java b/src/test/scala/org/apache/nlpcraft/models/stm/NCStmTestModelSpec.java
deleted file mode 100644
index 90ba5a2..0000000
--- a/src/test/scala/org/apache/nlpcraft/models/stm/NCStmTestModelSpec.java
+++ /dev/null
@@ -1,85 +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.models.stm;
-
-import org.apache.nlpcraft.common.NCException;
-import org.apache.nlpcraft.model.tools.test.NCTestClient;
-import org.apache.nlpcraft.model.tools.test.NCTestClientBuilder;
-import org.apache.nlpcraft.model.tools.test.NCTestResult;
-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.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-/**
- * Server and probe with deployed org.apache.nlpcraft.models.stm.NCStmTestModel should be started before.
- */
-class NCStmTestModelSpec {
-    private NCTestClient cli;
-    
-    @BeforeEach
-    void setUp() throws NCException, IOException {
-        NCEmbeddedProbe.start(NCStmTestModel.class);
-
-        cli = new NCTestClientBuilder().newBuilder().build();
-        
-        cli.open("nlpcraft.stm.test"); // See phone_model.json
-    }
-    
-    @AfterEach
-    void tearDown() throws NCException, IOException {
-        if (cli != null)
-            cli.close();
-
-        NCEmbeddedProbe.stop();
-    }
-    
-    /**
-     * @param req
-     * @param expResp
-     * @throws IOException
-     */
-    private void check(String req, String expResp) throws IOException {
-        NCTestResult res = cli.ask(req);
-    
-        assertTrue(res.isOk());
-        assertTrue(res.getResult().isPresent());
-        assertEquals(expResp, res.getResult().get());
-    }
-    
-    /**
-     * Checks behaviour. It is based on intents and elements groups.
-     *
-     * @throws Exception
-     */
-    @Test
-    void test() throws Exception {
-        for (int i = 0; i < 3; i++) {
-            check("sale", "sale");
-            check("best", "sale_best_employee");
-            check("buy", "buy");
-            check("best", "buy_best_employee");
-            check("sale", "sale");
-        }
-    }
-}
diff --git a/src/test/scala/org/apache/nlpcraft/models/stm/NCStmTestModelSpec.scala b/src/test/scala/org/apache/nlpcraft/models/stm/NCStmTestModelSpec.scala
new file mode 100644
index 0000000..1070d8e
--- /dev/null
+++ b/src/test/scala/org/apache/nlpcraft/models/stm/NCStmTestModelSpec.scala
@@ -0,0 +1,83 @@
+/*
+ * 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.models.stm
+
+import java.io.IOException
+
+import org.apache.nlpcraft.common.NCException
+import org.apache.nlpcraft.model.tools.test.{NCTestClient, NCTestClientBuilder}
+import org.apache.nlpcraft.probe.embedded.NCEmbeddedProbe
+import org.junit.jupiter.api.Assertions.{assertEquals, assertTrue}
+import org.junit.jupiter.api.{AfterEach, BeforeEach, Test}
+
+/**
+ *
+ */
+class NCStmTestModelSpec {
+    private var cli: NCTestClient = _
+
+    @BeforeEach
+    @throws[NCException]
+    @throws[IOException]
+    private[stm] def setUp(): Unit = {
+        NCEmbeddedProbe.start(classOf[NCStmTestModel])
+
+        cli = new NCTestClientBuilder().newBuilder.build
+
+        cli.open("nlpcraft.stm.test") // See phone_model.json
+    }
+
+    @AfterEach
+    @throws[NCException]
+    @throws[IOException]
+    private[stm] def tearDown(): Unit = {
+        if (cli != null)
+            cli.close()
+
+        NCEmbeddedProbe.stop()
+    }
+
+    /**
+     * @param req
+     * @param expResp
+     * @throws IOException
+     */
+    @throws[IOException]
+    private def check(req: String, expResp: String): Unit = {
+        val res = cli.ask(req)
+
+        assertTrue(res.isOk)
+        assertTrue(res.getResult.isPresent)
+        assertEquals(expResp, res.getResult.get)
+    }
+
+    /**
+     * Checks behaviour. It is based on intents and elements groups.
+     *
+     * @throws Exception
+     */
+    @Test
+    @throws[Exception]
+    private[stm] def test(): Unit = for (i <- 0 until 3) {
+        check("sale", "sale")
+        check("best", "sale_best_employee")
+        check("buy", "buy")
+        check("best", "buy_best_employee")
+        check("sale", "sale")
+    }
+}
\ No newline at end of file