diff --git a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/SwitchDensity.xml b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/SwitchDensity.xml
index 4216e0073c..1c3c21bf4d 100644
--- a/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/SwitchDensity.xml
+++ b/pmd-java/src/test/resources/net/sourceforge/pmd/lang/java/rule/design/xml/SwitchDensity.xml
@@ -181,4 +181,78 @@ public class SwitchDensityPattern {
}
]]>
+
+
+ [java] SwitchDensity with pattern matching #5030
+ 4
+ 1
+ 0 ->
+ {
+ System.err.println("I am a fish.");
+ System.err.println("I am a fish.");
+ System.err.println("I am a fish.");
+ System.err.println("I am a fish.");
+ System.err.println("I am a fish.");
+ }
+ case Integer i ->
+ {
+ System.err.println("I am not a fish.");
+ System.err.println("I am not a fish.");
+ System.err.println("I am not a fish.");
+ System.err.println("I am not a fish.");
+ System.err.println("I am not a fish.");
+ System.err.println("I am not a fish.");
+ }
+ default ->
+ {
+ System.err.println("default");
+ }
+ }
+ }
+}
+ ]]>
+
+
+
+ Switch with Record Pattern, ok
+ 0
+ System.out.println(a);
+ }
+ }
+}
+]]>
+
+
+
+ Switch with Record Pattern, not ok
+ 4
+ 1
+ {
+ System.out.println(a);
+ System.out.println(a);
+ System.out.println(a);
+ System.out.println(a);
+ System.out.println(a);
+ }
+ }
+ }
+}
+]]>
+