IDEA-300739 Add tests for checking integration of lessons with tips

GitOrigin-RevId: 04aeced1e0b20f5f74f0296270fa6ce22020d66e
This commit is contained in:
Konstantin Hudyakov
2022-09-01 10:42:02 +03:00
committed by intellij-monorepo-bot
parent 5ae19d4044
commit 09cf2b1fee
7 changed files with 99 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.java.ift
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import training.simple.LessonsAndTipsIntegrationTest
@RunWith(JUnit4::class)
internal class JavaLessonsAndTipsIntegrationTest : LessonsAndTipsIntegrationTest() {
override val languageId = "JAVA"
override val languageSupport = JavaLangSupport()
override val learningCourse = JavaLearningCourse()
}

View File

@@ -5,6 +5,7 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/testSrc" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build" />
</content>
<orderEntry type="inheritedJdk" />
@@ -22,5 +23,6 @@
<orderEntry type="module" module-name="intellij.platform.vcs.log" />
<orderEntry type="module" module-name="intellij.vcs.git" />
<orderEntry type="module" module-name="intellij.platform.lang.impl" />
<orderEntry type="module" module-name="intellij.platform.testFramework" scope="TEST" />
</component>
</module>

View File

@@ -0,0 +1,14 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package git4idea.ift
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import training.lang.LangSupport
import training.simple.LessonsAndTipsIntegrationTest
@RunWith(JUnit4::class)
class GitLessonsAndTipsIntegrationTest : LessonsAndTipsIntegrationTest() {
override val languageId: String? = null
override val languageSupport: LangSupport? = null
override val learningCourse = GitLearningCourse()
}

View File

@@ -0,0 +1,44 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package training.simple
import com.intellij.lang.LanguageExtensionPoint
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.extensions.DefaultPluginDescriptor
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.testFramework.fixtures.BasePlatformTestCase
import com.intellij.testFramework.registerExtension
import org.junit.Assert
import org.junit.Test
import training.lang.LangSupport
import training.learn.course.LearningCourse
abstract class LessonsAndTipsIntegrationTest : BasePlatformTestCase() {
protected abstract val languageId: String?
protected abstract val languageSupport: LangSupport?
protected abstract val learningCourse: LearningCourse
override fun setUp() {
super.setUp()
val langId = languageId
val langSupport = languageSupport
val EP_NAME = ExtensionPointName<LanguageExtensionPoint<LangSupport>>(LangSupport.EP_NAME)
if (langId != null && langSupport != null && EP_NAME.extensionList.find { it.language == langId } == null) {
val langExtension = LanguageExtensionPoint(langId, langSupport)
// specify fake descriptor because it is required to be not null, but will not be used, because extension instance already created
langExtension.pluginDescriptor = DefaultPluginDescriptor("")
ApplicationManager.getApplication().registerExtension(EP_NAME, langExtension, testRootDisposable)
}
}
@Test
fun `All lessons specified in tips map exist`() {
val lessonIdToTipsMap = learningCourse.getLessonIdToTipsMap()
val lessonIds = learningCourse.modules().flatMap { it.lessons }.map { it.id }.toSet()
val unknownLessonIds = lessonIdToTipsMap.keys.filter { !lessonIds.contains(it) }
if (unknownLessonIds.isNotEmpty()) {
Assert.fail("Course $learningCourse do not contain lessons with ids:\n${unknownLessonIds.joinToString("\n")}")
}
}
}

View File

@@ -22,5 +22,6 @@
<orderEntry type="module" module-name="intellij.platform.testFramework" scope="TEST" />
<orderEntry type="module" module-name="kotlin.plugin.k1" scope="TEST" />
<orderEntry type="module" module-name="kotlin.idea" />
<orderEntry type="module" module-name="kotlin.features-trainer" scope="TEST" />
</component>
</module>

View File

@@ -0,0 +1,13 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.kotlin.training.ift
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import training.simple.LessonsAndTipsIntegrationTest
@RunWith(JUnit4::class)
class KotlinLessonsAndTipsIntegrationTest : LessonsAndTipsIntegrationTest() {
override val languageId = "kotlin"
override val languageSupport = KotlinLangSupport()
override val learningCourse = KotlinLearningCourse()
}

View File

@@ -0,0 +1,12 @@
package com.jetbrains.python.ift
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import training.simple.LessonsAndTipsIntegrationTest
@RunWith(JUnit4::class)
class PythonLessonsAndTipsIntegrationTest : LessonsAndTipsIntegrationTest() {
override val languageId = "Python"
override val languageSupport = PythonLangSupport()
override val learningCourse = PythonLearningCourse()
}