From e8552c9b162daa5cf4e651330e278dee4ea5198f Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 19 Dec 2016 22:53:53 +0300 Subject: fix protocol tests --- build.gradle | 2 +- src/test/java/com/juick/tests/ApiTests.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 02b010ad..0b4e3ca4 100644 --- a/build.gradle +++ b/build.gradle @@ -44,7 +44,7 @@ dependencies { testCompile "org.slf4j:slf4j-api:${slf4jVersion}" testCompile "junit:junit:${junitVersion}" testCompile "org.hamcrest:hamcrest-all:${hamcrestVersion}" - + testCompile "org.mockito:mockito-core:1.+" testRuntime "mysql:mysql-connector-java:5.1.40" } diff --git a/src/test/java/com/juick/tests/ApiTests.java b/src/test/java/com/juick/tests/ApiTests.java index 17bcc3db..931838d7 100644 --- a/src/test/java/com/juick/tests/ApiTests.java +++ b/src/test/java/com/juick/tests/ApiTests.java @@ -8,6 +8,7 @@ import com.juick.Tag; import com.juick.User; import com.juick.server.helpers.TagStats; import com.juick.server.protocol.JuickProtocol; +import com.juick.server.protocol.ProtocolListener; import com.juick.server.protocol.ProtocolReply; import com.juick.service.MessagesService; import com.juick.service.SubscriptionService; @@ -20,6 +21,8 @@ import org.apache.commons.lang3.StringEscapeUtils; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @@ -122,10 +125,14 @@ public class ApiTests { @Inject JuickProtocol juickProtocol; + @Mock + ProtocolListener listener; + @Before public void setup() { userService.createUser("ugnich", "secret"); userService.createUser("juick", "secret"); + MockitoAnnotations.initMocks(this); } @Test public void messageTests() { @@ -175,6 +182,7 @@ public class ApiTests { @Test public void protocolTests() throws IllegalAccessException, NoSuchMethodException, InvocationTargetException, ParseException, JsonProcessingException { + juickProtocol.setListener(listener); assertEquals("juick user should have uid 2", 2, userService.getUIDbyName("juick")); int uid = userService.createUser("me", "secret"); User user = userService.getUserByUID(uid).orElse(new User()); -- cgit v1.2.3