1
2
3
4
5 package com.qulice.pmd;
6
7 import org.hamcrest.Matchers;
8 import org.hamcrest.core.IsEqual;
9 import org.hamcrest.text.IsEmptyString;
10 import org.junit.jupiter.api.Test;
11
12
13
14
15
16
17 final class UseCollectionsSingletonListRuleTest {
18
19 @Test
20 void detectsArraysAsListWithSingleScalar() throws Exception {
21 new PmdAssert(
22 "ArraysAsListSingleScalar.java",
23 new IsEqual<>(false),
24 Matchers.containsString(
25 "Use Collections.singletonList instead of Arrays.asList with a single non-array argument"
26 )
27 ).assertOk();
28 }
29
30 @Test
31 void allowsMultipleArgumentsAndArrayArgument() throws Exception {
32 new PmdAssert(
33 "ArraysAsListAllowedCases.java",
34 new IsEqual<>(true),
35 IsEmptyString.emptyString()
36 ).assertOk();
37 }
38 }