Author: mthl
Date: Mon Apr 22 13:45:42 2019 New Revision: 1857959 URL: http://svn.apache.org/viewvc?rev=1857959&view=rev Log: Improved: Use ‘containsInAnyOrder’ matcher when possible (OFBIZ-10941) It is more precise to use ‘containsInAnyOrder’ matcher than checking the presence of items and the size of the collections separately. Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/org/apache/ofbiz/base/collections/MultivaluedMapContextAdapterTests.java ofbiz/ofbiz-framework/trunk/framework/widget/src/test/java/org/apache/ofbiz/widget/renderer/FormRendererTest.java Modified: ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/org/apache/ofbiz/base/collections/MultivaluedMapContextAdapterTests.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/org/apache/ofbiz/base/collections/MultivaluedMapContextAdapterTests.java?rev=1857959&r1=1857958&r2=1857959&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/org/apache/ofbiz/base/collections/MultivaluedMapContextAdapterTests.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/base/src/test/java/org/apache/ofbiz/base/collections/MultivaluedMapContextAdapterTests.java Mon Apr 22 13:45:42 2019 @@ -18,8 +18,7 @@ *******************************************************************************/ package org.apache.ofbiz.base.collections; -import static org.hamcrest.CoreMatchers.hasItems; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.containsInAnyOrder; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; @@ -56,8 +55,7 @@ public class MultivaluedMapContextAdapte @Test public void valuesBasic() { - assertThat(adapter.values(), hasItems(0, 3)); - assertThat(adapter.values().size(), is(2)); + assertThat(adapter.values(), containsInAnyOrder(0, 3)); } @Test Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/test/java/org/apache/ofbiz/widget/renderer/FormRendererTest.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/test/java/org/apache/ofbiz/widget/renderer/FormRendererTest.java?rev=1857959&r1=1857958&r2=1857959&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/test/java/org/apache/ofbiz/widget/renderer/FormRendererTest.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/test/java/org/apache/ofbiz/widget/renderer/FormRendererTest.java Mon Apr 22 13:45:42 2019 @@ -18,8 +18,7 @@ *******************************************************************************/ package org.apache.ofbiz.widget.renderer; -import static org.hamcrest.CoreMatchers.hasItems; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.containsInAnyOrder; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -58,8 +57,7 @@ public class FormRendererTest { fields.add(a); ModelFormField b = ModelFormField.from(new ModelFormFieldBuilder().setName("B")); fields.add(b); - assertThat(renderer.getUsedFields(context), hasItems(a, b)); - assertThat(renderer.getUsedFields(context).size(), is(2)); + assertThat(renderer.getUsedFields(context), containsInAnyOrder(a, b)); } @Test @@ -70,8 +68,7 @@ public class FormRendererTest { fields.add(b); ModelFormField a2 = ModelFormField.from(new ModelFormFieldBuilder().setName("A")); fields.add(a2); - assertThat(renderer.getUsedFields(context), hasItems(a1, a2, b)); - assertThat(renderer.getUsedFields(context).size(), is(3)); + assertThat(renderer.getUsedFields(context), containsInAnyOrder(a1, a2, b)); } @Test @@ -82,8 +79,7 @@ public class FormRendererTest { ModelFormField a2 = ModelFormField.from(new ModelFormFieldBuilder().setName("A").setUseWhen("false")); fields.add(a2); useWhenFields.add(a2.getName()); - assertThat(renderer.getUsedFields(context), hasItems(a1, a2)); - assertThat(renderer.getUsedFields(context).size(), is(2)); + assertThat(renderer.getUsedFields(context), containsInAnyOrder(a1, a2)); } @Test @@ -97,8 +93,7 @@ public class FormRendererTest { ModelFormField a3 = ModelFormField.from(new ModelFormFieldBuilder().setName("A").setUseWhen("true")); fields.add(a3); useWhenFields.add(a3.getName()); - assertThat(renderer.getUsedFields(context), hasItems(a1, a2)); - assertThat(renderer.getUsedFields(context).size(), is(2)); + assertThat(renderer.getUsedFields(context), containsInAnyOrder(a1, a2)); } } |
Free forum by Nabble | Edit this page |