Make sure that you set the minimum token count low enough. Your short piece of duplicate code has fewer tokens than the default 100.
According to the docs, the property is called minimumTokens
. Older versions of the Maven PMD plugin had a property maven.pmd.cpd.minimumtokencount
. Set it to 5 for testing. In real life, the default of 100 is a good value.