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 2022/09/06 10:42:37 UTC
[incubator-nlpcraft] branch master updated: Junit library changed to scalatests.
This is an automated email from the ASF dual-hosted git repository.
sergeykamov 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 803e0bd3 Junit library changed to scalatests.
803e0bd3 is described below
commit 803e0bd30d379d2576ff1ccec35ea85cd57a6260
Author: Sergey Kamov <sk...@gmail.com>
AuthorDate: Tue Sep 6 13:42:24 2022 +0300
Junit library changed to scalatests.
---
nlpcraft-examples/lightswitch-fr/pom.xml | 4 +-
.../examples/lightswitch/LightSwitchFrModel.scala | 2 +-
.../token/enricher/NCFrLemmaPosTokenEnricher.scala | 1 -
.../enricher/NCFrStopWordsTokenEnricher.scala | 3 --
.../nlp/token/parser/NCFrTokenParser.scala | 1 -
.../lightswitch/NCModelValidationSpec.scala | 59 +++++++++++-----------
nlpcraft-examples/lightswitch-ru/pom.xml | 4 +-
.../examples/lightswitch/LightSwitchRuModel.scala | 6 +--
.../token/enricher/NCRuLemmaPosTokenEnricher.scala | 2 -
.../lightswitch/NCModelValidationSpec.scala | 41 +++++++--------
nlpcraft-examples/lightswitch/pom.xml | 4 +-
.../lightswitch/NCModelValidationSpec.scala | 9 ++--
nlpcraft-examples/pizzeria/pom.xml | 4 +-
.../examples/pizzeria/PizzeriaModelSpec.scala | 14 ++---
nlpcraft-examples/time/pom.xml | 4 +-
.../examples/time/NCModelValidationSpec.scala | 21 ++++----
nlpcraft-stanford/pom.xml | 9 +---
.../parser/stanford/NCStanfordNLPTokenParser.scala | 4 +-
.../stanford/NCStanfordNLPEntityParserSpec.scala | 10 ++--
.../stanford/NCStanfordNLPTokenParserSpec.scala | 11 ++--
nlpcraft/pom.xml | 31 +++++++++---
.../internal/impl/NCModelPipelineManager.scala | 5 +-
.../nlpcraft/internal/impl/NCModelScanner.scala | 1 -
.../nlp/parsers/NCOpenNLPEntityParser.scala | 1 -
.../nlp/parsers/impl/NCSemanticSourceReader.scala | 1 -
.../conversation/NCConversationManagerSpec.scala | 13 +++--
.../internal/conversation/NCConversationSpec.scala | 20 ++++----
.../conversation/NCConversationTimeoutSpec.scala | 11 ++--
.../dialogflow/NCDialogFlowManagerSpec.scala | 20 ++++----
.../internal/impl/NCModelCallbacksSpec.scala | 58 ++++++++++-----------
.../nlpcraft/internal/impl/NCModelClientSpec.scala | 15 +++---
.../internal/impl/NCModelClientSpec2.scala | 10 ++--
.../internal/impl/NCModelClientSpec3.scala | 12 ++---
.../internal/impl/NCModelPingPongSpec.scala | 37 +++++++-------
.../internal/impl/NCPipelineManagerSpec.scala | 18 +++----
.../impl/scan/NCModelIntentsInvalidArgsSpec.scala | 10 ++--
.../scan/NCModelIntentsInvalidIntentsSpec.scala | 22 ++++----
.../impl/scan/NCModelIntentsNestedSpec.scala | 14 ++---
.../internal/impl/scan/NCModelIntentsSpec.scala | 9 ++--
.../intent/compiler/NCIDLCompilerSpec.scala | 25 +++++----
.../compiler/NCIDLFragmentsOverridingSpec.scala | 10 ++--
.../compiler/NCIDLFragmentsOverridingSpec2.scala | 10 ++--
.../intent/compiler/NCIDLFragmentsSpec.scala | 10 ++--
.../intent/compiler/functions/NCIDLFunctions.scala | 6 +--
.../functions/NCIDLFunctionsCollections.scala | 6 +--
.../compiler/functions/NCIDLFunctionsDate.scala | 5 +-
.../functions/NCIDLFunctionsEntitiesUsed.scala | 5 +-
.../compiler/functions/NCIDLFunctionsEntity.scala | 23 ++++-----
.../compiler/functions/NCIDLFunctionsMath.scala | 29 +++++------
.../compiler/functions/NCIDLFunctionsMeta.scala | 40 +++++++--------
.../compiler/functions/NCIDLFunctionsModel.scala | 10 ++--
.../compiler/functions/NCIDLFunctionsOther.scala | 21 ++++----
.../compiler/functions/NCIDLFunctionsRequest.scala | 6 +--
.../compiler/functions/NCIDLFunctionsStat.scala | 24 ++++-----
.../compiler/functions/NCIDLFunctionsStrings.scala | 9 ++--
.../nlpcraft/internal/util/NCResourceSpec.scala | 10 ++--
.../apache/nlpcraft/nlp/NCEntityEnricherSpec.scala | 11 ++--
.../apache/nlpcraft/nlp/NCEntityMapperSpec.scala | 13 +++--
.../nlpcraft/nlp/NCEntityValidatorSpec.scala | 11 ++--
.../apache/nlpcraft/nlp/NCTokenEnricherSpec.scala | 11 ++--
.../apache/nlpcraft/nlp/NCTokenValidatorSpec.scala | 9 ++--
.../apache/nlpcraft/nlp/NCVariantFilterSpec.scala | 11 ++--
.../enrichers/NCBracketsTokenEnricherSpec.scala | 10 ++--
.../enrichers/NCDictionaryTokenEnricherSpec.scala | 15 ++----
.../nlp/enrichers/NCQuotesTokenEnricherSpec.scala | 13 ++---
.../nlp/enrichers/NCStopWordsEnricherSpec.scala | 13 ++---
.../enrichers/NCSwearWordsTokenEnricherSpec.scala | 14 ++---
.../nlp/enrichers/impl/NCStopWordsImplSpec.scala | 11 ++--
.../nlp/parsers/NCNLPEntityParserSpec.scala | 14 ++---
.../nlp/parsers/NCOpenNLPEntityParserSpec.scala | 21 ++++----
.../nlp/parsers/NCOpenNLPTokenParserSpec.scala | 13 ++---
.../parsers/NCSemanticEntityParserJsonSpec.scala | 12 ++---
.../parsers/NCSemanticEntityParserLemmaSpec.scala | 13 ++---
.../nlp/parsers/NCSemanticEntityParserSpec.scala | 11 ++--
.../parsers/NCSemanticEntityParserYamlSpec.scala | 12 ++---
.../nlp/parsers/NCSemanticTestElement.scala | 1 -
.../org/apache/nlpcraft/nlp/util/NCTestUtils.scala | 2 -
pom.xml | 11 +---
78 files changed, 471 insertions(+), 551 deletions(-)
diff --git a/nlpcraft-examples/lightswitch-fr/pom.xml b/nlpcraft-examples/lightswitch-fr/pom.xml
index 2dd9fe60..02e0c50b 100644
--- a/nlpcraft-examples/lightswitch-fr/pom.xml
+++ b/nlpcraft-examples/lightswitch-fr/pom.xml
@@ -58,8 +58,8 @@
<!-- Test dependencies. -->
<dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
+ <groupId>org.scalatest</groupId>
+ <artifactId>scalatest_${scala.major.ver}</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
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 494d098d..5f8c0e32 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
@@ -24,9 +24,9 @@ import org.apache.nlpcraft.examples.lightswitch.nlp.entity.parser.NCFrSemanticEn
import org.apache.nlpcraft.examples.lightswitch.nlp.token.enricher.*
import org.apache.nlpcraft.examples.lightswitch.nlp.token.parser.NCFrTokenParser
import org.apache.nlpcraft.nlp.parsers.NCOpenNLPTokenParser
+import scala.jdk.CollectionConverters.*
import java.util
-import scala.jdk.CollectionConverters.*
/**
* This example provides very simple implementation for NLI-powered light switch.
diff --git a/nlpcraft-examples/lightswitch-fr/src/main/scala/org/apache/nlpcraft/examples/lightswitch/nlp/token/enricher/NCFrLemmaPosTokenEnricher.scala b/nlpcraft-examples/lightswitch-fr/src/main/scala/org/apache/nlpcraft/examples/lightswitch/nlp/token/enricher/NCFrLemmaPosTokenEnricher.scala
index 92e62dba..0e22e24b 100644
--- a/nlpcraft-examples/lightswitch-fr/src/main/scala/org/apache/nlpcraft/examples/lightswitch/nlp/token/enricher/NCFrLemmaPosTokenEnricher.scala
+++ b/nlpcraft-examples/lightswitch-fr/src/main/scala/org/apache/nlpcraft/examples/lightswitch/nlp/token/enricher/NCFrLemmaPosTokenEnricher.scala
@@ -20,7 +20,6 @@ package org.apache.nlpcraft.examples.lightswitch.nlp.token.enricher
import org.apache.nlpcraft.*
import org.languagetool.AnalyzedToken
import org.languagetool.tagging.fr.FrenchTagger
-
import scala.jdk.CollectionConverters.*
/**
diff --git a/nlpcraft-examples/lightswitch-fr/src/main/scala/org/apache/nlpcraft/examples/lightswitch/nlp/token/enricher/NCFrStopWordsTokenEnricher.scala b/nlpcraft-examples/lightswitch-fr/src/main/scala/org/apache/nlpcraft/examples/lightswitch/nlp/token/enricher/NCFrStopWordsTokenEnricher.scala
index ffc68de0..afb712d2 100644
--- a/nlpcraft-examples/lightswitch-fr/src/main/scala/org/apache/nlpcraft/examples/lightswitch/nlp/token/enricher/NCFrStopWordsTokenEnricher.scala
+++ b/nlpcraft-examples/lightswitch-fr/src/main/scala/org/apache/nlpcraft/examples/lightswitch/nlp/token/enricher/NCFrStopWordsTokenEnricher.scala
@@ -20,9 +20,6 @@ package org.apache.nlpcraft.examples.lightswitch.nlp.token.enricher
import org.apache.lucene.analysis.fr.FrenchAnalyzer
import org.apache.nlpcraft.*
-import java.util
-import scala.jdk.CollectionConverters.*
-
/**
*
*/
diff --git a/nlpcraft-examples/lightswitch-fr/src/main/scala/org/apache/nlpcraft/examples/lightswitch/nlp/token/parser/NCFrTokenParser.scala b/nlpcraft-examples/lightswitch-fr/src/main/scala/org/apache/nlpcraft/examples/lightswitch/nlp/token/parser/NCFrTokenParser.scala
index 09ab107b..e59c6b75 100644
--- a/nlpcraft-examples/lightswitch-fr/src/main/scala/org/apache/nlpcraft/examples/lightswitch/nlp/token/parser/NCFrTokenParser.scala
+++ b/nlpcraft-examples/lightswitch-fr/src/main/scala/org/apache/nlpcraft/examples/lightswitch/nlp/token/parser/NCFrTokenParser.scala
@@ -20,7 +20,6 @@ package org.apache.nlpcraft.examples.lightswitch.nlp.token.parser
import org.apache.nlpcraft.*
import org.languagetool.tokenizers.WordTokenizer
import org.languagetool.tokenizers.fr.FrenchWordTokenizer
-
import scala.jdk.CollectionConverters.*
/**
diff --git a/nlpcraft-examples/lightswitch-fr/src/test/scala/org/apache/nlpcraft/examples/lightswitch/NCModelValidationSpec.scala b/nlpcraft-examples/lightswitch-fr/src/test/scala/org/apache/nlpcraft/examples/lightswitch/NCModelValidationSpec.scala
index 11fe249e..1d15dda4 100644
--- a/nlpcraft-examples/lightswitch-fr/src/test/scala/org/apache/nlpcraft/examples/lightswitch/NCModelValidationSpec.scala
+++ b/nlpcraft-examples/lightswitch-fr/src/test/scala/org/apache/nlpcraft/examples/lightswitch/NCModelValidationSpec.scala
@@ -18,38 +18,39 @@
package org.apache.nlpcraft.examples.lightswitch
import org.apache.nlpcraft.*
-import org.junit.jupiter.api.*
+import org.scalatest.funsuite.AnyFunSuite
import scala.util.Using
/**
* JUnit models validation.
*/
-class NCModelValidationSpec:
- @Test
- def test(): Unit = Using.resource(new NCModelClient(new LightSwitchFrModel)) { client =>
- def check(txt: String): Unit = client.debugAsk(txt, "userId", true).getIntentId == "ls"
-
- check("Éteignez les lumières dans toute la maison.")
- check("Éteignez toutes les lumières maintenant.")
- check("Allumez l'éclairage dans le placard de la chambre des maîtres.")
- check("Éteindre les lumières au 1er étage.")
- check("Allumez les lumières.")
- check("Allumes dans la cuisine.")
- check("S'il vous plait, éteignez la lumière dans la chambre à l'étage.")
- check("Allumez les lumières dans toute la maison.")
- check("Éteignez les lumières dans la chambre d'hôtes.")
- check("Pourriez-vous éteindre toutes les lumières s'il vous plait?")
- check("Désactivez l'éclairage au 2ème étage.")
- check("Éteignez les lumières dans la chambre au 1er étage.")
- check("Lumières allumées à la cuisine du deuxième étage.")
- check("S'il te plaît, pas de lumières!")
- check("Coupez toutes les lumières maintenant!")
- check("Éteindre les lumières dans le garage.")
- check("Lumières éteintes dans la cuisine!")
- check("Augmentez l'éclairage dans le garage et la chambre des maîtres.")
- check("Baissez toute la lumière maintenant!")
- check("Pas de lumières dans la chambre, s'il vous plait.")
- check("Allumez le garage, s'il vous plait.")
- check("Tuez l'illumination maintenant.")
- }
+class NCModelValidationSpec extends AnyFunSuite:
+ test("test") {
+ Using.resource(new NCModelClient(new LightSwitchFrModel)) { client =>
+ def check(txt: String): Unit = client.debugAsk(txt, "userId", true).getIntentId == "ls"
+
+ check("Éteignez les lumières dans toute la maison.")
+ check("Éteignez toutes les lumières maintenant.")
+ check("Allumez l'éclairage dans le placard de la chambre des maîtres.")
+ check("Éteindre les lumières au 1er étage.")
+ check("Allumez les lumières.")
+ check("Allumes dans la cuisine.")
+ check("S'il vous plait, éteignez la lumière dans la chambre à l'étage.")
+ check("Allumez les lumières dans toute la maison.")
+ check("Éteignez les lumières dans la chambre d'hôtes.")
+ check("Pourriez-vous éteindre toutes les lumières s'il vous plait?")
+ check("Désactivez l'éclairage au 2ème étage.")
+ check("Éteignez les lumières dans la chambre au 1er étage.")
+ check("Lumières allumées à la cuisine du deuxième étage.")
+ check("S'il te plaît, pas de lumières!")
+ check("Coupez toutes les lumières maintenant!")
+ check("Éteindre les lumières dans le garage.")
+ check("Lumières éteintes dans la cuisine!")
+ check("Augmentez l'éclairage dans le garage et la chambre des maîtres.")
+ check("Baissez toute la lumière maintenant!")
+ check("Pas de lumières dans la chambre, s'il vous plait.")
+ check("Allumez le garage, s'il vous plait.")
+ check("Tuez l'illumination maintenant.")
+ }
+ }
\ No newline at end of file
diff --git a/nlpcraft-examples/lightswitch-ru/pom.xml b/nlpcraft-examples/lightswitch-ru/pom.xml
index 68e55453..92bfd021 100644
--- a/nlpcraft-examples/lightswitch-ru/pom.xml
+++ b/nlpcraft-examples/lightswitch-ru/pom.xml
@@ -58,8 +58,8 @@
<!-- Test dependencies. -->
<dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
+ <groupId>org.scalatest</groupId>
+ <artifactId>scalatest_${scala.major.ver}</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
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 81021e4e..92b2211c 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
@@ -19,13 +19,13 @@ package org.apache.nlpcraft.examples.lightswitch
import com.google.gson.Gson
import org.apache.nlpcraft.*
+import org.apache.nlpcraft.annotations.*
import org.apache.nlpcraft.examples.lightswitch.nlp.entity.parser.NCRuSemanticEntityParser
import org.apache.nlpcraft.examples.lightswitch.nlp.token.enricher.*
import org.apache.nlpcraft.examples.lightswitch.nlp.token.parser.NCRuTokenParser
-import org.apache.nlpcraft.annotations.*
import org.apache.nlpcraft.nlp.enrichers.NCEnStopWordsTokenEnricher
-import org.apache.nlpcraft.nlp.parsers.{NCNLPEntityParser, NCOpenNLPTokenParser, NCSemanticEntityParser}
-import java.util
+import org.apache.nlpcraft.nlp.parsers.*
+
import scala.jdk.CollectionConverters.*
/**
diff --git a/nlpcraft-examples/lightswitch-ru/src/main/scala/org/apache/nlpcraft/examples/lightswitch/nlp/token/enricher/NCRuLemmaPosTokenEnricher.scala b/nlpcraft-examples/lightswitch-ru/src/main/scala/org/apache/nlpcraft/examples/lightswitch/nlp/token/enricher/NCRuLemmaPosTokenEnricher.scala
index a243f874..6544ec91 100644
--- a/nlpcraft-examples/lightswitch-ru/src/main/scala/org/apache/nlpcraft/examples/lightswitch/nlp/token/enricher/NCRuLemmaPosTokenEnricher.scala
+++ b/nlpcraft-examples/lightswitch-ru/src/main/scala/org/apache/nlpcraft/examples/lightswitch/nlp/token/enricher/NCRuLemmaPosTokenEnricher.scala
@@ -20,9 +20,7 @@ package org.apache.nlpcraft.examples.lightswitch.nlp.token.enricher
import org.apache.nlpcraft.*
import org.languagetool.AnalyzedToken
import org.languagetool.tagging.ru.RussianTagger
-
import scala.jdk.CollectionConverters.*
-
/**
*
*/
diff --git a/nlpcraft-examples/lightswitch-ru/src/test/scala/org/apache/nlpcraft/examples/lightswitch/NCModelValidationSpec.scala b/nlpcraft-examples/lightswitch-ru/src/test/scala/org/apache/nlpcraft/examples/lightswitch/NCModelValidationSpec.scala
index c61cbcd0..05662f99 100644
--- a/nlpcraft-examples/lightswitch-ru/src/test/scala/org/apache/nlpcraft/examples/lightswitch/NCModelValidationSpec.scala
+++ b/nlpcraft-examples/lightswitch-ru/src/test/scala/org/apache/nlpcraft/examples/lightswitch/NCModelValidationSpec.scala
@@ -18,29 +18,30 @@
package org.apache.nlpcraft.examples.lightswitch
import org.apache.nlpcraft.*
-import org.junit.jupiter.api.*
+import org.scalatest.funsuite.AnyFunSuite
import scala.util.Using
/**
* JUnit models validation.
*/
-class NCModelValidationSpec:
- @Test
- def test(): Unit = Using.resource(new NCModelClient(new LightSwitchRuModel)) { client =>
- def check(txt: String): Unit = client.debugAsk(txt, "userId", true).getIntentId == "ls"
-
- check("Выключи свет по всем доме")
- check("Выруби электричество!")
- check("Включи свет в детской")
- check("Включай повсюду освещение")
- check("Включайте лампы в детской комнате")
- check("Свет на кухне, пожалуйста, приглуши")
- check("Нельзя ли повсюду выключить свет?")
- check("Пожалуйста без света")
- check("Отключи электричество в ванной")
- check("Выключи, пожалуйста, тут всюду свет")
- check("Выключай все!")
- check("Свет пожалуйста везде включи")
- check("Зажги лампу на кухне")
- }
+class NCModelValidationSpec extends AnyFunSuite:
+ test("test") {
+ Using.resource(new NCModelClient(new LightSwitchRuModel)) { client =>
+ def check(txt: String): Unit = client.debugAsk(txt, "userId", true).getIntentId == "ls"
+
+ check("Выключи свет по всем доме")
+ check("Выруби электричество!")
+ check("Включи свет в детской")
+ check("Включай повсюду освещение")
+ check("Включайте лампы в детской комнате")
+ check("Свет на кухне, пожалуйста, приглуши")
+ check("Нельзя ли повсюду выключить свет?")
+ check("Пожалуйста без света")
+ check("Отключи электричество в ванной")
+ check("Выключи, пожалуйста, тут всюду свет")
+ check("Выключай все!")
+ check("Свет пожалуйста везде включи")
+ check("Зажги лампу на кухне")
+ }
+ }
\ No newline at end of file
diff --git a/nlpcraft-examples/lightswitch/pom.xml b/nlpcraft-examples/lightswitch/pom.xml
index 412426c1..67e33747 100644
--- a/nlpcraft-examples/lightswitch/pom.xml
+++ b/nlpcraft-examples/lightswitch/pom.xml
@@ -40,8 +40,8 @@
<!-- Test dependencies. -->
<dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
+ <groupId>org.scalatest</groupId>
+ <artifactId>scalatest_${scala.major.ver}</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/nlpcraft-examples/lightswitch/src/test/scala/org/apache/nlpcraft/examples/lightswitch/NCModelValidationSpec.scala b/nlpcraft-examples/lightswitch/src/test/scala/org/apache/nlpcraft/examples/lightswitch/NCModelValidationSpec.scala
index 4735bb90..94f53c6c 100644
--- a/nlpcraft-examples/lightswitch/src/test/scala/org/apache/nlpcraft/examples/lightswitch/NCModelValidationSpec.scala
+++ b/nlpcraft-examples/lightswitch/src/test/scala/org/apache/nlpcraft/examples/lightswitch/NCModelValidationSpec.scala
@@ -18,14 +18,14 @@
package org.apache.nlpcraft.examples.lightswitch
import org.apache.nlpcraft.*
-import org.junit.jupiter.api.*
+import org.scalatest.funsuite.AnyFunSuite
import scala.util.Using
/**
* JUnit models validation.
*/
-class NCModelValidationSpec:
+class NCModelValidationSpec extends AnyFunSuite:
private def test(mdl: NCModel): Unit = Using.resource(new NCModelClient(mdl)) { client =>
def check(txt: String): Unit = client.debugAsk(txt, "userId", true).getIntentId == "ls"
@@ -53,5 +53,6 @@ class NCModelValidationSpec:
check("Kill the illumination now!")
}
- @Test
- def test(): Unit = test(new LightSwitchScalaModel())
+ test("test") {
+ test(new LightSwitchScalaModel())
+ }
diff --git a/nlpcraft-examples/pizzeria/pom.xml b/nlpcraft-examples/pizzeria/pom.xml
index c1c06bab..78bf78a5 100644
--- a/nlpcraft-examples/pizzeria/pom.xml
+++ b/nlpcraft-examples/pizzeria/pom.xml
@@ -45,8 +45,8 @@
<!-- Test dependencies. -->
<dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
+ <groupId>org.scalatest</groupId>
+ <artifactId>scalatest_${scala.major.ver}</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/nlpcraft-examples/pizzeria/src/test/scala/org/apache/nlpcraft/examples/pizzeria/PizzeriaModelSpec.scala b/nlpcraft-examples/pizzeria/src/test/scala/org/apache/nlpcraft/examples/pizzeria/PizzeriaModelSpec.scala
index 8d5c3723..df559a66 100644
--- a/nlpcraft-examples/pizzeria/src/test/scala/org/apache/nlpcraft/examples/pizzeria/PizzeriaModelSpec.scala
+++ b/nlpcraft-examples/pizzeria/src/test/scala/org/apache/nlpcraft/examples/pizzeria/PizzeriaModelSpec.scala
@@ -21,7 +21,8 @@ import org.apache.nlpcraft.*
import org.apache.nlpcraft.NCResultType.*
import org.apache.nlpcraft.examples.pizzeria.PizzeriaModel.Result
import org.apache.nlpcraft.examples.pizzeria.PizzeriaOrderState.*
-import org.junit.jupiter.api.*
+import org.scalatest.BeforeAndAfter
+import org.scalatest.funsuite.AnyFunSuite
import scala.language.implicitConversions
import scala.util.Using
@@ -55,7 +56,7 @@ import PizzeriaModelSpec.*
/**
*
*/
-class PizzeriaModelSpec:
+class PizzeriaModelSpec extends AnyFunSuite with BeforeAndAfter:
private val mdl = new ModelTestWrapper()
private val client = new NCModelClient(mdl)
private val msgs = mutable.ArrayBuffer.empty[mutable.ArrayBuffer[String]]
@@ -63,7 +64,7 @@ class PizzeriaModelSpec:
private var testNum: Int = 0
- @AfterEach def tearDown(): Unit =
+ after {
if client != null then client.close()
for ((seq, num) <- msgs.zipWithIndex)
@@ -74,6 +75,7 @@ class PizzeriaModelSpec:
case None => // No-op.
require(errs.isEmpty, s"There are ${errs.size} errors above.")
+ }
private def dialog(exp: PizzeriaOrder, reqs: Request*): Unit =
val testMsgs = mutable.ArrayBuffer.empty[String]
@@ -110,8 +112,7 @@ class PizzeriaModelSpec:
testNum += 1
- @Test
- def test(): Unit =
+ test("test") {
given Conversion[String, Request] with
def apply(txt: String): Request = (txt, ASK_DIALOG)
@@ -207,4 +208,5 @@ class PizzeriaModelSpec:
"large",
"yes",
"yes" -> ASK_RESULT
- )
\ No newline at end of file
+ )
+ }
\ No newline at end of file
diff --git a/nlpcraft-examples/time/pom.xml b/nlpcraft-examples/time/pom.xml
index 5645fb6e..aae93094 100644
--- a/nlpcraft-examples/time/pom.xml
+++ b/nlpcraft-examples/time/pom.xml
@@ -40,8 +40,8 @@
<!-- Test dependencies. -->
<dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
+ <groupId>org.scalatest</groupId>
+ <artifactId>scalatest_${scala.major.ver}</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/nlpcraft-examples/time/src/test/scala/org/apache/nlpcraft/examples/time/NCModelValidationSpec.scala b/nlpcraft-examples/time/src/test/scala/org/apache/nlpcraft/examples/time/NCModelValidationSpec.scala
index 14f51db0..686d4b0b 100644
--- a/nlpcraft-examples/time/src/test/scala/org/apache/nlpcraft/examples/time/NCModelValidationSpec.scala
+++ b/nlpcraft-examples/time/src/test/scala/org/apache/nlpcraft/examples/time/NCModelValidationSpec.scala
@@ -18,22 +18,23 @@
package org.apache.nlpcraft.examples.time
import org.apache.nlpcraft.*
-import org.junit.jupiter.api.*
+import org.scalatest.funsuite.AnyFunSuite
import scala.util.Using
/**
* JUnit model validation.
*/
-class NCModelValidationSpec:
- @Test
- def test(): Unit = Using.resource(new NCModelClient(new TimeModel())) { client =>
- def check(txt: String, intentId: String): Unit = client.debugAsk(txt, "userId", true).getIntentId == intentId
+class NCModelValidationSpec extends AnyFunSuite:
+ test("test") {
+ Using.resource(new NCModelClient(new TimeModel())) { client =>
+ def check(txt: String, intentId: String): Unit = client.debugAsk(txt, "userId", true).getIntentId == intentId
- check("What time is it now in New York City?", "intent2")
- check("What's the current time in Moscow?", "intent2")
- check("Show me time of the day in London.", "intent2")
- check("Can you please give me the Tokyo's current date and time.", "intent2")
+ check("What time is it now in New York City?", "intent2")
+ check("What's the current time in Moscow?", "intent2")
+ check("Show me time of the day in London.", "intent2")
+ check("Can you please give me the Tokyo's current date and time.", "intent2")
- check("What's the local time?", "intent1")
+ check("What's the local time?", "intent1")
+ }
}
diff --git a/nlpcraft-stanford/pom.xml b/nlpcraft-stanford/pom.xml
index c6300a22..ccab104d 100644
--- a/nlpcraft-stanford/pom.xml
+++ b/nlpcraft-stanford/pom.xml
@@ -48,7 +48,7 @@
</dependency>
<!--
- JUnit & ScalaTest dependencies.
+ ScalaTest dependencies.
===============================
-->
<dependency>
@@ -58,16 +58,9 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- <version>${junit.ver}</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_${scala.major.ver}</artifactId>
- <version>${scalatest.ver}</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/nlpcraft-stanford/src/main/scala/org/apache/nlpcraft/nlp/token/parser/stanford/NCStanfordNLPTokenParser.scala b/nlpcraft-stanford/src/main/scala/org/apache/nlpcraft/nlp/token/parser/stanford/NCStanfordNLPTokenParser.scala
index 408a240a..0869ea2a 100644
--- a/nlpcraft-stanford/src/main/scala/org/apache/nlpcraft/nlp/token/parser/stanford/NCStanfordNLPTokenParser.scala
+++ b/nlpcraft-stanford/src/main/scala/org/apache/nlpcraft/nlp/token/parser/stanford/NCStanfordNLPTokenParser.scala
@@ -24,9 +24,7 @@ import edu.stanford.nlp.util.*
import org.apache.nlpcraft.*
import java.io.StringReader
-import java.util.Objects
import scala.collection.mutable
-import scala.jdk.CollectionConverters.*
/**
*
@@ -43,6 +41,8 @@ class NCStanfordNLPTokenParser(stanford: StanfordCoreNLP) extends NCTokenParser:
val ann = doc.annotation().get(classOf[SentencesAnnotation])
if ann == null then E("Sentence annotation not found.")
+ import scala.jdk.CollectionConverters.*
+
ann.asScala.flatMap(_.asInstanceOf[ArrayCoreMap].get(classOf[TokensAnnotation]).asScala).
zipWithIndex.map { (t, idx) =>
val txt = t.originalText()
diff --git a/nlpcraft-stanford/src/test/scala/org/apache/nlpcraft/nlp/entity/parser/stanford/NCStanfordNLPEntityParserSpec.scala b/nlpcraft-stanford/src/test/scala/org/apache/nlpcraft/nlp/entity/parser/stanford/NCStanfordNLPEntityParserSpec.scala
index 13201f29..707b15c0 100644
--- a/nlpcraft-stanford/src/test/scala/org/apache/nlpcraft/nlp/entity/parser/stanford/NCStanfordNLPEntityParserSpec.scala
+++ b/nlpcraft-stanford/src/test/scala/org/apache/nlpcraft/nlp/entity/parser/stanford/NCStanfordNLPEntityParserSpec.scala
@@ -19,15 +19,14 @@ package org.apache.nlpcraft.nlp.entity.parser.stanford
import org.apache.nlpcraft.nlp.util.{CFG, *}
import org.apache.nlpcraft.nlp.util.stanford.*
-import org.junit.jupiter.api.Test
+import org.scalatest.funsuite.AnyFunSuite
/**
*
*/
-class NCStanfordNLPEntityParserSpec:
+class NCStanfordNLPEntityParserSpec extends AnyFunSuite:
private val parser = NCStanfordNLPEntityParser(STANFORD, Set("city", "date", "number", "email"))
- @Test
- def test(): Unit =
+ test("test") {
val txt = "Los Angeles, 23 August, 23 and sergeykamov@apache.org, tomorrow"
val toks = TOK_STANFORD_PARSER.tokenize(txt)
@@ -36,4 +35,5 @@ class NCStanfordNLPEntityParserSpec:
val res = parser.parse(NCTestRequest(txt), CFG, toks)
NCTestUtils.printEntities(txt, res)
- require(res.size == 5)
\ No newline at end of file
+ require(res.size == 5)
+ }
\ No newline at end of file
diff --git a/nlpcraft-stanford/src/test/scala/org/apache/nlpcraft/nlp/token/parser/stanford/NCStanfordNLPTokenParserSpec.scala b/nlpcraft-stanford/src/test/scala/org/apache/nlpcraft/nlp/token/parser/stanford/NCStanfordNLPTokenParserSpec.scala
index bfbbaa90..271807a6 100644
--- a/nlpcraft-stanford/src/test/scala/org/apache/nlpcraft/nlp/token/parser/stanford/NCStanfordNLPTokenParserSpec.scala
+++ b/nlpcraft-stanford/src/test/scala/org/apache/nlpcraft/nlp/token/parser/stanford/NCStanfordNLPTokenParserSpec.scala
@@ -20,17 +20,13 @@ package org.apache.nlpcraft.nlp.token.parser.stanford
import edu.stanford.nlp.pipeline.StanfordCoreNLP
import org.apache.nlpcraft.nlp.util.*
import org.apache.nlpcraft.nlp.util.stanford.*
-import org.junit.jupiter.api.*
-
-import java.util.Properties
-import scala.jdk.CollectionConverters.*
+import org.scalatest.funsuite.AnyFunSuite
/**
*
*/
-class NCStanfordNLPTokenParserSpec:
- @Test
- def test(): Unit =
+class NCStanfordNLPTokenParserSpec extends AnyFunSuite:
+ test("test") {
val toks = TOK_STANFORD_PARSER.tokenize("I had a lunch with brand names 'AAA'")
require(toks.sizeIs > 1)
@@ -39,3 +35,4 @@ class NCStanfordNLPTokenParserSpec:
val words = toks.map(_.getText)
require(toks.map(_["String"]("pos")).filter(_ != null).distinct.sizeIs > 1)
require(toks.map(_[String]("lemma")).filter(_ != null).zip(words).exists {_ != _})
+ }
diff --git a/nlpcraft/pom.xml b/nlpcraft/pom.xml
index 89afb0df..9511d838 100644
--- a/nlpcraft/pom.xml
+++ b/nlpcraft/pom.xml
@@ -140,16 +140,9 @@
</dependency>
<!--
- JUnit & ScalaTest dependencies.
+ ScalaTest dependencies.
===============================
-->
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-api</artifactId>
- <version>${junit.ver}</version>
- <scope>test</scope>
- </dependency>
-
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_${scala.major.ver}</artifactId>
@@ -218,6 +211,28 @@
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>${maven.surefire.plugin.ver}</version>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.scalatest</groupId>
+ <artifactId>scalatest-maven-plugin</artifactId>
+ <version>${maven.scalatest.plugin.ver}</version>
+ <executions>
+ <execution>
+ <id>test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelPipelineManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelPipelineManager.scala
index 9e096efa..203e63c9 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelPipelineManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelPipelineManager.scala
@@ -26,13 +26,11 @@ import org.apache.nlpcraft.internal.impl.*
import org.apache.nlpcraft.internal.intent.matcher.*
import org.apache.nlpcraft.internal.util.*
-import java.util
+import java.util.UUID
import java.util.concurrent.*
import java.util.concurrent.atomic.*
import java.util.function.Predicate
-import java.util.{Objects, UUID}
import scala.concurrent.ExecutionContext
-import scala.jdk.CollectionConverters.*
/**
*
@@ -159,6 +157,7 @@ class NCModelPipelineManager(cfg: NCModelConfig, pipeline: NCPipeline) extends L
map { case (_, ents) => if ents.sizeIs > 1 then ents.toSet else Set.empty }.filter(_.nonEmpty)
var variants: List[NCVariant] =
+ import scala.jdk.CollectionConverters.*
if overlapEnts.nonEmpty then
NCModelPipelineHelper.
findCombinations(overlapEnts.map(_.asJava).asJava, pool).asScala.
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelScanner.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelScanner.scala
index 70bbdfc8..ecc50fd4 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelScanner.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelScanner.scala
@@ -28,7 +28,6 @@ import org.apache.nlpcraft.internal.util.NCUtils
import java.lang.annotation.Annotation
import java.lang.reflect.*
import scala.collection.mutable
-import scala.jdk.CollectionConverters.*
import scala.util.Using
/**
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/parsers/NCOpenNLPEntityParser.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/parsers/NCOpenNLPEntityParser.scala
index ee99cfdc..64bc8137 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/parsers/NCOpenNLPEntityParser.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/parsers/NCOpenNLPEntityParser.scala
@@ -29,7 +29,6 @@ import java.util.Objects
import scala.Option.*
import scala.collection.mutable
import scala.concurrent.ExecutionContext
-import scala.jdk.CollectionConverters.*
import scala.language.postfixOps
import scala.util.Using
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/parsers/impl/NCSemanticSourceReader.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/parsers/impl/NCSemanticSourceReader.scala
index 667409a4..4a35e3d2 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/parsers/impl/NCSemanticSourceReader.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/parsers/impl/NCSemanticSourceReader.scala
@@ -28,7 +28,6 @@ import org.apache.nlpcraft.nlp.parsers.impl.NCSemanticSourceType.*
import java.io.InputStream
import java.util
-import scala.jdk.CollectionConverters.*
/**
*
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/conversation/NCConversationManagerSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/conversation/NCConversationManagerSpec.scala
index e0c1d413..747d1e90 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/conversation/NCConversationManagerSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/conversation/NCConversationManagerSpec.scala
@@ -18,15 +18,15 @@
package org.apache.nlpcraft.internal.conversation
import org.apache.nlpcraft.*
-import org.junit.jupiter.api.Test
import org.apache.nlpcraft.nlp.util.*
+import org.scalatest.funsuite.AnyFunSuite
import java.util.function.Predicate
/**
*
*/
-class NCConversationManagerSpec:
+class NCConversationManagerSpec extends AnyFunSuite:
def mkConfig(timeout: Long = Long.MaxValue):NCModelConfig =
NCModelConfig(
"testId",
@@ -37,8 +37,7 @@ class NCConversationManagerSpec:
NCModelConfig.DFLT_CONV_DEPTH
)
- @Test
- def test(): Unit =
+ test("test") {
val mgr = NCConversationManager(mkConfig())
val t = NCTestToken()
val reqId = "req1"
@@ -63,9 +62,9 @@ class NCConversationManagerSpec:
conv.clear(_.getId == "e1")
checkSize(1)
require(conv.getEntities.head.getId == "e2")
+ }
- @Test
- def testTimeout(): Unit =
+ test("test timeout") {
val timeout = 1000
val mgr = NCConversationManager(mkConfig(timeout))
@@ -95,4 +94,4 @@ class NCConversationManagerSpec:
checkSize(0)
finally
mgr.close()
-
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/conversation/NCConversationSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/conversation/NCConversationSpec.scala
index 6366a9c1..2d566338 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/conversation/NCConversationSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/conversation/NCConversationSpec.scala
@@ -18,19 +18,17 @@
package org.apache.nlpcraft.internal.conversation
import org.apache.nlpcraft.*
-import annotations.*
-import nlp.util.*
-import nlp.parsers.*
+import org.apache.nlpcraft.annotations.*
+import org.apache.nlpcraft.nlp.parsers.*
+import org.apache.nlpcraft.nlp.util.*
+import org.scalatest.funsuite.AnyFunSuite
-import org.junit.jupiter.api.Assertions.*
-import org.junit.jupiter.api.Test
-import scala.jdk.CollectionConverters.*
import scala.util.Using
/**
*
*/
-class NCConversationSpec:
+class NCConversationSpec extends AnyFunSuite:
private val usrId = "userId"
import NCSemanticTestElement as TE
@@ -38,8 +36,7 @@ class NCConversationSpec:
/**
*
*/
- @Test
- def test(): Unit =
+ test("test") {
val mdl: NCModel =
new NCTestModelAdapter:
override val getPipeline: NCPipeline = mkEnPipeline(TE("e1"), TE("e2"))
@@ -74,9 +71,9 @@ class NCConversationSpec:
// 'e1' received from conversation.
execOk("e2")
}
+ }
- @Test
- def testClearEmptyData(): Unit =
+ test("test clear empty data") {
val mdl: NCModel =
new NCTestModelAdapter:
override val getPipeline: NCPipeline = mkEnPipeline(TE("e1"))
@@ -95,3 +92,4 @@ class NCConversationSpec:
client.clearStm("userId3", _ => true)
client.clearStm("user4")
}
+ }
\ No newline at end of file
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 2cc1ecb6..2941d41a 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
@@ -21,16 +21,13 @@ import org.apache.nlpcraft.*
import annotations.*
import nlp.util.*
import nlp.parsers.*
+import org.scalatest.funsuite.AnyFunSuite
-import org.junit.jupiter.api.Assertions.*
-import org.junit.jupiter.api.Test
-import scala.jdk.CollectionConverters.*
import scala.util.Using
-
/**
*
*/
-class NCConversationTimeoutSpec:
+class NCConversationTimeoutSpec extends AnyFunSuite:
private val TIMEOUT = 200
private val VALUE = "value"
private val EMPTY = "empty"
@@ -38,8 +35,7 @@ class NCConversationTimeoutSpec:
/**
*
*/
- @Test
- def test(): Unit =
+ test("test") {
import NCSemanticTestElement as TE
val mdl: NCModel =
@@ -71,3 +67,4 @@ class NCConversationTimeoutSpec:
check(false)
check(true)
}
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/dialogflow/NCDialogFlowManagerSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/dialogflow/NCDialogFlowManagerSpec.scala
index b14c4ffd..cc029e17 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/dialogflow/NCDialogFlowManagerSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/dialogflow/NCDialogFlowManagerSpec.scala
@@ -20,7 +20,8 @@ package org.apache.nlpcraft.internal.dialogflow
import org.apache.nlpcraft.*
import org.apache.nlpcraft.internal.util.NCUtils
import org.apache.nlpcraft.nlp.util.NCTestRequest
-import org.junit.jupiter.api.*
+import org.scalatest.BeforeAndAfter
+import org.scalatest.funsuite.AnyFunSuite
import java.util
import java.util.function.Predicate
@@ -28,7 +29,7 @@ import java.util.function.Predicate
/**
*
*/
-class NCDialogFlowManagerSpec:
+class NCDialogFlowManagerSpec extends AnyFunSuite with BeforeAndAfter:
case class IntentMatchMock(intentId: String) extends NCIntentMatch:
override val getIntentId: String = intentId
override val getIntentEntities: List[List[NCEntity]] = null
@@ -71,14 +72,13 @@ class NCDialogFlowManagerSpec:
*/
private def addMatchedIntent(id: String, ctx: NCContext): Unit = mgr.addMatchedIntent(IntentMatchMock(id), null, ctx)
+ after {
+ if mgr != null then mgr.close()
+ }
/**
*
*/
- @AfterEach
- def cleanUp(): Unit = if mgr != null then mgr.close()
-
- @Test
- def test(): Unit =
+ test("test") {
mgr = NCDialogFlowManager(mkConfig())
val now = NCUtils.now()
@@ -105,10 +105,11 @@ class NCDialogFlowManagerSpec:
mgr.clear(usrId = "user2")
mgr.clear(usrId = "user3")
check("user1" -> 0, "user2" -> 0, "user3" -> 0, "user4" -> 0)
+ }
- @Test
- def testTimeout(): Unit =
+ test("test timeout") {
val delay = 10
+
val timeout = delay * 1000
mgr = NCDialogFlowManager(mkConfig(timeout))
@@ -130,3 +131,4 @@ class NCDialogFlowManagerSpec:
mgr.close()
check("user1" -> 0, "user2" -> 0)
+ }
\ No newline at end of file
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 5c07dbb5..52c725fa 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
@@ -22,15 +22,14 @@ import NCResultType.*
import annotations.*
import nlp.parsers.*
import nlp.util.*
+import org.scalatest.funsuite.AnyFunSuite
-import org.junit.jupiter.api.*
-import scala.jdk.CollectionConverters.*
import scala.util.Using
/**
*
*/
-class NCModelCallbacksSpec:
+class NCModelCallbacksSpec extends AnyFunSuite:
enum State:
case
MatchFalse, VariantFalse,
@@ -51,8 +50,8 @@ class NCModelCallbacksSpec:
new NCTestModelAdapter():
@NCIntent("intent=x term(x)={# == 'x'}")
def intent(ctx: NCContext, im: NCIntentMatch, @NCIntentTerm("x") x: NCEntity): NCResult =
- if has(IntentError) then throw new RuntimeException("Error")
- else if has(IntentReject) then throw new NCRejection("Rejection")
+ if has(IntentError) then throw new RuntimeException("Expected test error")
+ else if has(IntentReject) then throw new NCRejection("Expected test rejection")
else RESULT_INTENT
override def onMatchedIntent(ctx: NCContext, im: NCIntentMatch): Boolean = getOrElse(MatchFalse, false, true)
@@ -119,27 +118,28 @@ class NCModelCallbacksSpec:
/**
*
*/
- @Test
- def test(): Unit = Using.resource(new NCModelClient(MDL)) { client =>
- testOk(client, RESULT_INTENT)
- testOk(client, RESULT_RESULT, ResultNotNull)
- testOk(client, RESULT_CONTEXT, ContextNotNull)
-
- testFail(client, IntentReject)
- testFail(client, IntentError)
- testFail(client, VariantFalse)
-
- testOk(client, RESULT_REJECTION, IntentReject, RejectionNotNull)
- testOk(client, RESULT_ERROR, IntentError, ErrorNotNull)
-
- // To avoid endless loop.
- val threadReset =
- new Thread("reset-thread"):
- override def run(): Unit =
- Thread.sleep(500)
- states.clear()
-
- threadReset.start()
-
- testOk(client, RESULT_INTENT, MatchFalse)
- }
+ test("test") {
+ Using.resource(new NCModelClient(MDL)) { client =>
+ testOk(client, RESULT_INTENT)
+ testOk(client, RESULT_RESULT, ResultNotNull)
+ testOk(client, RESULT_CONTEXT, ContextNotNull)
+
+ testFail(client, IntentReject)
+ testFail(client, IntentError)
+ testFail(client, VariantFalse)
+
+ testOk(client, RESULT_REJECTION, IntentReject, RejectionNotNull)
+ testOk(client, RESULT_ERROR, IntentError, ErrorNotNull)
+
+ // To avoid endless loop.
+ val threadReset =
+ new Thread("reset-thread"):
+ override def run(): Unit =
+ Thread.sleep(500)
+ states.clear()
+
+ threadReset.start()
+
+ testOk(client, RESULT_INTENT, MatchFalse)
+ }
+ }
\ No newline at end of file
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 9ad62623..e44ee36e 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
@@ -21,15 +21,14 @@ import org.apache.nlpcraft.*
import annotations.*
import nlp.parsers.*
import nlp.util.*
-import org.junit.jupiter.api.Test
+import org.scalatest.funsuite.AnyFunSuite
-import scala.jdk.CollectionConverters.*
import scala.util.Using
/**
*
*/
-class NCModelClientSpec:
+class NCModelClientSpec extends AnyFunSuite:
/**
*
* @param e
@@ -59,21 +58,21 @@ class NCModelClientSpec:
/**
*
*/
- @Test
- def test(): Unit =
+ test("test 1") {
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 = TEST_RESULT
)
+ }
+
/**
*
*/
- @Test
- def test2(): Unit =
+ test("test 2") {
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 = TEST_RESULT
)
-
+ }
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 88b61ea4..bb24a3ef 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
@@ -21,19 +21,17 @@ import org.apache.nlpcraft.*
import annotations.*
import nlp.parsers.*
import nlp.util.*
+import org.scalatest.funsuite.AnyFunSuite
-import org.junit.jupiter.api.Test
import java.util
import scala.collection.mutable
-import scala.jdk.CollectionConverters.*
import scala.util.Using
/**
*
*/
-class NCModelClientSpec2:
- @Test
- def test(): Unit =
+class NCModelClientSpec2 extends AnyFunSuite:
+ test("test") {
val mdl = new NCTestModelAdapter:
import NCSemanticTestElement as TE
override val getPipeline =
@@ -94,6 +92,6 @@ class NCModelClientSpec2:
case e: NCRejection => println(s"Expected rejection: ${e.getMessage}")
case e: Throwable => throw e
}
-
+ }
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 4b6d610c..b1a98634 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
@@ -21,22 +21,20 @@ import org.apache.nlpcraft.*
import annotations.*
import nlp.parsers.*
import nlp.util.*
+import org.scalatest.funsuite.AnyFunSuite
-import org.junit.jupiter.api.Test
import java.util
import scala.collection.mutable
-import scala.jdk.CollectionConverters.*
import scala.util.Using
/**
*
*/
-class NCModelClientSpec3:
- @Test
- def test(): Unit =
+class NCModelClientSpec3 extends AnyFunSuite:
+ test("test") {
import NCSemanticTestElement as TE
- val mdl: NCTestModelAdapter = new NCTestModelAdapter:
+ val mdl: NCTestModelAdapter = new NCTestModelAdapter :
override val getPipeline: NCPipeline = mkEnPipeline(TE("e1"))
@NCIntent("intent=i1 term(t1)={# == 'e1'}")
@@ -61,6 +59,6 @@ class NCModelClientSpec3:
ask()
execCallbackFail(cbData) // Cannot be called, because there are new requests (Error is 'Callback is out of date.')
}
-
+ }
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelPingPongSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelPingPongSpec.scala
index a8d58a75..ee638b48 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelPingPongSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCModelPingPongSpec.scala
@@ -18,19 +18,19 @@
package org.apache.nlpcraft.internal.impl
import org.apache.nlpcraft.*
-import annotations.*
-import nlp.parsers.*
-import nlp.util.*
-import NCResultType.*
-import org.junit.jupiter.api.*
+import org.apache.nlpcraft.NCResultType.*
+import org.apache.nlpcraft.annotations.*
+import org.apache.nlpcraft.nlp.parsers.*
+import org.apache.nlpcraft.nlp.util.*
+import org.scalatest.BeforeAndAfter
+import org.scalatest.funsuite.AnyFunSuite
-import scala.jdk.CollectionConverters.*
import scala.util.Using
/**
*
*/
-class NCModelPingPongSpec:
+class NCModelPingPongSpec extends AnyFunSuite with BeforeAndAfter:
private var client: NCModelClient = _
def mkResult(resType: NCResultType, txt: String): NCResult =
@@ -71,11 +71,13 @@ class NCModelPingPongSpec:
NCSemanticTestElement("other")
))
- @BeforeEach
- def setUp(): Unit = client = new NCModelClient(MDL)
+ before {
+ client = new NCModelClient(MDL)
+ }
- @AfterEach
- def tearDown(): Unit = client.close()
+ after {
+ client.close()
+ }
private def ask(txt: String, typ: NCResultType): Unit =
val res = client.ask(txt, "userId")
@@ -87,19 +89,15 @@ class NCModelPingPongSpec:
private def askForReject(txt: String): Unit =
try ask(txt, ASK_RESULT) catch case e: NCRejection => println(s"Expected reject on: $txt")
- /**
- *
- */
- @Test
- def test(): Unit =
+ test("test 1") {
askForDialog("command")
askForResult("confirm")
+ }
/**
*
*/
- @Test
- def test2(): Unit =
+ test("test 2") {
// 1. Nothing to confirm. No history.
askForReject("confirm")
@@ -109,4 +107,5 @@ class NCModelPingPongSpec:
// 3. Last question is `command`. Can be confirmed.
askForDialog("command")
- askForResult("confirm")
\ No newline at end of file
+ askForResult("confirm")
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCPipelineManagerSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCPipelineManagerSpec.scala
index 3e446da1..a9f44005 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCPipelineManagerSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/NCPipelineManagerSpec.scala
@@ -18,25 +18,23 @@
package org.apache.nlpcraft.internal.impl
import org.apache.nlpcraft.*
-import nlp.parsers.*
-import nlp.util.*
-import org.junit.jupiter.api.*
-import org.junit.jupiter.api.function.Executable
+import org.apache.nlpcraft.nlp.parsers.*
+import org.apache.nlpcraft.nlp.util.*
+import org.scalatest.funsuite.AnyFunSuite
+import org.scalatest.*
+
import java.util
import java.util.concurrent.*
-import scala.concurrent.CancellationException
-import scala.jdk.CollectionConverters.*
/**
*
*/
-class NCPipelineManagerSpec:
+class NCPipelineManagerSpec extends AnyFunSuite:
/**
*
*/
- @Test
- def test(): Unit =
+ test("test") {
def test(txt: String, variantCnt: Int, elements: NCSemanticElement*): Unit =
val pipeline = mkEnPipeline
@@ -53,4 +51,4 @@ class NCPipelineManagerSpec:
test("t1 t2", 4, NCSemanticTestElement("t1", "t2"), NCSemanticTestElement("t2", "t1"))
test("t1 t2", 2, NCSemanticTestElement("t1", "t2"), NCSemanticTestElement("t2"))
-
+ }
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 eae13ea3..c8fddab5 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
@@ -22,15 +22,15 @@ import annotations.*
import nlp.enrichers.*
import nlp.util.*
import internal.impl.{NCCallbackInput, NCModelScanner}
+import org.scalatest.funsuite.AnyFunSuite
-import org.junit.jupiter.api.Test
import java.util
/**
* It tests invalid intents methods parameters types usage.
* Note that for some kind of models (it depends on creation type) we can't check methods arguments during scan.
*/
-class NCModelIntentsInvalidArgsSpec:
+class NCModelIntentsInvalidArgsSpec extends AnyFunSuite:
class DefinedClassModelValid extends NCTestModelAdapter:
@NCIntent("intent=validList term(list)~{# == 'x'}[0,10]")
def validList(ctx: NCContext, im: NCIntentMatch, @NCIntentTerm("list") list: List[NCEntity]): NCResult = processListEntity(list)
@@ -149,8 +149,7 @@ class NCModelIntentsInvalidArgsSpec:
println("Expected stack trace:")
e.printStackTrace(System.out)
- @Test
- def test(): Unit =
+ test("test") {
testOk(CHECKED_MDL_VALID, "validList")
testOk(CHECKED_MDL_VALID, "validOpt")
@@ -166,4 +165,5 @@ class NCModelIntentsInvalidArgsSpec:
testOk(UNCHECKED_MDL, "validList")
testOk(UNCHECKED_MDL, "validOpt")
testRuntimeClassCast(UNCHECKED_MDL, "invalidList")
- testRuntimeClassCast(UNCHECKED_MDL, "invalidOpt")
\ No newline at end of file
+ testRuntimeClassCast(UNCHECKED_MDL, "invalidOpt")
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/scan/NCModelIntentsInvalidIntentsSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/scan/NCModelIntentsInvalidIntentsSpec.scala
index 24c02f15..33867f22 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/scan/NCModelIntentsInvalidIntentsSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/scan/NCModelIntentsInvalidIntentsSpec.scala
@@ -21,14 +21,14 @@ import org.apache.nlpcraft.*
import annotations.*
import nlp.util.*
import internal.impl.NCModelScanner
+import org.scalatest.funsuite.AnyFunSuite
-import org.junit.jupiter.api.Test
import java.util
/**
* It tests invalid intents definition.
*/
-class NCModelIntentsInvalidIntentsSpec:
+class NCModelIntentsInvalidIntentsSpec extends AnyFunSuite:
private def testError(mdl: NCModel): Unit =
try
NCModelScanner.scan(mdl)
@@ -42,31 +42,30 @@ class NCModelIntentsInvalidIntentsSpec:
/**
* Two intents on one method.
*/
- @Test
- def testError1(): Unit =
+ test("test error 1") {
testError(
new NCTestModelAdapter():
@NCIntent("intent=validList1 term(list)~{# == 'x'}[0,10]")
@NCIntent("intent=validList2 term(list)~{# == 'x'}[0,10]")
def x(ctx: NCContext, im: NCIntentMatch, @NCIntentTerm("list") list: List[NCEntity]): NCResult = null
)
+ }
/**
* Invalid reference.
*/
- @Test
- def testError2(): Unit =
+ test("test error 2") {
testError(
new NCTestModelAdapter():
@NCIntentRef("missed")
def x(ctx: NCContext, im: NCIntentMatch, @NCIntentTerm("list") list: List[NCEntity]): NCResult = null
)
+ }
/**
* Duplicated intents definitions.
*/
- @Test
- def testError3(): Unit =
+ test("test error 3") {
@NCIntent("intent=validList1 term(list)~{# == 'x'}[0,10]")
@NCIntent("intent=validList1 term(list)~{# == 'x'}[0,11]")
class X:
@@ -77,14 +76,15 @@ class NCModelIntentsInvalidIntentsSpec:
@NCIntentObject
val x = new X()
)
+ }
/**
* Invalid argument type.
*/
- @Test
- def testError4(): Unit =
+ test("test error 4") {
testError(
new NCTestModelAdapter():
@NCIntent("intent=validList1 term(list)~{# == 'x'}[0,10]")
def x(ctx: NCContext, im: NCIntentMatch, @NCIntentTerm("list") e: NCEntity): NCResult = null
- )
\ No newline at end of file
+ )
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/scan/NCModelIntentsNestedSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/scan/NCModelIntentsNestedSpec.scala
index e09d8511..4e117c60 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/scan/NCModelIntentsNestedSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/scan/NCModelIntentsNestedSpec.scala
@@ -21,13 +21,13 @@ import org.apache.nlpcraft.*
import annotations.*
import nlp.util.*
import internal.impl.NCModelScanner
+import org.scalatest.funsuite.AnyFunSuite
-import org.junit.jupiter.api.Test
/**
* It tests imports and nested objects usage.
*/
-class NCModelIntentsNestedSpec:
+class NCModelIntentsNestedSpec extends AnyFunSuite:
private val MDL_VALID1: NCModel = new NCTestModelAdapter:
@NCIntentObject
val nested1: Object = new Object():
@@ -83,13 +83,12 @@ class NCModelIntentsNestedSpec:
@NCIntentObject
val nested2: Object = null
- @Test
- def test(): Unit =
+ test("test") {
require(NCModelScanner.scan(MDL_VALID1).sizeIs == 4)
require(NCModelScanner.scan(MDL_VALID2).sizeIs == 4)
+ }
- @Test
- def testNull(): Unit =
+ test("test null") {
try
NCModelScanner.scan(MDL_INVALID)
@@ -97,4 +96,5 @@ class NCModelIntentsNestedSpec:
catch
case e: NCException =>
println("Expected stack trace:")
- e.printStackTrace(System.out)
\ No newline at end of file
+ e.printStackTrace(System.out)
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/scan/NCModelIntentsSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/scan/NCModelIntentsSpec.scala
index 498a6d0d..1122f34c 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/scan/NCModelIntentsSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/impl/scan/NCModelIntentsSpec.scala
@@ -19,12 +19,12 @@ package org.apache.nlpcraft.internal.impl.scan
import org.apache.nlpcraft.NCModel
import org.apache.nlpcraft.internal.impl.*
-import org.junit.jupiter.api.Test
+import org.scalatest.funsuite.AnyFunSuite
/**
* It tests various ways created models scanning.
*/
-class NCModelIntentsSpec:
+class NCModelIntentsSpec extends AnyFunSuite:
// Different ways preparing model instances.
private val mdls = Seq(
NCTestModelScala.mkModel,
@@ -32,6 +32,7 @@ class NCModelIntentsSpec:
new NCTestModelScala.NCTestModelScalaClass
)
- @Test
- def test(): Unit = for (mdl <- mdls) require(NCModelScanner.scan(mdl).nonEmpty)
+ test("test") {
+ for (mdl <- mdls) require(NCModelScanner.scan(mdl).nonEmpty)
+ }
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCompilerSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCompilerSpec.scala
index 2b4bff1b..5f1af486 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCompilerSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCompilerSpec.scala
@@ -19,12 +19,12 @@ package org.apache.nlpcraft.internal.intent.compiler
import org.apache.nlpcraft.*
import nlp.util.*
-import org.junit.jupiter.api.Test
+import org.scalatest.funsuite.AnyFunSuite
/**
* Tests for IDL compiler.
*/
-class NCIDLCompilerSpec:
+class NCIDLCompilerSpec extends AnyFunSuite:
private final val MODEL_ID = "test.mdl.id"
private final val compiler = new NCIDLCompiler(CFG)
@@ -37,7 +37,7 @@ class NCIDLCompilerSpec:
try
compiler.compile(idl, MODEL_ID)
assert(true)
- catch case e: Exception => assert(assertion = false, e)
+ catch case e: Exception => assert(condition = false, e)
/**
*
@@ -52,9 +52,7 @@ class NCIDLCompilerSpec:
println(e.getMessage)
assert(true)
- @Test
- @throws[NCException]
- def testInlineCompileOk(): Unit =
+ test("test inline compile ok") {
checkCompileOk(
"""
|import('org/apache/nlpcraft/internal/intent/compiler/test_ok.idl')
@@ -116,10 +114,9 @@ class NCIDLCompilerSpec:
| fragment(f21, {'a': true, 'b': ["s1", "s2"]})
|""".stripMargin
)
+ }
- @Test
- @throws[NCException]
- def testInlineCompileFail(): Unit =
+ test("test inline compile fail") {
checkCompileError(
"""
|intent=i1
@@ -288,12 +285,13 @@ class NCIDLCompilerSpec:
| fragment(f1_, {'a': true, 'b': ["s1", "s2"]})
|""".stripMargin
)
+ }
- @Test
- def testImport(): Unit = require(compiler.compile("import('scan/idl.idl')", "test-origin").size == 1)
+ test("test import") {
+ require(compiler.compile("import('scan/idl.idl')", "test-origin").size == 1)
+ }
- @Test
- def testEmpty(): Unit =
+ test("test empty") {
def test0(idl: String): Unit =
try
compiler.compile(idl, "test-origin")
@@ -303,4 +301,5 @@ class NCIDLCompilerSpec:
test0("")
test0(" ")
+ }
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
index ca071802..21e78f93 100644
--- 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
@@ -22,11 +22,11 @@ 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 org.scalatest.funsuite.AnyFunSuite
import scala.util.Using
-class NCIDLFragmentsOverridingSpec:
+class NCIDLFragmentsOverridingSpec extends AnyFunSuite:
@NCIntent("fragment=f term(x)~{# == 'x1'}")
class M extends NCTestModelAdapter:
// Uses fragment defined on class level.
@@ -39,11 +39,11 @@ class NCIDLFragmentsOverridingSpec:
override val getPipeline: NCPipeline = mkEnPipeline(TE("x1"), TE("x2"))
- @Test
- def test(): Unit =
+ test("test") {
Using.resource(new NCModelClient(new M())) { client =>
def test(ps: (String, Int)*): Unit =
ps.foreach { case (txt, res) => require(client.ask(txt, "usr").getBody == res) }
test("x1" -> 1, "x2" -> 2)
- }
\ No newline at end of file
+ }
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec2.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec2.scala
index c5b74543..59cf911f 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec2.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec2.scala
@@ -22,11 +22,11 @@ import org.apache.nlpcraft.annotations.{NCIntent, NCIntentRef}
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 org.scalatest.funsuite.AnyFunSuite
import scala.util.Using
-class NCIDLFragmentsOverridingSpec2:
+class NCIDLFragmentsOverridingSpec2 extends AnyFunSuite:
@NCIntent("import('org/apache/nlpcraft/internal/intent/compiler/impl_level2.idl')")
class M extends NCTestModelAdapter:
// Uses initial fragment version (with intent), defined in impl_level1.idl.
@@ -43,10 +43,10 @@ class NCIDLFragmentsOverridingSpec2:
override val getPipeline: NCPipeline = mkEnPipeline(TE("x1"), TE("x2"), TE("x3"))
- @Test
- def test(): Unit =
+ test("test") {
Using.resource(new NCModelClient(new M())) { client =>
def test(ps: (String, Int)*): Unit = ps.foreach { case (txt, res) => require(client.ask(txt, "usr").getBody == res) }
test("x1" -> 1, "x2" -> 2, "x3" -> 3)
- }
\ No newline at end of file
+ }
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsSpec.scala
index 8c33c50b..f34fbc74 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsSpec.scala
@@ -21,11 +21,11 @@ import org.apache.nlpcraft.*
import org.apache.nlpcraft.annotations.NCIntent
import org.apache.nlpcraft.internal.impl.NCModelScanner
import org.apache.nlpcraft.nlp.util.*
-import org.junit.jupiter.api.Test
+import org.scalatest.funsuite.AnyFunSuite
import scala.util.Using
-class NCIDLFragmentsSpec:
+class NCIDLFragmentsSpec extends AnyFunSuite:
// Normal models.
// Fragment. One annotations order.
@@ -83,8 +83,7 @@ class NCIDLFragmentsSpec:
require(false, s"Model shouldn't be scanned: ${mdl.getConfig.getId}")
catch case e: NCException => println(s"Model '${mdl.getConfig.getId}' expected error: '${e.getMessage}'")
- @Test
- def test(): Unit =
+ test("test") {
testOk(
new M1(),
new M2(),
@@ -96,4 +95,5 @@ class NCIDLFragmentsSpec:
new E1(),
new E2(),
new E3()
- )
\ No newline at end of file
+ )
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctions.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctions.scala
index bc0a5b61..dd0edb17 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctions.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctions.scala
@@ -22,13 +22,11 @@ import internal.intent.*
import internal.intent.compiler.*
import internal.intent.compiler.functions.*
import nlp.util.*
-import org.junit.jupiter.api.BeforeEach
+import org.scalatest.funsuite.AnyFunSuite
import java.util
import java.util.UUID
-import scala.jdk.CollectionConverters.*
import scala.language.implicitConversions
-
/**
*
*/
@@ -163,7 +161,7 @@ import org.apache.nlpcraft.internal.intent.compiler.functions.NCIDLFunctions.*
/**
* Tests for IDL functions.
*/
-private[functions] trait NCIDLFunctions:
+private[functions] trait NCIDLFunctions extends AnyFunSuite:
/**
*
* @param funcs
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsCollections.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsCollections.scala
index a7ab2728..818d1c22 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsCollections.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsCollections.scala
@@ -18,7 +18,6 @@
package org.apache.nlpcraft.internal.intent.compiler.functions
import org.apache.nlpcraft.*
-import org.junit.jupiter.api.Test
import scala.language.implicitConversions
@@ -28,8 +27,7 @@ import scala.language.implicitConversions
class NCIDLFunctionsCollections extends NCIDLFunctions:
private final val js = "{\"k1\": \"v1\"}"
- @Test
- def test(): Unit =
+ test("test") {
test(
"list(1, 2, 3) == list(1, 2, 3)",
"list(1.0, 2, 3) == list(1.0, 2, 3)",
@@ -77,4 +75,4 @@ class NCIDLFunctionsCollections extends NCIDLFunctions:
"concat(list(), list()) == list()",
"concat(list(1, 2), list(3.0)) == list(1, 2, 3.0)"
)
-
+ }
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsDate.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsDate.scala
index 9628449f..171e43d3 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsDate.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsDate.scala
@@ -20,7 +20,6 @@ package org.apache.nlpcraft.internal.intent.compiler.functions
import org.apache.nlpcraft.*
import org.apache.nlpcraft.internal.intent.compiler.functions.NCIDLFunctions.*
import org.apache.nlpcraft.internal.util.NCUtils
-import org.junit.jupiter.api.Test
import java.time.*
import java.time.temporal.IsoFields
@@ -31,8 +30,7 @@ import scala.language.implicitConversions
* Tests for 'dates' functions.
*/
class NCIDLFunctionsDate extends NCIDLFunctions:
- @Test
- def test(): Unit =
+ test("test") {
def test0(): Unit =
val d = LocalDate.now
val t = LocalTime.now
@@ -56,3 +54,4 @@ class NCIDLFunctionsDate extends NCIDLFunctions:
try test0()
// Some field more than `second` can be changed. One more attempt.
catch case _: AssertionError => test0()
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsEntitiesUsed.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsEntitiesUsed.scala
index d2acafa7..75f18b1b 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsEntitiesUsed.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsEntitiesUsed.scala
@@ -19,14 +19,12 @@ package org.apache.nlpcraft.internal.intent.compiler.functions
import org.apache.nlpcraft.internal.intent.compiler.functions.NCIDLFunctions.*
import org.apache.nlpcraft.nlp.util.NCTestToken
-import org.junit.jupiter.api.Test
/**
* Tests for 'entities used' result.
*/
class NCIDLFunctionsEntitiesUsed extends NCIDLFunctions:
- @Test
- def test(): Unit =
+ test("test") {
val e1 = mkEntity(id = "a", tokens = NCTestToken())
val e2 = mkEntity(id = "b", tokens = NCTestToken())
@@ -61,3 +59,4 @@ class NCIDLFunctionsEntitiesUsed extends NCIDLFunctions:
entitiesUsed = Option(3)
)
)
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsEntity.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsEntity.scala
index 0c91a5e0..3fa008c8 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsEntity.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsEntity.scala
@@ -19,7 +19,6 @@ package org.apache.nlpcraft.internal.intent.compiler.functions
import org.apache.nlpcraft.internal.intent.compiler.functions.NCIDLFunctions.*
import org.apache.nlpcraft.nlp.util.NCTestToken
-import org.junit.jupiter.api.Test
import java.lang.{Boolean as JBool, Integer as JInt}
import scala.language.implicitConversions
@@ -28,8 +27,7 @@ import scala.language.implicitConversions
* Tests for 'entities' functions.
*/
class NCIDLFunctionsEntity extends NCIDLFunctions:
- @Test
- def testMain(): Unit =
+ test("test") {
val t1 = NCTestToken(txt = "W1", idx = 0)
val t2 = NCTestToken(txt = "w2", idx = 1)
@@ -70,9 +68,9 @@ class NCIDLFunctionsEntity extends NCIDLFunctions:
entity = mkEntity(id = "a", tokens = t1, t2)
)
)
+ }
- @Test
- def testTokenFirstLast(): Unit =
+ test("test tokens first and last") {
val e1 = mkEntity(id = "a", tokens = NCTestToken(idx = 0))
val e2 = mkEntity(id = "b", tokens = NCTestToken(idx = 1))
@@ -90,9 +88,9 @@ class NCIDLFunctionsEntity extends NCIDLFunctions:
idlCtx = ctx
)
)
+ }
- @Test
- def testBeforeAfter(): Unit =
+ test("test before and after") {
val e1 = mkEntity(id = "1", tokens = NCTestToken(idx = 0))
val e2 = mkEntity(id = "2", tokens = NCTestToken(idx = 1))
@@ -120,9 +118,9 @@ class NCIDLFunctionsEntity extends NCIDLFunctions:
idlCtx = ctx
)
)
+ }
- @Test
- def testBetween(): Unit =
+ test("test between") {
val e1 = mkEntity(id = "1", groups = Set("grp1"), tokens = NCTestToken(idx = 0))
val e2 = mkEntity(id = "2", groups = Set("grp2"), tokens = NCTestToken(idx = 1))
val e3 = mkEntity(id = "3", groups = Set("grp3"), tokens = NCTestToken(idx = 2))
@@ -141,9 +139,9 @@ class NCIDLFunctionsEntity extends NCIDLFunctions:
idlCtx = ctx
)
)
-
- @Test
- def testForAll(): Unit =
+ }
+
+ test("test all methods") {
val e1 = mkEntity(id = "1", tokens = NCTestToken())
val e2 = mkEntity(id = "2", groups = Set("g", "z", "w"), tokens = NCTestToken())
val e3 = mkEntity(id = "2", tokens = NCTestToken())
@@ -165,3 +163,4 @@ class NCIDLFunctionsEntity extends NCIDLFunctions:
idlCtx = ctx
)
)
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsMath.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsMath.scala
index 857321b2..c28b88fc 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsMath.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsMath.scala
@@ -19,7 +19,6 @@
package org.apache.nlpcraft.internal.intent.compiler.functions
import org.apache.nlpcraft.internal.intent.compiler.functions.NCIDLFunctions.*
-import org.junit.jupiter.api.Test
import scala.language.implicitConversions
@@ -27,19 +26,7 @@ import scala.language.implicitConversions
* Tests for 'math' functions.
*/
class NCIDLFunctionsMath extends NCIDLFunctions:
- @Test
- def testError(): Unit =
- expectError(
- // Invalid name.
- "xxx(1, 1)",
- "xxx()",
- // Invalid arguments count.
- "atan(1, 1) == 1",
- "pi(1)"
- )
-
- @Test
- def test(): Unit =
+ test("test") {
test(
"abs(2) == 2",
"abs(-2.2) == 2.2",
@@ -92,4 +79,16 @@ class NCIDLFunctionsMath extends NCIDLFunctions:
"1 == 1.0",
// Special case. acos(100) == Nan and Nan != Nan
"acos(100) != acos(100)"
- )
\ No newline at end of file
+ )
+ }
+
+ test("test errors") {
+ expectError(
+ // Invalid name.
+ "xxx(1, 1)",
+ "xxx()",
+ // Invalid arguments count.
+ "atan(1, 1) == 1",
+ "pi(1)"
+ )
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsMeta.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsMeta.scala
index 31ef4974..6b7929d8 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsMeta.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsMeta.scala
@@ -21,7 +21,6 @@ import org.apache.nlpcraft.*
import org.apache.nlpcraft.internal.intent.NCIDLContext
import org.apache.nlpcraft.internal.intent.compiler.functions.NCIDLFunctions.*
import org.apache.nlpcraft.nlp.util.NCTestToken
-import org.junit.jupiter.api.Test
import java.util
import java.util.Optional
@@ -33,8 +32,10 @@ import scala.sys.SystemProperties
* Tests for 'meta' functions.
*/
class NCIDLFunctionsMeta extends NCIDLFunctions:
- @Test
- def testMetaSys(): Unit =
+ private def testValue(f: String, idlCtx: => NCIDLContext = mkIdlContext(), entity: Option[NCEntity] = None): Unit = test(TestDesc(truth = s"$f('k1') == 'v1'", entity = entity, idlCtx = idlCtx))
+ private def testNoValue(f: String, idlCtx: => NCIDLContext = mkIdlContext(), entity: Option[NCEntity] = None): Unit = test(TestDesc(truth = s"$f('k1') == null", entity = entity, idlCtx = idlCtx))
+
+ test("test sys meta") {
val sys = new SystemProperties
sys.put("k1", "v1")
@@ -43,45 +44,42 @@ class NCIDLFunctionsMeta extends NCIDLFunctions:
testValue("meta_sys")
finally
sys.remove("k1")
+ }
- @Test
- def testMetaEntity(): Unit =
+ test("test entity meta") {
testValue(
"meta_ent",
entity = Option(mkEntity(meta = Map("k1" -> "v1"), NCTestToken()))
)
+ }
- @Test
- def testMetaRequest(): Unit =
+ test("test request meta") {
testValue(
"meta_req",
mkIdlContext(reqData = Map("k1" -> "v1"))
)
+ }
- @Test
- def testMetaConv(): Unit =
+ test("test conversation meta") {
testValue(
"meta_conv",
mkIdlContext(convMeta = Map("k1" -> "v1"))
)
+ }
- @Test
- def testMetaFrag(): Unit =
+ test("test fragment meta") {
testValue(
"meta_frag",
mkIdlContext(fragMeta = Map("k1" -> "v1"))
)
+ }
// Simplified test.
- @Test
- def testMetaConfig(): Unit = testNoValue("meta_cfg", mkIdlContext())
+ test("test config meta") {
+ testNoValue("meta_cfg", mkIdlContext())
+ }
// Simplified test.
- @Test
- def testMetaIntent(): Unit = testNoValue("meta_intent", mkIdlContext())
-
- private def testValue(f: String, idlCtx: => NCIDLContext = mkIdlContext(), entity: Option[NCEntity] = None): Unit =
- test(TestDesc(truth = s"$f('k1') == 'v1'", entity = entity, idlCtx = idlCtx))
-
- private def testNoValue(f: String, idlCtx: => NCIDLContext = mkIdlContext(), entity: Option[NCEntity] = None): Unit =
- test(TestDesc(truth = s"$f('k1') == null", entity = entity, idlCtx = idlCtx))
+ test("test intent meta") {
+ testNoValue("meta_intent", mkIdlContext())
+ }
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsModel.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsModel.scala
index a059f4ee..18a84b09 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsModel.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsModel.scala
@@ -21,15 +21,13 @@ import org.apache.nlpcraft.*
import nlp.util.*
import internal.intent.compiler.functions.NCIDLFunctions.*
-import org.junit.jupiter.api.Test
import scala.language.implicitConversions
/**
* Tests for 'requests' functions.
*/
class NCIDLFunctionsModel extends NCIDLFunctions:
- @Test
- def test(): Unit =
+ test("test") {
val idlCtx = mkIdlContext(cfg = CFG)
require(idlCtx.mdlCfg.getOrigin.nonEmpty)
@@ -42,12 +40,12 @@ class NCIDLFunctionsModel extends NCIDLFunctions:
mkTestDesc(s"mdl_ver == '${idlCtx.mdlCfg.getVersion}'"),
mkTestDesc(s"mdl_origin == '${idlCtx.mdlCfg.getOrigin.orNull}'")
)
+ }
- @Test
- def testEmptyOrigin(): Unit =
+ test("test empty origin") {
val idlCtx = mkIdlContext(cfg = NCModelConfig("testId", "test", "1.0"))
require(idlCtx.mdlCfg.getOrigin.isEmpty)
test(TestDesc(truth = s"null == ${idlCtx.mdlCfg.getOrigin.orNull}", idlCtx = idlCtx))
-
+ }
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsOther.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsOther.scala
index 650a773c..d7fca7fc 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsOther.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsOther.scala
@@ -18,7 +18,6 @@
package org.apache.nlpcraft.internal.intent.compiler.functions
import org.apache.nlpcraft.internal.intent.compiler.functions.NCIDLFunctions.*
-import org.junit.jupiter.api.Test
import scala.language.implicitConversions
import scala.sys.SystemProperties
@@ -27,8 +26,7 @@ import scala.sys.SystemProperties
* Tests for 'other' functions.
*/
class NCIDLFunctionsOther extends NCIDLFunctions:
- @Test
- def test1(): Unit =
+ test("test 1") {
// If.
test(
TestDesc(truth = "if(true, 1, 0) == 1"),
@@ -37,14 +35,14 @@ class NCIDLFunctionsOther extends NCIDLFunctions:
TestDesc(truth = "or_else('s', list(1, 2, 3)) == 's'"),
TestDesc(truth = "or_else(meta_cfg('unknown_prop'), list(1, 2, 3)) == list(1, 2, 3)")
)
-
- @Test
- def test2(): Unit =
+ }
+
+ test("test 2") {
val sys = new SystemProperties
sys.put("k1", "v1")
- try
+ try
val js = "{\"k1\": \"v1\"}"
// JSON.
@@ -54,16 +52,16 @@ class NCIDLFunctionsOther extends NCIDLFunctions:
)
finally
sys.remove("k1")
+ }
- @Test
- def test3(): Unit =
+ test("test 3") {
test(
"to_string(list(1, 2, 3)) == list('1', '2', '3')",
"to_string(3.123) == '3.123'"
)
+ }
- @Test
- def test4(): Unit =
+ test("test 4") {
test(
"true",
"true == true",
@@ -72,3 +70,4 @@ class NCIDLFunctionsOther extends NCIDLFunctions:
"true != false",
"null == null"
)
+ }
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsRequest.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsRequest.scala
index c9010140..11ab53e9 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsRequest.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsRequest.scala
@@ -18,16 +18,13 @@
package org.apache.nlpcraft.internal.intent.compiler.functions
import org.apache.nlpcraft.internal.intent.compiler.functions.NCIDLFunctions.*
-import org.junit.jupiter.api.Test
-import scala.language.implicitConversions
/**
* Tests for 'requests' functions.
*/
class NCIDLFunctionsRequest extends NCIDLFunctions:
- @Test
- def test(): Unit =
+ test("test") {
val reqSrvReqId = "id"
val text = "some text"
val reqTstamp: java.lang.Long = 123
@@ -48,3 +45,4 @@ class NCIDLFunctionsRequest extends NCIDLFunctions:
mkTestDesc(s"req_tstamp == $reqTstamp"),
mkTestDesc(s"user_id == '$userId'"),
)
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsStat.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsStat.scala
index c05d5f5f..a8ea58b0 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsStat.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsStat.scala
@@ -18,25 +18,13 @@
package org.apache.nlpcraft.internal.intent.compiler.functions
import org.apache.nlpcraft.internal.intent.compiler.functions.NCIDLFunctions.*
-import org.junit.jupiter.api.Test
-
import scala.language.implicitConversions
/**
* Tests for 'stat' functions.
*/
class NCIDLFunctionsStat extends NCIDLFunctions:
- @Test
- def testError(): Unit =
- expectError(
- "avg(list()) == 2",
- "avg(list('A')) == 2",
- "stdev(list()) == 2",
- "stdev(list('A')) == 2"
- )
-
- @Test
- def test(): Unit =
+ test("test") {
test(
"max(list(1, 2, 3)) == 3",
"max(list(1.0, 2.0, 3.0)) == 3.0",
@@ -51,3 +39,13 @@ class NCIDLFunctionsStat extends NCIDLFunctions:
"stdev(list(0.0, 0.0, 0.0)) == 0.0",
"stdev(list(0, 0, 0)) == 0.0"
)
+ }
+
+ test("test errors") {
+ expectError(
+ "avg(list()) == 2",
+ "avg(list('A')) == 2",
+ "stdev(list()) == 2",
+ "stdev(list('A')) == 2"
+ )
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsStrings.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsStrings.scala
index d9515128..32e45851 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsStrings.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsStrings.scala
@@ -18,7 +18,6 @@
package org.apache.nlpcraft.internal.intent.compiler.functions
import org.apache.nlpcraft.internal.intent.compiler.functions.NCIDLFunctions.*
-import org.junit.jupiter.api.Test
import scala.language.implicitConversions
@@ -26,8 +25,7 @@ import scala.language.implicitConversions
* Tests for 'strings' functions.
*/
class NCIDLFunctionsStrings extends NCIDLFunctions:
- @Test
- def test(): Unit =
+ test("test") {
test(
"trim(' a b ') == 'a b'",
"strip(' a b ') == 'a b'",
@@ -80,9 +78,9 @@ class NCIDLFunctionsStrings extends NCIDLFunctions:
"is_whitespace(' ') == true",
"trim(' ') == ''"
)
+ }
- @Test
- def testError(): Unit =
+ test("test errors") {
expectError(
"substr('abc', 10, 30) == 'bc'",
"split('1 A') == true",
@@ -90,3 +88,4 @@ class NCIDLFunctionsStrings extends NCIDLFunctions:
"to_double('1, 1') == true",
"to_double('A') == true"
)
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/util/NCResourceSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/util/NCResourceSpec.scala
index 2ffae4b4..e1f9f4c6 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/util/NCResourceSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/util/NCResourceSpec.scala
@@ -17,14 +17,13 @@
package org.apache.nlpcraft.internal.util
-import org.junit.jupiter.api.Test
+import org.scalatest.funsuite.AnyFunSuite
/**
*
*/
-class NCResourceSpec:
- @Test
- def test(): Unit =
+class NCResourceSpec extends AnyFunSuite:
+ test("test") {
val path = "opennlp/en-token.bin"
// Get and delete.
@@ -39,4 +38,5 @@ class NCResourceSpec:
// By absolute path.
f = NCResourceReader.get(f.getAbsolutePath)
- require(f.exists())
\ No newline at end of file
+ require(f.exists())
+ }
\ No newline at end of file
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 2a031087..7a462408 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityEnricherSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityEnricherSpec.scala
@@ -22,14 +22,13 @@ import annotations.*
import nlp.parsers.*
import nlp.util.*
import internal.util.NCResourceReader
-import org.junit.jupiter.api.Test
+import org.scalatest.funsuite.AnyFunSuite
import scala.util.Using
-
/**
*
*/
-class NCEntityEnricherSpec:
+class NCEntityEnricherSpec extends AnyFunSuite:
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'}")
@@ -45,8 +44,7 @@ class NCEntityEnricherSpec:
private def mkPipeline(apply: NCPipelineBuilder => NCPipelineBuilder): NCPipeline = apply(mkBuilder()).build
- @Test
- def test(): Unit =
+ test("test") {
test0(
mkBuilder().build,
false
@@ -57,4 +55,5 @@ class NCEntityEnricherSpec:
(_: NCRequest, _: NCModelConfig, ents: List[NCEntity]) => ents.foreach(_.put("k1", "v1"))
)),
true
- )
\ No newline at end of file
+ )
+ }
\ No newline at end of file
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 ff73f090..893c0f3e 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityMapperSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityMapperSpec.scala
@@ -22,15 +22,13 @@ import annotations.*
import nlp.parsers.*
import nlp.util.*
import internal.util.NCResourceReader
-import org.junit.jupiter.api.Test
+import org.scalatest.funsuite.AnyFunSuite
-import scala.jdk.CollectionConverters.*
import scala.util.Using
-
/**
*
*/
-class NCEntityMapperSpec:
+class NCEntityMapperSpec extends AnyFunSuite:
private case class Combiner(ids: String*) extends NCEntityMapper:
override def map(req: NCRequest, cfg: NCModelConfig, es: List[NCEntity]): List[NCEntity] =
val replaced = es.filter(p => ids.contains(p.getId))
@@ -69,7 +67,8 @@ class NCEntityMapperSpec:
@NCIntent("intent=abcd term(abcd)={# == 'abcd'}")
def onMatch(ctx: NCContext, im: NCIntentMatch, @NCIntentTerm("abcd") abcd: NCEntity): NCResult = TEST_RESULT
- @Test
- def test(): Unit = Using.resource(new NCModelClient(mdl)) { client =>
- require(client.ask("a b c d", "userId").getIntentId.orNull == "abcd")
+ test("test") {
+ Using.resource(new NCModelClient(mdl)) { client =>
+ require(client.ask("a b c d", "userId").getIntentId.orNull == "abcd")
+ }
}
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 51de067b..b442252f 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityValidatorSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityValidatorSpec.scala
@@ -22,14 +22,13 @@ import annotations.*
import nlp.parsers.*
import nlp.util.*
import internal.util.NCResourceReader
-import org.junit.jupiter.api.Test
+import org.scalatest.funsuite.AnyFunSuite
import scala.util.Using
-
/**
*
*/
-class NCEntityValidatorSpec:
+class NCEntityValidatorSpec extends AnyFunSuite:
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(TEST_RESULT)
@@ -44,8 +43,7 @@ class NCEntityValidatorSpec:
private def mkPipeline(apply: NCPipelineBuilder => NCPipelineBuilder): NCPipeline = apply(mkBuilder()).build
- @Test
- def test(): Unit =
+ test("test") {
test0(
mkBuilder().build,
true
@@ -59,4 +57,5 @@ class NCEntityValidatorSpec:
test0(
mkPipeline(_.withEntityValidator((_: NCRequest, _: NCModelConfig, _: List[NCEntity]) => throw new NCException("Checked Exception"))),
false
- )
\ No newline at end of file
+ )
+ }
\ No newline at end of file
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 86033532..9c19d687 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCTokenEnricherSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCTokenEnricherSpec.scala
@@ -22,14 +22,13 @@ import annotations.*
import nlp.parsers.*
import nlp.util.*
import internal.util.NCResourceReader
+import org.scalatest.funsuite.AnyFunSuite
-import org.junit.jupiter.api.Test
import scala.util.Using
-
/**
*
*/
-class NCTokenEnricherSpec:
+class NCTokenEnricherSpec extends AnyFunSuite:
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'}")
@@ -45,8 +44,7 @@ class NCTokenEnricherSpec:
private def mkPipeline(apply: NCPipelineBuilder => NCPipelineBuilder): NCPipeline = apply(mkBuilder()).build
- @Test
- def test(): Unit =
+ test("test") {
test0(
mkBuilder().build,
false
@@ -57,4 +55,5 @@ class NCTokenEnricherSpec:
(_: NCRequest, _: NCModelConfig, toks: List[NCToken]) => toks.foreach(_.put("k1", "v1"))
)),
true
- )
\ No newline at end of file
+ )
+ }
\ No newline at end of file
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 7be9bda7..1e0bf1ed 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCTokenValidatorSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCTokenValidatorSpec.scala
@@ -21,14 +21,13 @@ import org.apache.nlpcraft.*
import nlp.util.*
import nlp.parsers.*
import internal.util.NCResourceReader
+import org.scalatest.funsuite.AnyFunSuite
-import org.junit.jupiter.api.Test
import scala.util.Using
-
/**
*
*/
-class NCTokenValidatorSpec:
+class NCTokenValidatorSpec extends AnyFunSuite:
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(TEST_RESULT)
@@ -42,8 +41,7 @@ class NCTokenValidatorSpec:
withEntityParser(new NCNLPEntityParser())
private def mkPipeline(apply: NCPipelineBuilder => NCPipelineBuilder): NCPipeline = apply(mkBuilder()).build
- @Test
- def test(): Unit =
+ test("test") {
test0(
mkBuilder().build,
true
@@ -58,3 +56,4 @@ class NCTokenValidatorSpec:
mkPipeline(_.withTokenValidator((req: NCRequest, cfg: NCModelConfig, toks: List[NCToken]) => throw new NCException("Checked Exception"))),
false
)
+ }
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 c0644da4..efea0866 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCVariantFilterSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCVariantFilterSpec.scala
@@ -22,15 +22,14 @@ import annotations.*
import nlp.util.*
import nlp.parsers.*
import internal.util.NCResourceReader
+import org.scalatest.funsuite.AnyFunSuite
-import org.junit.jupiter.api.Test
import java.util
import scala.util.Using
-
/**
*
*/
-class NCVariantFilterSpec:
+class NCVariantFilterSpec extends AnyFunSuite:
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}")
@@ -46,8 +45,7 @@ class NCVariantFilterSpec:
private def mkPipeline(apply: NCPipelineBuilder => NCPipelineBuilder): NCPipeline = apply(mkBuilder()).build
- @Test
- def test(): Unit =
+ test("test") {
test0(
mkBuilder().build,
true
@@ -56,4 +54,5 @@ class NCVariantFilterSpec:
test0(
mkPipeline(_.withVariantFilter((_: NCRequest, _: NCModelConfig, _: List[NCVariant]) => List.empty)),
false
- )
\ No newline at end of file
+ )
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/NCBracketsTokenEnricherSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/NCBracketsTokenEnricherSpec.scala
index 6e3e195a..480edd24 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/NCBracketsTokenEnricherSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/NCBracketsTokenEnricherSpec.scala
@@ -20,14 +20,12 @@ package org.apache.nlpcraft.nlp.enrichers
import org.apache.nlpcraft.*
import nlp.enrichers.NCEnBracketsTokenEnricher
import nlp.util.*
-import org.junit.jupiter.api.*
-
-import scala.jdk.CollectionConverters.*
+import org.scalatest.funsuite.AnyFunSuite
/**
*
*/
-class NCBracketsTokenEnricherSpec:
+class NCBracketsTokenEnricherSpec extends AnyFunSuite:
private val bracketsEnricher = new NCEnBracketsTokenEnricher()
/**
@@ -43,8 +41,8 @@ class NCBracketsTokenEnricherSpec:
toks.foreach (tok => require(!(tok[Boolean]("brackets") ^ brackets.contains(tok.getIndex))))
- @Test
- def test(): Unit =
+ test("test") {
check("A [ B C ] D", Set(2, 3))
check("A [ B { C } ] D", Set(2, 3, 4, 5))
check("A [ B { C } ] [ [ D ] ] [ E ]", Set(2, 3, 4, 5, 8, 9, 10, 13))
+ }
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/NCDictionaryTokenEnricherSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/NCDictionaryTokenEnricherSpec.scala
index d17eafc6..f6f945b7 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/NCDictionaryTokenEnricherSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/NCDictionaryTokenEnricherSpec.scala
@@ -22,18 +22,12 @@ import annotations.*
import nlp.enrichers.*
import nlp.util.*
import internal.util.NCResourceReader
-import org.junit.jupiter.api.*
+import org.scalatest.funsuite.AnyFunSuite
-import scala.jdk.CollectionConverters.*
-
-/**
- *
- */
-class NCDictionaryTokenEnricherSpec:
+class NCDictionaryTokenEnricherSpec extends AnyFunSuite:
private val dictEnricher = new NCEnDictionaryTokenEnricher()
- @Test
- def test(): Unit =
+ test("test") {
val txt = "milk XYZ"
val toks = EN_TOK_PARSER.tokenize(txt)
@@ -47,4 +41,5 @@ class NCDictionaryTokenEnricherSpec:
NCTestUtils.printTokens(toks)
require(toks.head[Boolean]("dict"))
- require(!toks.last[Boolean]("dict"))
\ No newline at end of file
+ require(!toks.last[Boolean]("dict"))
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/NCQuotesTokenEnricherSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/NCQuotesTokenEnricherSpec.scala
index 9be63daa..3f87f757 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/NCQuotesTokenEnricherSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/NCQuotesTokenEnricherSpec.scala
@@ -22,15 +22,12 @@ import annotations.*
import nlp.enrichers.*
import nlp.util.*
import internal.util.NCResourceReader
-
-import org.junit.jupiter.api.*
-
-import scala.jdk.CollectionConverters.*
+import org.scalatest.funsuite.AnyFunSuite
/**
*
*/
-class NCQuotesTokenEnricherSpec:
+class NCQuotesTokenEnricherSpec extends AnyFunSuite:
private val quoteEnricher = new NCEnQuotesTokenEnricher
/**
@@ -48,7 +45,7 @@ class NCQuotesTokenEnricherSpec:
NCTestUtils.printTokens(toks)
toks.foreach (tok => require(!(tok[Boolean]("quoted") ^ quotes.contains(tok.getIndex))))
- @Test
- def test(): Unit =
+ test("test") {
check("It called ' test data '", Set(3, 4))
- check("It called ' test data ' , ' test data '", Set(3, 4, 8, 9))
\ No newline at end of file
+ check("It called ' test data ' , ' test data '", Set(3, 4, 8, 9))
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/NCStopWordsEnricherSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/NCStopWordsEnricherSpec.scala
index 118e2876..d0c92d40 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/NCStopWordsEnricherSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/NCStopWordsEnricherSpec.scala
@@ -21,15 +21,12 @@ import org.apache.nlpcraft.*
import internal.util.NCResourceReader
import nlp.util.*
import nlp.enrichers.NCEnStopWordsTokenEnricher
-
-import org.junit.jupiter.api.*
-import java.util
-import scala.jdk.CollectionConverters.*
+import org.scalatest.funsuite.AnyFunSuite
/**
*
*/
-class NCStopWordsEnricherSpec:
+class NCStopWordsEnricherSpec extends AnyFunSuite:
/**
*
* @param stopEnricher
@@ -50,8 +47,7 @@ class NCStopWordsEnricherSpec:
NCTestUtils.printTokens(toks)
toks.zip(boolVals).foreach { (tok, boolVal) => require(tok[Boolean]("stopword") == boolVal) }
- @Test
- def test(): Unit =
+ test("test") {
test(
EN_TOK_STOP_ENRICHER,
"the test",
@@ -63,4 +59,5 @@ class NCStopWordsEnricherSpec:
"the test",
false,
true
- )
\ No newline at end of file
+ )
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/NCSwearWordsTokenEnricherSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/NCSwearWordsTokenEnricherSpec.scala
index 930d3263..86303dea 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/NCSwearWordsTokenEnricherSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/NCSwearWordsTokenEnricherSpec.scala
@@ -21,19 +21,14 @@ import org.apache.nlpcraft.internal.util.NCResourceReader
import org.apache.nlpcraft.nlp.enrichers.NCEnSwearWordsTokenEnricher
import org.apache.nlpcraft.nlp.enrichers.*
import org.apache.nlpcraft.nlp.util.*
-import org.junit.jupiter.api.*
-
-import scala.jdk.CollectionConverters.*
-
-
+import org.scalatest.funsuite.AnyFunSuite
/**
*
*/
-class NCSwearWordsTokenEnricherSpec:
+class NCSwearWordsTokenEnricherSpec extends AnyFunSuite:
private val swEnricher = new NCEnSwearWordsTokenEnricher(NCResourceReader.getPath("badfilter/swear_words.txt"))
- @Test
- def test(): Unit =
+ test("test") {
val toks = EN_TOK_PARSER.tokenize("english ass")
require(toks.head.get[Boolean]("swear:en").isEmpty)
@@ -44,4 +39,5 @@ class NCSwearWordsTokenEnricherSpec:
NCTestUtils.printTokens(toks)
require(!toks.head[Boolean]("swear"))
- require(toks.last[Boolean]("swear"))
\ No newline at end of file
+ require(toks.last[Boolean]("swear"))
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/impl/NCStopWordsImplSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/impl/NCStopWordsImplSpec.scala
index 1b14e1f3..5cdc5476 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/impl/NCStopWordsImplSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/enrichers/impl/NCStopWordsImplSpec.scala
@@ -20,15 +20,12 @@ package org.apache.nlpcraft.nlp.enrichers.impl
import org.apache.nlpcraft.*
import org.apache.nlpcraft.nlp.enrichers.NCEnStopWordsTokenEnricher
import org.apache.nlpcraft.nlp.util.*
-import org.junit.jupiter.api.*
-
-import scala.jdk.CollectionConverters.*
-
+import org.scalatest.funsuite.AnyFunSuite
/**
*
*/
-class NCStopWordsImplSpec:
+class NCStopWordsImplSpec extends AnyFunSuite:
case class W(text: String, stop: Boolean)
/**
@@ -49,8 +46,7 @@ class NCStopWordsImplSpec:
require(expectedSorted == resSorted, s"Expected=$expectedSorted, result=$resSorted")
- @Test
- def testPermute(): Unit =
+ test("test permute") {
test0(
Seq(W("A", false), W("B", true), W("C", true)),
Seq("ABC", "AB", "AC", "BC", "A", "B", "C")
@@ -59,3 +55,4 @@ class NCStopWordsImplSpec:
Seq(W("A", false), W("B", false), W("C", false)),
Seq("ABC", "AB", "BC", "A", "B", "C")
)
+ }
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCNLPEntityParserSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCNLPEntityParserSpec.scala
index f0c3755d..6248a926 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCNLPEntityParserSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCNLPEntityParserSpec.scala
@@ -20,25 +20,18 @@ package org.apache.nlpcraft.nlp.parsers
import org.apache.nlpcraft.*
import nlp.parsers.*
import nlp.util.*
+import org.scalatest.funsuite.AnyFunSuite
-import org.junit.jupiter.api.*
import java.util
import scala.collection.mutable
import scala.concurrent.ExecutionContext
-import scala.jdk.CollectionConverters.*
-import scala.jdk.OptionConverters.RichOptional
-
/**
*
*/
-class NCNLPEntityParserSpec:
+class NCNLPEntityParserSpec extends AnyFunSuite:
private val parser = new NCNLPEntityParser()
- /**
- *
- */
- @Test
- def test(): Unit =
+ test("test") {
val req = NCTestRequest("I had the lunch")
val toks = EN_TOK_PARSER.tokenize(req.txt)
val entities = parser.parse(req, CFG, toks)
@@ -50,3 +43,4 @@ class NCNLPEntityParserSpec:
require(ent.getTokens.size == 1)
require(ent.getTokens.head == toks(idx))
}
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCOpenNLPEntityParserSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCOpenNLPEntityParserSpec.scala
index 72137148..628864eb 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCOpenNLPEntityParserSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCOpenNLPEntityParserSpec.scala
@@ -18,24 +18,27 @@
package org.apache.nlpcraft.nlp.parsers
import org.apache.nlpcraft.*
-import internal.util.*
-import nlp.parsers.*
-import nlp.util.*
+import org.apache.nlpcraft.internal.util.*
+import org.apache.nlpcraft.nlp.parsers.*
+import org.apache.nlpcraft.nlp.util.*
+import org.scalatest.funsuite.AnyFunSuite
-import org.junit.jupiter.api.*
+import java.io.File
import java.util
import scala.collection.mutable
import scala.concurrent.ExecutionContext
import scala.jdk.CollectionConverters.*
-import scala.jdk.OptionConverters.RichOptional
/**
*
*/
-class NCOpenNLPEntityParserSpec:
+class NCOpenNLPEntityParserSpec extends AnyFunSuite:
private val parser =
val list = new java.util.concurrent.CopyOnWriteArrayList[String]()
+ // Added to avoid errors on missed folder creation.
+ new File(s"${System.getProperty("user.home")}/.nlpcraft/extcfg/opennlp").mkdirs()
+
NCUtils.execPar(
Seq(
"opennlp/en-ner-location.bin",
@@ -66,11 +69,11 @@ class NCOpenNLPEntityParserSpec:
/**
*
*/
- @Test
- def test(): Unit =
+ test("test") {
check("today", "date")
check("Moscow", "location")
check("10 is 5 % from 200", "percentage")
check("Tim Cook", "person")
check("Microsoft", "organization")
- check("Current price is higher for 20 USA dollars", "money")
\ No newline at end of file
+ check("Current price is higher for 20 USA dollars", "money")
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCOpenNLPTokenParserSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCOpenNLPTokenParserSpec.scala
index cfa201c3..dae3e961 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCOpenNLPTokenParserSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCOpenNLPTokenParserSpec.scala
@@ -22,15 +22,12 @@ import org.apache.nlpcraft.internal.ascii.NCAsciiTable
import org.apache.nlpcraft.internal.util.NCResourceReader
import org.apache.nlpcraft.nlp.enrichers.*
import org.apache.nlpcraft.nlp.util.*
-import org.junit.jupiter.api.*
-
-import java.util
-import scala.jdk.CollectionConverters.*
+import org.scalatest.funsuite.AnyFunSuite
/**
*
*/
-class NCOpenNLPTokenParserSpec:
+class NCOpenNLPTokenParserSpec extends AnyFunSuite:
private def isStopWord(t: NCToken): Boolean = t[Boolean]("stopword")
private def test(txt: String, validate: Seq[NCToken] => _): Unit =
@@ -45,8 +42,7 @@ class NCOpenNLPTokenParserSpec:
NCTestUtils.printTokens(toks)
validate(toks)
- @Test
- def test(): Unit =
+ test("test") {
test(
"Test requests!",
toks =>
@@ -95,4 +91,5 @@ class NCOpenNLPTokenParserSpec:
// Nested brackets.
"< < [ a ] > >",
toks => require(!isStopWord(toks.find(_.getText == "a").get))
- )
\ No newline at end of file
+ )
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticEntityParserJsonSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticEntityParserJsonSpec.scala
index 16b26160..4d1cbe09 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticEntityParserJsonSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticEntityParserJsonSpec.scala
@@ -20,18 +20,16 @@ package org.apache.nlpcraft.nlp.parsers
import org.apache.nlpcraft.*
import nlp.parsers.*
import nlp.util.*
-import org.junit.jupiter.api.*
+import org.scalatest.funsuite.AnyFunSuite
import java.util
import scala.collection.mutable
import scala.concurrent.ExecutionContext
-import scala.jdk.CollectionConverters.*
-import scala.jdk.OptionConverters.RichOptional
/**
*
*/
-class NCSemanticEntityParserJsonSpec:
+class NCSemanticEntityParserJsonSpec extends AnyFunSuite:
private val semParser = NCTestUtils.mkEnSemanticParser("models/alarm_model.json")
/**
@@ -56,11 +54,11 @@ class NCSemanticEntityParserJsonSpec:
/**
*
*/
- @Test
- def test(): Unit =
+ test("test") {
check(
"Ping me in 3 minutes tomorrow",
"x:alarm",
// File contains these data for element.
elemData = Option(Map("testKey" -> "testValue"))
- )
\ No newline at end of file
+ )
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticEntityParserLemmaSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticEntityParserLemmaSpec.scala
index 1f2168fa..299a8fdf 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticEntityParserLemmaSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticEntityParserLemmaSpec.scala
@@ -22,18 +22,15 @@ import annotations.*
import nlp.parsers.*
import internal.impl.*
import nlp.util.*
-import org.junit.jupiter.api.*
+import org.scalatest.funsuite.AnyFunSuite
import java.util
import java.util.UUID
import scala.collection.mutable
-import scala.jdk.CollectionConverters.*
-
/**
*
*/
-class NCSemanticEntityParserLemmaSpec:
-
+class NCSemanticEntityParserLemmaSpec extends AnyFunSuite:
private val lemmaStemmer =
new NCSemanticStemmer():
override def stem(txt: String): String = if wrapped(txt) then unwrap(txt) else UUID.randomUUID().toString
@@ -92,8 +89,7 @@ class NCSemanticEntityParserLemmaSpec:
/**
*
*/
- @Test
- def test(): Unit =
+ test("test") {
// Lemma.
ask(
"my test",
@@ -113,4 +109,5 @@ class NCSemanticEntityParserLemmaSpec:
"my test",
List(NCSemanticTestElement("X", synonyms = Set(deepWrap("my test"), wrap("my //[a-z]+//")))),
List(List(Data("my test", "X")))
- )
\ No newline at end of file
+ )
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticEntityParserSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticEntityParserSpec.scala
index 0a551023..9330a331 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticEntityParserSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticEntityParserSpec.scala
@@ -21,16 +21,15 @@ import org.apache.nlpcraft.*
import annotations.*
import nlp.parsers.*
import nlp.util.*
+import org.scalatest.funsuite.AnyFunSuite
-import org.junit.jupiter.api.*
-import java.util
import scala.collection.mutable
import scala.concurrent.ExecutionContext
/**
*
*/
-class NCSemanticEntityParserSpec:
+class NCSemanticEntityParserSpec extends AnyFunSuite:
private val semParser: NCSemanticEntityParser =
NCTestUtils.mkEnSemanticParser(
List(
@@ -107,8 +106,7 @@ class NCSemanticEntityParserSpec:
/**
*
*/
- @Test
- def test(): Unit =
+ test("test") {
check("t1", "t1")
check("the t1", "t1")
check("t2", "t2")
@@ -123,4 +121,5 @@ class NCSemanticEntityParserSpec:
check("A", "t8")
check("B", "t8")
- checkMultiple("t1 the x abc the x the abc", "t1", "t7", "t7")
\ No newline at end of file
+ checkMultiple("t1 the x abc the x the abc", "t1", "t7", "t7")
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticEntityParserYamlSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticEntityParserYamlSpec.scala
index 807f66ab..1828b759 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticEntityParserYamlSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticEntityParserYamlSpec.scala
@@ -21,18 +21,15 @@ import org.apache.nlpcraft.*
import annotations.*
import nlp.parsers.*
import nlp.util.*
-import org.junit.jupiter.api.*
+import org.scalatest.funsuite.AnyFunSuite
import java.util
import scala.collection.mutable
import scala.concurrent.ExecutionContext
-import scala.jdk.CollectionConverters.*
-import scala.jdk.OptionConverters.RichOptional
-
/**
*
*/
-class NCSemanticEntityParserYamlSpec:
+class NCSemanticEntityParserYamlSpec extends AnyFunSuite:
private val semParser: NCSemanticEntityParser = NCTestUtils.mkEnSemanticParser("models/lightswitch_model.yaml")
/**
@@ -53,5 +50,6 @@ class NCSemanticEntityParserYamlSpec:
/**
*
*/
- @Test
- def test(): Unit = check("Turn the lights off in the entire house.", "ls:off")
\ No newline at end of file
+ test("test") {
+ check("Turn the lights off in the entire house.", "ls:off")
+ }
\ No newline at end of file
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticTestElement.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticTestElement.scala
index ea8a528f..b4090868 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticTestElement.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/parsers/NCSemanticTestElement.scala
@@ -21,7 +21,6 @@ import org.apache.nlpcraft.*
import org.apache.nlpcraft.nlp.parsers.NCSemanticElement
import java.util
-import scala.jdk.CollectionConverters.*
/**
*
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/util/NCTestUtils.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/util/NCTestUtils.scala
index ffe60163..64b9dbaa 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/util/NCTestUtils.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/util/NCTestUtils.scala
@@ -26,8 +26,6 @@ import org.apache.nlpcraft.nlp.parsers
import org.apache.nlpcraft.nlp.parsers.{NCOpenNLPTokenParser, NCSemanticElement, NCSemanticEntityParser, NCSemanticStemmer}
import java.util
-import scala.jdk.CollectionConverters.*
-import scala.jdk.OptionConverters.RichOptional
import scala.util.Using
/**
diff --git a/pom.xml b/pom.xml
index d3a88596..7e04b1ee 100644
--- a/pom.xml
+++ b/pom.xml
@@ -90,6 +90,7 @@
<maven.compiler.plugin.ver>3.8.1</maven.compiler.plugin.ver>
<maven.enforcer.plugin.ver>1.4.1</maven.enforcer.plugin.ver>
<maven.surefire.plugin.ver>2.22.1</maven.surefire.plugin.ver>
+ <maven.scalatest.plugin.ver>2.1.0</maven.scalatest.plugin.ver>
<maven.shade.plugin.ver>3.2.1</maven.shade.plugin.ver>
<maven.project.info.reports.plugin.ver>2.2</maven.project.info.reports.plugin.ver>
<maven.install.plugin.ver>2.5.2</maven.install.plugin.ver>
@@ -103,12 +104,11 @@
<commons.codec.ver>1.15</commons.codec.ver>
<commons.collections.ver>4.4</commons.collections.ver>
<scala3.ref.ver>1.1.4</scala3.ref.ver>
- <junit.ver>5.9.0</junit.ver>
- <scalatest.ver>3.2.13</scalatest.ver>
<jackson.ver>2.13.3</jackson.ver>
<jackson.yaml.ver>2.13.3</jackson.yaml.ver>
<apache.opennlp.ver>2.0.0</apache.opennlp.ver>
<gson.ver>2.9.1</gson.ver>
+ <scalatest.ver>3.2.13</scalatest.ver>
<!-- Force specific encoding on text resources. -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -265,13 +265,6 @@
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.junit.jupiter</groupId>
- <artifactId>junit-jupiter-engine</artifactId>
- <version>${junit.ver}</version>
- <scope>test</scope>
- </dependency>
-
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>