From d16275ecf30c76a913b965a18eb69098f94a5008 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 17 Oct 2017 15:18:15 +0300 Subject: notifications: fix test --- .../java/com/juick/components/test/NotificationTests.java | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'juick-notifications/src/test/java/com') diff --git a/juick-notifications/src/test/java/com/juick/components/test/NotificationTests.java b/juick-notifications/src/test/java/com/juick/components/test/NotificationTests.java index 09a0c59a..9ca9c187 100644 --- a/juick-notifications/src/test/java/com/juick/components/test/NotificationTests.java +++ b/juick-notifications/src/test/java/com/juick/components/test/NotificationTests.java @@ -23,7 +23,6 @@ import ch.qos.logback.core.Appender; import com.juick.components.CleanUp; import com.juick.components.Notifications; import com.juick.components.service.TokenService; -import com.notnoop.apns.ApnsService; import org.junit.Before; import org.junit.Test; import org.mockito.InjectMocks; @@ -32,6 +31,7 @@ import org.mockito.MockitoAnnotations; import org.slf4j.LoggerFactory; import org.springframework.web.client.RestTemplate; +import java.util.Collections; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -48,8 +48,6 @@ public class NotificationTests { @InjectMocks CleanUp cleanUp; - @Mock - ApnsService service; @Mock RestTemplate rest; @Mock @@ -65,19 +63,13 @@ public class NotificationTests { @Test public void CleanUpTest() { - Map inactiveDevices = new HashMap<>(); - inactiveDevices.put("yoyoyo", new Date()); - when(service.getInactiveDevices()).thenReturn(inactiveDevices); + when(push.getInvalidAPNSTokens()).thenReturn(Collections.singleton("yoyo")); ch.qos.logback.classic.Logger root = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); final Appender mockAppender = mock(Appender.class); when(mockAppender.getName()).thenReturn("MOCK"); root.addAppender(mockAppender); cleanUp.cleanupTokens(); verify(mockAppender).doAppend(argThat(argument -> - ((LoggingEvent)argument).getFormattedMessage().contains("1 tokens to delete"))); - when(service.getInactiveDevices()).thenReturn(new HashMap<>()); - cleanUp.cleanupTokens(); - verify(mockAppender).doAppend(argThat(argument -> - ((LoggingEvent)argument).getFormattedMessage().contains("No APNS tokens to delete"))); + ((LoggingEvent)argument).getFormattedMessage().contains("1 tokens"))); } } -- cgit v1.2.3