-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1334 Notifications records in the promotion run page
- Loading branch information
1 parent
87fdd51
commit e9e28fe
Showing
21 changed files
with
1,511 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
...test/java/net/nemerosa/ontrack/extension/notifications/recording/NotificationRecordsIT.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package net.nemerosa.ontrack.extension.notifications.recording | ||
|
||
import net.nemerosa.ontrack.extension.notifications.AbstractNotificationTestSupport | ||
import net.nemerosa.ontrack.extension.notifications.mock.MockNotificationChannelConfig | ||
import net.nemerosa.ontrack.extension.notifications.sources.EntitySubscriptionNotificationSourceDataType | ||
import net.nemerosa.ontrack.extension.notifications.subscriptions.subscribe | ||
import net.nemerosa.ontrack.json.asJson | ||
import net.nemerosa.ontrack.model.events.EventFactory | ||
import net.nemerosa.ontrack.model.structure.ProjectEntityType | ||
import net.nemerosa.ontrack.model.structure.toProjectEntityID | ||
import net.nemerosa.ontrack.test.TestUtils.uid | ||
import org.junit.jupiter.api.Test | ||
import org.springframework.beans.factory.annotation.Autowired | ||
import kotlin.test.assertEquals | ||
|
||
class NotificationRecordsIT : AbstractNotificationTestSupport() { | ||
|
||
@Autowired | ||
private lateinit var notificationRecordingService: NotificationRecordingService | ||
|
||
@Test | ||
fun `Getting the notifications linked to a promotion run`() { | ||
asAdmin { | ||
project { | ||
branch { | ||
val pl = promotionLevel() | ||
// Subscription at promotion level | ||
val target = uid("pl-") | ||
val subscriptionName = uid("pl-sub-") | ||
eventSubscriptionService.subscribe( | ||
name = subscriptionName, | ||
channel = mockNotificationChannel, | ||
channelConfig = MockNotificationChannelConfig(target), | ||
projectEntity = pl, | ||
keywords = null, | ||
origin = "test", | ||
contentTemplate = null, | ||
EventFactory.NEW_PROMOTION_RUN | ||
) | ||
// Creating a separate promotion | ||
build { | ||
promote(pl) | ||
} | ||
// Tracking a specific promotion | ||
build { | ||
val run = promote(pl) | ||
// Looking at the records for THIS run | ||
val records = notificationRecordingService.filter( | ||
filter = NotificationRecordFilter( | ||
eventEntityId = run.toProjectEntityID(), | ||
) | ||
).pageItems | ||
assertEquals(1, records.size) | ||
val record = records.first() | ||
assertEquals( | ||
"entity-subscription", | ||
record.source?.id | ||
) | ||
assertEquals( | ||
EntitySubscriptionNotificationSourceDataType( | ||
entityType = ProjectEntityType.PROMOTION_LEVEL, | ||
entityId = pl.id(), | ||
subscriptionName = subscriptionName, | ||
).asJson(), | ||
record.source?.data | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.