This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch NLPCRAFT-27
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-27 by this push:
new d21dc45 CR.
d21dc45 is described below
commit d21dc4540c59bccfd7c5166db79c69e055022e38
Author: Aaron Radzinzski <[email protected]>
AuthorDate: Wed Mar 25 11:33:37 2020 -0700
CR.
---
docs/examples/alarm_clock.html | 14 +++++-----
.../apache/nlpcraft/examples/alarm/AlarmTest.java | 16 +++++------
.../apache/nlpcraft/examples/echo/EchoTest.java | 14 +++++-----
.../examples/helloworld/HelloWorldTest.java | 16 +++++------
.../examples/lightswitch/LightSwitchTest.java | 32 +++++++++++-----------
.../apache/nlpcraft/examples/phone/PhoneTest.java | 16 +++++------
.../apache/nlpcraft/examples/time/TimeTest.java | 24 ++++++++--------
.../nlpcraft/examples/weather/WeatherTest.java | 27 +++++++++---------
.../nlpcraft/model/tools/test/NCTestClient.java | 19 ++++++++-----
.../nlpcraft/model/tools/test/package-info.java | 23 ++++++++++------
.../nlpcraft/model/intent/dsl/NCDslTest.java | 12 ++++----
.../nlpcraft/models/stm/NCStmTestModelSpec.java | 12 ++++----
12 files changed, 117 insertions(+), 108 deletions(-)
diff --git a/docs/examples/alarm_clock.html b/docs/examples/alarm_clock.html
index 8736a88..ad42fc4 100644
--- a/docs/examples/alarm_clock.html
+++ b/docs/examples/alarm_clock.html
@@ -361,25 +361,25 @@ import java.io.IOException;
import static org.junit.jupiter.api.Assertions.assertTrue;
class AlarmTest {
- private NCTestClient client;
+ private NCTestClient cli;
@BeforeEach
void setUp() throws NCException, IOException {
- client = new NCTestClientBuilder().newBuilder().build();
+ cli = new NCTestClientBuilder().newBuilder().build();
- client.open("nlpcraft.alarm.ex"); // See alarm_model.json
+ cli.open("nlpcraft.alarm.ex"); // See alarm_model.json
}
@AfterEach
void tearDown() throws NCException, IOException {
- client.close();
+ cli.close();
}
@Test
void test() throws NCException, IOException {
- assertTrue(client.ask("Ping me in 3 minutes").isOk());
- assertTrue(client.ask("Buzz me in an hour and 15mins").isOk());
- assertTrue(client.ask("Set my alarm for 30s").isOk());
+ assertTrue(cli.ask("Ping me in 3 minutes").isOk());
+ assertTrue(cli.ask("Buzz me in an hour and 15mins").isOk());
+ assertTrue(cli.ask("Set my alarm for 30s").isOk());
}
} </pre>
<p>
diff --git a/src/main/scala/org/apache/nlpcraft/examples/alarm/AlarmTest.java
b/src/main/scala/org/apache/nlpcraft/examples/alarm/AlarmTest.java
index ae69e11..9dbf835 100644
--- a/src/main/scala/org/apache/nlpcraft/examples/alarm/AlarmTest.java
+++ b/src/main/scala/org/apache/nlpcraft/examples/alarm/AlarmTest.java
@@ -35,29 +35,29 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* @see AlarmModel
*/
class AlarmTest {
- static private NCTestClient client;
+ static private NCTestClient cli;
@BeforeAll
static void setUp() throws NCException, IOException {
NCEmbeddedProbe.start(AlarmModel.class);
- client = new NCTestClientBuilder().newBuilder().build();
+ cli = new NCTestClientBuilder().newBuilder().build();
- client.open("nlpcraft.alarm.ex"); // See alarm_model.json
+ cli.open("nlpcraft.alarm.ex"); // See alarm_model.json
}
@AfterAll
static void tearDown() throws NCException, IOException {
- if (client != null)
- client.close();
+ if (cli != null)
+ cli.close();
NCEmbeddedProbe.stop();
}
@Test
void test() throws NCException, IOException {
- assertTrue(client.ask("Ping me in 3 minutes").isOk());
- assertTrue(client.ask("Buzz me in an hour and 15mins").isOk());
- assertTrue(client.ask("Set my alarm for 30s").isOk());
+ assertTrue(cli.ask("Ping me in 3 minutes").isOk());
+ assertTrue(cli.ask("Buzz me in an hour and 15mins").isOk());
+ assertTrue(cli.ask("Set my alarm for 30s").isOk());
}
}
diff --git a/src/main/scala/org/apache/nlpcraft/examples/echo/EchoTest.java
b/src/main/scala/org/apache/nlpcraft/examples/echo/EchoTest.java
index 5936925..98a8a0f 100644
--- a/src/main/scala/org/apache/nlpcraft/examples/echo/EchoTest.java
+++ b/src/main/scala/org/apache/nlpcraft/examples/echo/EchoTest.java
@@ -35,28 +35,28 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* @see EchoModel
*/
class EchoTest {
- private NCTestClient client;
+ private NCTestClient cli;
@BeforeEach
void setUp() throws NCException, IOException {
NCEmbeddedProbe.start(EchoModel.class);
- client = new NCTestClientBuilder().newBuilder().build();
+ cli = new NCTestClientBuilder().newBuilder().build();
- client.open("nlpcraft.echo.ex");
+ cli.open("nlpcraft.echo.ex");
}
@AfterEach
void tearDown() throws NCException, IOException {
- if (client != null)
- client.close();
+ if (cli != null)
+ cli.close();
NCEmbeddedProbe.stop();
}
@Test
void test() throws NCException, IOException {
- assertTrue(client.ask("LA weather last Friday").isOk());
- assertTrue(client.ask("Just about any sentence you can
imagine!").isOk());
+ assertTrue(cli.ask("LA weather last Friday").isOk());
+ assertTrue(cli.ask("Just about any sentence you can imagine!").isOk());
}
}
diff --git
a/src/main/scala/org/apache/nlpcraft/examples/helloworld/HelloWorldTest.java
b/src/main/scala/org/apache/nlpcraft/examples/helloworld/HelloWorldTest.java
index f24b359..a89a1df 100644
--- a/src/main/scala/org/apache/nlpcraft/examples/helloworld/HelloWorldTest.java
+++ b/src/main/scala/org/apache/nlpcraft/examples/helloworld/HelloWorldTest.java
@@ -35,22 +35,22 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* @see HelloWorldModel
*/
class HelloWorldTest {
- private NCTestClient client;
+ private NCTestClient cli;
@BeforeEach
void setUp() throws NCException, IOException {
NCEmbeddedProbe.start(HelloWorldModel.class);
// Use all defaults.
- client = new NCTestClientBuilder().newBuilder().build();
+ cli = new NCTestClientBuilder().newBuilder().build();
- client.open("nlpcraft.helloworld.ex");
+ cli.open("nlpcraft.helloworld.ex");
}
@AfterEach
void tearDown() throws NCException, IOException {
- if (client != null)
- client.close();
+ if (cli != null)
+ cli.close();
NCEmbeddedProbe.stop();
}
@@ -58,12 +58,12 @@ class HelloWorldTest {
@Test
void test() throws NCException, IOException {
// Empty parameter.
- assertTrue(client.ask("").isFailed());
+ assertTrue(cli.ask("").isFailed());
// Only latin charset is supported.
- assertTrue(client.ask("El tiempo en España").isFailed());
+ assertTrue(cli.ask("El tiempo en España").isFailed());
// Should be passed.
- assertTrue(client.ask("Hi!").isOk());
+ assertTrue(cli.ask("Hi!").isOk());
}
}
diff --git
a/src/main/scala/org/apache/nlpcraft/examples/lightswitch/LightSwitchTest.java
b/src/main/scala/org/apache/nlpcraft/examples/lightswitch/LightSwitchTest.java
index 0565f4b..e411f5a 100644
---
a/src/main/scala/org/apache/nlpcraft/examples/lightswitch/LightSwitchTest.java
+++
b/src/main/scala/org/apache/nlpcraft/examples/lightswitch/LightSwitchTest.java
@@ -35,37 +35,37 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* @see LightSwitchModel
*/
class LightSwitchTest {
- private NCTestClient client;
+ private NCTestClient cli;
@BeforeEach
void setUp() throws NCException, IOException {
NCEmbeddedProbe.start(LightSwitchModel.class);
- client = new NCTestClientBuilder().newBuilder().build();
+ cli = new NCTestClientBuilder().newBuilder().build();
- client.open("nlpcraft.lightswitch.ex");
+ cli.open("nlpcraft.lightswitch.ex");
}
@AfterEach
void tearDown() throws NCException, IOException {
- if (client != null)
- client.close();
+ if (cli != null)
+ cli.close();
NCEmbeddedProbe.stop();
}
@Test
void test() throws NCException, IOException {
- assertTrue(client.ask("Turn the lights off in the entire
house.").isOk());
- assertTrue(client.ask("Switch on the illumination in the master
bedroom closet.").isOk());
- assertTrue(client.ask("Get the lights on.").isOk());
- assertTrue(client.ask("Please, put the light out in the upstairs
bedroom.").isOk());
- assertTrue(client.ask("Set the lights on in the entire
house.").isOk());
- assertTrue(client.ask("Turn the lights off in the guest
bedroom.").isOk());
- assertTrue(client.ask("Could you please switch off all the
lights?").isOk());
- assertTrue(client.ask("Dial off illumination on the 2nd
floor.").isOk());
- assertTrue(client.ask("Please, no lights!").isOk());
- assertTrue(client.ask("Kill off all the lights now!").isOk());
- assertTrue(client.ask("No lights in the bedroom, please.").isOk());
+ assertTrue(cli.ask("Turn the lights off in the entire house.").isOk());
+ assertTrue(cli.ask("Switch on the illumination in the master bedroom
closet.").isOk());
+ assertTrue(cli.ask("Get the lights on.").isOk());
+ assertTrue(cli.ask("Please, put the light out in the upstairs
bedroom.").isOk());
+ assertTrue(cli.ask("Set the lights on in the entire house.").isOk());
+ assertTrue(cli.ask("Turn the lights off in the guest
bedroom.").isOk());
+ assertTrue(cli.ask("Could you please switch off all the
lights?").isOk());
+ assertTrue(cli.ask("Dial off illumination on the 2nd floor.").isOk());
+ assertTrue(cli.ask("Please, no lights!").isOk());
+ assertTrue(cli.ask("Kill off all the lights now!").isOk());
+ assertTrue(cli.ask("No lights in the bedroom, please.").isOk());
}
}
diff --git a/src/main/scala/org/apache/nlpcraft/examples/phone/PhoneTest.java
b/src/main/scala/org/apache/nlpcraft/examples/phone/PhoneTest.java
index 959e628..217c564 100644
--- a/src/main/scala/org/apache/nlpcraft/examples/phone/PhoneTest.java
+++ b/src/main/scala/org/apache/nlpcraft/examples/phone/PhoneTest.java
@@ -36,21 +36,21 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* @see PhoneModel
*/
class PhoneTest {
- private NCTestClient client;
+ private NCTestClient cli;
@BeforeEach
void setUp() throws NCException, IOException {
NCEmbeddedProbe.start(PhoneModel.class);
- client = new NCTestClientBuilder().newBuilder().build();
+ cli = new NCTestClientBuilder().newBuilder().build();
- client.open("nlpcraft.phone.ex"); // See phone_model.json
+ cli.open("nlpcraft.phone.ex"); // See phone_model.json
}
@AfterEach
void tearDown() throws NCException, IOException {
- if (client != null)
- client.close();
+ if (cli != null)
+ cli.close();
NCEmbeddedProbe.stop();
}
@@ -59,8 +59,8 @@ class PhoneTest {
@Disabled
@Test
void test() throws NCException, IOException {
- assertTrue(client.ask("Call to Apple office").isOk());
- assertTrue(client.ask("Can you please ping John Smith?").isOk());
- assertTrue(client.ask("Could you dial +7 (931) 188 34 58 and ask
Mike?").isOk());
+ assertTrue(cli.ask("Call to Apple office").isOk());
+ assertTrue(cli.ask("Can you please ping John Smith?").isOk());
+ assertTrue(cli.ask("Could you dial +7 (931) 188 34 58 and ask
Mike?").isOk());
}
}
diff --git a/src/main/scala/org/apache/nlpcraft/examples/time/TimeTest.java
b/src/main/scala/org/apache/nlpcraft/examples/time/TimeTest.java
index 0a5441e..a801710 100644
--- a/src/main/scala/org/apache/nlpcraft/examples/time/TimeTest.java
+++ b/src/main/scala/org/apache/nlpcraft/examples/time/TimeTest.java
@@ -35,21 +35,21 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* @see TimeModel
*/
class TimeTest {
- private NCTestClient client;
+ private NCTestClient cli;
@BeforeEach
void setUp() throws NCException, IOException {
NCEmbeddedProbe.start(TimeModel.class);
- client = new NCTestClientBuilder().newBuilder().build();
+ cli = new NCTestClientBuilder().newBuilder().build();
- client.open("nlpcraft.time.ex"); // See time_model.json
+ cli.open("nlpcraft.time.ex"); // See time_model.json
}
@AfterEach
void tearDown() throws NCException, IOException {
- if (client != null)
- client.close();
+ if (cli != null)
+ cli.close();
NCEmbeddedProbe.stop();
}
@@ -57,16 +57,16 @@ class TimeTest {
@Test
void test() throws NCException, IOException {
// Empty parameter.
- assertTrue(client.ask("").isFailed());
+ assertTrue(cli.ask("").isFailed());
// Only latin charset is supported.
- assertTrue(client.ask("El tiempo en España").isFailed());
+ assertTrue(cli.ask("El tiempo en España").isFailed());
// Should be passed.
- assertTrue(client.ask("What time is it now in New York City?").isOk());
- assertTrue(client.ask("What's the current time in Moscow?").isOk());
- assertTrue(client.ask("Show me time of the day in London.").isOk());
- assertTrue(client.ask("Can you please give me the San Francisco's
current date and time.").isOk());
- assertTrue(client.ask("What's the local time?").isOk());
+ assertTrue(cli.ask("What time is it now in New York City?").isOk());
+ assertTrue(cli.ask("What's the current time in Moscow?").isOk());
+ assertTrue(cli.ask("Show me time of the day in London.").isOk());
+ assertTrue(cli.ask("Can you please give me the San Francisco's current
date and time.").isOk());
+ assertTrue(cli.ask("What's the local time?").isOk());
}
}
diff --git
a/src/main/scala/org/apache/nlpcraft/examples/weather/WeatherTest.java
b/src/main/scala/org/apache/nlpcraft/examples/weather/WeatherTest.java
index 32e2eb5..6bd0949 100644
--- a/src/main/scala/org/apache/nlpcraft/examples/weather/WeatherTest.java
+++ b/src/main/scala/org/apache/nlpcraft/examples/weather/WeatherTest.java
@@ -43,20 +43,19 @@ import static org.junit.jupiter.api.Assertions.*;
*/
class WeatherTest {
private static final Gson GSON = new Gson();
- private static final Type TYPE_MAP_RESP = new TypeToken<HashMap<String,
Object>>() {
- }.getType();
+ private static final Type TYPE_MAP_RESP = new TypeToken<HashMap<String,
Object>>() {}.getType();
- private NCTestClient client;
+ private NCTestClient cli;
/**
* Checks given intent.
*
- * @param txt Sentence.
- * @param intentId Intent ID.
+ * @param txt Sentence.
+ * @param intentId Intent ID.
* @param shouldBeSame Equal vs. non-equal intent ID flag.
*/
private void checkIntent(String txt, String intentId, boolean
shouldBeSame) throws NCException, IOException {
- NCTestResult res = client.ask(txt);
+ NCTestResult res = cli.ask(txt);
assertTrue(res.isOk(), () -> res.getResultError().get());
@@ -74,15 +73,15 @@ class WeatherTest {
void setUp() throws NCException, IOException {
NCEmbeddedProbe.start(WeatherModel.class);
- client = new NCTestClientBuilder().newBuilder().build();
+ cli = new NCTestClientBuilder().newBuilder().build();
- client.open("nlpcraft.weather.ex"); // See weather_model.json
+ cli.open("nlpcraft.weather.ex"); // See weather_model.json
}
@AfterEach
void tearDown() throws NCException, IOException {
- if (client != null)
- client.close();
+ if (cli != null)
+ cli.close();
NCEmbeddedProbe.stop();
}
@@ -90,10 +89,10 @@ class WeatherTest {
@Test
void test() throws NCException, IOException {
// Empty parameter.
- assertTrue(client.ask("").isFailed());
+ assertTrue(cli.ask("").isFailed());
// Only latin charset is supported.
- assertTrue(client.ask("El tiempo en España").isFailed());
+ assertTrue(cli.ask("El tiempo en España").isFailed());
// Should be passed.
checkIntent("What's the local weather forecast?", "fcast", true);
@@ -102,9 +101,9 @@ class WeatherTest {
checkIntent("Chance of snow?", "curr", true);
checkIntent("Moscow", "curr", true);
- client.clearConversation();
+ cli.clearConversation();
// Cannot be answered without conversation.
- assertTrue(client.ask("Moscow").isFailed());
+ assertTrue(cli.ask("Moscow").isFailed());
}
}
diff --git
a/src/main/scala/org/apache/nlpcraft/model/tools/test/NCTestClient.java
b/src/main/scala/org/apache/nlpcraft/model/tools/test/NCTestClient.java
index 26890e5..2de6fc0 100644
--- a/src/main/scala/org/apache/nlpcraft/model/tools/test/NCTestClient.java
+++ b/src/main/scala/org/apache/nlpcraft/model/tools/test/NCTestClient.java
@@ -29,26 +29,31 @@ import java.io.IOException;
* the usage of test framework together with JUnit 5:
* <pre class="brush: java, highlight: [6, 8, 13, 19, 22, 25, 26, 27]">
* public class AlarmTest {
- * private NCTestClient client;
+ * private NCTestClient cli;
*
* @BeforeEach
* void setUp() throws NCException, IOException {
- * client = new NCTestClientBuilder().newBuilder().build();
+ * NCEmbeddedProbe.start(AlarmModel.class);
*
- * client.open("nlpcraft.alarm.ex");
+ * cli = new NCTestClientBuilder().newBuilder().build();
+ *
+ * cli.open("nlpcraft.alarm.ex");
* }
*
* @AfterEach
* void tearDown() throws NCException, IOException {
- * client.close();
+ * if (cli != null)
+ * cli.close();
+ *
+ * NCEmbeddedProbe.stop();
* }
*
* @Test
* public void test() throws NCException, IOException {
* // Should be passed.
- * assertTrue(client.ask("Ping me in 3 minutes").isOk());
- * assertTrue(client.ask("Buzz me in an hour and 15mins").isOk());
- * assertTrue(client.ask("Set my alarm for 30s").isOk());
+ * assertTrue(cli.ask("Ping me in 3 minutes").isOk());
+ * assertTrue(cli.ask("Buzz me in an hour and 15mins").isOk());
+ * assertTrue(cli.ask("Set my alarm for 30s").isOk());
* }
* }
* </pre>
diff --git
a/src/main/scala/org/apache/nlpcraft/model/tools/test/package-info.java
b/src/main/scala/org/apache/nlpcraft/model/tools/test/package-info.java
index 06e4703..aad453e 100644
--- a/src/main/scala/org/apache/nlpcraft/model/tools/test/package-info.java
+++ b/src/main/scala/org/apache/nlpcraft/model/tools/test/package-info.java
@@ -22,32 +22,37 @@
* the usage of test framework together with JUnit 5:
* <pre class="brush: java">
* public class AlarmTest {
- * private NCTestClient client;
+ * private NCTestClient cli;
*
* @BeforeEach
* void setUp() throws NCException, IOException {
- * client = new NCTestClientBuilder().newBuilder().build();
+ * NCEmbeddedProbe.start(AlarmModel.class);
*
- * client.open("nlpcraft.alarm.ex");
+ * cli = new NCTestClientBuilder().newBuilder().build();
+ *
+ * cli.open("nlpcraft.alarm.ex");
* }
*
* @AfterEach
* void tearDown() throws NCException, IOException {
- * client.close();
+ * if (cli != null)
+ * cli.close();
+ *
+ * NCEmbeddedProbe.stop();
* }
*
* @Test
* public void test() throws NCException, IOException {
* // Empty parameter.
- * assertTrue(client.ask("").isFailed());
+ * assertTrue(cli.ask("").isFailed());
*
* // Only latin charset is supported.
- * assertTrue(client.ask("El tiempo en España").isFailed());
+ * assertTrue(cli.ask("El tiempo en España").isFailed());
*
* // Should be passed.
- * assertTrue(client.ask("Ping me in 3 minutes").isOk());
- * assertTrue(client.ask("Buzz me in an hour and 15mins").isOk());
- * assertTrue(client.ask("Set my alarm for 30s").isOk());
+ * assertTrue(cli.ask("Ping me in 3 minutes").isOk());
+ * assertTrue(cli.ask("Buzz me in an hour and 15mins").isOk());
+ * assertTrue(cli.ask("Set my alarm for 30s").isOk());
* }
* }
* </pre>
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 9f61f65..4934ca1 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
@@ -29,28 +29,28 @@ import static org.junit.jupiter.api.Assertions.*;
* DSL test model test. Make sure to start up the NLPCraft server before
running this test.
*/
class NCDslTest {
- private NCTestClient client;
+ private NCTestClient cli;
@BeforeEach
void setUp() throws NCException, IOException {
// Start embedded probe with the test model.
NCEmbeddedProbe.start(NCDslTestModel.class);
- client = new NCTestClientBuilder().newBuilder().build();
+ cli = new NCTestClientBuilder().newBuilder().build();
- client.open("nlpcraft.dsl.test");
+ cli.open("nlpcraft.dsl.test");
}
@AfterEach
void tearDown() throws NCException, IOException {
- if (client != null)
- client.close();
+ if (cli != null)
+ cli.close();
NCEmbeddedProbe.stop();
}
@Test
void test() throws NCException, IOException {
- assertTrue(client.ask("aa").isOk());
+ assertTrue(cli.ask("aa").isOk());
}
}
diff --git
a/src/test/scala/org/apache/nlpcraft/models/stm/NCStmTestModelSpec.java
b/src/test/scala/org/apache/nlpcraft/models/stm/NCStmTestModelSpec.java
index c995f51..90ba5a2 100644
--- a/src/test/scala/org/apache/nlpcraft/models/stm/NCStmTestModelSpec.java
+++ b/src/test/scala/org/apache/nlpcraft/models/stm/NCStmTestModelSpec.java
@@ -35,21 +35,21 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* Server and probe with deployed
org.apache.nlpcraft.models.stm.NCStmTestModel should be started before.
*/
class NCStmTestModelSpec {
- private NCTestClient client;
+ private NCTestClient cli;
@BeforeEach
void setUp() throws NCException, IOException {
NCEmbeddedProbe.start(NCStmTestModel.class);
- client = new NCTestClientBuilder().newBuilder().build();
+ cli = new NCTestClientBuilder().newBuilder().build();
- client.open("nlpcraft.stm.test"); // See phone_model.json
+ cli.open("nlpcraft.stm.test"); // See phone_model.json
}
@AfterEach
void tearDown() throws NCException, IOException {
- if (client != null)
- client.close();
+ if (cli != null)
+ cli.close();
NCEmbeddedProbe.stop();
}
@@ -60,7 +60,7 @@ class NCStmTestModelSpec {
* @throws IOException
*/
private void check(String req, String expResp) throws IOException {
- NCTestResult res = client.ask(req);
+ NCTestResult res = cli.ask(req);
assertTrue(res.isOk());
assertTrue(res.getResult().isPresent());