This is an automated email from the ASF dual-hosted git repository.
sergeykamov pushed a commit to branch NLPCRAFT-28
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-28 by this push:
new ec15238 WIP.
ec15238 is described below
commit ec15238e4db737b8f4c2313fea7c4becbb04f695
Author: Sergey Kamov <[email protected]>
AuthorDate: Sun Mar 29 14:17:17 2020 +0300
WIP.
---
pom.xml | 1 +
.../common/blowfish/NCBlowfishHasherSpec.scala | 5 +-
.../nlpcraft/common/crypto/NCCipherSpec.scala | 6 +-
.../nlpcraft/common/makro/NCMacroParserSpec.scala | 37 +++---
.../apache/nlpcraft/common/util/NCUtilsSpec.scala | 15 +--
.../nlpcraft/model/intent/dsl/NCDslTest.java | 16 ++-
.../intent/impl/NCIntentSolverEngineSpec.scala | 19 +--
.../model/tools/NCSqlModelEngineSpec.scala | 41 +++----
.../mgrs/nlp/enrichers/NCDefaultTestModel.scala | 2 +-
.../mgrs/nlp/enrichers/NCEnrichersTestBeans.scala | 2 +-
.../nlp/enrichers/limit/NCEnricherLimitSpec.scala | 2 +-
.../relation/NCEnricherRelationSpec.scala | 2 +-
.../nlp/enrichers/sort/NCEnricherSortSpec.scala | 2 +-
.../enrichers/date/tools/NCDateGeneratorSpec.scala | 129 +++++++++++++--------
14 files changed, 163 insertions(+), 116 deletions(-)
diff --git a/pom.xml b/pom.xml
index 7f21291..5456bd7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -552,6 +552,7 @@
</goals>
<configuration>
<skip>false</skip>
+ <!-- Mandatory part. -->
<includes>
<include>**/*.*</include>
</includes>
diff --git
a/src/test/scala/org/apache/nlpcraft/common/blowfish/NCBlowfishHasherSpec.scala
b/src/test/scala/org/apache/nlpcraft/common/blowfish/NCBlowfishHasherSpec.scala
index 93901e6..a7529c9 100644
---
a/src/test/scala/org/apache/nlpcraft/common/blowfish/NCBlowfishHasherSpec.scala
+++
b/src/test/scala/org/apache/nlpcraft/common/blowfish/NCBlowfishHasherSpec.scala
@@ -17,6 +17,7 @@
package org.apache.nlpcraft.common.blowfish
+import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
/**
@@ -36,8 +37,8 @@ class NCBlowfishHasherSpec {
val hash1 = NCBlowfishHasher.hash(passwd, salt1)
val hash2 = NCBlowfishHasher.hash(passwd, salt1)
-
- assert(hash1 == hash2)
+
+ assertTrue(hash1 == hash2)
println(s"Salt: $salt1")
println(s"Hash: $hash1")
diff --git
a/src/test/scala/org/apache/nlpcraft/common/crypto/NCCipherSpec.scala
b/src/test/scala/org/apache/nlpcraft/common/crypto/NCCipherSpec.scala
index a1398fc..d0af6c0 100644
--- a/src/test/scala/org/apache/nlpcraft/common/crypto/NCCipherSpec.scala
+++ b/src/test/scala/org/apache/nlpcraft/common/crypto/NCCipherSpec.scala
@@ -20,7 +20,7 @@ package org.apache.nlpcraft.common.crypto
import java.util.Base64
import org.apache.nlpcraft.common._
-import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Assertions.{assertEquals, assertTrue}
import org.junit.jupiter.api.Test
/**
* Tests for crypto and PKI support.
@@ -42,8 +42,8 @@ class NCCipherSpec {
val s2 = NCCipher.encrypt(IN)
val s3 = NCCipher.encrypt(IN)
- assert(s1 != s2)
- assert(s2 != s3)
+ assertTrue(s1 != s2)
+ assertTrue(s2 != s3)
val r1 = NCCipher.decrypt(s1)
val r2 = NCCipher.decrypt(s2)
diff --git
a/src/test/scala/org/apache/nlpcraft/common/makro/NCMacroParserSpec.scala
b/src/test/scala/org/apache/nlpcraft/common/makro/NCMacroParserSpec.scala
index 1068d21..1a77bf4 100644
--- a/src/test/scala/org/apache/nlpcraft/common/makro/NCMacroParserSpec.scala
+++ b/src/test/scala/org/apache/nlpcraft/common/makro/NCMacroParserSpec.scala
@@ -18,6 +18,7 @@
package org.apache.nlpcraft.common.makro
import org.apache.nlpcraft.common._
+import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import scala.compat.Platform._
@@ -63,8 +64,8 @@ class NCMacroParserSpec {
def testToken(txt: String, tokHead: String, tokTail: String): Unit = {
val tok = parser.nextToken(txt)
- assert(tok.get.head == tokHead)
- assert(tok.get.tail == tokTail)
+ assertTrue(tok.get.head == tokHead)
+ assertTrue(tok.get.tail == tokTail)
}
/**
@@ -73,7 +74,7 @@ class NCMacroParserSpec {
* @param exp Expected expansion strings.
*/
def testParser(txt: String, exp: Seq[String]): Unit =
- assert(parser.expand(txt).sorted == exp.sorted)
+ assertTrue(parser.expand(txt).sorted == exp.sorted)
/**
*
@@ -83,7 +84,7 @@ class NCMacroParserSpec {
def testGroup(txt: String, grps: Seq[String]): Unit = {
val elms = parser.parseGroup(txt)
- assert(grps == elms.map(_.head))
+ assertTrue(grps == elms.map(_.head))
}
@Test
@@ -212,10 +213,10 @@ class NCMacroParserSpec {
"a c"
))
- ignoreNCE { testParser("a | b", Seq.empty); assert(false) }
- ignoreNCE { testParser("a *", Seq.empty); assert(false) }
- ignoreNCE { testParser("a}}", Seq.empty); assert(false) }
- ignoreNCE { testParser("a {a|b} *", Seq.empty); assert(false) }
+ ignoreNCE { testParser("a | b", Seq.empty); assertTrue(false) }
+ ignoreNCE { testParser("a *", Seq.empty); assertTrue(false) }
+ ignoreNCE { testParser("a}}", Seq.empty); assertTrue(false) }
+ ignoreNCE { testParser("a {a|b} *", Seq.empty); assertTrue(false) }
}
@Test
@@ -228,9 +229,9 @@ class NCMacroParserSpec {
testGroup("{a {c}|b|*}", Seq("a {c}", "b", "*"))
testGroup("""{/abc.\*/|\{\*\}}""", Seq("/abc.\\*/", "\\{\\*\\}"))
- ignoreNCE { parser.parseGroup("a"); assert(false) }
- ignoreNCE { parser.parseGroup("{a"); assert(false) }
- ignoreNCE { parser.parseGroup("a}"); assert(false) }
+ ignoreNCE { parser.parseGroup("a"); assertTrue(false) }
+ ignoreNCE { parser.parseGroup("{a"); assertTrue(false) }
+ ignoreNCE { parser.parseGroup("a}"); assertTrue(false) }
}
@Test
@@ -246,13 +247,13 @@ class NCMacroParserSpec {
testToken("c{a} b", "c", "{a} b")
testToken("{{{a}}}", "{{{a}}}", "")
- ignoreNCE { parser.nextToken("a } b"); assert(false) }
- ignoreNCE { parser.nextToken("{c b"); assert(false) }
- ignoreNCE { parser.nextToken("a | b"); assert(false) }
- ignoreNCE { parser.nextToken("a |*"); assert(false) }
+ ignoreNCE { parser.nextToken("a } b"); assertTrue(false) }
+ ignoreNCE { parser.nextToken("{c b"); assertTrue(false) }
+ ignoreNCE { parser.nextToken("a | b"); assertTrue(false) }
+ ignoreNCE { parser.nextToken("a |*"); assertTrue(false) }
- assert(parser.nextToken("").isEmpty)
- assert(parser.nextToken(" ").isDefined)
+ assertTrue(parser.nextToken("").isEmpty)
+ assertTrue(parser.nextToken(" ").isDefined)
}
@Test
@@ -260,7 +261,7 @@ class NCMacroParserSpec {
ignoreNCE {
parser.expand("<METRICS> <USER> <BY> <WEBSITE> <BY> <SES> <BY>
<METRICS> <BY> <USER> <BY> <METRICS>")
- assert(false)
+ assertTrue(false)
}
}
}
diff --git a/src/test/scala/org/apache/nlpcraft/common/util/NCUtilsSpec.scala
b/src/test/scala/org/apache/nlpcraft/common/util/NCUtilsSpec.scala
index d4b5e5c..4a4ed27 100644
--- a/src/test/scala/org/apache/nlpcraft/common/util/NCUtilsSpec.scala
+++ b/src/test/scala/org/apache/nlpcraft/common/util/NCUtilsSpec.scala
@@ -18,6 +18,7 @@
package org.apache.nlpcraft.common.util
import org.apache.nlpcraft.common._
+import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
/**
@@ -41,21 +42,21 @@ class NCUtilsSpec {
println(s"Compressed length: " + zipStr.length())
- assert(rawStr == rawStr2)
+ assertTrue(rawStr == rawStr2)
}
@Test
def testGetDups() {
- assert(U.getDups(Seq("a", "b", "a")) == Set("a"))
- assert(U.getDups(Seq("a", "a", "a", "b", "a")) == Set("a"))
- assert(U.getDups(Seq("a", "d", "c", "b", "e")) == Set())
+ assertTrue(U.getDups(Seq("a", "b", "a")) == Set("a"))
+ assertTrue(U.getDups(Seq("a", "a", "a", "b", "a")) == Set("a"))
+ assertTrue(U.getDups(Seq("a", "d", "c", "b", "e")) == Set())
}
@Test
def testToFirstLastName() {
- assert(U.toFirstLastName("A BbbBB") == ("A", "Bbbbb"))
- assert(U.toFirstLastName("aBC BbbBB CCC") == ("Abc", "Bbbbb ccc"))
- assert(U.toFirstLastName("abc b C C C") == ("Abc", "B c c c"))
+ assertTrue(U.toFirstLastName("A BbbBB") == ("A", "Bbbbb"))
+ assertTrue(U.toFirstLastName("aBC BbbBB CCC") == ("Abc", "Bbbbb ccc"))
+ assertTrue(U.toFirstLastName("abc b C C C") == ("Abc", "B c c c"))
}
@Test
diff --git a/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslTest.java
b/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslTest.java
index 4934ca1..48192f2 100644
--- a/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslTest.java
+++ b/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslTest.java
@@ -17,13 +17,17 @@
package org.apache.nlpcraft.model.intent.dsl;
-import org.junit.jupiter.api.*;
-import org.apache.nlpcraft.common.*;
-import org.apache.nlpcraft.model.tools.test.*;
-import org.apache.nlpcraft.probe.embedded.*;
-import java.io.*;
+import org.apache.nlpcraft.common.NCException;
+import org.apache.nlpcraft.model.tools.test.NCTestClient;
+import org.apache.nlpcraft.model.tools.test.NCTestClientBuilder;
+import org.apache.nlpcraft.probe.embedded.NCEmbeddedProbe;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.*;
+import java.io.IOException;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* DSL test model test. Make sure to start up the NLPCraft server before
running this test.
diff --git
a/src/test/scala/org/apache/nlpcraft/model/intent/impl/NCIntentSolverEngineSpec.scala
b/src/test/scala/org/apache/nlpcraft/model/intent/impl/NCIntentSolverEngineSpec.scala
index 6bd7f1c..85f75a5 100644
---
a/src/test/scala/org/apache/nlpcraft/model/intent/impl/NCIntentSolverEngineSpec.scala
+++
b/src/test/scala/org/apache/nlpcraft/model/intent/impl/NCIntentSolverEngineSpec.scala
@@ -18,6 +18,7 @@
package org.apache.nlpcraft.model.intent.impl
import org.apache.nlpcraft.model.intent.utils.NCDslFlowItem
+import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
/**
@@ -39,14 +40,14 @@ class NCIntentSolverEngineSpec {
@Test
def testMatchDialogFlow() {
- assert(!matchFlow("", ("a", 1, 1)))
- assert(matchFlow("a c", ("a", 1, 1), ("b", 0, 2), ("c", 1, 1)))
- assert(matchFlow("a b c", ("a", 1, 1), ("b", 0, 2), ("c", 1, 1)))
- assert(matchFlow("a b b c", ("a", 1, 1), ("b", 0, 2), ("c", 1, 1)))
- assert(matchFlow("a b b c", ("a", 1, 1), ("b|c", 0, 2), ("c", 1, 1)))
- assert(matchFlow("a a c c", ("a", 2, 2), ("b|c", 1, 2), ("d", 0, 1)))
- assert(matchFlow("a a c c d", ("a", 2, 2), ("b|c", 1, 2), ("d", 0, 1)))
- assert(matchFlow("a a c c e f g h", ("a", 2, 2), ("b|c", 1, 2), ("d",
0, 1)))
- assert(!matchFlow("a a c c x", ("a", 2, 2), ("b|c", 1, 2), ("d", 1,
1)))
+ assertTrue(!matchFlow("", ("a", 1, 1)))
+ assertTrue(matchFlow("a c", ("a", 1, 1), ("b", 0, 2), ("c", 1, 1)))
+ assertTrue(matchFlow("a b c", ("a", 1, 1), ("b", 0, 2), ("c", 1, 1)))
+ assertTrue(matchFlow("a b b c", ("a", 1, 1), ("b", 0, 2), ("c", 1, 1)))
+ assertTrue(matchFlow("a b b c", ("a", 1, 1), ("b|c", 0, 2), ("c", 1,
1)))
+ assertTrue(matchFlow("a a c c", ("a", 2, 2), ("b|c", 1, 2), ("d", 0,
1)))
+ assertTrue(matchFlow("a a c c d", ("a", 2, 2), ("b|c", 1, 2), ("d", 0,
1)))
+ assertTrue(matchFlow("a a c c e f g h", ("a", 2, 2), ("b|c", 1, 2),
("d", 0, 1)))
+ assertTrue(!matchFlow("a a c c x", ("a", 2, 2), ("b|c", 1, 2), ("d",
1, 1)))
}
}
diff --git
a/src/test/scala/org/apache/nlpcraft/model/tools/NCSqlModelEngineSpec.scala
b/src/test/scala/org/apache/nlpcraft/model/tools/NCSqlModelEngineSpec.scala
index 11c7729..c9c5dd2 100644
--- a/src/test/scala/org/apache/nlpcraft/model/tools/NCSqlModelEngineSpec.scala
+++ b/src/test/scala/org/apache/nlpcraft/model/tools/NCSqlModelEngineSpec.scala
@@ -17,6 +17,7 @@
package org.apache.nlpcraft.model.tools
+import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
/**
@@ -79,12 +80,12 @@ class NCSqlModelEngineSpec {
val fun2 = mkPrefixFun("")
val fun3 = mkPrefixFun("tbl_tbl_, col_")
- assert(fun1("tbl_table") == "table")
- assert(fun1("tbl_tbl_table") == "tbl_table")
- assert(fun3("tbl_tbl_table") == "table")
- assert(fun1("col_column") == "column")
- assert(fun1("_col_column") == "_col_column")
- assert(fun2("col_column") == "col_column")
+ assertTrue(fun1("tbl_table") == "table")
+ assertTrue(fun1("tbl_tbl_table") == "tbl_table")
+ assertTrue(fun3("tbl_tbl_table") == "table")
+ assertTrue(fun1("col_column") == "column")
+ assertTrue(fun1("_col_column") == "_col_column")
+ assertTrue(fun2("col_column") == "col_column")
}
@Test
@@ -93,27 +94,27 @@ class NCSqlModelEngineSpec {
val fun2 = mkSuffixFun("")
val fun3 = mkSuffixFun("_tmp_tmp")
- assert(fun1("table_old") == "table")
- assert(fun1("table_old_old") == "table_old")
- assert(fun3("table_tmp_tmp") == "table")
- assert(fun1("column_old") == "column")
- assert(fun1("column_old_") == "column_old_")
- assert(fun2("column_old") == "column_old")
+ assertTrue(fun1("table_old") == "table")
+ assertTrue(fun1("table_old_old") == "table_old")
+ assertTrue(fun3("table_tmp_tmp") == "table")
+ assertTrue(fun1("column_old") == "column")
+ assertTrue(fun1("column_old_") == "column_old_")
+ assertTrue(fun2("column_old") == "column_old")
}
@Test
def testSubstituteMacros() {
- assert(substituteMacros("a id") == "a <ID>")
- assert(substituteMacros("a id ") == "a <ID>")
- assert(substituteMacros("id") == "<ID>")
+ assertTrue(substituteMacros("a id") == "a <ID>")
+ assertTrue(substituteMacros("a id ") == "a <ID>")
+ assertTrue(substituteMacros("id") == "<ID>")
}
@Test
def testRemoveSequentialDups() {
- assert(removeSeqDups("a a b b") == "a b")
- assert(removeSeqDups("aa b b") == "aa b")
- assert(removeSeqDups("aa b b") == "aa b")
- assert(removeSeqDups("aa b bb") == "aa b bb")
- assert(removeSeqDups("a a b b") != "a b c")
+ assertTrue(removeSeqDups("a a b b") == "a b")
+ assertTrue(removeSeqDups("aa b b") == "aa b")
+ assertTrue(removeSeqDups("aa b b") == "aa b")
+ assertTrue(removeSeqDups("aa b bb") == "aa b bb")
+ assertTrue(removeSeqDups("a a b b") != "a b c")
}
}
diff --git
a/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/NCDefaultTestModel.scala
b/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/NCDefaultTestModel.scala
index f0e55fa..4048005 100644
---
a/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/NCDefaultTestModel.scala
+++
b/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/NCDefaultTestModel.scala
@@ -21,10 +21,10 @@ import java.util
import java.util.Collections
import org.apache.nlpcraft.model.{NCContext, NCElement, NCModelAdapter,
NCResult, NCValue}
+import org.apache.nlpcraft.probe.mgrs.nlp.enrichers.NCDefaultTestModel._
import scala.collection.JavaConverters._
import scala.language.implicitConversions
-import NCDefaultTestModel._
/**
* Enrichers default test model.
diff --git
a/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/NCEnrichersTestBeans.scala
b/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/NCEnrichersTestBeans.scala
index 79cb207..9775ba1 100644
---
a/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/NCEnrichersTestBeans.scala
+++
b/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/NCEnrichersTestBeans.scala
@@ -24,8 +24,8 @@ import java.util.{Base64, Optional}
import org.apache.nlpcraft.model.NCToken
import resource.managed
-import scala.compat.java8.OptionConverters._
import scala.collection.JavaConverters._
+import scala.compat.java8.OptionConverters._
/**
* Tests infrastructure beans.
diff --git
a/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/limit/NCEnricherLimitSpec.scala
b/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/limit/NCEnricherLimitSpec.scala
index 2ba3638..f6cb6ae 100644
---
a/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/limit/NCEnricherLimitSpec.scala
+++
b/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/limit/NCEnricherLimitSpec.scala
@@ -17,7 +17,7 @@
package org.apache.nlpcraft.probe.mgrs.nlp.enrichers.limit
-import org.apache.nlpcraft.probe.mgrs.nlp.enrichers.{NCEnricherBaseSpec,
NCTestLimitToken ⇒ lim, NCTestUserToken ⇒ usr}
+import org.apache.nlpcraft.probe.mgrs.nlp.enrichers.{NCEnricherBaseSpec,
NCTestLimitToken => lim, NCTestUserToken => usr}
import org.junit.jupiter.api.Test
/**
diff --git
a/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/relation/NCEnricherRelationSpec.scala
b/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/relation/NCEnricherRelationSpec.scala
index 8253217..89dd938 100644
---
a/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/relation/NCEnricherRelationSpec.scala
+++
b/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/relation/NCEnricherRelationSpec.scala
@@ -17,7 +17,7 @@
package org.apache.nlpcraft.probe.mgrs.nlp.enrichers.relation
-import org.apache.nlpcraft.probe.mgrs.nlp.enrichers.{NCEnricherBaseSpec,
NCTestRelationToken ⇒ rel, NCTestUserToken ⇒ usr, NCTestNlpToken ⇒ nlp}
+import org.apache.nlpcraft.probe.mgrs.nlp.enrichers.{NCEnricherBaseSpec,
NCTestNlpToken => nlp, NCTestRelationToken => rel, NCTestUserToken => usr}
import org.junit.jupiter.api.Test
/**
diff --git
a/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/sort/NCEnricherSortSpec.scala
b/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/sort/NCEnricherSortSpec.scala
index a74c835..fb478c0 100644
---
a/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/sort/NCEnricherSortSpec.scala
+++
b/src/test/scala/org/apache/nlpcraft/probe/mgrs/nlp/enrichers/sort/NCEnricherSortSpec.scala
@@ -17,7 +17,7 @@
package org.apache.nlpcraft.probe.mgrs.nlp.enrichers.sort
-import org.apache.nlpcraft.probe.mgrs.nlp.enrichers.{NCEnricherBaseSpec,
NCTestNlpToken ⇒ nlp, NCTestSortToken ⇒ srt, NCTestUserToken ⇒ usr}
+import org.apache.nlpcraft.probe.mgrs.nlp.enrichers.{NCEnricherBaseSpec,
NCTestNlpToken => nlp, NCTestSortToken => srt, NCTestUserToken => usr}
import org.junit.jupiter.api.Test
/**
diff --git
a/src/test/scala/org/apache/nlpcraft/server/nlp/enrichers/date/tools/NCDateGeneratorSpec.scala
b/src/test/scala/org/apache/nlpcraft/server/nlp/enrichers/date/tools/NCDateGeneratorSpec.scala
index 3f9f970..7e2b789 100644
---
a/src/test/scala/org/apache/nlpcraft/server/nlp/enrichers/date/tools/NCDateGeneratorSpec.scala
+++
b/src/test/scala/org/apache/nlpcraft/server/nlp/enrichers/date/tools/NCDateGeneratorSpec.scala
@@ -21,22 +21,24 @@ import java.text.SimpleDateFormat
import java.util.{Calendar, Date, Locale}
import org.apache.nlpcraft.common.ascii.NCAsciiTable
+import org.apache.nlpcraft.server.nlp.enrichers.date.NCDateConstants._
+import org.apache.nlpcraft.server.nlp.enrichers.date.NCDateFormatType._
import
org.apache.nlpcraft.server.nlp.enrichers.date.tools.NCDateGenerator.LHM_SS
import org.apache.nlpcraft.server.nlp.enrichers.date.{NCDateParser,
NCDateRange}
-import org.apache.nlpcraft.server.nlp.enrichers.date.NCDateFormatType._
-
-import org.scalatest.FunSuite
+import org.junit.jupiter.api.Assertions.{assertTrue, fail}
+import org.junit.jupiter.api.{Disabled, Test}
import scala.collection.JavaConverters._
import scala.collection._
-import scala.collection.mutable.{LinkedHashMap ⇒ LHM}
-import org.apache.nlpcraft.server.nlp.enrichers.date.NCDateConstants._
+import scala.collection.mutable.{LinkedHashMap => LHM}
import scala.language.implicitConversions
/**
- * Tests for dates templates generators.
- */
-class NCDateGeneratorSpec extends FunSuite {
+ * Tests for dates templates generators.
+ * Excluded from suite because added for manual testing.
+ */
+@Disabled
+class NCDateGeneratorSpec {
private def print(
f: LHM[String, String] ⇒ Unit, cnt: Int = 500, asc: Boolean = true,
keys2Check: Option[Seq[String]] = None
) {
@@ -62,7 +64,7 @@ class NCDateGeneratorSpec extends FunSuite {
case Some(keys) ⇒
val missed = keys.filter(k ⇒ !map.contains(k))
- assert(missed.isEmpty, s"Missed keys: ${missed.mkString(",
")}")
+ assertTrue(missed.isEmpty, s"Missed keys: ${missed.mkString(",
")}")
case None ⇒ // No-op.
}
}
@@ -84,7 +86,8 @@ class NCDateGeneratorSpec extends FunSuite {
fail(s"Duplicated data expected.")
}
- test("formatters") {
+ @Test
+ def testFormatters(): Unit = {
val f = new SimpleDateFormat("MM.dd.yyyy")
// M.D
@@ -113,129 +116,159 @@ class NCDateGeneratorSpec extends FunSuite {
checkFormatters(d4, NCDateGenerator.FMT_DAYS_YEAR_COMMON,
NCDateGenerator.FMT_DAYS_YEAR_DIGITS, withDup = true)
}
- test("relativeDays") {
+ @Test
+ def testRelativeDays(): Unit = {
print(NCDateGenerator.relativeDays)
}
- test("periods") {
+ @Test
+ def testPeriods(): Unit = {
print(NCDateGenerator.periods)
}
- test("years") {
+ @Test
+ def testYears(): Unit = {
print(NCDateGenerator.years)
}
- test("months") {
+ @Test
+ def testMonths(): Unit = {
print((df: LHM_SS) ⇒ NCDateGenerator.months(df,
MONTH_YEAR_COMMON.map(new SimpleDateFormat(_))))
}
- test("months.dmy") {
+ @Test
+ def testMonthsDmy(): Unit = {
print((df: LHM_SS) ⇒ NCDateGenerator.months(df,
MONTH_YEAR_COUNTRY(DMY).map(new SimpleDateFormat(_))))
}
- test("months.mdy") {
+ @Test
+ def testMonthsMdy(): Unit = {
print((df: LHM_SS) ⇒ NCDateGenerator.months(df,
MONTH_YEAR_COUNTRY(MDY).map(new SimpleDateFormat(_))))
}
- test("months.ymd") {
+ @Test
+ def testMonthsYmd(): Unit = {
print((df: LHM_SS) ⇒ NCDateGenerator.months(df,
MONTH_YEAR_COUNTRY(YMD).map(new SimpleDateFormat(_))))
}
- test("seasons") {
+ @Test
+ def testSeasons(): Unit = {
print(NCDateGenerator.seasons)
}
- test("days") {
+ @Test
+ def testDays(): Unit = {
print((df: LHM_SS) ⇒ NCDateGenerator.days(df,
NCDateGenerator.FMT_DAYS_YEAR_COMMON), cnt = 5000)
}
- test("dates") {
+ @Test
+ def testDates(): Unit = {
print((df: LHM_SS) ⇒ NCDateGenerator.dates(df,
NCDateGenerator.FMT_DATES_COMMON), cnt = 2000)
print((df: LHM_SS) ⇒ NCDateGenerator.days(df,
NCDateGenerator.FMT_DAYS_YEAR_COMMON), cnt = 2000, asc = false)
}
- test("simpleYears") {
+ @Test
+ def testSimpleYears(): Unit = {
print(NCDateGenerator.simpleYears)
}
- test("simpleQuarters") {
+ @Test
+ def tesSimpleQuarters(): Unit = {
print(NCDateGenerator.simpleQuarters, cnt = 5000)
}
- test("durationDays") {
+ @Test
+ def testDurationDays(): Unit = {
print(NCDateGenerator.durationDays, cnt = 1000, keys2Check =
Some(Seq("next couple of days", "few next days", "few last days")))
print(NCDateGenerator.durationDays, cnt = 5000, asc = false)
}
- test("durationWeeks") {
+ @Test
+ def testDurationWeeks(): Unit = {
print(NCDateGenerator.durationWeeks)
print(NCDateGenerator.durationWeeks, asc = false)
}
- test("durationMonths") {
+ @Test
+ def testDurationMonths(): Unit = {
print(NCDateGenerator.durationMonths)
print(NCDateGenerator.durationMonths, cnt = 5000, asc = false)
}
- test("durationYears") {
+ @Test
+ def testDurationYears(): Unit = {
print(NCDateGenerator.durationYears)
print(NCDateGenerator.durationYears, asc = false)
}
- test("durationDecades") {
+ @Test
+ def testDurationDecades(): Unit = {
print(NCDateGenerator.durationDecades, cnt = 5000)
}
- test("durationQuarters") {
+ @Test
+ def testDurationQuarters(): Unit = {
print(NCDateGenerator.durationQuarters, cnt = 5000)
}
- test("durationCenturies") {
+ @Test
+ def testDurationCenturies(): Unit = {
print(NCDateGenerator.durationCenturies, cnt = 5000)
}
- test("relativeDaysOfWeekByNum") {
+ @Test
+ def testRelativeDaysOfWeekByNum(): Unit = {
print(NCDateGenerator.relativeDaysOfWeekByNum, cnt = 5000)
}
- test("relativeDaysOfWeekByName") {
+ @Test
+ def testRelativeDaysOfWeekByName(): Unit = {
print(NCDateGenerator.relativeDaysOfWeekByName)
}
- test("relativeDaysOfMonth") {
+ @Test
+ def testRelativeDaysOfMonth(): Unit = {
print(NCDateGenerator.relativeDaysOfMonth, cnt = 5000)
}
- test("relativeWeeksOfMonth") {
+ @Test
+ def testRelativeWeeksOfMonth(): Unit = {
print(NCDateGenerator.relativeWeeksOfMonth)
}
- test("relativeWeeksOfQuarter") {
+ @Test
+ def testRelativeWeeksOfQuarter(): Unit = {
print(NCDateGenerator.relativeWeeksOfQuarter, cnt = 5000)
}
- test("relativeWeeksOfYear") {
+ @Test
+ def testRelativeWeeksOfYear(): Unit = {
print(NCDateGenerator.relativeWeeksOfYear, cnt = 5000)
}
- test("relativeMonthsOfYear") {
+ @Test
+ def testRelativeMonthsOfYear(): Unit = {
print(NCDateGenerator.relativeMonthsOfYear, cnt = 5000)
}
- test("relativeQuartersOfYear") {
+ @Test
+ def testRelativeQuartersOfYear(): Unit = {
print(NCDateGenerator.relativeQuartersOfYear)
}
- test("relativeYearOfDecade") {
+ @Test
+ def testelativeYearOfDecade(): Unit = {
print(NCDateGenerator.relativeYearOfDecade)
}
- test("relativeFromYear") {
+ @Test
+ def testRelativeFromYear(): Unit = {
print(NCDateGenerator.relativeFromYear, cnt = 5000)
print(NCDateGenerator.relativeFromYear, cnt = 5000, asc = false)
}
- test("calendar.behaviour") {
+ @Test
+ def testCalendar(): Unit = {
Locale.setDefault(Locale.forLanguageTag("EN"))
// Sunday.
@@ -253,17 +286,19 @@ class NCDateGeneratorSpec extends FunSuite {
println(s"$s, Sunday for this day: ${c.getTime}")
- assert(c.getTime == sunday)
+ assertTrue(c.getTime == sunday)
})
}
- test("all") {
+ @Test
+ def testAll(): Unit = {
val n = (NCDateGenerator.generateFull() ++
NCDateGenerator.generateParts()).size
println(s"Summary generated $n templates.")
}
- test("last day of month command") {
+ @Test
+ def testLastDayOfMonth(): Unit = {
def test(base: String, exp: String): Unit = {
val date = new SimpleDateFormat("MM.dd.yyyy").parse(base)
@@ -276,14 +311,15 @@ class NCDateGeneratorSpec extends FunSuite {
println(s"Result: $res")
println(s"Range: $range")
- assert(range.toString == exp)
+ assertTrue(range.toString == exp)
}
test("06.10.2018", "[06-24-2018:07-01-2018]")
test("11.20.2017", "[11-26-2017:12-03-2017]")
}
- test("last day function") {
+ @Test
+ def testLastDay(): Unit = {
val date = scala.compat.Platform.currentTime
def print(f: String): Unit = {
@@ -306,7 +342,8 @@ class NCDateGeneratorSpec extends FunSuite {
print("$ds")
}
- test("parse") {
+ @Test
+ def testParse(): Unit = {
val date = scala.compat.Platform.currentTime
val f = "m, $dm, 1dw, w1"