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

[incubator-nlpcraft] 01/01: Tests converted.

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

sergeykamov pushed a commit to branch NLPCRAFT-35
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git

commit 4f2d2c5fabae2095f6dcd47efb76f719b7ff7222
Author: Sergey Kamov <se...@apache.org>
AuthorDate: Sat Apr 11 20:35:46 2020 +0300

    Tests converted.
---
 .../nlpcraft/models/stm/NCStmTestModelSpec.java    | 85 ----------------------
 .../nlpcraft/models/stm/NCStmTestModelSpec.scala   | 83 +++++++++++++++++++++
 2 files changed, 83 insertions(+), 85 deletions(-)

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