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

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

commit 167461bdc596f3fa79044379f06d0e9e4af0fb6d
Author: Sergey Kamov <[email protected]>
AuthorDate: Thu Aug 25 12:07:23 2022 +0300

    IDL fragments related fixes.
---
 .../examples/lightswitch/LightSwitchFrModel.scala  |  5 +--
 .../examples/lightswitch/LightSwitchRuModel.scala  |  5 +--
 .../lightswitch/LightSwitchScalaModel.scala        |  5 +--
 .../apache/nlpcraft/examples/time/TimeModel.scala  |  2 +-
 .../main/scala/org/apache/nlpcraft/NCResult.scala  |  6 +++
 .../internal/intent/compiler/NCIDLCompiler.scala   | 13 ++++--
 .../conversation/NCConversationTimeoutSpec.scala   |  2 +-
 .../internal/impl/NCModelCallbacksSpec.scala       | 10 ++---
 .../nlpcraft/internal/impl/NCModelClientSpec.scala |  4 +-
 .../internal/impl/NCModelClientSpec3.scala         |  2 +-
 .../impl/scan/NCModelIntentsInvalidArgsSpec.scala  |  2 +-
 .../compiler/NCIDLFragmentsOverridingSpec.scala    | 50 ++++++++++++++++++++++
 .../apache/nlpcraft/nlp/NCEntityEnricherSpec.scala |  2 +-
 .../apache/nlpcraft/nlp/NCEntityMapperSpec.scala   |  2 +-
 .../nlpcraft/nlp/NCEntityValidatorSpec.scala       |  2 +-
 .../apache/nlpcraft/nlp/NCTokenEnricherSpec.scala  |  2 +-
 .../apache/nlpcraft/nlp/NCTokenValidatorSpec.scala |  2 +-
 .../apache/nlpcraft/nlp/NCVariantFilterSpec.scala  |  2 +-
 .../apache/nlpcraft/nlp/util/NCTestResult.scala    |  7 ++-
 19 files changed, 89 insertions(+), 36 deletions(-)

diff --git 
a/nlpcraft-examples/lightswitch-fr/src/main/scala/org/apache/nlpcraft/examples/lightswitch/LightSwitchFrModel.scala
 
b/nlpcraft-examples/lightswitch-fr/src/main/scala/org/apache/nlpcraft/examples/lightswitch/LightSwitchFrModel.scala
index 7989fe05..494d098d 100644
--- 
a/nlpcraft-examples/lightswitch-fr/src/main/scala/org/apache/nlpcraft/examples/lightswitch/LightSwitchFrModel.scala
+++ 
b/nlpcraft-examples/lightswitch-fr/src/main/scala/org/apache/nlpcraft/examples/lightswitch/LightSwitchFrModel.scala
@@ -68,7 +68,4 @@ class LightSwitchFrModel extends NCModelAdapter(
 
         // Add HomeKit, Arduino or other integration here.
         // By default - just return a descriptive action string.
-        NCResult(
-            new Gson().toJson(Map("locations" -> locations, "action" -> 
action).asJava),
-            NCResultType.ASK_RESULT
-        )
\ No newline at end of file
+        NCResult(new Gson().toJson(Map("locations" -> locations, "action" -> 
action).asJava))
\ No newline at end of file
diff --git 
a/nlpcraft-examples/lightswitch-ru/src/main/scala/org/apache/nlpcraft/examples/lightswitch/LightSwitchRuModel.scala
 
b/nlpcraft-examples/lightswitch-ru/src/main/scala/org/apache/nlpcraft/examples/lightswitch/LightSwitchRuModel.scala
index ef6063ab..81021e4e 100644
--- 
a/nlpcraft-examples/lightswitch-ru/src/main/scala/org/apache/nlpcraft/examples/lightswitch/LightSwitchRuModel.scala
+++ 
b/nlpcraft-examples/lightswitch-ru/src/main/scala/org/apache/nlpcraft/examples/lightswitch/LightSwitchRuModel.scala
@@ -60,7 +60,4 @@ class LightSwitchRuModel extends NCModelAdapter(
 
         // Add HomeKit, Arduino or other integration here.
         // By default - just return a descriptive action string.
-        NCResult(
-           new Gson().toJson(Map("locations" -> locations, "action" -> 
action).asJava),
-           NCResultType.ASK_RESULT
-        )
\ No newline at end of file
+        NCResult(new Gson().toJson(Map("locations" -> locations, "action" -> 
action).asJava))
\ No newline at end of file
diff --git 
a/nlpcraft-examples/lightswitch/src/main/scala/org/apache/nlpcraft/examples/lightswitch/LightSwitchScalaModel.scala
 
b/nlpcraft-examples/lightswitch/src/main/scala/org/apache/nlpcraft/examples/lightswitch/LightSwitchScalaModel.scala
index 42b43495..df159909 100644
--- 
a/nlpcraft-examples/lightswitch/src/main/scala/org/apache/nlpcraft/examples/lightswitch/LightSwitchScalaModel.scala
+++ 
b/nlpcraft-examples/lightswitch/src/main/scala/org/apache/nlpcraft/examples/lightswitch/LightSwitchScalaModel.scala
@@ -59,7 +59,4 @@ class LightSwitchScalaModel extends NCModelAdapter(
 
         // Add HomeKit, Arduino or other integration here.=
         // By default - just return a descriptive action string.
-        NCResult(
-            s"Lights are [$status] in [${locations.toLowerCase}].",
-            NCResultType.ASK_RESULT
-        )
\ No newline at end of file
+        NCResult(s"Lights are [$status] in [${locations.toLowerCase}].")
\ No newline at end of file
diff --git 
a/nlpcraft-examples/time/src/main/scala/org/apache/nlpcraft/examples/time/TimeModel.scala
 
b/nlpcraft-examples/time/src/main/scala/org/apache/nlpcraft/examples/time/TimeModel.scala
index 89c8fadb..4524a817 100644
--- 
a/nlpcraft-examples/time/src/main/scala/org/apache/nlpcraft/examples/time/TimeModel.scala
+++ 
b/nlpcraft-examples/time/src/main/scala/org/apache/nlpcraft/examples/time/TimeModel.scala
@@ -66,7 +66,7 @@ class TimeModel extends NCModelAdapter(
             )
 
         try
-            NCResult(new ObjectMapper(new YAMLFactory).writeValueAsString(m), 
NCResultType.ASK_RESULT)
+            NCResult(new ObjectMapper(new YAMLFactory).writeValueAsString(m))
         catch
             case e: JsonProcessingException => throw new 
RuntimeException("YAML conversion error.", e)
 
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCResult.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCResult.scala
index 67bd4789..0dfaca5c 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCResult.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCResult.scala
@@ -33,6 +33,12 @@ object NCResult:
             def getType: NCResultType = resultType
             def getIntentId: Option[String] = None
 
+    def apply(body: Any): NCResult =
+        new NCResult() :
+            def getBody: Any = body
+            def getType: NCResultType = NCResultType.ASK_RESULT
+            def getIntentId: Option[String] = None
+
 trait NCResult:
     def getBody: Any
     def getType: NCResultType
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCompiler.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCompiler.scala
index bb93bd9d..d54028d5 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCompiler.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCompiler.scala
@@ -182,7 +182,6 @@ class NCIDLCompiler(cfg: NCModelConfig) extends LazyLogging 
with mutable.Cloneab
 
         override def exitFragId(ctx: IDP.FragIdContext): Unit =
             fragId = ctx.id().getText
-            if fragCache.contains(fragId) then SE(s"Duplicate fragment ID: 
$fragId")(ctx.id())
 
         override def exitFragRef(ctx: IDP.FragRefContext): Unit =
             val id = ctx.id().getText
@@ -258,7 +257,15 @@ class NCIDLCompiler(cfg: NCModelConfig) extends 
LazyLogging with mutable.Cloneab
 
         override def exitFrag(ctx: IDP.FragContext): Unit =
             val frag = NCIDLFragment(fragId, terms.toList)
+
+            fragCache.get(frag.id) match
+                case Some(exFrag) =>
+                    if frag.terms != exFrag.terms then logger.warn(s"Fragment 
'${frag.id}' was override for origin: '${this.origin}'.")
+                case None => // No-op.
+
             fragCache += frag.id -> frag
+
+
             terms.clear()
             fragId = null
 
@@ -279,7 +286,7 @@ class NCIDLCompiler(cfg: NCModelConfig) extends LazyLogging 
with mutable.Cloneab
                     idl,
                     intentId,
                     intentOpts,
-                    if (intentMeta == null) Map.empty else intentMeta,
+                    if intentMeta == null then Map.empty else intentMeta,
                     flowRegex,
                     terms.toList
                 )
@@ -307,7 +314,7 @@ class NCIDLCompiler(cfg: NCModelConfig) extends LazyLogging 
with mutable.Cloneab
                     // Second, try as a classloader resource.
                     if imports == null then
                         val in = 
cfg.getClass.getClassLoader.getResourceAsStream(x)
-                        if (in != null)
+                        if in != null then
                             val idl = NCUtils.readStream(in).mkString("\n")
                             imports = compile(idl, x)
 
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/conversation/NCConversationTimeoutSpec.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/conversation/NCConversationTimeoutSpec.scala
index 3417b93b..726f966c 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/conversation/NCConversationTimeoutSpec.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/conversation/NCConversationTimeoutSpec.scala
@@ -55,7 +55,7 @@ class NCConversationTimeoutSpec:
                 @NCIntent("intent=i term(e)~{# == 'test'}")
                 def onMatch(ctx: NCContext, im: NCIntentMatch, 
@NCIntentTerm("e") e: NCEntity): NCResult =
                     val conv = ctx.getConversation
-                    val res = 
NCResult(conv.getData.getOpt("key").getOrElse(EMPTY), NCResultType.ASK_RESULT)
+                    val res = 
NCResult(conv.getData.getOpt("key").getOrElse(EMPTY))
 
                     // For next calls.
                     conv.getData.put("key", VALUE)
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelCallbacksSpec.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelCallbacksSpec.scala
index b5af15f5..5c07dbb5 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelCallbacksSpec.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelCallbacksSpec.scala
@@ -41,11 +41,11 @@ class NCModelCallbacksSpec:
 
     private val states = collection.mutable.HashSet.empty[State]
 
-    private val RESULT_INTENT = NCResult("result-intent", 
NCResultType.ASK_RESULT)
-    private val RESULT_CONTEXT = NCResult("result-context", 
NCResultType.ASK_RESULT)
-    private val RESULT_RESULT = NCResult("result-result", 
NCResultType.ASK_RESULT)
-    private val RESULT_REJECTION = NCResult("result-rejection", 
NCResultType.ASK_RESULT)
-    private val RESULT_ERROR = NCResult("result-error", 
NCResultType.ASK_RESULT)
+    private val RESULT_INTENT = NCResult("result-intent")
+    private val RESULT_CONTEXT = NCResult("result-context")
+    private val RESULT_RESULT = NCResult("result-result")
+    private val RESULT_REJECTION = NCResult("result-rejection")
+    private val RESULT_ERROR = NCResult("result-error")
 
     private val MDL: NCTestModelAdapter =
         new NCTestModelAdapter():
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec.scala
index 9b2140ef..ccfbd2cb 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec.scala
@@ -64,7 +64,7 @@ class NCModelClientSpec:
         test0(
             new NCTestModelAdapter():
                 @NCIntent("intent=ls term(act)={# == 'ls:on'} term(loc)={# == 
'ls:loc'}*")
-                def onMatch(ctx: NCContext, im: NCIntentMatch, 
@NCIntentTerm("act") act: NCEntity, @NCIntentTerm("loc") locs: List[NCEntity]): 
NCResult = NCResult("test", NCResultType.ASK_RESULT)
+                def onMatch(ctx: NCContext, im: NCIntentMatch, 
@NCIntentTerm("act") act: NCEntity, @NCIntentTerm("loc") locs: List[NCEntity]): 
NCResult = TEST_RESULT
         )
     /**
       * 
@@ -74,6 +74,6 @@ class NCModelClientSpec:
         test0(
             new NCTestModelAdapter():
                 @NCIntent("intent=ls term(act)={has(ent_groups, 'act')} 
term(loc)={# == 'ls:loc'}*")
-                def onMatch(ctx: NCContext, im: NCIntentMatch, 
@NCIntentTerm("act") act: NCEntity, @NCIntentTerm("loc") locs: List[NCEntity]): 
NCResult = NCResult("test", NCResultType.ASK_RESULT)
+                def onMatch(ctx: NCContext, im: NCIntentMatch, 
@NCIntentTerm("act") act: NCEntity, @NCIntentTerm("loc") locs: List[NCEntity]): 
NCResult = TEST_RESULT
         )
 
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec3.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec3.scala
index 9850b4fe..a18a2885 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec3.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec3.scala
@@ -43,7 +43,7 @@ class NCModelClientSpec3:
                 pl
 
             @NCIntent("intent=i1 term(t1)={# == 'e1'}")
-            def onMatch(ctx: NCContext, im: NCIntentMatch, @NCIntentTerm("t1") 
t1: NCEntity): NCResult = NCResult("Data", NCResultType.ASK_RESULT)
+            def onMatch(ctx: NCContext, im: NCIntentMatch, @NCIntentTerm("t1") 
t1: NCEntity): NCResult = TEST_RESULT
 
         Using.resource(new NCModelClient(mdl)) { client =>
             def ask(): NCFiredIntent = client.debugAsk("e1", "userId", true)
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/scan/NCModelIntentsInvalidArgsSpec.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/scan/NCModelIntentsInvalidArgsSpec.scala
index 5043c0d1..eae13ea3 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/scan/NCModelIntentsInvalidArgsSpec.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/scan/NCModelIntentsInvalidArgsSpec.scala
@@ -97,7 +97,7 @@ class NCModelIntentsInvalidArgsSpec:
 
     private def mkResult0(obj: Any): NCResult =
         println(s"Result body: $obj, class=${obj.getClass}")
-        NCResult(obj, NCResultType.ASK_RESULT)
+        NCResult(obj)
 
     private def processOptInt(opt: Option[Int]): NCResult =
         // Access and cast.
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec.scala
new file mode 100644
index 00000000..23f228a2
--- /dev/null
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec.scala
@@ -0,0 +1,50 @@
+/*
+ * 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
+ *
+ *      https://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.internal.intent.compiler
+
+import org.apache.nlpcraft.*
+import org.apache.nlpcraft.annotations.NCIntent
+import org.apache.nlpcraft.internal.impl.NCModelScanner
+import org.apache.nlpcraft.nlp.parsers.NCSemanticTestElement as TE
+import org.apache.nlpcraft.nlp.util.*
+import org.junit.jupiter.api.Test
+
+import scala.util.Using
+
+class NCIDLFragmentsOverridingSpec:
+    @NCIntent("fragment=f term(x)~{# == 'x'}")
+    class M extends NCTestModelAdapter:
+        override val getPipeline: NCPipeline =
+            val pl = mkEnPipeline
+            pl.entParsers += NCTestUtils.mkEnSemanticParser(TE("x"), TE("y"))
+            pl
+
+        // Uses fragment defined on class level.
+        @NCIntent("intent=i2 fragment(f)")
+        private def onX(ctx: NCContext, im: NCIntentMatch): NCResult = 
NCResult("onX")
+
+        // Overrides fragment defined on class level.
+        @NCIntent("fragment=f term(y)~{# == 'y'} intent=i1 fragment(f)")
+        private def onY(ctx: NCContext, im: NCIntentMatch): NCResult = 
NCResult("onY")
+    
+    @Test
+    def test(): Unit =
+        Using.resource(new NCModelClient(new M())) { client =>
+            require(client.ask("x", "usr").getBody == "onX")
+            require(client.ask("y", "usr").getBody == "onY")
+        }
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityEnricherSpec.scala 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityEnricherSpec.scala
index 1ae0b536..2a031087 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityEnricherSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityEnricherSpec.scala
@@ -33,7 +33,7 @@ class NCEntityEnricherSpec:
     private def test0(pipeline: NCPipeline, ok: Boolean): Unit =
         val mdl: NCModel = new NCModelAdapter(NCModelConfig("test.id", "Test 
model", "1.0"), pipeline):
             @NCIntent("intent=i term(any)={meta_ent('k1') == 'v1'}")
-            def onMatch(ctx: NCContext, im: NCIntentMatch): NCResult = 
NCResult("OK", NCResultType.ASK_RESULT)
+            def onMatch(ctx: NCContext, im: NCIntentMatch): NCResult = 
TEST_RESULT
 
         NCTestUtils.askSomething(mdl, ok)
 
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityMapperSpec.scala 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityMapperSpec.scala
index 76db57d5..ff73f090 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityMapperSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityMapperSpec.scala
@@ -67,7 +67,7 @@ class NCEntityMapperSpec:
             pl
 
         @NCIntent("intent=abcd term(abcd)={# == 'abcd'}")
-        def onMatch(ctx: NCContext, im: NCIntentMatch, @NCIntentTerm("abcd") 
abcd: NCEntity): NCResult = NCResult("OK", NCResultType.ASK_RESULT)
+        def onMatch(ctx: NCContext, im: NCIntentMatch, @NCIntentTerm("abcd") 
abcd: NCEntity): NCResult = TEST_RESULT
 
     @Test
     def test(): Unit = Using.resource(new NCModelClient(mdl)) { client =>
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityValidatorSpec.scala 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityValidatorSpec.scala
index 362797e9..51de067b 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityValidatorSpec.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityValidatorSpec.scala
@@ -32,7 +32,7 @@ import scala.util.Using
 class NCEntityValidatorSpec:
     private def test0(pipeline: NCPipeline, ok: Boolean): Unit =
         val mdl: NCModel = new NCModelAdapter(NCModelConfig("test.id", "Test 
model", "1.0"), pipeline):
-            override def onContext(ctx: NCContext): Option[NCResult] = 
Option(NCResult("OK", NCResultType.ASK_RESULT))
+            override def onContext(ctx: NCContext): Option[NCResult] = 
Option(TEST_RESULT)
 
         NCTestUtils.askSomething(mdl, ok)
 
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCTokenEnricherSpec.scala 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCTokenEnricherSpec.scala
index bb80677d..86033532 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCTokenEnricherSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCTokenEnricherSpec.scala
@@ -33,7 +33,7 @@ class NCTokenEnricherSpec:
     private def test0(pipeline: NCPipeline, ok: Boolean): Unit =
         val mdl: NCModel = new NCModelAdapter(NCModelConfig("test.id", "Test 
model", "1.0"), pipeline):
             @NCIntent("intent=i term(any)={meta_ent('nlp:token:k1') == 'v1'}")
-            def onMatch(ctx: NCContext, im: NCIntentMatch): NCResult = 
NCResult("OK", NCResultType.ASK_RESULT)
+            def onMatch(ctx: NCContext, im: NCIntentMatch): NCResult = 
TEST_RESULT
 
         NCTestUtils.askSomething(mdl, ok)
 
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCTokenValidatorSpec.scala 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCTokenValidatorSpec.scala
index b1cf7047..7be9bda7 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCTokenValidatorSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCTokenValidatorSpec.scala
@@ -31,7 +31,7 @@ import scala.util.Using
 class NCTokenValidatorSpec:
     private def test0(pipeline: NCPipeline, ok: Boolean): Unit =
         val mdl: NCModel = new NCModelAdapter(NCModelConfig("test.id", "Test 
model", "1.0"), pipeline):
-            override def onContext(ctx: NCContext): Option[NCResult] = 
Option(NCResult("OK", NCResultType.ASK_RESULT))
+            override def onContext(ctx: NCContext): Option[NCResult] = 
Option(TEST_RESULT)
 
         NCTestUtils.askSomething(mdl, ok)
 
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCVariantFilterSpec.scala 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCVariantFilterSpec.scala
index aed99a34..c0644da4 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCVariantFilterSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCVariantFilterSpec.scala
@@ -34,7 +34,7 @@ class NCVariantFilterSpec:
     private def test0(pipeline: NCPipeline, ok: Boolean): Unit =
         val mdl: NCModel = new NCModelAdapter(NCModelConfig("test.id", "Test 
model", "1.0"), pipeline):
             @NCIntent("intent=i term(any)={true}")
-            def onMatch(ctx: NCContext, im: NCIntentMatch): NCResult = 
NCResult("OK", NCResultType.ASK_RESULT)
+            def onMatch(ctx: NCContext, im: NCIntentMatch): NCResult = 
TEST_RESULT
 
         NCTestUtils.askSomething(mdl, ok)
 
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/util/NCTestResult.scala 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/util/NCTestResult.scala
index 14b86626..1936ed70 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/util/NCTestResult.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/util/NCTestResult.scala
@@ -17,16 +17,15 @@
 
 package org.apache.nlpcraft.nlp.util
 
-import org.apache.nlpcraft.{NCResult, NCResultType}
+import org.apache.nlpcraft.*
 
 /**
   *
   */
-object  NCTestResult {
+object NCTestResult:
     def apply(): NCResult = TEST_RESULT
-}
 
 /**
   *
   */
-val TEST_RESULT = NCResult("test", NCResultType.ASK_RESULT)
+val TEST_RESULT = NCResult("test")

Reply via email to