import net.pterodactylus.util.template.*
import org.hamcrest.MatcherAssert.*
import org.hamcrest.Matchers.*
-import java.io.*
import kotlin.test.*
/**
@Test
fun `handler does not add notification during first start`() {
- notificationManager.addNotification(object : AbstractNotification("first-start-notification") {
- override fun render(writer: Writer?) = Unit
- })
+ notificationManager.firstStart()
eventBus.post(NewPostFoundEvent(remotePost))
assertThat(notificationManager.notifications, not(hasItem<Notification>(notification)))
}
import net.pterodactylus.util.notify.*
import org.hamcrest.MatcherAssert.*
import org.hamcrest.Matchers.*
-import java.io.*
import java.util.function.Consumer
import kotlin.test.*
@Test
fun `new post is marked as known during first start`() {
- notificationManager.addNotification(object : AbstractNotification("first-start-notification") {
- override fun render(writer: Writer?) = Unit
- })
+ notificationManager.firstStart()
eventBus.post(NewPostFoundEvent(post))
assertThat(markedPosts, contains(post))
}
import net.pterodactylus.util.template.*
import org.hamcrest.MatcherAssert.*
import org.hamcrest.Matchers.*
-import java.io.*
import kotlin.test.*
/**
@Test
fun `handler does not add notification to notification manager during first start`() {
- notificationManager.addNotification(object : AbstractNotification("first-start-notification") {
- override fun render(writer: Writer?) = Unit
- })
+ notificationManager.firstStart()
eventBus.post(NewPostFoundEvent(remotePost))
assertThat(notificationManager.notifications, not(hasItem(notification)))
}
import net.pterodactylus.util.template.*
import org.hamcrest.MatcherAssert.*
import org.hamcrest.Matchers.*
-import java.io.*
import kotlin.test.*
class NewSoneHandlerTest {
@Test
fun `handler does not add notification on new sone event if first-start notification is present`() {
- notificationManager.addNotification(object : AbstractNotification("first-start-notification") {
- override fun render(writer: Writer) = Unit
- })
+ notificationManager.firstStart()
eventBus.post(NewSoneFoundEvent(sone))
assertThat(notificationManager.notifications.single().id, equalTo("first-start-notification"))
}
import org.hamcrest.Matchers.*
import org.mockito.*
import org.mockito.Mockito.*
-import java.io.*
import java.util.concurrent.*
import java.util.concurrent.TimeUnit.*
import java.util.function.*
@Test
fun `mark-post-known-during-first-start handler is created with correct action`() {
- notificationManager.addNotification(object : AbstractNotification("first-start-notification") {
- override fun render(writer: Writer?) = Unit
- })
+ notificationManager.firstStart()
val handler = injector.getInstance<MarkPostKnownDuringFirstStartHandler>()
val post = mock<Post>()
handler.newPostFound(NewPostFoundEvent(post))
package net.pterodactylus.sone.web.notification
+import net.pterodactylus.util.notify.*
+import java.io.*
import java.util.concurrent.*
/** Information about a scheduled runnable. */
.also { scheduleds += Scheduled(command, delay, unit, it) }
}
+
+fun NotificationManager.firstStart() {
+ addNotification(object : AbstractNotification("first-start-notification") {
+ override fun render(writer: Writer?) = Unit
+ })
+}