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

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


The following commit(s) were added to refs/heads/NLPCRAFT-510 by this push:
     new 25dd4f51 Test client.
25dd4f51 is described below

commit 25dd4f51dfaeb54cd95a5df0575309e9e4f0c0be
Author: Sergey Kamov <skhdlem...@gmail.com>
AuthorDate: Sat Aug 6 21:26:07 2022 +0300

    Test client.
---
 .../src/main/scala/org/apache/nlpcraft/NCModelClient.scala    |  2 +-
 .../org/apache/nlpcraft/validation/NCModelValidator.scala     | 11 +++++------
 .../apache/nlpcraft/internal/impl/NCModelClientSpec2.scala    |  2 +-
 .../apache/nlpcraft/internal/impl/NCModelClientSpec3.scala    |  2 +-
 4 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelClient.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelClient.scala
index b3db6315..2289fd30 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelClient.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelClient.scala
@@ -207,7 +207,7 @@ class NCModelClient(mdl: NCModel) extends LazyLogging, 
AutoCloseable:
     /**
       *
       */
-    def close(): Unit =
+    override def close(): Unit =
         plMgr.close()
         dlgMgr.close()
         convMgr.close()
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/validation/NCModelValidator.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/validation/NCModelValidator.scala
index e70935fd..e8d6d26e 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/validation/NCModelValidator.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/validation/NCModelValidator.scala
@@ -26,14 +26,13 @@ import 
org.apache.nlpcraft.internal.intent.matcher.NCIntentSolveType.*
 import java.util.UUID
 
 object NCModelValidator:
-    def apply(client: NCModelClient): NCModelValidator = new 
NCModelValidator(client, false)
+    def apply(client: NCModelClient): NCModelValidator = new 
NCModelValidator(client)
     def apply(mdl: NCModel): NCModelValidator = new NCModelValidator(new 
NCModelClient(mdl), true)
 
-class NCModelValidator(private val client: NCModelClient, private val 
shouldClose: Boolean) extends LazyLogging, AutoCloseable:
-    def close(): Unit = if shouldClose then client.close()
+class NCModelValidator(private val client: NCModelClient, private val 
autoClose: Boolean = false) extends LazyLogging, AutoCloseable:
+    override def close(): Unit = if autoClose then client.close()
 
-    def debugAsk(txt: String, data: Map[String, AnyRef], usrId: String, 
saveHist: Boolean): NCCallbackData =
+    def validateAsk(txt: String, usrId: String, saveHist: Boolean = false, 
data: Map[String, AnyRef] = Map.empty): NCCallbackData =
         client.debugAsk(txt, data, usrId, saveHist)
-    def debugAsk(txt: String, usrId: String, saveHist: Boolean): 
NCCallbackData =
-        client.debugAsk(txt, Map.empty, usrId, saveHist)
+
     def validateSamples(): Unit = client.validateSamples()
\ No newline at end of file
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec2.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec2.scala
index a3358c21..55989707 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec2.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelClientSpec2.scala
@@ -50,7 +50,7 @@ class NCModelClientSpec2:
 
         Using.resource(new NCModelClient(mdl)) { client =>
             case class Result(txt: String):
-                private val wi = Using.resource(NCModelValidator(mdl)) { 
_.debugAsk(txt, "userId", true) }
+                private val wi = Using.resource(NCModelValidator(mdl)) { 
_.validateAsk(txt, "userId", true) }
                 private val allArgs: List[List[NCEntity]] = 
wi.getCallbackArguments
 
                 val intentId: String = wi.getIntentId
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 bb265309..9cb901c3 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
@@ -48,7 +48,7 @@ class NCModelClientSpec3:
             def onMatch(ctx: NCContext, im: NCIntentMatch, @NCIntentTerm("t1") 
t1: NCEntity): NCResult = NCResult("Data", NCResultType.ASK_RESULT)
 
         Using.resource(new NCModelClient(mdl)) { client =>
-            def ask(): NCCallbackData = 
Using.resource(NCModelValidator(client)) { _.debugAsk("e1", "userId", true) }
+            def ask(): NCCallbackData = 
Using.resource(NCModelValidator(client)) { _.validateAsk("e1", "userId", true) }
             def execCallback(cb: NCCallbackData): NCResult = 
cb.getCallback.apply(cb.getCallbackArguments)
             def execCallbackOk(cb: NCCallbackData): Unit = println(s"Result: 
${execCallback(cb).getBody}")
             def execCallbackFail(cb: NCCallbackData): Unit =

Reply via email to