Skip to content

Commit

Permalink
Fix failed tests
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Oertel <christian.oertel@tngtech.com>
  • Loading branch information
fudler committed Aug 18, 2023
1 parent 7cdcd3f commit 2d09f77
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ package com.tngtech.jgiven.usage.filter
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.project.Project
import com.intellij.usages.ConfigurableUsageTarget
import com.intellij.usages.UsageTarget
import com.intellij.usages.UsageView
import com.intellij.usages.impl.UsageViewImpl
import com.intellij.usages.rules.UsageFilteringRule
import com.intellij.usages.rules.UsageFilteringRuleProvider
import com.tngtech.jgiven.scenario.state.ScenarioStateAnnotationProvider
import java.util.*

class ScenarioStateFilteringRuleProvider : UsageFilteringRuleProvider {
private val scenarioStateAnnotationProvider = ScenarioStateAnnotationProvider()

@Deprecated("Use instead getApplicableRules", ReplaceWith("getApplicableRules()"))
override fun getActiveRules(project: Project): Array<UsageFilteringRule> {
return emptyArray()
}

@Deprecated("Use instead UsageFilteringRule.getActionId", ReplaceWith("UsageFilteringRule.getActionId()"))
override fun createFilteringActions(view: UsageView): Array<AnAction> {
return when {
isNormalFindUsagesDialogAndNotShowUsages(view) -> arrayOf(
Expand Down
20 changes: 17 additions & 3 deletions src/test/java/com/tngtech/jgiven/LibraryTestUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,23 @@ class LibraryTestUtil constructor(private val myModule: Module) {
private val references = ArrayList<Ref<Library>>()

private fun addJarContaining(clazz: Class<*>): LibraryTestUtil {
val path = clazz.protectionDomain.codeSource.location.path
addLibraryAt(path)
val path = getJarPath(clazz)
if (path != null)
addLibraryAt(path)
return this
}

private fun getJarPath(clazz: Class<*>): String? {
val className = clazz.name.replace('.', '/') + ".class"
val classPath = clazz.classLoader.getResource(className)?.toString() ?: return null
return if (classPath.startsWith("jar")) {
classPath.substringAfter("jar:file:").substringBefore('!')
} else {
null
}
}


fun addJGiven(): LibraryTestUtil {
return addJarContaining(ScenarioState::class.java)
}
Expand All @@ -31,7 +43,9 @@ class LibraryTestUtil constructor(private val myModule: Module) {
val file = File(path)
VfsRootAccess.allowRootAccess(myModule, parts[0])
val fileName = file.name
ModuleRootModificationUtil.updateModel(myModule) { model -> references.add(Ref.create(PsiTestUtil.addLibrary(model, fileName, file.parent, fileName))) }
ModuleRootModificationUtil.updateModel(myModule) { model -> references.add(Ref.create(PsiTestUtil.addLibrary(
model, fileName, file.parent, fileName
))) }
}

internal fun removeLibraries() {
Expand Down

0 comments on commit 2d09f77

Please sign in to comment.