diff --git a/platform/whatsNew/BUILD.bazel b/platform/whatsNew/BUILD.bazel index 387b92aeeb32..623906193894 100644 --- a/platform/whatsNew/BUILD.bazel +++ b/platform/whatsNew/BUILD.bazel @@ -16,6 +16,12 @@ resourcegroup( strip_prefix = "resources" ) +resourcegroup( + name = "whatsNew_test_resources", + srcs = glob(["testResources/**/*"]), + strip_prefix = "testResources" +) + jvm_library( name = "whatsNew", module_name = "intellij.platform.whatsNew", @@ -48,6 +54,7 @@ jvm_library( name = "whatsNew_test_lib", visibility = ["//visibility:public"], srcs = glob(["testSrc/**/*.kt", "testSrc/**/*.java", "testSrc/**/*.form"], allow_empty = True), + resources = [":whatsNew_test_resources"], kotlinc_opts = ":custom_whatsNew", associates = [":whatsNew"], deps = [ diff --git a/platform/whatsNew/intellij.platform.whatsNew.iml b/platform/whatsNew/intellij.platform.whatsNew.iml index 2641cca98c4b..2a381edd37e7 100644 --- a/platform/whatsNew/intellij.platform.whatsNew.iml +++ b/platform/whatsNew/intellij.platform.whatsNew.iml @@ -27,6 +27,7 @@ + diff --git a/platform/whatsNew/src/com/intellij/platform/whatsNew/WhatsNewInVisionContentProvider.kt b/platform/whatsNew/src/com/intellij/platform/whatsNew/WhatsNewInVisionContentProvider.kt index bba81a50ac93..2efb1d9010e6 100644 --- a/platform/whatsNew/src/com/intellij/platform/whatsNew/WhatsNewInVisionContentProvider.kt +++ b/platform/whatsNew/src/com/intellij/platform/whatsNew/WhatsNewInVisionContentProvider.kt @@ -133,9 +133,9 @@ class ResourceContentSource(private val classLoader: ClassLoader, private val re constructor(classLoader: ClassLoader, resourceName: String) : this(classLoader, listOf(resourceName)) override suspend fun openStream(): InputStream? = withContext(Dispatchers.IO) { - resourceNames.asSequence().map { + resourceNames.firstNotNullOfOrNull { classLoader.getResourceAsStream(it) - }.firstOrNull() + } } override suspend fun checkAvailability(): Boolean = withContext(Dispatchers.IO) { resourceNames.any { classLoader.getResource(it) != null } diff --git a/platform/whatsNew/testResources/com/intellij/platform/whatsNew/idea/eap/vision.json b/platform/whatsNew/testResources/com/intellij/platform/whatsNew/idea/eap/vision.json new file mode 100644 index 000000000000..9e26dfeeb6e6 --- /dev/null +++ b/platform/whatsNew/testResources/com/intellij/platform/whatsNew/idea/eap/vision.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/platform/whatsNew/testSrc/com/intellij/platform/whatsNew/WhatsNewVisionContentProviderTest.kt b/platform/whatsNew/testSrc/com/intellij/platform/whatsNew/WhatsNewVisionContentProviderTest.kt new file mode 100644 index 000000000000..c7bf42a7fcb9 --- /dev/null +++ b/platform/whatsNew/testSrc/com/intellij/platform/whatsNew/WhatsNewVisionContentProviderTest.kt @@ -0,0 +1,26 @@ +// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.platform.whatsNew + +import com.intellij.testFramework.junit5.TestApplication +import kotlinx.coroutines.runBlocking +import org.junit.jupiter.api.Assertions +import org.junit.jupiter.api.Test + +@TestApplication +class WhatsNewVisionContentProviderTest { + // IJPL-217529 + @Test + fun testLegacyResourceNaming() { + val provider = object : WhatsNewInVisionContentProvider() { + fun extractResourceNames() = getVisionJsonResourceNames() + } + + val resourceNames = provider.extractResourceNames() + + val contentSource = ResourceContentSource(this::class.java.classLoader, resourceNames) + runBlocking { + Assertions.assertTrue(contentSource.checkAvailability(), "Resource availability check failed") + Assertions.assertTrue(contentSource.openStream() != null, "Resource stream opening failed") + } + } +} \ No newline at end of file