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

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


The following commit(s) were added to refs/heads/NLPCRAFT-91-MODULES by this 
push:
     new 0a21bb5  WIP.
0a21bb5 is described below

commit 0a21bb5a48ba40225142fdd45d7b602db98d0a09
Author: Sergey Kamov <[email protected]>
AuthorDate: Thu Apr 22 22:03:08 2021 +0300

    WIP.
---
 nlpcraft-examples/alarm/pom.xml                    |  7 +++++
 .../examples/alarm/NCTestExampleModelsSpec.scala   | 18 ++++++++---
 nlpcraft-examples/echo/pom.xml                     |  7 +++++
 .../examples/echo/NCTestExampleModelsSpec.scala    | 18 ++++++++---
 nlpcraft-examples/helloworld/pom.xml               |  7 +++++
 .../helloworld/NCTestExampleModelsSpec.scala       | 18 ++++++++---
 nlpcraft-examples/lightswitch/pom.xml              |  7 +++++
 .../lightswitch/LightSwitchGroovyModel.groovy      |  2 +-
 .../examples/lightswitch/LightSwitchJavaModel.java |  2 +-
 .../examples/lightswitch/LightSwitchKotlinModel.kt |  2 +-
 .../examples/lightswitch/LightSwitchModel.scala    |  2 +-
 .../lightswitch/NCTestExampleModelsSpec.scala      | 18 ++++++++---
 .../nlpcraft/example/NCTestExampleModelsSpec.scala | 19 +++++++++---
 .../apache/nlpcraft/examples/sql/SqlModel.scala    |  2 +-
 .../examples/sql/NCTestExampleModelsSpec.scala     | 18 ++++++++---
 .../apache/nlpcraft/examples/time/TimeModel.java   |  2 +-
 .../examples/time/NCTestExampleModelsSpec.scala    | 18 ++++++++---
 nlpcraft-examples/weather/pom.xml                  |  7 +++++
 .../nlpcraft/examples/weather/WeatherModel.java    |  2 +-
 .../examples/weather/NCTestExampleModelsSpec.scala | 36 ++++++++++------------
 .../nlpcraft/server/rest/NCRestAskSpec.scala       | 16 +++++-----
 .../nlpcraft/server/rest/NCRestClearSpec.scala     |  8 ++---
 .../nlpcraft/server/rest/NCRestModelSpec.scala     |  5 +--
 .../nlpcraft/server/rest/RestTestModel.scala       | 24 +++++++++++++--
 24 files changed, 193 insertions(+), 72 deletions(-)

diff --git a/nlpcraft-examples/alarm/pom.xml b/nlpcraft-examples/alarm/pom.xml
index 3a82fd4..a98847d 100644
--- a/nlpcraft-examples/alarm/pom.xml
+++ b/nlpcraft-examples/alarm/pom.xml
@@ -37,6 +37,13 @@
             <artifactId>nlpcraft</artifactId>
             <version>${project.version}</version>
         </dependency>
+
+        <!-- Test dependencies. -->
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala 
b/nlpcraft-examples/alarm/src/test/java/org/apache/nlpcraft/examples/alarm/NCTestExampleModelsSpec.scala
similarity index 58%
copy from 
nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala
copy to 
nlpcraft-examples/alarm/src/test/java/org/apache/nlpcraft/examples/alarm/NCTestExampleModelsSpec.scala
index c054f53..b942742 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala
+++ 
b/nlpcraft-examples/alarm/src/test/java/org/apache/nlpcraft/examples/alarm/NCTestExampleModelsSpec.scala
@@ -15,11 +15,21 @@
  * limitations under the License.
  */
 
-package org.apache.nlpcraft.server.rest
+package org.apache.nlpcraft.examples.alarm
 
-import org.apache.nlpcraft.model.NCModelAdapter
+import org.apache.nlpcraft.model.tools.test.NCTestAutoModelValidator
+import org.junit.jupiter.api.{Assertions, Test}
 
-// TODO:
-class RestTestModel extends NCModelAdapter("", "", "") {
+/**
+  * JUnit example models validation.
+  */
+class NCTestExampleModelsSpec {
+    @Test
+    def test(): Unit = {
+        // Instruct auto-validator what models to test.
+        System.setProperty("NLPCRAFT_TEST_MODELS", 
"org.apache.nlpcraft.examples.alarm.AlarmModel")
 
+        // Start model auto-validator.
+        Assertions.assertTrue(NCTestAutoModelValidator.isValid(),"See error 
logs above.")
+    }
 }
diff --git a/nlpcraft-examples/echo/pom.xml b/nlpcraft-examples/echo/pom.xml
index bcd846d..d9bbe18 100644
--- a/nlpcraft-examples/echo/pom.xml
+++ b/nlpcraft-examples/echo/pom.xml
@@ -37,6 +37,13 @@
             <artifactId>nlpcraft</artifactId>
             <version>${project.version}</version>
         </dependency>
+
+        <!-- Test dependencies. -->
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala 
b/nlpcraft-examples/echo/src/test/java/org/apache/nlpcraft/examples/echo/NCTestExampleModelsSpec.scala
similarity index 59%
copy from 
nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala
copy to 
nlpcraft-examples/echo/src/test/java/org/apache/nlpcraft/examples/echo/NCTestExampleModelsSpec.scala
index c054f53..7805be9 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala
+++ 
b/nlpcraft-examples/echo/src/test/java/org/apache/nlpcraft/examples/echo/NCTestExampleModelsSpec.scala
@@ -15,11 +15,21 @@
  * limitations under the License.
  */
 
-package org.apache.nlpcraft.server.rest
+package org.apache.nlpcraft.examples.echo
 
-import org.apache.nlpcraft.model.NCModelAdapter
+import org.apache.nlpcraft.model.tools.test.NCTestAutoModelValidator
+import org.junit.jupiter.api.{Assertions, Test}
 
-// TODO:
-class RestTestModel extends NCModelAdapter("", "", "") {
+/**
+  * JUnit example models validation.
+  */
+class NCTestExampleModelsSpec {
+    @Test
+    def test(): Unit = {
+        // Instruct auto-validator what models to test.
+        System.setProperty("NLPCRAFT_TEST_MODELS", 
"org.apache.nlpcraft.examples.echo.EchoModel")
 
+        // Start model auto-validator.
+        Assertions.assertTrue(NCTestAutoModelValidator.isValid(),"See error 
logs above.")
+    }
 }
diff --git a/nlpcraft-examples/helloworld/pom.xml 
b/nlpcraft-examples/helloworld/pom.xml
index 9fbdc4b..fcc380f 100644
--- a/nlpcraft-examples/helloworld/pom.xml
+++ b/nlpcraft-examples/helloworld/pom.xml
@@ -37,6 +37,13 @@
             <artifactId>nlpcraft</artifactId>
             <version>${project.version}</version>
         </dependency>
+
+        <!-- Test dependencies. -->
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala 
b/nlpcraft-examples/helloworld/src/test/java/org/apache/nlpcraft/examples/helloworld/NCTestExampleModelsSpec.scala
similarity index 58%
copy from 
nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala
copy to 
nlpcraft-examples/helloworld/src/test/java/org/apache/nlpcraft/examples/helloworld/NCTestExampleModelsSpec.scala
index c054f53..e7c561f 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala
+++ 
b/nlpcraft-examples/helloworld/src/test/java/org/apache/nlpcraft/examples/helloworld/NCTestExampleModelsSpec.scala
@@ -15,11 +15,21 @@
  * limitations under the License.
  */
 
-package org.apache.nlpcraft.server.rest
+package org.apache.nlpcraft.examples.helloworld
 
-import org.apache.nlpcraft.model.NCModelAdapter
+import org.apache.nlpcraft.model.tools.test.NCTestAutoModelValidator
+import org.junit.jupiter.api.{Assertions, Test}
 
-// TODO:
-class RestTestModel extends NCModelAdapter("", "", "") {
+/**
+  * JUnit example models validation.
+  */
+class NCTestExampleModelsSpec {
+    @Test
+    def test(): Unit = {
+        // Instruct auto-validator what models to test.
+        System.setProperty("NLPCRAFT_TEST_MODELS", 
"org.apache.nlpcraft.examples.helloworld.HelloWorldModel")
 
+        // Start model auto-validator.
+        Assertions.assertTrue(NCTestAutoModelValidator.isValid(),"See error 
logs above.")
+    }
 }
diff --git a/nlpcraft-examples/lightswitch/pom.xml 
b/nlpcraft-examples/lightswitch/pom.xml
index 63379d3..9207554 100644
--- a/nlpcraft-examples/lightswitch/pom.xml
+++ b/nlpcraft-examples/lightswitch/pom.xml
@@ -37,6 +37,13 @@
             <artifactId>nlpcraft</artifactId>
             <version>${project.version}</version>
         </dependency>
+
+        <!-- Test dependencies. -->
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git 
a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchGroovyModel.groovy
 
b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchGroovyModel.groovy
index 0cadb57..b8f0cc6 100644
--- 
a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchGroovyModel.groovy
+++ 
b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchGroovyModel.groovy
@@ -34,7 +34,7 @@ import org.apache.nlpcraft.model.*
 class LightSwitchGroovyModel extends NCModelFileAdapter {
     LightSwitchGroovyModel() {
         // Loading the model from the file in the classpath.
-        
super("org/apache/nlpcraft/examples/lightswitch/lightswitch_model.yaml")
+        super("lightswitch_model.yaml")
     }
 
     /**
diff --git 
a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchJavaModel.java
 
b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchJavaModel.java
index 1d7923c..9b81e82 100644
--- 
a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchJavaModel.java
+++ 
b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchJavaModel.java
@@ -37,7 +37,7 @@ import java.util.stream.Collectors;
 public class LightSwitchJavaModel extends NCModelFileAdapter {
     public LightSwitchJavaModel() {
         // Loading the model from the file in the classpath.
-        
super("org/apache/nlpcraft/examples/lightswitch/lightswitch_model.yaml");
+        super("lightswitch_model.yaml");
     }
 
     /**
diff --git 
a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchKotlinModel.kt
 
b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchKotlinModel.kt
index 18862f9..cc87371 100644
--- 
a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchKotlinModel.kt
+++ 
b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchKotlinModel.kt
@@ -33,7 +33,7 @@ import java.util.stream.Collectors
  *
  * See 'README.md' file in the same folder for running and testing 
instructions.
  */
-class LightSwitchKotlinModel : 
NCModelFileAdapter("org/apache/nlpcraft/examples/lightswitch/lightswitch_model.yaml")
 {
+class LightSwitchKotlinModel : NCModelFileAdapter("lightswitch_model.yaml") {
     /**
      * Intent and its on-match callback.
      *
diff --git 
a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchModel.scala
 
b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchModel.scala
index 0eae768..a8f65b1 100644
--- 
a/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchModel.scala
+++ 
b/nlpcraft-examples/lightswitch/src/main/java/org/apache/nlpcraft/examples/lightswitch/LightSwitchModel.scala
@@ -31,7 +31,7 @@ import org.apache.nlpcraft.model.{NCIntentTerm, _}
   * <p>
   * See 'README.md' file in the same folder for running and testing 
instructions.
   */
-class LightSwitchModel extends 
NCModelFileAdapter("org/apache/nlpcraft/examples/lightswitch/lightswitch_model.yaml")
 {
+class LightSwitchModel extends NCModelFileAdapter("lightswitch_model.yaml") {
     /**
       * Intent and its on-match callback.
       *
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala 
b/nlpcraft-examples/lightswitch/src/test/java/org/apache/nlpcraft/examples/lightswitch/NCTestExampleModelsSpec.scala
similarity index 57%
copy from 
nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala
copy to 
nlpcraft-examples/lightswitch/src/test/java/org/apache/nlpcraft/examples/lightswitch/NCTestExampleModelsSpec.scala
index c054f53..ada9677 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala
+++ 
b/nlpcraft-examples/lightswitch/src/test/java/org/apache/nlpcraft/examples/lightswitch/NCTestExampleModelsSpec.scala
@@ -15,11 +15,21 @@
  * limitations under the License.
  */
 
-package org.apache.nlpcraft.server.rest
+package org.apache.nlpcraft.examples.lightswitch
 
-import org.apache.nlpcraft.model.NCModelAdapter
+import org.apache.nlpcraft.model.tools.test.NCTestAutoModelValidator
+import org.junit.jupiter.api.{Assertions, Test}
 
-// TODO:
-class RestTestModel extends NCModelAdapter("", "", "") {
+/**
+  * JUnit example models validation.
+  */
+class NCTestExampleModelsSpec {
+    @Test
+    def test(): Unit = {
+        // Instruct auto-validator what models to test.
+        System.setProperty("NLPCRAFT_TEST_MODELS", 
"org.apache.nlpcraft.examples.lightswitch.LightSwitchJavaModel")
 
+        // Start model auto-validator.
+        Assertions.assertTrue(NCTestAutoModelValidator.isValid(),"See error 
logs above.")
+    }
 }
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala 
b/nlpcraft-examples/minecraft/src/test/kotlin/org/apache/nlpcraft/example/NCTestExampleModelsSpec.scala
similarity index 59%
copy from 
nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala
copy to 
nlpcraft-examples/minecraft/src/test/kotlin/org/apache/nlpcraft/example/NCTestExampleModelsSpec.scala
index c054f53..91687a6 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala
+++ 
b/nlpcraft-examples/minecraft/src/test/kotlin/org/apache/nlpcraft/example/NCTestExampleModelsSpec.scala
@@ -15,11 +15,20 @@
  * limitations under the License.
  */
 
-package org.apache.nlpcraft.server.rest
+package org.apache.nlpcraft.example
 
-import org.apache.nlpcraft.model.NCModelAdapter
-
-// TODO:
-class RestTestModel extends NCModelAdapter("", "", "") {
+import org.apache.nlpcraft.model.tools.test.NCTestAutoModelValidator
+import org.junit.jupiter.api.{Assertions, Test}
+/**
+  * JUnit example models validation.
+  */
+class NCTestExampleModelsSpec {
+    @Test
+    def test(): Unit = {
+        // Instruct auto-validator what models to test.
+        System.setProperty("NLPCRAFT_TEST_MODELS", 
"org.apache.nlpcraft.example.MinecraftModel")
 
+        // Start model auto-validator.
+        Assertions.assertTrue(NCTestAutoModelValidator.isValid(),"See error 
logs above.")
+    }
 }
diff --git 
a/nlpcraft-examples/sql/src/main/java/org/apache/nlpcraft/examples/sql/SqlModel.scala
 
b/nlpcraft-examples/sql/src/main/java/org/apache/nlpcraft/examples/sql/SqlModel.scala
index c05eb00..c0a29f7 100644
--- 
a/nlpcraft-examples/sql/src/main/java/org/apache/nlpcraft/examples/sql/SqlModel.scala
+++ 
b/nlpcraft-examples/sql/src/main/java/org/apache/nlpcraft/examples/sql/SqlModel.scala
@@ -34,7 +34,7 @@ import scala.language.implicitConversions
   *  - File `sql_model.yaml` is modified version of the `sql_model_init.yaml` 
file with additional model elements,
   *    metadata, etc. You can run a diff between these two files to see what 
changes were made.
   */
-class SqlModel extends 
NCModelFileAdapter("org/apache/nlpcraft/examples/sql/sql_model.yaml") with 
LazyLogging {
+class SqlModel extends NCModelFileAdapter("sql_model.yaml") with LazyLogging {
     private final val GSON = new Gson()
     private final val SCHEMA = NCSqlSchemaBuilder.makeSchema(this)
 
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala 
b/nlpcraft-examples/sql/src/test/java/org/apache/nlpcraft/examples/sql/NCTestExampleModelsSpec.scala
similarity index 59%
copy from 
nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala
copy to 
nlpcraft-examples/sql/src/test/java/org/apache/nlpcraft/examples/sql/NCTestExampleModelsSpec.scala
index c054f53..a43f754 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala
+++ 
b/nlpcraft-examples/sql/src/test/java/org/apache/nlpcraft/examples/sql/NCTestExampleModelsSpec.scala
@@ -15,11 +15,21 @@
  * limitations under the License.
  */
 
-package org.apache.nlpcraft.server.rest
+package org.apache.nlpcraft.examples.sql
 
-import org.apache.nlpcraft.model.NCModelAdapter
+import org.apache.nlpcraft.model.tools.test.NCTestAutoModelValidator
+import org.junit.jupiter.api.{Assertions, Test}
 
-// TODO:
-class RestTestModel extends NCModelAdapter("", "", "") {
+/**
+  * JUnit example models validation.
+  */
+class NCTestExampleModelsSpec {
+    @Test
+    def test(): Unit = {
+        // Instruct auto-validator what models to test.
+        System.setProperty("NLPCRAFT_TEST_MODELS", 
"org.apache.nlpcraft.examples.sql.SqlModel")
 
+        // Start model auto-validator.
+        Assertions.assertTrue(NCTestAutoModelValidator.isValid(),"See error 
logs above.")
+    }
 }
diff --git 
a/nlpcraft-examples/time/src/main/java/org/apache/nlpcraft/examples/time/TimeModel.java
 
b/nlpcraft-examples/time/src/main/java/org/apache/nlpcraft/examples/time/TimeModel.java
index 1bdf98e..6a5ebf6 100644
--- 
a/nlpcraft-examples/time/src/main/java/org/apache/nlpcraft/examples/time/TimeModel.java
+++ 
b/nlpcraft-examples/time/src/main/java/org/apache/nlpcraft/examples/time/TimeModel.java
@@ -60,7 +60,7 @@ public class TimeModel extends NCModelFileAdapter {
      * @throws NCException If any errors occur.
      */
     public TimeModel() throws NCException {
-        super("org/apache/nlpcraft/examples/time/time_model.yaml");
+        super("time_model.yaml");
     }
 
     /**
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala 
b/nlpcraft-examples/time/src/test/java/org/apache/nlpcraft/examples/time/NCTestExampleModelsSpec.scala
similarity index 59%
copy from 
nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala
copy to 
nlpcraft-examples/time/src/test/java/org/apache/nlpcraft/examples/time/NCTestExampleModelsSpec.scala
index c054f53..f49aa0b 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala
+++ 
b/nlpcraft-examples/time/src/test/java/org/apache/nlpcraft/examples/time/NCTestExampleModelsSpec.scala
@@ -15,11 +15,21 @@
  * limitations under the License.
  */
 
-package org.apache.nlpcraft.server.rest
+package org.apache.nlpcraft.examples.time
 
-import org.apache.nlpcraft.model.NCModelAdapter
+import org.apache.nlpcraft.model.tools.test.NCTestAutoModelValidator
+import org.junit.jupiter.api.{Assertions, Test}
 
-// TODO:
-class RestTestModel extends NCModelAdapter("", "", "") {
+/**
+  * JUnit example models validation.
+  */
+class NCTestExampleModelsSpec {
+    @Test
+    def test(): Unit = {
+        // Instruct auto-validator what models to test.
+        System.setProperty("NLPCRAFT_TEST_MODELS", 
"org.apache.nlpcraft.examples.sql.SqlModel")
 
+        // Start model auto-validator.
+        Assertions.assertTrue(NCTestAutoModelValidator.isValid(),"See error 
logs above.")
+    }
 }
diff --git a/nlpcraft-examples/weather/pom.xml 
b/nlpcraft-examples/weather/pom.xml
index 9468d03..d0e205e 100644
--- a/nlpcraft-examples/weather/pom.xml
+++ b/nlpcraft-examples/weather/pom.xml
@@ -37,6 +37,13 @@
             <artifactId>nlpcraft</artifactId>
             <version>${project.version}</version>
         </dependency>
+
+        <!-- Test dependencies. -->
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git 
a/nlpcraft-examples/weather/src/main/java/org/apache/nlpcraft/examples/weather/WeatherModel.java
 
b/nlpcraft-examples/weather/src/main/java/org/apache/nlpcraft/examples/weather/WeatherModel.java
index bbdd5c9..9d7de36 100644
--- 
a/nlpcraft-examples/weather/src/main/java/org/apache/nlpcraft/examples/weather/WeatherModel.java
+++ 
b/nlpcraft-examples/weather/src/main/java/org/apache/nlpcraft/examples/weather/WeatherModel.java
@@ -210,7 +210,7 @@ public class WeatherModel extends NCModelFileAdapter {
      */
     public WeatherModel() {
         // Load model from external JSON file on classpath.
-        super("org/apache/nlpcraft/examples/weather/weather_model.json");
+        super("weather_model.json");
     }
 
     @Override
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestClearSpec.scala 
b/nlpcraft-examples/weather/src/test/java/org/apache/nlpcraft/examples/weather/NCTestExampleModelsSpec.scala
similarity index 51%
copy from 
nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestClearSpec.scala
copy to 
nlpcraft-examples/weather/src/test/java/org/apache/nlpcraft/examples/weather/NCTestExampleModelsSpec.scala
index e1581ff..25f24e9 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestClearSpec.scala
+++ 
b/nlpcraft-examples/weather/src/test/java/org/apache/nlpcraft/examples/weather/NCTestExampleModelsSpec.scala
@@ -15,29 +15,27 @@
  * limitations under the License.
  */
 
-package org.apache.nlpcraft.server.rest
+package org.apache.nlpcraft.examples.weather
 
-import org.apache.nlpcraft.NCTestEnvironment
-import org.junit.jupiter.api.Assertions.assertTrue
-import org.junit.jupiter.api.{BeforeEach, Test}
-
-@NCTestEnvironment(model = classOf[RestTestModel], startClient = false)
-class NCRestClearSpec extends NCRestSpec {
-    private var usrId: Long = 0
-
-    @BeforeEach
-    def setUp(): Unit = {
-        post("user/get")(("$.id", (id: Number) ⇒ usrId = id.longValue()))
-
-        assertTrue(usrId > 0)
-    }
+import org.apache.nlpcraft.model.tools.test.NCTestAutoModelValidator
+import org.junit.jupiter.api.{Assertions, Test}
 
+/**
+  * JUnit example models validation.
+  */
+class NCTestExampleModelsSpec {
     @Test
     def test(): Unit = {
-        post("clear/conversation", "mdlId" → "nlpcraft.time.ex")()
-        post("clear/conversation", "mdlId" → "nlpcraft.time.ex", "usrId" → 
usrId)()
+        val maven = System.getProperty("NLPCRAFT_TEST_MAVEN_ENV")
+
+        if (maven == null || maven.toLowerCase != "true") {
+            // Instruct auto-validator what models to test.
+            System.setProperty("NLPCRAFT_TEST_MODELS", 
"org.apache.nlpcraft.examples.weather.WeatherModel")
 
-        post("clear/dialog", "mdlId" → "nlpcraft.time.ex")()
-        post("clear/dialog", "mdlId" → "nlpcraft.time.ex", "usrId" → usrId)()
+            // Start model auto-validator.
+            Assertions.assertTrue(NCTestAutoModelValidator.isValid(),"See 
error logs above.")
+        }
+        else
+            println(s"Test skipped")
     }
 }
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestAskSpec.scala 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestAskSpec.scala
index 8939111..56fc5ba 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestAskSpec.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestAskSpec.scala
@@ -38,19 +38,19 @@ class NCRestAskSpec extends NCRestSpec {
     def testSync(): Unit = {
         post(
             "ask/sync",
-            "txt" → "What's the local time?",
-            "mdlId" → "nlpcraft.time.ex"
+            "txt" → "a",
+            "mdlId" → "rest.test.model"
         )(
             ("$.state.status", (status: String) ⇒ assertEquals("QRY_READY", 
status))
         )
 
         post(
             "ask/sync",
-            "txt" → "What's the local time?",
+            "txt" → "b",
             "enableLog" → true,
             "usrId" → usrId,
             "data" → Map("k1" → "v1", "k1" → "v2").asJava,
-            "mdlId" → "nlpcraft.time.ex"
+            "mdlId" → "rest.test.model"
         )(
             ("$.state.status", (status: String) ⇒ assertEquals("QRY_READY", 
status))
         )
@@ -101,8 +101,8 @@ class NCRestAskSpec extends NCRestSpec {
 
         post(
             "ask",
-            "txt" → "What's the local time?",
-            "mdlId" → "nlpcraft.time.ex"
+            "txt" → "a",
+            "mdlId" → "rest.test.model"
         )(
             ("$.srvReqId", (srvReqId: String) ⇒ id = srvReqId)
         )
@@ -141,8 +141,8 @@ class NCRestAskSpec extends NCRestSpec {
     ): Unit = {
         post(
             if (sync) "ask/sync" else "ask",
-            "txt" → "What's the local time?",
-            "mdlId" → "nlpcraft.time.ex",
+            "txt" → "a",
+            "mdlId" → "rest.test.model",
             "enableLog" → enableLog.orNull,
             "usrId" → usrId.orNull,
             "data" → data.orNull
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestClearSpec.scala 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestClearSpec.scala
index e1581ff..340738a 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestClearSpec.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestClearSpec.scala
@@ -34,10 +34,10 @@ class NCRestClearSpec extends NCRestSpec {
 
     @Test
     def test(): Unit = {
-        post("clear/conversation", "mdlId" → "nlpcraft.time.ex")()
-        post("clear/conversation", "mdlId" → "nlpcraft.time.ex", "usrId" → 
usrId)()
+        post("clear/conversation", "mdlId" → "rest.test.model")()
+        post("clear/conversation", "mdlId" → "rest.test.model", "usrId" → 
usrId)()
 
-        post("clear/dialog", "mdlId" → "nlpcraft.time.ex")()
-        post("clear/dialog", "mdlId" → "nlpcraft.time.ex", "usrId" → usrId)()
+        post("clear/dialog", "mdlId" → "rest.test.model")()
+        post("clear/dialog", "mdlId" → "rest.test.model", "usrId" → usrId)()
     }
 }
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestModelSpec.scala 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestModelSpec.scala
index 37036e6..7ec4888 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestModelSpec.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestModelSpec.scala
@@ -29,12 +29,13 @@ import scala.collection.JavaConverters._
 @NCTestEnvironment(model = classOf[RestTestModel], startClient = false)
 class NCRestModelSpec extends NCRestSpec {
     @Test
+    // TODO:!
     def test(): Unit = {
         def extract(data: java.util.List[java.util.Map[String, Object]]): 
Seq[Double] =
             data.asScala.map(_.get("score").asInstanceOf[Number].doubleValue())
 
         // Note that checked values are valid for current configuration of 
`nlpcraft.alarm.ex` model.
-        post("model/sugsyn", "mdlId" → "nlpcraft.alarm.ex")(
+        post("model/sugsyn", "mdlId" → "rest.test.model")(
             ("$.status", (status: String) ⇒ assertEquals("API_OK", status)),
             ("$.result.suggestions[:1].x:alarm.*", (data: 
java.util.List[java.util.Map[String, Object]]) ⇒ {
                 val scores = extract(data)
@@ -45,7 +46,7 @@ class NCRestModelSpec extends NCRestSpec {
                 assertTrue(scores.exists(_ <= 0.5))
             })
         )
-        post("model/sugsyn", "mdlId" → "nlpcraft.alarm.ex", "minScore" → 0.5)(
+        post("model/sugsyn", "mdlId" → "rest.test.model", "minScore" → 0.5)(
             ("$.status", (status: String) ⇒ assertEquals("API_OK", status)),
             ("$.result.suggestions[:1].x:alarm.*", (data: 
java.util.List[java.util.Map[String, Object]]) ⇒ {
                 val scores = extract(data)
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala
index c054f53..16b25b7 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/RestTestModel.scala
@@ -17,9 +17,27 @@
 
 package org.apache.nlpcraft.server.rest
 
-import org.apache.nlpcraft.model.NCModelAdapter
+import org.apache.nlpcraft.NCTestElement
+import org.apache.nlpcraft.model.{NCElement, NCIntent, NCIntentMatch, 
NCModelAdapter, NCResult}
 
-// TODO:
-class RestTestModel extends NCModelAdapter("", "", "") {
+import java.util
 
+/**
+  * REST test model.
+  */
+class RestTestModel extends NCModelAdapter("rest.test.model", "REST test 
model", "1.0.0") {
+    override def getElements: util.Set[NCElement] =
+        Set(
+            NCTestElement("a"),
+            NCTestElement("b")
+        )
+
+    @NCIntent("intent=onA term(t)={tok_id() == 'a'}")
+    private def a(ctx: NCIntentMatch): NCResult = NCResult.text("OK")
+
+    @NCIntent("intent=onB term(t)={tok_id() == 'b'}")
+    private def b(ctx: NCIntentMatch): NCResult = NCResult.text("OK")
+
+    @NCIntent("intent=onB term(t)={tok_id() == 'a' && tok_id() == 'b'}")
+    private def ab(ctx: NCIntentMatch): NCResult = NCResult.text("OK")
 }

Reply via email to