Polish CollectionFactoryTests

Closes gh-1334
This commit is contained in:
stonio 2017-02-21 16:06:07 +01:00 committed by Stephane Nicoll
parent 0ddcce4169
commit 412947a53f
1 changed files with 6 additions and 5 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -39,6 +39,7 @@ import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.Matchers.empty;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import static org.springframework.core.CollectionFactory.*; import static org.springframework.core.CollectionFactory.*;
@ -165,7 +166,7 @@ public class CollectionFactoryTests {
@Test @Test
public void createApproximateCollectionFromEmptyHashSet() { public void createApproximateCollectionFromEmptyHashSet() {
Collection<String> set = createApproximateCollection(new HashSet<String>(), 2); Collection<String> set = createApproximateCollection(new HashSet<String>(), 2);
assertThat(set.size(), is(0)); assertThat(set, is(empty()));
} }
@Test @Test
@ -173,19 +174,19 @@ public class CollectionFactoryTests {
HashSet<String> hashSet = new HashSet<>(); HashSet<String> hashSet = new HashSet<>();
hashSet.add("foo"); hashSet.add("foo");
Collection<String> set = createApproximateCollection(hashSet, 2); Collection<String> set = createApproximateCollection(hashSet, 2);
assertThat(set.size(), is(0)); assertThat(set, is(empty()));
} }
@Test @Test
public void createApproximateCollectionFromEmptyEnumSet() { public void createApproximateCollectionFromEmptyEnumSet() {
Collection<Color> colors = createApproximateCollection(EnumSet.noneOf(Color.class), 2); Collection<Color> colors = createApproximateCollection(EnumSet.noneOf(Color.class), 2);
assertThat(colors.size(), is(0)); assertThat(colors, is(empty()));
} }
@Test @Test
public void createApproximateCollectionFromNonEmptyEnumSet() { public void createApproximateCollectionFromNonEmptyEnumSet() {
Collection<Color> colors = createApproximateCollection(EnumSet.of(Color.BLUE), 2); Collection<Color> colors = createApproximateCollection(EnumSet.of(Color.BLUE), 2);
assertThat(colors.size(), is(0)); assertThat(colors, is(empty()));
} }
@Test @Test