@JvmOverloads
constructor(id: String, key: String, template: Template, dismissable: Boolean = true) : super(id, currentTimeMillis(), currentTimeMillis(), dismissable, template) {
this.key = key
- template.initialContext.set(key, elements)
+ template.initialContext.set(key, realElements)
}
constructor(listNotification: ListNotification<T>) : super(listNotification.id, listNotification.createdTime, listNotification.lastUpdatedTime, listNotification.isDismissable, Template()) {
this.key = listNotification.key
template.add(listNotification.template)
- template.initialContext.set(key, elements)
+ template.initialContext.set(key, realElements)
}
fun setElements(elements: Collection<T>) {
}
@Test
+ @Suppress("UNCHECKED_CAST")
+ fun `list in template context gets updated when elements are added`() {
+ listNotification.add("a")
+ listNotification.add("b")
+ assertThat(template.initialContext.get(KEY) as Iterable<String>, contains("a", "b"))
+ }
+
+ @Test
fun `new list notification has no element`() {
assertThat(listNotification.elements, emptyIterable())
}