44
55import java .util .Collection ;
66import java .util .List ;
7+ import java .util .Locale ;
78
89import static java .lang .Float .parseFloat ;
910import static org .assertj .core .api .Assertions .assertThat ;
@@ -15,7 +16,6 @@ class CommerceTest extends BaseFakerTest {
1516 private static final String PROMOTION_CODE_REGEX = CAPITALIZED_WORD_REGEX + "(-" + CAPITALIZED_WORD_REGEX + ")*" ;
1617
1718 private final Commerce commerce = faker .commerce ();
18- private final String [] commerceProductName = commerce .productName ().split (" " );
1919
2020 @ Test
2121 void testDepartment () {
@@ -27,14 +27,27 @@ void testProductName() {
2727 assertThat (commerce .productName ()).matches ("(\\ w+ ?){3,4}" );
2828 }
2929
30+ @ Test
31+ void productNameConsistsOf_adjective_material_and_productType () {
32+ BaseFaker faker = new BaseFaker (new Locale ("test" ));
33+ assertThat (faker .commerce ().productName ()).isIn (
34+ "Silver Linings Playbook" ,
35+ "Silver Linings Train" ,
36+ "Silver Iron Playbook" ,
37+ "Silver Iron Train" ,
38+ "Silent Linings Playbook" ,
39+ "Silent Linings Train" ,
40+ "Silent Iron Playbook" ,
41+ "Silent Iron Train"
42+ );
43+ }
44+
3045 @ Override
3146 protected Collection <TestSpec > providerListTest () {
3247 return List .of (TestSpec .of (commerce ::material , "commerce.product_name.material" ),
3348 TestSpec .of (commerce ::brand , "commerce.brand" ),
34- TestSpec .of (commerce ::vendor , "commerce.vendor" ),
35- TestSpec .of (() -> commerceProductName [0 ], "commerce.product_name.adjective" ),
36- TestSpec .of (() -> commerceProductName [1 ], "commerce.product_name.material" ),
37- TestSpec .of (() -> commerceProductName [2 ], "commerce.product_name.product" ));
49+ TestSpec .of (commerce ::vendor , "commerce.vendor" )
50+ );
3851 }
3952
4053 @ Test
0 commit comments