\n+ \n+ Only the following page types may be chosen for this field: Simple page, Event page. Search results will exclude pages of other types.\n+
\n+ \"\"\"\n+\n+ self.assertTagInHTML(expected, html)\n+\n def test_with_unknown_page_type(self):\n response = self.get({\"page_type\": \"foo.bar\"})\n self.assertEqual(response.status_code, 404)\n"} {"repo_name": "wagtail", "task_num": 12569, "gold_patch": "diff --git a/CHANGELOG.txt b/CHANGELOG.txt\nindex d73e9511bea8..6c4de8502305 100644\n--- a/CHANGELOG.txt\n+++ b/CHANGELOG.txt\n@@ -52,6 +52,8 @@ Changelog\n * Maintenance: Various performance optimizations to page publishing (Jake Howard)\n * Maintenance: Remove unnecessary DOM canvas.toBlob polyfill (LB (Ben) Johnston)\n * Maintenance: Ensure Storybook core files are correctly running through Eslint (LB (Ben) Johnston)\n+ * Maintenance: Add a new Stimulus `ZoneController` (`w-zone`) to support dynamic class name changes & event handling on container elements (Ayaan Qadri)\n+ * Maintenance: Migrate jQuery class toggling & drag/drop event handling within the multiple upload views to the Stimulus ZoneController usage (Ayaan Qadri)\n \n \n 6.3.1 (19.11.2024)\ndiff --git a/client/src/controllers/ZoneController.stories.js b/client/src/controllers/ZoneController.stories.js\nnew file mode 100644\nindex 000000000000..d1a33aa8bd69\n--- /dev/null\n+++ b/client/src/controllers/ZoneController.stories.js\n@@ -0,0 +1,46 @@\n+import React from 'react';\n+\n+import { StimulusWrapper } from '../../storybook/StimulusWrapper';\n+import { ZoneController } from './ZoneController';\n+\n+export default {\n+ title: 'Stimulus / ZoneController',\n+ argTypes: {\n+ debug: {\n+ control: 'boolean',\n+ defaultValue: false,\n+ },\n+ },\n+};\n+\n+const definitions = [\n+ {\n+ identifier: 'w-zone',\n+ controllerConstructor: ZoneController,\n+ },\n+];\n+\n+const Template = ({ debug = false }) => (\n+\n+ Drag an item over the box, and drop it to see class activation and\n+ deactivation in action.\n+
\n+{% trans \"Drag and drop documents into this area to upload immediately.\" %}
\n{{ help_text }}
\n \ndiff --git a/wagtail/images/static_src/wagtailimages/js/add-multiple.js b/wagtail/images/static_src/wagtailimages/js/add-multiple.js\nindex 7255bf2f28ff..35608cdb1fc4 100644\n--- a/wagtail/images/static_src/wagtailimages/js/add-multiple.js\n+++ b/wagtail/images/static_src/wagtailimages/js/add-multiple.js\n@@ -1,9 +1,4 @@\n $(function () {\n- // prevents browser default drag/drop\n- $(document).on('drop dragover', function (e) {\n- e.preventDefault();\n- });\n-\n $('#fileupload').fileupload({\n dataType: 'html',\n sequentialUploads: true,\ndiff --git a/wagtail/images/templates/wagtailimages/multiple/add.html b/wagtail/images/templates/wagtailimages/multiple/add.html\nindex 0fb1c6574c34..e7accfb35436 100644\n--- a/wagtail/images/templates/wagtailimages/multiple/add.html\n+++ b/wagtail/images/templates/wagtailimages/multiple/add.html\n@@ -10,7 +10,13 @@\n {% endblock %}\n \n {% block main_content %}\n-{% trans \"Drag and drop images into this area to upload immediately.\" %}
\n{{ help_text }}
\n \n", "commit": "b9575f3498bba69fa2a8f53be110ec11ea3746f0", "edit_prompt": "Add drag and drop event handling to the document upload zone, showing the \"hovered\" class during dragover with a 10ms delay, and prevent default browser drag/drop behavior.", "prompt": "The following is the text of a github issue and related comments for this repository:\n\n\ud83c\udf9b\ufe0f Create a new `ZoneController` to remove reliance on jQuery for toggling classes based on DOM events\n### Is your proposal related to a problem?\n\nCurrently we use jQuery for common behaviour such as 'add this class when hovered' or 'remove this class when event fires', these are common use cases that would be great candidates for our Stimulus migration.\n\nAs a start, we should replace this specific jQuery usage with a new Stimulus controller.\n\nhttps://github.com/wagtail/wagtail/blob/246f3c7eb542be2081556bf5334bc22256776bf4/client/src/entrypoints/admin/core.js#L62-L71\n\n### Describe the solution you'd like\n\nIntroduce a new Stimulus controller (calling this `ZoneController` for now, better names can be suggested), that allows us to use events to add/remove classes declaratively within HTML.\n\nWe could remove the above referenced code in `core.js` and then update the HTML in [`wagtail/documents/templates/wagtaildocs/multiple/add.html`](https://github.com/wagtail/wagtail/blob/main/wagtail/images/templates/wagtaildocs/multiple/add.html) & [`wagtail/images/templates/wagtailimages/multiple/add.html`](https://github.com/wagtail/wagtail/blob/main/wagtail/images/templates/wagtailimages/multiple/add.html).\n\n> This is used in the multiple upload views for both images & documents.\n\n\n\nFinally, we could probably also remove the need for the `preventDefault` calls in both JS variations. This can be done on the controller instead.\n\nhttps://github.com/wagtail/wagtail/blob/246f3c7eb542be2081556bf5334bc22256776bf4/wagtail/documents/static_src/wagtaildocs/js/add-multiple.js#L2-L5\n\ne.g. \n\n```html\n{% block main_content %}\n{% trans \"Drag and drop documents into this area to upload immediately.\" %}
\n{{ help_text }}
\n ", "test_patch": "diff --git a/client/src/controllers/ZoneController.test.js b/client/src/controllers/ZoneController.test.js\nnew file mode 100644\nindex 000000000000..238798c0af8a\n--- /dev/null\n+++ b/client/src/controllers/ZoneController.test.js\n@@ -0,0 +1,169 @@\n+import { Application } from '@hotwired/stimulus';\n+import { ZoneController } from './ZoneController';\n+\n+jest.useFakeTimers();\n+\n+describe('ZoneController', () => {\n+ let application;\n+\n+ const setup = async (html) => {\n+ document.body.innerHTML = `Must be a positive number.\n+\t *
Must be a positive number or {@code -1} to allow an unlimited number\n+\t * of characters.\n \t *\n \t *
Defaults to {@code 4096}.\n \t *\ndiff --git a/junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/CsvParserFactory.java b/junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/CsvParserFactory.java\nindex 0efb81b3252b..d7ffee880cbc 100644\n--- a/junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/CsvParserFactory.java\n+++ b/junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/CsvParserFactory.java\n@@ -77,8 +77,8 @@ private static CsvParserSettings createParserSettings(String delimiter, String l\n \t\tsettings.setAutoConfigurationEnabled(false);\n \t\tsettings.setIgnoreLeadingWhitespaces(ignoreLeadingAndTrailingWhitespace);\n \t\tsettings.setIgnoreTrailingWhitespaces(ignoreLeadingAndTrailingWhitespace);\n-\t\tPreconditions.condition(maxCharsPerColumn > 0,\n-\t\t\t() -> \"maxCharsPerColumn must be a positive number: \" + maxCharsPerColumn);\n+\t\tPreconditions.condition(maxCharsPerColumn > 0 || maxCharsPerColumn == -1,\n+\t\t\t() -> \"maxCharsPerColumn must be a positive number or -1: \" + maxCharsPerColumn);\n \t\tsettings.setMaxCharsPerColumn(maxCharsPerColumn);\n \t\t// Do not use the built-in support for skipping rows/lines since it will\n \t\t// throw an IllegalArgumentException if the file does not contain at least\ndiff --git a/junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/CsvSource.java b/junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/CsvSource.java\nindex ef09eea27ba6..6ee1c92e7c10 100644\n--- a/junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/CsvSource.java\n+++ b/junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/CsvSource.java\n@@ -261,7 +261,8 @@\n \t/**\n \t * The maximum number of characters allowed per CSV column.\n \t *\n-\t *
Must be a positive number.\n+\t *
Must be a positive number or {@code -1} to allow an unlimited number\n+\t * of characters.\n \t *\n \t *
Defaults to {@code 4096}.\n \t *\n", "commit": "0b10f86dd2e0a7fd232c1de032d1e2fbe312f615", "edit_prompt": "Allow -1 as a valid value for maxCharsPerColumn by updating the precondition check and its error message.", "prompt": "The following is the text of a github issue and related comments for this repository:\n\n@CsvFileSource is unusable for datasets involving very long lines\n# Description\n\nIf you want to use a CSV file-based dataset, that contains very long values in the columns, you have to increase the `maxCharsPerColumn` property from the default value of `4096`. If, however, you don't know what is the length of the largest datapoint in your dataset, or cannot be sure to set a hard limit for future expansion, a logical thing to do would be to set the value to the largest possible one, i.e. `Integer.MAX_VALUE`.\n\nThis to my surprise crashes the test execution with :\n```\nException in thread \"main\" java.lang.OutOfMemoryError: Requested array size exceeds VM limit\n\tat org.junit.jupiter.params.shadow.com.univocity.parsers.common.input.DefaultCharAppender. These utilities are intended solely for usage within the JUnit framework\n+ * itself. Any usage by external parties is not supported.\n+ * Use at your own risk!\n+ *\n * @since 1.11\n */\n-class ClasspathResource implements Resource {\n+@API(status = INTERNAL, since = \"1.12\")\n+public class DefaultResource implements Resource {\n \n \tprivate final String name;\n \tprivate final URI uri;\n \n-\tClasspathResource(String name, URI uri) {\n+\tpublic DefaultResource(String name, URI uri) {\n \t\tthis.name = Preconditions.notNull(name, \"name must not be null\");\n \t\tthis.uri = Preconditions.notNull(uri, \"uri must not be null\");\n \t}\n@@ -44,7 +55,7 @@ public boolean equals(Object o) {\n \t\t\treturn true;\n \t\tif (o == null || getClass() != o.getClass())\n \t\t\treturn false;\n-\t\tClasspathResource that = (ClasspathResource) o;\n+\t\tDefaultResource that = (DefaultResource) o;\n \t\treturn name.equals(that.name) && uri.equals(that.uri);\n \t}\n \ndiff --git a/junit-platform-commons/src/main/java/org/junit/platform/commons/support/conversion/package-info.java b/junit-platform-commons/src/main/java/org/junit/platform/commons/support/conversion/package-info.java\nindex e51977179941..18807d6a4e90 100644\n--- a/junit-platform-commons/src/main/java/org/junit/platform/commons/support/conversion/package-info.java\n+++ b/junit-platform-commons/src/main/java/org/junit/platform/commons/support/conversion/package-info.java\n@@ -1,5 +1,5 @@\n /**\n- * Maintained conversion APIs provided by the JUnit Platform.\n+ * Conversion APIs provided by the JUnit Platform.\n */\n \n package org.junit.platform.commons.support.conversion;\ndiff --git a/junit-platform-commons/src/main/java/org/junit/platform/commons/support/package-info.java b/junit-platform-commons/src/main/java/org/junit/platform/commons/support/package-info.java\nindex 6e9c460116f4..fae0c2a81547 100644\n--- a/junit-platform-commons/src/main/java/org/junit/platform/commons/support/package-info.java\n+++ b/junit-platform-commons/src/main/java/org/junit/platform/commons/support/package-info.java\n@@ -1,5 +1,5 @@\n /**\n- * Maintained common support APIs provided by the JUnit Platform.\n+ * Common support APIs provided by the JUnit Platform.\n *\n * The purpose of this package is to provide {@code TestEngine} and\n * {@code Extension} authors convenient access to a subset of internal utility\ndiff --git a/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ClassFilter.java b/junit-platform-commons/src/main/java/org/junit/platform/commons/support/scanning/ClassFilter.java\nsimilarity index 59%\nrename from junit-platform-commons/src/main/java/org/junit/platform/commons/util/ClassFilter.java\nrename to junit-platform-commons/src/main/java/org/junit/platform/commons/support/scanning/ClassFilter.java\nindex 8b0728213055..4e222c89f683 100644\n--- a/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ClassFilter.java\n+++ b/junit-platform-commons/src/main/java/org/junit/platform/commons/support/scanning/ClassFilter.java\n@@ -8,30 +8,28 @@\n * https://www.eclipse.org/legal/epl-v20.html\n */\n \n-package org.junit.platform.commons.util;\n+package org.junit.platform.commons.support.scanning;\n \n-import static org.apiguardian.api.API.Status.INTERNAL;\n+import static org.apiguardian.api.API.Status.EXPERIMENTAL;\n \n import java.util.function.Predicate;\n \n import org.apiguardian.api.API;\n+import org.junit.platform.commons.util.Preconditions;\n \n /**\n * Class-related predicate used by reflection utilities.\n *\n- * These utilities are intended solely for usage within the JUnit framework\n- * itself. Any usage by external parties is not supported.\n- * Use at your own risk!\n- *\n * @since 1.1\n */\n-@API(status = INTERNAL, since = \"1.1\")\n-public class ClassFilter implements Predicate An implementation of this interface can be registered via the\n+ * {@link java.util.ServiceLoader ServiceLoader} mechanism.\n+ *\n+ * @since 1.12\n+ */\n+@API(status = Status.EXPERIMENTAL, since = \"1.12\")\n+public interface ClasspathScanner {\n+\n+\t/**\n+\t * Find all {@linkplain Class classes} in the supplied classpath {@code root}\n+\t * that match the specified {@code classFilter} filter.\n+\t *\n+\t * The classpath scanning algorithm searches recursively in subpackages\n+\t * beginning with the root of the classpath.\n+\t *\n+\t * @param basePackageName the name of the base package in which to start\n+\t * scanning; must not be {@code null} and must be valid in terms of Java\n+\t * syntax\n+\t * @param classFilter the class type filter; never {@code null}\n+\t * @return a list of all such classes found; never {@code null}\n+\t * but potentially empty\n+\t */\n+\tList The classpath scanning algorithm searches recursively in subpackages\n+\t * beginning with the root of the classpath.\n+\t *\n+\t * @param root the URI for the classpath root in which to scan; never\n+\t * {@code null}\n+\t * @param classFilter the class type filter; never {@code null}\n+\t * @return a list of all such classes found; never {@code null}\n+\t * but potentially empty\n+\t */\n+\tList The classpath scanning algorithm searches recursively in subpackages\n+\t * beginning with the root of the classpath.\n+\t *\n+\t * @param basePackageName the name of the base package in which to start\n+\t * scanning; must not be {@code null} and must be valid in terms of Java\n+\t * syntax\n+\t * @param resourceFilter the resource type filter; never {@code null}\n+\t * @return a list of all such resources found; never {@code null}\n+\t * but potentially empty\n+\t */\n+\tList The classpath scanning algorithm searches recursively in subpackages\n+\t * beginning with the root of the classpath.\n+\t *\n+\t * @param root the URI for the classpath root in which to scan; never\n+\t * {@code null}\n+\t * @param resourceFilter the resource type filter; never {@code null}\n+\t * @return a list of all such resources found; never {@code null}\n+\t * but potentially empty\n+\t */\n+\tList If it returns {@code null}, the default display name generator will be used instead.\n+\t * If this method returns {@code null}, the default display name\n+\t * generator will be used instead.\n \t *\n \t * @param testClass the class to generate a name for; never {@code null}\n \t * @return the display name for the class; never blank\n@@ -82,19 +87,52 @@ public interface DisplayNameGenerator {\n \tString generateDisplayNameForClass(Class> testClass);\n \n \t/**\n-\t * Generate a display name for the given {@link Nested @Nested} inner test class.\n+\t * Generate a display name for the given {@link Nested @Nested} inner test\n+\t * class.\n \t *\n-\t * If it returns {@code null}, the default display name generator will be used instead.\n+\t * If this method returns {@code null}, the default display name\n+\t * generator will be used instead.\n \t *\n \t * @param nestedClass the class to generate a name for; never {@code null}\n \t * @return the display name for the nested class; never blank\n+\t * @deprecated in favor of {@link #generateDisplayNameForNestedClass(List, Class)}\n \t */\n-\tString generateDisplayNameForNestedClass(Class> nestedClass);\n+\t@API(status = DEPRECATED, since = \"5.12\")\n+\t@Deprecated\n+\tdefault String generateDisplayNameForNestedClass(Class> nestedClass) {\n+\t\tthrow new UnsupportedOperationException(\n+\t\t\t\"Implement generateDisplayNameForNestedClass(List If this method returns {@code null}, the default display name\n+\t * generator will be used instead.\n+\t *\n+\t * @implNote The classes supplied as {@code enclosingInstanceTypes} may\n+\t * differ from the classes returned from invocations of\n+\t * {@link Class#getEnclosingClass()} — for example, when a nested test\n+\t * class is inherited from a superclass.\n+\t *\n+\t * @param enclosingInstanceTypes the runtime types of the enclosing\n+\t * instances for the test class, ordered from outermost to innermost,\n+\t * excluding {@code nestedClass}; never {@code null}\n+\t * @param nestedClass the class to generate a name for; never {@code null}\n+\t * @return the display name for the nested class; never blank\n+\t * @since 5.12\n+\t */\n+\t@API(status = EXPERIMENTAL, since = \"5.12\")\n+\tdefault String generateDisplayNameForNestedClass(List If it returns {@code null}, the default display name generator will be used instead.\n+\t * If this method returns {@code null}, the default display name\n+\t * generator will be used instead.\n \t *\n \t * @implNote The class instance supplied as {@code testClass} may differ from\n \t * the class returned by {@code testMethod.getDeclaringClass()} — for\n@@ -103,8 +141,42 @@ public interface DisplayNameGenerator {\n \t * @param testClass the class the test method is invoked on; never {@code null}\n \t * @param testMethod method to generate a display name for; never {@code null}\n \t * @return the display name for the test; never blank\n+\t * @deprecated in favor of {@link #generateDisplayNameForMethod(List, Class, Method)}\n \t */\n-\tString generateDisplayNameForMethod(Class> testClass, Method testMethod);\n+\t@API(status = DEPRECATED, since = \"5.12\")\n+\t@Deprecated\n+\tdefault String generateDisplayNameForMethod(Class> testClass, Method testMethod) {\n+\t\tthrow new UnsupportedOperationException(\n+\t\t\t\"Implement generateDisplayNameForMethod(List If this method returns {@code null}, the default display name\n+\t * generator will be used instead.\n+\t *\n+\t * @implNote The classes supplied as {@code enclosingInstanceTypes} may\n+\t * differ from the classes returned from invocations of\n+\t * {@link Class#getEnclosingClass()} — for example, when a nested test\n+\t * class is inherited from a superclass. Similarly, the class instance\n+\t * supplied as {@code testClass} may differ from the class returned by\n+\t * {@code testMethod.getDeclaringClass()} — for example, when a test\n+\t * method is inherited from a superclass.\n+\t *\n+\t * @param enclosingInstanceTypes the runtime types of the enclosing\n+\t * instances for the test class, ordered from outermost to innermost,\n+\t * excluding {@code testClass}; never {@code null}\n+\t * @param testClass the class the test method is invoked on; never {@code null}\n+\t * @param testMethod method to generate a display name for; never {@code null}\n+\t * @return the display name for the test; never blank\n+\t * @since 5.12\n+\t */\n+\t@API(status = EXPERIMENTAL, since = \"5.12\")\n+\tdefault String generateDisplayNameForMethod(List For backward compatibility, it first checks for a default constructor\n+\t * which takes precedence over any other constructor. If no default\n+\t * constructor is found, it checks for a single constructor and returns it.\n+\t */\n+\tprivate static Implementations must provide a no-args constructor and should not make any\n- * assumptions regarding when they are instantiated or how often they are called.\n- * Since instances may potentially be cached and called from different threads,\n- * they should be thread-safe and designed to be used as singletons.\n+ * Implementations must provide a no-args constructor or a single unambiguous\n+ * constructor to use {@linkplain ParameterResolver parameter resolution}. They\n+ * should not make any assumptions regarding when they are instantiated or how\n+ * often they are called. Since instances may potentially be cached and called\n+ * from different threads, they should be thread-safe.\n *\n * @since 5.2\n * @see AggregateWith\ndiff --git a/junit-jupiter-params/src/main/java/org/junit/jupiter/params/converter/ArgumentConverter.java b/junit-jupiter-params/src/main/java/org/junit/jupiter/params/converter/ArgumentConverter.java\nindex 46f7e9a84b79..b18d96887069 100644\n--- a/junit-jupiter-params/src/main/java/org/junit/jupiter/params/converter/ArgumentConverter.java\n+++ b/junit-jupiter-params/src/main/java/org/junit/jupiter/params/converter/ArgumentConverter.java\n@@ -14,6 +14,7 @@\n \n import org.apiguardian.api.API;\n import org.junit.jupiter.api.extension.ParameterContext;\n+import org.junit.jupiter.api.extension.ParameterResolver;\n \n /**\n * {@code ArgumentConverter} is an abstraction that allows an input object to\n@@ -24,10 +25,11 @@\n * method with the help of a\n * {@link org.junit.jupiter.params.converter.ConvertWith @ConvertWith} annotation.\n *\n- * Implementations must provide a no-args constructor and should not make any\n- * assumptions regarding when they are instantiated or how often they are called.\n- * Since instances may potentially be cached and called from different threads,\n- * they should be thread-safe and designed to be used as singletons.\n+ * Implementations must provide a no-args constructor or a single unambiguous\n+ * constructor to use {@linkplain ParameterResolver parameter resolution}. They\n+ * should not make any assumptions regarding when they are instantiated or how\n+ * often they are called. Since instances may potentially be cached and called\n+ * from different threads, they should be thread-safe.\n *\n * Extend {@link SimpleArgumentConverter} if your implementation only needs\n * to know the target type and does not need access to the {@link ParameterContext}\ndiff --git a/junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/ArgumentsProvider.java b/junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/ArgumentsProvider.java\nindex 689517d607b8..c18d100ad3c5 100644\n--- a/junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/ArgumentsProvider.java\n+++ b/junit-jupiter-params/src/main/java/org/junit/jupiter/params/provider/ArgumentsProvider.java\n@@ -16,6 +16,7 @@\n \n import org.apiguardian.api.API;\n import org.junit.jupiter.api.extension.ExtensionContext;\n+import org.junit.jupiter.api.extension.ParameterResolver;\n \n /**\n * An {@code ArgumentsProvider} is responsible for {@linkplain #provideArguments\n@@ -25,7 +26,8 @@\n * An {@code ArgumentsProvider} can be registered via the\n * {@link ArgumentsSource @ArgumentsSource} annotation.\n *\n- * Implementations must provide a no-args constructor.\n+ * Implementations must provide a no-args constructor or a single unambiguous\n+ * constructor to use {@linkplain ParameterResolver parameter resolution}.\n *\n * @since 5.0\n * @see org.junit.jupiter.params.ParameterizedTest\n", "commit": "54a6cb16e53f31885ede29e002d171bd588d558c", "edit_prompt": "Use the `ParameterizedTestSpiInstantiator` to create argument converters and aggregators instead of directly instantiating them, and pass the extension context to the resolver creation methods.", "prompt": "The following is the text of a github issue and related comments for this repository:\n\nAdd constructor injection support for `ArgumentsProvider`, `ArgumentConverter`, and `ArgumentsAggregator`\nIt is possible to provide parameters to the constructor of a test class, and also to a method used by `@ParameterizedTest`/`@MethodSource`.\n\nRequest: Be able to provide parameters to the constructor of an `ArgumentsProvider` implementation.\n\nSample:\n\n```java\n@ExtendWith(MyExtension.class) // this extension provides values for type 'Pojo' parameters\npublic class WithArgumentsProvider {\n\n @Nested\n public class NestedTest1 {\n\n @ParameterizedTest\n @ArgumentsSource(MyArgumentsProvider.class)\n public void test1(String a) {\n System.out.println(\"NestedTest1 - Test1: \" + a);\n }\n\n }\n\n @Nested\n public class NestedTest2 {\n\n @ParameterizedTest\n @ArgumentsSource(MyArgumentsProvider.class)\n public void test2(String a) {\n System.out.println(\"NestedTest2 - Test2: \" + a);\n }\n\n }\n\n public static class MyArgumentsProvider implements ArgumentsProvider {\n\n public MyArgumentsProvider(Pojo pojo) {\n // ...\n }\n\n @Override\n public Stream extends Arguments> provideArguments(ExtensionContext context) {\n return Stream.of(\"a\", \"b\", \"c\").map(Arguments::of);\n }\n\n }\n\n}\n```\n\nDev hint: https://github.com/junit-team/junit5/blob/e8c92f8cdeafe80ae485da4b4d8bd77f7b33e345/junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTestExtension.java#L87\n\nIn the meantime, as a workaround, you can do this:\n\n```\n@ExtendWith(WithArgumentsProvider.MyExtension.class) // this extension provides values for type 'Pojo' parameters\npublic class WithArgumentsProvider {\n\n @Nested\n public class NestedTest1 {\n\n @ParameterizedTest\n @ArgumentsSource(MyArgumentsProvider.class)\n public void test1(String a) {\n System.out.println(\"NestedTest1 - Test1: \" + a);\n }\n\n }\n\n @Nested\n public class NestedTest2 {\n\n @ParameterizedTest\n @ArgumentsSource(MyArgumentsProvider.class)\n public void test2(String a) {\n System.out.println(\"NestedTest2 - Test2: \" + a);\n }\n\n }\n\n public static class MyArgumentsProvider implements ArgumentsProvider {\n\n @SuppressWarnings(\"unchecked\")\n\t\t@Override\n public Stream extends Arguments> provideArguments(ExtensionContext context) throws Exception {\n Method method = getClass().getDeclaredMethod(\"provideArguments\", Pojo.class);\n\t\t\treturn (Stream extends Arguments>) context.getExecutableInvoker().invoke(method, this);\n }\n\n Stream extends Arguments> provideArguments(Pojo pojo) {\n return Stream.of(Arguments.of(pojo.toString()));\n }\n }\n\n}\n```\n\nI think the only reason that's not implemented is because @ParameterizedTest is implemented as an extension and predates ExecutableInvoker. Adding support should be as simple as changing\n\njunit5/junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTestExtension.java\n\nLine 103 in c24d9a6\n```\n return ReflectionSupport.newInstance(clazz); \n```\n\nto use context.getExecutableInvoker().invoke(clazz.getDeclaredConstructor()).\n\n\nResolve the issue described above. Do not modify tests or user code. The issue can be resolved by modifying the actual library/application code. Make the minimal changes to resolve the issue while adhering to the specification and coding style of the codebase.", "edit_patch": "diff --git a/junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTestMethodContext.java b/junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTestMethodContext.java\nindex 1b88b3a14467..a7469d4f4003 100644\n--- a/junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTestMethodContext.java\n+++ b/junit-jupiter-params/src/main/java/org/junit/jupiter/params/ParameterizedTestMethodContext.java\n@@ -20,6 +20,7 @@\n import java.util.List;\n import java.util.Optional;\n \n+import org.junit.jupiter.api.extension.ExtensionContext;\n import org.junit.jupiter.api.extension.ParameterContext;\n import org.junit.jupiter.api.extension.ParameterResolutionException;\n import org.junit.jupiter.params.aggregator.AggregateWith;\n@@ -31,7 +32,6 @@\n import org.junit.jupiter.params.converter.DefaultArgumentConverter;\n import org.junit.jupiter.params.support.AnnotationConsumerInitializer;\n import org.junit.platform.commons.support.AnnotationSupport;\n-import org.junit.platform.commons.support.ReflectionSupport;\n import org.junit.platform.commons.util.StringUtils;\n \n /**\n@@ -43,16 +43,18 @@\n class ParameterizedTestMethodContext {\n \n \tprivate final Parameter[] parameters;\n+\tprivate final ExtensionContext extensionContext;\n \tprivate final Resolver[] resolvers;\n \tprivate final List These utilities are intended solely for usage within the JUnit framework\n+ * itself. Any usage by external parties is not supported.\n+ * Use at your own risk!\n+ *\n+ * @since 1.11.3\n+ */\n+class PackageNameUtils {\n+\n+\tstatic String getPackageName(Class> clazz) {\n+\t\tPackage p = clazz.getPackage();\n+\t\tif (p != null) {\n+\t\t\treturn p.getName();\n+\t\t}\n+\t\tString className = clazz.getName();\n+\t\tint index = className.lastIndexOf('.');\n+\t\treturn index == -1 ? DEFAULT_PACKAGE_NAME : className.substring(0, index);\n+\t}\n+\n+}\ndiff --git a/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ReflectionUtils.java b/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ReflectionUtils.java\nindex 26bd8e1698cf..77e270376854 100644\n--- a/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ReflectionUtils.java\n+++ b/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ReflectionUtils.java\n@@ -19,6 +19,7 @@\n import static org.apiguardian.api.API.Status.INTERNAL;\n import static org.apiguardian.api.API.Status.STABLE;\n import static org.junit.platform.commons.util.CollectionUtils.toUnmodifiableList;\n+import static org.junit.platform.commons.util.PackageNameUtils.getPackageName;\n import static org.junit.platform.commons.util.ReflectionUtils.HierarchyTraversalMode.BOTTOM_UP;\n import static org.junit.platform.commons.util.ReflectionUtils.HierarchyTraversalMode.TOP_DOWN;\n \n@@ -1903,7 +1904,7 @@ private static boolean isPackagePrivate(Member member) {\n \t}\n \n \tprivate static boolean declaredInSamePackage(Method m1, Method m2) {\n-\t\treturn m1.getDeclaringClass().getPackage().getName().equals(m2.getDeclaringClass().getPackage().getName());\n+\t\treturn getPackageName(m1.getDeclaringClass()).equals(getPackageName(m2.getDeclaringClass()));\n \t}\n \n \t/**\ndiff --git a/junit-platform-commons/src/main/java9/org/junit/platform/commons/util/PackageNameUtils.java b/junit-platform-commons/src/main/java9/org/junit/platform/commons/util/PackageNameUtils.java\nnew file mode 100644\nindex 000000000000..84afaf736290\n--- /dev/null\n+++ b/junit-platform-commons/src/main/java9/org/junit/platform/commons/util/PackageNameUtils.java\n@@ -0,0 +1,30 @@\n+/*\n+ * Copyright 2015-2024 the original author or authors.\n+ *\n+ * All rights reserved. This program and the accompanying materials are\n+ * made available under the terms of the Eclipse Public License v2.0 which\n+ * accompanies this distribution and is available at\n+ *\n+ * https://www.eclipse.org/legal/epl-v20.html\n+ */\n+\n+package org.junit.platform.commons.util;\n+\n+/**\n+ * Collection of utilities for working with package names.\n+ *\n+ * These utilities are intended solely for usage within the JUnit framework\n+ * itself. Any usage by external parties is not supported.\n+ * Use at your own risk!\n+ *\n+ * @since 1.11.3\n+ */\n+class PackageNameUtils {\n+\n+\tstatic String getPackageName(Class> clazz) {\n+\t\treturn clazz.getPackageName();\n+\t}\n+\n+}\n", "commit": "91924ec1f18066f8c36890882a9c321cf7a50841", "edit_prompt": "Use the getPackageName utility function to safely compare package names of declaring classes.", "prompt": "The following is the text of a github issue and related comments for this repository:\n\nTest discovery failing with NullPointerException when trying to find methods of a test class\n## Context\n\nWe observe test discovery failing with a `NullPointerException` when trying to find test class methods (stacktrace is attached below). This seems to be a regression in 1.11.x version of `junit-platform-commons`. Discovery succeeds when using 1.10.x versions. Apparently, the `.getPackage()` in this method can yield `null`:\nhttps://github.com/junit-team/junit5/blob/0de9d1033da1880dc61c72b02840941cfcc2d10e/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ReflectionUtils.java#L1905-L1907\n\nAccording to the [docs](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getPackage--) this can happen if the package object is not created by the classloader. I have not been able to create a standalone reproducer yet, but I'll keep trying :) So far, we've seen this happen only when running Spock 1.3 tests located in the root package. \n\n\n### Stacktrace\n```\nCaused by: java.lang.NullPointerException\n\tat org.junit.platform.commons.util.ReflectionUtils.declaredInSamePackage(ReflectionUtils.java:1902)\n\tat org.junit.platform.commons.util.ReflectionUtils.isMethodOverriddenBy(ReflectionUtils.java:1888)\n\tat org.junit.platform.commons.util.ReflectionUtils.lambda$isMethodOverriddenByLocalMethods$35(ReflectionUtils.java:1870)\n\tat java.util.stream.MatchOps$1MatchSink.accept(MatchOps.java:90)\n\tat java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1361)\n\tat java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)\n\tat java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:499)\n\tat java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:486)\n\tat java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)\n\tat java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:230)\n\tat java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:196)\n\tat java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)\n\tat java.util.stream.ReferencePipeline.anyMatch(ReferencePipeline.java:516)\n\tat org.junit.platform.commons.util.ReflectionUtils.isMethodOverriddenByLocalMethods(ReflectionUtils.java:1870)\n\tat org.junit.platform.commons.util.ReflectionUtils.lambda$findAllMethodsInHierarchy$29(ReflectionUtils.java:1661)\n\tat java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:174)\n\tat java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1384)\n\tat java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)\n\tat java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)\n\tat java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)\n\tat java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)\n\tat java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566)\n\tat org.junit.platform.commons.util.ReflectionUtils.findAllMethodsInHierarchy(ReflectionUtils.java:1662)\n\tat org.junit.platform.commons.util.ReflectionUtils.streamMethods(ReflectionUtils.java:1642)\n\tat org.junit.platform.commons.util.ReflectionUtils.findMethods(ReflectionUtils.java:1627)\n\tat org.junit.platform.commons.util.ReflectionUtils.findMethods(ReflectionUtils.java:1618)\n\tat org.junit.vintage.engine.descriptor.TestSourceProvider.lambda$findMethod$1(TestSourceProvider.java:75)\n\tat java.util.HashMap.computeIfAbsent(HashMap.java:1128)\n\tat java.util.Collections$SynchronizedMap.computeIfAbsent(Collections.java:2674)\n\tat org.junit.vintage.engine.descriptor.TestSourceProvider.findMethod(TestSourceProvider.java:75)\n\tat org.junit.vintage.engine.descriptor.TestSourceProvider.computeTestSource(TestSourceProvider.java:56)\n\tat java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1660)\n\tat org.junit.vintage.engine.descriptor.TestSourceProvider.findTestSource(TestSourceProvider.java:47)\n\tat org.junit.vintage.engine.discovery.RunnerTestDescriptorPostProcessor.addChildrenRecursively(RunnerTestDescriptorPostProcessor.java:62)\n\tat org.junit.vintage.engine.discovery.RunnerTestDescriptorPostProcessor.applyFiltersAndCreateDescendants(RunnerTestDescriptorPostProcessor.java:41)\n\tat org.junit.vintage.engine.discovery.VintageDiscoverer.discover(VintageDiscoverer.java:46)\n\tat org.junit.vintage.engine.VintageTestEngine.discover(VintageTestEngine.java:64)\n\tat org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:152)\n\t... 13 more\n```\n\nI have a reproducer on Java 8 (probably related to JDK-8193889) when a class in the default package extends a class from a non-default package and both declare a package private method with the same signature.\n\n\nResolve the issue described above. Do not modify tests or user code. The issue can be resolved by modifying the actual library/application code. Make the minimal changes to resolve the issue while adhering to the specification and coding style of the codebase.", "edit_patch": "diff --git a/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ReflectionUtils.java b/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ReflectionUtils.java\nindex 26bd8e1698cf..77e270376854 100644\n--- a/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ReflectionUtils.java\n+++ b/junit-platform-commons/src/main/java/org/junit/platform/commons/util/ReflectionUtils.java\n@@ -19,6 +19,7 @@\n import static org.apiguardian.api.API.Status.INTERNAL;\n import static org.apiguardian.api.API.Status.STABLE;\n import static org.junit.platform.commons.util.CollectionUtils.toUnmodifiableList;\n+import static org.junit.platform.commons.util.PackageNameUtils.getPackageName;\n import static org.junit.platform.commons.util.ReflectionUtils.HierarchyTraversalMode.BOTTOM_UP;\n import static org.junit.platform.commons.util.ReflectionUtils.HierarchyTraversalMode.TOP_DOWN;\n \n@@ -1903,7 +1904,7 @@ private static boolean isPackagePrivate(Member member) {\n \t}\n \n \tprivate static boolean declaredInSamePackage(Method m1, Method m2) {\n-\t\treturn m1.getDeclaringClass().getPackage().getName().equals(m2.getDeclaringClass().getPackage().getName());\n+\t\treturn getPackageName(m1.getDeclaringClass()).equals(getPackageName(m2.getDeclaringClass()));\n \t}\n \n \t/**", "test_patch": "diff --git a/platform-tooling-support-tests/projects/vintage/src/test/java/DefaultPackageTest.java b/platform-tooling-support-tests/projects/vintage/src/test/java/DefaultPackageTest.java\nnew file mode 100644\nindex 000000000000..beebfdd5fd54\n--- /dev/null\n+++ b/platform-tooling-support-tests/projects/vintage/src/test/java/DefaultPackageTest.java\n@@ -0,0 +1,22 @@\n+\n+/*\n+ * Copyright 2015-2024 the original author or authors.\n+ *\n+ * All rights reserved. This program and the accompanying materials are\n+ * made available under the terms of the Eclipse Public License v2.0 which\n+ * accompanies this distribution and is available at\n+ *\n+ * https://www.eclipse.org/legal/epl-v20.html\n+ */\n+import com.example.vintage.VintageTest;\n+\n+import org.junit.Ignore;\n+\n+/**\n+ * Reproducer for https://github.com/junit-team/junit5/issues/4076\n+ */\n+@Ignore\n+public class DefaultPackageTest extends VintageTest {\n+\tvoid packagePrivateMethod() {\n+\t}\n+}\ndiff --git a/platform-tooling-support-tests/projects/vintage/src/test/java/com/example/vintage/VintageTest.java b/platform-tooling-support-tests/projects/vintage/src/test/java/com/example/vintage/VintageTest.java\nindex 1632b1e3537b..a6efb8990791 100644\n--- a/platform-tooling-support-tests/projects/vintage/src/test/java/com/example/vintage/VintageTest.java\n+++ b/platform-tooling-support-tests/projects/vintage/src/test/java/com/example/vintage/VintageTest.java\n@@ -15,6 +15,9 @@\n import org.junit.Test;\n \n public class VintageTest {\n+\tvoid packagePrivateMethod() {\n+\t}\n+\n \t@Test\n \tpublic void success() {\n \t\t// pass\n"}
{"repo_name": "json", "task_num": 4512, "autocomplete_prompts": "diff --git a/include/nlohmann/detail/iterators/iter_impl.hpp b/include/nlohmann/detail/iterators/iter_impl.hpp\nindex 4447091347..106c23fb2e 100644\n--- a/include/nlohmann/detail/iterators/iter_impl.hpp\n+++ b/include/nlohmann/detail/iterators/iter_impl.hpp\n@@ -474,7 +474,11 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci\n // value-initialized forward iterators can be compared, and must compare equal to other value-initialized iterators of the same type #4493\n if (m_object == nullptr)\n {\n@@ -519,7 +523,12 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci\n // value-initialized forward iterators can be compared, and must compare equal to other value-initialized iterators of the same type #4493\n if (m_object == nullptr)\n {", "gold_patch": "diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml\nindex 152a4514b9..4ba491a831 100644\n--- a/.github/workflows/macos.yml\n+++ b/.github/workflows/macos.yml\n@@ -35,28 +35,29 @@ jobs:\n # - name: Test\n # run: cd build ; ctest -j 10 --output-on-failure\n \n- macos-12:\n- runs-on: macos-12 # https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md\n- strategy:\n- matrix:\n- xcode: ['13.1', '13.2.1', '13.3.1', '13.4.1', '14.0', '14.0.1', '14.1']\n- env:\n- DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer\n-\n- steps:\n- - uses: actions/checkout@v4\n- - name: Run CMake\n- run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON\n- - name: Build\n- run: cmake --build build --parallel 10\n- - name: Test\n- run: cd build ; ctest -j 10 --output-on-failure\n+# macos-12 is deprecated (https://github.com/actions/runner-images/issues/10721)\n+# macos-12:\n+# runs-on: macos-12 # https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md\n+# strategy:\n+# matrix:\n+# xcode: ['13.1', '13.2.1', '13.3.1', '13.4.1', '14.0', '14.0.1', '14.1']\n+# env:\n+# DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer\n+#\n+# steps:\n+# - uses: actions/checkout@v4\n+# - name: Run CMake\n+# run: cmake -S . -B build -D CMAKE_BUILD_TYPE=Debug -DJSON_BuildTests=On -DJSON_FastTests=ON\n+# - name: Build\n+# run: cmake --build build --parallel 10\n+# - name: Test\n+# run: cd build ; ctest -j 10 --output-on-failure\n \n macos-13:\n runs-on: macos-13 # https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md\n strategy:\n matrix:\n- xcode: [ '14.2', '14.3', '14.3.1', '15.0.1', '15.1', '15.2']\n+ xcode: ['14.1', '14.2', '14.3', '14.3.1', '15.0.1', '15.1', '15.2']\n env:\n DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer\n \ndiff --git a/README.md b/README.md\nindex 34a79f400e..a493092827 100644\n--- a/README.md\n+++ b/README.md\n@@ -1115,7 +1115,7 @@ Though it's 2024 already, the support for C++11 is still a bit sparse. Currently\n \n - GCC 4.8 - 14.2 (and possibly later)\n - Clang 3.4 - 20.0 (and possibly later)\n-- Apple Clang 9.1 - 16.0 (and possibly later)\n+- Apple Clang 9.1 - 16.1 (and possibly later)\n - Intel C++ Compiler 17.0.2 (and possibly later)\n - Nvidia CUDA Compiler 11.0.221 (and possibly later)\n - Microsoft Visual C++ 2015 / Build Tools 14.0.25123.0 (and possibly later)\n@@ -1146,13 +1146,7 @@ The following compilers are currently used in continuous integration at [AppVeyo\n \n | Compiler | Operating System | CI Provider |\n |--------------------------------------------------------------------------------------------------------|--------------------|----------------|\n-| Apple Clang 13.0.0 (clang-1300.0.29.3); Xcode 13.1 | macOS 12.7.6 | GitHub Actions |\n-| Apple Clang 13.0.0 (clang-1300.0.29.30); Xcode 13.2.1 | macOS 12.7.6 | GitHub Actions |\n-| Apple Clang 13.1.6 (clang-1316.0.21.2.3); Xcode 13.3.1 | macOS 12.7.6 | GitHub Actions |\n-| Apple Clang 13.1.6 (clang-1316.0.21.2.5); Xcode 13.4.1 | macOS 12.7.6 | GitHub Actions |\n-| Apple Clang 14.0.0 (clang-1400.0.29.102); Xcode 14.0 | macOS 12.7.6 | GitHub Actions |\n-| Apple Clang 14.0.0 (clang-1400.0.29.102); Xcode 14.0.1 | macOS 12.7.6 | GitHub Actions |\n-| Apple Clang 14.0.0 (clang-1400.0.29.202); Xcode 14.1 | macOS 12.7.6 | GitHub Actions |\n+| Apple Clang 14.0.0 (clang-1400.0.29.202); Xcode 14.1 | macOS 13.7 | GitHub Actions |\n | Apple Clang 14.0.0 (clang-1400.0.29.202); Xcode 14.2 | macOS 13.7 | GitHub Actions |\n | Apple Clang 14.0.3 (clang-1403.0.22.14.1); Xcode 14.3 | macOS 13.7 | GitHub Actions |\n | Apple Clang 14.0.3 (clang-1403.0.22.14.1); Xcode 14.3.1 | macOS 13.7.1 | GitHub Actions |\ndiff --git a/include/nlohmann/detail/iterators/iter_impl.hpp b/include/nlohmann/detail/iterators/iter_impl.hpp\nindex 4447091347..106c23fb2e 100644\n--- a/include/nlohmann/detail/iterators/iter_impl.hpp\n+++ b/include/nlohmann/detail/iterators/iter_impl.hpp\n@@ -463,7 +463,7 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci\n \n /*!\n @brief comparison: equal\n- @pre The iterator is initialized; i.e. `m_object != nullptr`.\n+ @pre (1) Both iterators are initialized to point to the same object, or (2) both iterators are value-initialized.\n */\n template < typename IterImpl, detail::enable_if_t < (std::is_sameDISCLAIMER
\n+ *\n+ * DISCLAIMER
\n- *\n- * DISCLAIMER
\n@@ -50,9 +56,10 @@\n *\n * @since 1.0\n */\n-class ClasspathScanner {\n+@API(status = INTERNAL, since = \"1.12\")\n+public class DefaultClasspathScanner implements ClasspathScanner {\n \n-\tprivate static final Logger logger = LoggerFactory.getLogger(ClasspathScanner.class);\n+\tprivate static final Logger logger = LoggerFactory.getLogger(DefaultClasspathScanner.class);\n \n \tprivate static final char CLASSPATH_RESOURCE_PATH_SEPARATOR = '/';\n \tprivate static final String CLASSPATH_RESOURCE_PATH_SEPARATOR_STRING = String.valueOf(\n@@ -69,14 +76,15 @@ class ClasspathScanner {\n \n \tprivate final BiFunction>> enclosingInstanceTypes, Class> testClass,\n+\t\t\tMethod testMethod, JupiterConfiguration configuration) {\n \t\treturn determineDisplayName(testMethod,\n-\t\t\tcreateDisplayNameSupplierForMethod(testClass, testMethod, configuration));\n+\t\t\tcreateDisplayNameSupplierForMethod(enclosingInstanceTypes, testClass, testMethod, configuration));\n \t}\n \n \tstatic Supplier
>> enclosingInstanceTypes,\n+\t\t\tClass> testClass, JupiterConfiguration configuration) {\n \t\treturn createDisplayNameSupplier(testClass, configuration,\n-\t\t\tgenerator -> generator.generateDisplayNameForNestedClass(testClass));\n+\t\t\tgenerator -> generator.generateDisplayNameForNestedClass(enclosingInstanceTypes.get(), testClass));\n \t}\n \n-\tprivate static Supplier
>> enclosingInstanceTypes,\n+\t\t\tClass> testClass, Method testMethod, JupiterConfiguration configuration) {\n \t\treturn createDisplayNameSupplier(testClass, configuration,\n-\t\t\tgenerator -> generator.generateDisplayNameForMethod(testClass, testMethod));\n+\t\t\tgenerator -> generator.generateDisplayNameForMethod(enclosingInstanceTypes.get(), testClass, testMethod));\n \t}\n \n \tprivate static Supplier
>> enclosingInstanceTypes, JupiterConfiguration configuration) {\n+\t\tthis(uniqueId, determineDisplayNameForMethod(enclosingInstanceTypes, testClass, testMethod, configuration),\n+\t\t\ttestClass, testMethod, configuration);\n \t}\n \n \tMethodBasedTestDescriptor(UniqueId uniqueId, String displayName, Class> testClass, Method testMethod,\ndiff --git a/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/NestedClassTestDescriptor.java b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/NestedClassTestDescriptor.java\nindex 6d4dc1e2d088..72d11ce5b09e 100644\n--- a/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/NestedClassTestDescriptor.java\n+++ b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/NestedClassTestDescriptor.java\n@@ -19,6 +19,7 @@\n import java.util.List;\n import java.util.Optional;\n import java.util.Set;\n+import java.util.function.Supplier;\n \n import org.apiguardian.api.API;\n import org.junit.jupiter.api.extension.TestInstances;\n@@ -46,8 +47,10 @@ public class NestedClassTestDescriptor extends ClassBasedTestDescriptor {\n \n \tpublic static final String SEGMENT_TYPE = \"nested-class\";\n \n-\tpublic NestedClassTestDescriptor(UniqueId uniqueId, Class> testClass, JupiterConfiguration configuration) {\n-\t\tsuper(uniqueId, testClass, createDisplayNameSupplierForNestedClass(testClass, configuration), configuration);\n+\tpublic NestedClassTestDescriptor(UniqueId uniqueId, Class> testClass,\n+\t\t\tSupplier
>> enclosingInstanceTypes, JupiterConfiguration configuration) {\n+\t\tsuper(uniqueId, testClass,\n+\t\t\tcreateDisplayNameSupplierForNestedClass(enclosingInstanceTypes, testClass, configuration), configuration);\n \t}\n \n \t// --- TestDescriptor ------------------------------------------------------\n@@ -62,7 +65,11 @@ public final Set
>> enclosingInstanceTypes, JupiterConfiguration configuration) {\n+\t\tsuper(uniqueId, testClass, testMethod, enclosingInstanceTypes, configuration);\n \t}\n \n \t// --- Filterable ----------------------------------------------------------\ndiff --git a/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/TestMethodTestDescriptor.java b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/TestMethodTestDescriptor.java\nindex 423f2e3b9013..67fa136a52d1 100644\n--- a/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/TestMethodTestDescriptor.java\n+++ b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/TestMethodTestDescriptor.java\n@@ -17,6 +17,8 @@\n import static org.junit.platform.commons.util.CollectionUtils.forEachInReverseOrder;\n \n import java.lang.reflect.Method;\n+import java.util.List;\n+import java.util.function.Supplier;\n \n import org.apiguardian.api.API;\n import org.junit.jupiter.api.TestInstance.Lifecycle;\n@@ -75,8 +77,8 @@ public class TestMethodTestDescriptor extends MethodBasedTestDescriptor {\n \tprivate final ReflectiveInterceptorCall
>> enclosingInstanceTypes, JupiterConfiguration configuration) {\n+\t\tsuper(uniqueId, testClass, testMethod, enclosingInstanceTypes, configuration);\n \t\tthis.interceptorCall = defaultInterceptorCall;\n \t}\n \ndiff --git a/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/TestTemplateTestDescriptor.java b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/TestTemplateTestDescriptor.java\nindex f89c17b26a32..e592ba3a6326 100644\n--- a/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/TestTemplateTestDescriptor.java\n+++ b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/descriptor/TestTemplateTestDescriptor.java\n@@ -18,6 +18,7 @@\n import java.util.List;\n import java.util.Optional;\n import java.util.concurrent.atomic.AtomicInteger;\n+import java.util.function.Supplier;\n import java.util.stream.Stream;\n \n import org.apiguardian.api.API;\n@@ -46,8 +47,8 @@ public class TestTemplateTestDescriptor extends MethodBasedTestDescriptor implem\n \tprivate final DynamicDescendantFilter dynamicDescendantFilter = new DynamicDescendantFilter();\n \n \tpublic TestTemplateTestDescriptor(UniqueId uniqueId, Class> testClass, Method templateMethod,\n-\t\t\tJupiterConfiguration configuration) {\n-\t\tsuper(uniqueId, testClass, templateMethod, configuration);\n+\t\t\tSupplier
>> enclosingInstanceTypes, JupiterConfiguration configuration) {\n+\t\tsuper(uniqueId, testClass, templateMethod, enclosingInstanceTypes, configuration);\n \t}\n \n \t// --- Filterable ----------------------------------------------------------\ndiff --git a/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/discovery/ClassSelectorResolver.java b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/discovery/ClassSelectorResolver.java\nindex 46d97088c358..0f809dcbde47 100644\n--- a/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/discovery/ClassSelectorResolver.java\n+++ b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/discovery/ClassSelectorResolver.java\n@@ -12,6 +12,7 @@\n \n import static java.util.function.Predicate.isEqual;\n import static java.util.stream.Collectors.toCollection;\n+import static org.junit.jupiter.engine.descriptor.NestedClassTestDescriptor.getEnclosingTestClasses;\n import static org.junit.jupiter.engine.discovery.predicates.IsTestClassWithTests.isTestOrTestFactoryOrTestTemplateMethod;\n import static org.junit.platform.commons.support.HierarchyTraversalMode.TOP_DOWN;\n import static org.junit.platform.commons.support.ReflectionSupport.findMethods;\n@@ -122,9 +123,9 @@ private ClassTestDescriptor newClassTestDescriptor(TestDescriptor parent, Class<\n \t}\n \n \tprivate NestedClassTestDescriptor newNestedClassTestDescriptor(TestDescriptor parent, Class> testClass) {\n-\t\treturn new NestedClassTestDescriptor(\n-\t\t\tparent.getUniqueId().append(NestedClassTestDescriptor.SEGMENT_TYPE, testClass.getSimpleName()), testClass,\n-\t\t\tconfiguration);\n+\t\tUniqueId uniqueId = parent.getUniqueId().append(NestedClassTestDescriptor.SEGMENT_TYPE,\n+\t\t\ttestClass.getSimpleName());\n+\t\treturn new NestedClassTestDescriptor(uniqueId, testClass, () -> getEnclosingTestClasses(parent), configuration);\n \t}\n \n \tprivate Resolution toResolution(Optional extends ClassBasedTestDescriptor> testDescriptor) {\ndiff --git a/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/discovery/MethodSelectorResolver.java b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/discovery/MethodSelectorResolver.java\nindex 7f76e2d30fce..9d5af96aa103 100644\n--- a/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/discovery/MethodSelectorResolver.java\n+++ b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/discovery/MethodSelectorResolver.java\n@@ -166,8 +166,8 @@ private enum MethodType {\n \t\tTEST(new IsTestMethod(), TestMethodTestDescriptor.SEGMENT_TYPE) {\n \t\t\t@Override\n \t\t\tprotected TestDescriptor createTestDescriptor(UniqueId uniqueId, Class> testClass, Method method,\n-\t\t\t\t\tJupiterConfiguration configuration) {\n-\t\t\t\treturn new TestMethodTestDescriptor(uniqueId, testClass, method, configuration);\n+\t\t\t\t\tSupplier
>> enclosingInstanceTypes, JupiterConfiguration configuration) {\n+\t\t\t\treturn new TestMethodTestDescriptor(uniqueId, testClass, method, enclosingInstanceTypes, configuration);\n \t\t\t}\n \t\t},\n \n@@ -176,8 +176,9 @@ protected TestDescriptor createTestDescriptor(UniqueId uniqueId, Class> testCl\n \t\t\t\tTestFactoryTestDescriptor.DYNAMIC_TEST_SEGMENT_TYPE) {\n \t\t\t@Override\n \t\t\tprotected TestDescriptor createTestDescriptor(UniqueId uniqueId, Class> testClass, Method method,\n-\t\t\t\t\tJupiterConfiguration configuration) {\n-\t\t\t\treturn new TestFactoryTestDescriptor(uniqueId, testClass, method, configuration);\n+\t\t\t\t\tSupplier
>> enclosingInstanceTypes, JupiterConfiguration configuration) {\n+\t\t\t\treturn new TestFactoryTestDescriptor(uniqueId, testClass, method, enclosingInstanceTypes,\n+\t\t\t\t\tconfiguration);\n \t\t\t}\n \t\t},\n \n@@ -185,8 +186,9 @@ protected TestDescriptor createTestDescriptor(UniqueId uniqueId, Class> testCl\n \t\t\t\tTestTemplateInvocationTestDescriptor.SEGMENT_TYPE) {\n \t\t\t@Override\n \t\t\tprotected TestDescriptor createTestDescriptor(UniqueId uniqueId, Class> testClass, Method method,\n-\t\t\t\t\tJupiterConfiguration configuration) {\n-\t\t\t\treturn new TestTemplateTestDescriptor(uniqueId, testClass, method, configuration);\n+\t\t\t\t\tSupplier
>> enclosingInstanceTypes, JupiterConfiguration configuration) {\n+\t\t\t\treturn new TestTemplateTestDescriptor(uniqueId, testClass, method, enclosingInstanceTypes,\n+\t\t\t\t\tconfiguration);\n \t\t\t}\n \t\t};\n \n@@ -207,7 +209,7 @@ private Optional
>> enclosingInstanceTypes, JupiterConfiguration configuration);\n \n \t}\n \n", "commit": "6d260dadaa8416305fb2d80104827e916bc1f617", "edit_prompt": "Modify the display name utility methods to accept and use a list of enclosing instance types when generating display names for methods and nested classes.", "prompt": "The following is the text of a github issue and related comments for this repository:\n\n`DisplayNameGenerator` cannot access runtime enclosing type for `@Nested` test class\n## Overview\n\nA `DisplayNameGenerator` can access the type of a `@Nested` test class as well as the enclosing class in which a `@Nested` test class is declared, but it cannot access the concrete runtime type of the enclosing instance for a `@Nested` test class.\n\nWhen a `DisplayNameGenerator` is used to build hierarchical display names, this can lead to confusing results or even conflicting results depending on the structure of the test classes used, \"conflicting\" in the sense that two nested test classes may have identical display names that do not represent the runtime structure of the test classes.\n\n## Example\n\n```java\n@IndicativeSentencesGeneration\nabstract class AbstractBaseTests {\n\n\t@Nested\n\tclass NestedTests {\n\n\t\t@Test\n\t\tvoid test() {\n\t\t}\n\t}\n}\n```\n\n```java\nclass ScenarioOneTests extends AbstractBaseTests {\n}\n```\n\n```java\nclass ScenarioTwoTests extends AbstractBaseTests {\n}\n```\n\n## Actual Behavior\n\nWhen running `ScenarioOneTests` and `ScenarioTwoTests`, we currently see the following display names.\n\n- `ScenarioOneTests`\n - `AbstractBaseTests, NestedTests`\n - `AbstractBaseTests, NestedTests, test()`\n- `ScenarioTwoTests`\n - `AbstractBaseTests, NestedTests`\n - `AbstractBaseTests, NestedTests, test()`\n\n## Expected Behavior\n\nWhen running `ScenarioOneTests` and `ScenarioTwoTests`, we would expect the following display names.\n\n- `ScenarioOneTests`\n - `ScenarioOneTests, NestedTests`\n - `ScenarioOneTests, NestedTests, test()`\n- `ScenarioTwoTests`\n - `ScenarioTwoTests, NestedTests`\n - `ScenarioTwoTests, NestedTests, test()`\n\n## Related Issues\n\n- #4131 \n\n## Deliverables\n\n- [x] Ensure that a `DisplayNameGenerator` can access the concrete runtime type of the enclosing instance for a `@Nested` test class.\n\nTeam decision: Change DisplayNameGenerator as follows:\n\n@Deprecated\ndefault String generateDisplayNameForNestedClass(Class> nestedClass) {\n\tthrow new UnsupportedOperationException(\"Implement generateDisplayNameForNestedClass(List
>> enclosingInstanceTypes, Class> testClass,\n+\t\t\tMethod testMethod, JupiterConfiguration configuration) {\n \t\treturn determineDisplayName(testMethod,\n-\t\t\tcreateDisplayNameSupplierForMethod(testClass, testMethod, configuration));\n+\t\t\tcreateDisplayNameSupplierForMethod(enclosingInstanceTypes, testClass, testMethod, configuration));\n \t}\n \n \tstatic Supplier
>> enclosingInstanceTypes,\n+\t\t\tClass> testClass, JupiterConfiguration configuration) {\n \t\treturn createDisplayNameSupplier(testClass, configuration,\n-\t\t\tgenerator -> generator.generateDisplayNameForNestedClass(testClass));\n+\t\t\tgenerator -> generator.generateDisplayNameForNestedClass(enclosingInstanceTypes.get(), testClass));\n \t}\n \n-\tprivate static Supplier
>> enclosingInstanceTypes,\n+\t\t\tClass> testClass, Method testMethod, JupiterConfiguration configuration) {\n \t\treturn createDisplayNameSupplier(testClass, configuration,\n-\t\t\tgenerator -> generator.generateDisplayNameForMethod(testClass, testMethod));\n+\t\t\tgenerator -> generator.generateDisplayNameForMethod(enclosingInstanceTypes.get(), testClass, testMethod));\n \t}\n \n \tprivate static Supplier
DISCLAIMER
\n+ *\n+ * DISCLAIMER
\n+ *\n+ *