import org.junit.Test;
import java.util.Arrays;
import java.util.SortedSet;
import java.util.TreeSet;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
public class MainTest {
public SortedSet sortIntegers(Integer[] ints) {
return new TreeSet(Arrays.asList(ints));
}
@Test
public void it_should_return_a_sorted_set() throws Exception {
assertThat(sortIntegers(new Integer[]{5, 7, 1, 6}), is(instanceOf(SortedSet.class)));
}
@Test
public void it_should_return_four_elements() throws Exception {
assertThat(sortIntegers(new Integer[]{5, 7, 1, 6}).size(), is(4));
}
@Test
public void it_should_return_in_the_right_order() throws Exception {
Integer previous = 0;
for (Integer current : sortIntegers(new Integer[]{5, 7, 1, 6})) {
assertThat(current , is(greaterThan(previous)));
previous = current;
}
}
}