fun doTest()

in intellij-plugin/educational-core/testSrc/com/jetbrains/edu/learning/marketplace/lti/LtiGradingErrorNotificationTest.kt [124:170]


  fun doTest(
    courseLink: String?,
    lmsDescription: String?,
    serverStatus: PostTaskSolvedStatus,

    expectedNotificationType: NotificationType = NotificationType.ERROR,
    expectedNotificationText: String
  ) {
    // given
    val course = createEduCourse()
    val task = course.allTasks[0]

    val ltiSettingsManager = mockService<LTISettingsManager>(project)
    val ltiConnector = mockService<LTIConnector>(application)
    mockkObject(EduNotificationManager)

    every { ltiConnector.postTaskChecked(any(), any(), any(), any(), any()) } returns serverStatus
    every { ltiSettingsManager.settings } returns LTISettingsDTO(
      "launch-id-238",
      lmsDescription,
      LTIOnlineService.STANDALONE,
      courseLink
    )

    val notificationTypeSlot = slot<NotificationType>()
    val notificationTextSlot = slot<String>()
    every { EduNotificationManager.create(capture(notificationTypeSlot), any(), capture(notificationTextSlot)) } returns mockk(relaxed = true)

    // when
    NavigationUtils.navigateToTask(project, task)
    testAction(CheckAction(task.getUICheckLabel()))

    // then
    verify(exactly = 1) { EduNotificationManager.create(any(), any(), any()) }

    assertEquals(
      "Notification type is not as expected",
      expectedNotificationType,
      notificationTypeSlot.captured
    )

    assertEquals(
      "Notification text is not as expected",
      expectedNotificationText.trimIndent(),
      notificationTextSlot.captured.split("<br>").joinToString("\n")
    )
  }