projects
/
Sone.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
60b0b8a
)
🎨 Add helper for simulating first start
author
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Sat, 4 Jan 2020 15:30:29 +0000
(16:30 +0100)
committer
David ‘Bombe’ Roden
<bombe@pterodactylus.net>
Sat, 4 Jan 2020 15:30:29 +0000
(16:30 +0100)
src/test/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandlerTest.kt
patch
|
blob
|
history
src/test/kotlin/net/pterodactylus/sone/web/notification/MarkPostKnownDuringFirstStartHandlerTest.kt
patch
|
blob
|
history
src/test/kotlin/net/pterodactylus/sone/web/notification/NewRemotePostHandlerTest.kt
patch
|
blob
|
history
src/test/kotlin/net/pterodactylus/sone/web/notification/NewSoneHandlerTest.kt
patch
|
blob
|
history
src/test/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModuleTest.kt
patch
|
blob
|
history
src/test/kotlin/net/pterodactylus/sone/web/notification/Testing.kt
patch
|
blob
|
history
diff --git
a/src/test/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandlerTest.kt
b/src/test/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandlerTest.kt
index
d435101
..
45be33b
100644
(file)
--- a/
src/test/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandlerTest.kt
+++ b/
src/test/kotlin/net/pterodactylus/sone/web/notification/LocalPostHandlerTest.kt
@@
-26,7
+26,6
@@
import net.pterodactylus.util.notify.*
import net.pterodactylus.util.template.*
import org.hamcrest.MatcherAssert.*
import org.hamcrest.Matchers.*
import net.pterodactylus.util.template.*
import org.hamcrest.MatcherAssert.*
import org.hamcrest.Matchers.*
-import java.io.*
import kotlin.test.*
/**
import kotlin.test.*
/**
@@
-62,9
+61,7
@@
class LocalPostHandlerTest {
@Test
fun `handler does not add notification during first start`() {
@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)))
}
eventBus.post(NewPostFoundEvent(remotePost))
assertThat(notificationManager.notifications, not(hasItem<Notification>(notification)))
}
diff --git
a/src/test/kotlin/net/pterodactylus/sone/web/notification/MarkPostKnownDuringFirstStartHandlerTest.kt
b/src/test/kotlin/net/pterodactylus/sone/web/notification/MarkPostKnownDuringFirstStartHandlerTest.kt
index
28a1719
..
6efb472
100644
(file)
--- a/
src/test/kotlin/net/pterodactylus/sone/web/notification/MarkPostKnownDuringFirstStartHandlerTest.kt
+++ b/
src/test/kotlin/net/pterodactylus/sone/web/notification/MarkPostKnownDuringFirstStartHandlerTest.kt
@@
-23,7
+23,6
@@
import net.pterodactylus.sone.data.*
import net.pterodactylus.util.notify.*
import org.hamcrest.MatcherAssert.*
import org.hamcrest.Matchers.*
import net.pterodactylus.util.notify.*
import org.hamcrest.MatcherAssert.*
import org.hamcrest.Matchers.*
-import java.io.*
import java.util.function.Consumer
import kotlin.test.*
import java.util.function.Consumer
import kotlin.test.*
@@
-50,9
+49,7
@@
class MarkPostKnownDuringFirstStartHandlerTest {
@Test
fun `new post is marked as known during first start`() {
@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))
}
eventBus.post(NewPostFoundEvent(post))
assertThat(markedPosts, contains(post))
}
diff --git
a/src/test/kotlin/net/pterodactylus/sone/web/notification/NewRemotePostHandlerTest.kt
b/src/test/kotlin/net/pterodactylus/sone/web/notification/NewRemotePostHandlerTest.kt
index
5e4e5fc
..
a0d7bc6
100644
(file)
--- a/
src/test/kotlin/net/pterodactylus/sone/web/notification/NewRemotePostHandlerTest.kt
+++ b/
src/test/kotlin/net/pterodactylus/sone/web/notification/NewRemotePostHandlerTest.kt
@@
-27,7
+27,6
@@
import net.pterodactylus.util.notify.*
import net.pterodactylus.util.template.*
import org.hamcrest.MatcherAssert.*
import org.hamcrest.Matchers.*
import net.pterodactylus.util.template.*
import org.hamcrest.MatcherAssert.*
import org.hamcrest.Matchers.*
-import java.io.*
import kotlin.test.*
/**
import kotlin.test.*
/**
@@
-71,9
+70,7
@@
class NewRemotePostHandlerTest {
@Test
fun `handler does not add notification to notification manager during first start`() {
@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)))
}
eventBus.post(NewPostFoundEvent(remotePost))
assertThat(notificationManager.notifications, not(hasItem(notification)))
}
diff --git
a/src/test/kotlin/net/pterodactylus/sone/web/notification/NewSoneHandlerTest.kt
b/src/test/kotlin/net/pterodactylus/sone/web/notification/NewSoneHandlerTest.kt
index
ff0947d
..
0774992
100644
(file)
--- a/
src/test/kotlin/net/pterodactylus/sone/web/notification/NewSoneHandlerTest.kt
+++ b/
src/test/kotlin/net/pterodactylus/sone/web/notification/NewSoneHandlerTest.kt
@@
-26,7
+26,6
@@
import net.pterodactylus.util.notify.*
import net.pterodactylus.util.template.*
import org.hamcrest.MatcherAssert.*
import org.hamcrest.Matchers.*
import net.pterodactylus.util.template.*
import org.hamcrest.MatcherAssert.*
import org.hamcrest.Matchers.*
-import java.io.*
import kotlin.test.*
class NewSoneHandlerTest {
import kotlin.test.*
class NewSoneHandlerTest {
@@
-55,9
+54,7
@@
class NewSoneHandlerTest {
@Test
fun `handler does not add notification on new sone event if first-start notification is present`() {
@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"))
}
eventBus.post(NewSoneFoundEvent(sone))
assertThat(notificationManager.notifications.single().id, equalTo("first-start-notification"))
}
diff --git
a/src/test/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModuleTest.kt
b/src/test/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModuleTest.kt
index
ea5db56
..
7d96208
100644
(file)
--- a/
src/test/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModuleTest.kt
+++ b/
src/test/kotlin/net/pterodactylus/sone/web/notification/NotificationHandlerModuleTest.kt
@@
-37,7
+37,6
@@
import org.hamcrest.Matchers
import org.hamcrest.Matchers.*
import org.mockito.*
import org.mockito.Mockito.*
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.*
import java.util.concurrent.*
import java.util.concurrent.TimeUnit.*
import java.util.function.*
@@
-75,9
+74,7
@@
class NotificationHandlerModuleTest {
@Test
fun `mark-post-known-during-first-start handler is created with correct action`() {
@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))
val handler = injector.getInstance<MarkPostKnownDuringFirstStartHandler>()
val post = mock<Post>()
handler.newPostFound(NewPostFoundEvent(post))
diff --git
a/src/test/kotlin/net/pterodactylus/sone/web/notification/Testing.kt
b/src/test/kotlin/net/pterodactylus/sone/web/notification/Testing.kt
index
12088d0
..
4009ea0
100644
(file)
--- a/
src/test/kotlin/net/pterodactylus/sone/web/notification/Testing.kt
+++ b/
src/test/kotlin/net/pterodactylus/sone/web/notification/Testing.kt
@@
-17,6
+17,8
@@
package net.pterodactylus.sone.web.notification
package net.pterodactylus.sone.web.notification
+import net.pterodactylus.util.notify.*
+import java.io.*
import java.util.concurrent.*
/** Information about a scheduled runnable. */
import java.util.concurrent.*
/** Information about a scheduled runnable. */
@@
-35,3
+37,9
@@
class TestScheduledThreadPoolExecutor : ScheduledThreadPoolExecutor(1) {
.also { scheduleds += Scheduled(command, delay, unit, it) }
}
.also { scheduleds += Scheduled(command, delay, unit, it) }
}
+
+fun NotificationManager.firstStart() {
+ addNotification(object : AbstractNotification("first-start-notification") {
+ override fun render(writer: Writer?) = Unit
+ })
+}