diff options
author | Vitaly Takmazov | 2017-10-30 13:52:55 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2017-10-30 23:55:25 +0300 |
commit | 240a375ecdeb7592d8765f0edb7d2fd67c50ac10 (patch) | |
tree | 7d518988a1fc3c79ccb00cd07fdb4201569c674e /juick-xmpp/src/test/java/com/juick | |
parent | 3ca4188155e5f04a5cc96c4be20ef206e9f3ffde (diff) |
xmpp: bot refactoring
Diffstat (limited to 'juick-xmpp/src/test/java/com/juick')
-rw-r--r-- | juick-xmpp/src/test/java/com/juick/xmpp/server/XMPPServerTests.java | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/juick-xmpp/src/test/java/com/juick/xmpp/server/XMPPServerTests.java b/juick-xmpp/src/test/java/com/juick/xmpp/server/XMPPServerTests.java index ccc4f1d4..11ca75cf 100644 --- a/juick-xmpp/src/test/java/com/juick/xmpp/server/XMPPServerTests.java +++ b/juick-xmpp/src/test/java/com/juick/xmpp/server/XMPPServerTests.java @@ -1,5 +1,6 @@ package com.juick.xmpp.server; +import com.juick.User; import com.juick.components.JuickBot; import com.juick.components.XMPPServer; import com.juick.components.configuration.XmppAppConfiguration; @@ -18,16 +19,15 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; import rocks.xmpp.addr.Jid; -import rocks.xmpp.core.stanza.model.Message; import rocks.xmpp.core.stanza.model.Stanza; -import rocks.xmpp.core.stanza.model.StanzaError; -import rocks.xmpp.core.stanza.model.errors.Condition; import rocks.xmpp.core.stanza.model.server.ServerMessage; import javax.inject.Inject; +import java.lang.reflect.InvocationTargetException; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.is; import static org.mockito.Mockito.when; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @@ -70,4 +70,10 @@ public class XMPPServerTests { Stanza msg = server.parse(xmlMessage); bot.incomingMessage((ServerMessage)msg); } + @Test + public void botCommandsTests() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { + assertThat(bot.processCommand(new User(), Jid.of("test@localhost"), "PING").get(), is("PONG")); + // tag help have two lines, others have 1 + assertThat(bot.processCommand(new User(), Jid.of("test@localhost"), "help").get().split("\n").length, is(17)); + } } |