Commit cb134345 authored by Stein Eldar Johnsen's avatar Stein Eldar Johnsen 💬

Latest hamcrest, io-util.

Remove guava dep in testing.
parent 245da66d
......@@ -114,11 +114,6 @@
</dependency>
<!-- testing dependencies -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
......@@ -131,7 +126,7 @@
<dependency>
<groupId>net.morimekta.utils</groupId>
<artifactId>io-util</artifactId>
<version>3.2.0</version>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>net.morimekta.utils</groupId>
......@@ -148,11 +143,6 @@
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>26.0-jre</version>
</dependency>
<!-- testing dependencies -->
<dependency>
......@@ -168,17 +158,17 @@
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<version>2.1</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.22.0</version>
<version>2.25.1</version>
</dependency>
</dependencies>
</dependencyManagement>
......
package net.morimekta.testing.concurrent;
import com.google.common.collect.ImmutableList;
import net.morimekta.testing.time.FakeClock;
import org.junit.Before;
import org.junit.Test;
......@@ -16,6 +15,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import static net.morimekta.util.collect.UnmodifiableList.listOf;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
......@@ -100,7 +100,7 @@ public class FakeScheduledExecutorTest {
when(a.call()).thenReturn("a");
when(b.call()).thenReturn("b");
List<Future<String>> l = executor.invokeAll(ImmutableList.of(a, b), 10L, TimeUnit.MILLISECONDS);
List<Future<String>> l = executor.invokeAll(listOf(a, b), 10L, TimeUnit.MILLISECONDS);
clock.tick(1);
......@@ -268,28 +268,28 @@ public class FakeScheduledExecutorTest {
}
try {
executor.invokeAll(ImmutableList.of(), -3, TimeUnit.MILLISECONDS);
executor.invokeAll(listOf(), -3, TimeUnit.MILLISECONDS);
fail("no exception");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), is("Negative timeout: -3"));
}
try {
executor.invokeAny(ImmutableList.of(), -3, TimeUnit.MILLISECONDS);
executor.invokeAny(listOf(), -3, TimeUnit.MILLISECONDS);
fail("no exception");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), is("Negative timeout: -3"));
}
try {
executor.invokeAll(ImmutableList.of());
executor.invokeAll(listOf());
fail("no exception");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), is("Empty invoke collection"));
}
try {
executor.invokeAny(ImmutableList.of());
executor.invokeAny(listOf());
fail("no exception");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), is("Empty invoke collection"));
......@@ -314,14 +314,14 @@ public class FakeScheduledExecutorTest {
}
try {
executor.invokeAny(ImmutableList.of(callable));
executor.invokeAny(listOf(callable));
fail("no exception");
} catch (IllegalStateException e) {
assertThat(e.getMessage(), is("Executor is shut down"));
}
try {
executor.invokeAll(ImmutableList.of(callable));
executor.invokeAll(listOf(callable));
fail("no exception");
} catch (IllegalStateException e) {
assertThat(e.getMessage(), is("Executor is shut down"));
......
package net.morimekta.testing.concurrent;
import com.google.common.collect.ImmutableList;
import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Test;
......@@ -14,6 +13,7 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import static net.morimekta.util.collect.UnmodifiableList.listOf;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasSize;
......@@ -141,13 +141,13 @@ public class ImmediateExecutorTest {
}
try {
executor.invokeAll(ImmutableList.of(() -> null), 1, TimeUnit.MILLISECONDS);
executor.invokeAll(listOf(() -> null), 1, TimeUnit.MILLISECONDS);
} catch (IllegalStateException e) {
assertThat(e.getMessage(), is("Executor is shut down"));
}
try {
String s = executor.invokeAny(ImmutableList.of(() -> ""), 1L, TimeUnit.MILLISECONDS);
String s = executor.invokeAny(listOf(() -> ""), 1L, TimeUnit.MILLISECONDS);
} catch (IllegalStateException e) {
assertThat(e.getMessage(), is("Executor is shut down"));
}
......@@ -161,7 +161,7 @@ public class ImmediateExecutorTest {
when(a.call()).thenReturn("a");
when(b.call()).thenReturn("b");
List<Future<String>> l = executor.invokeAll(ImmutableList.of(a, b), 10L, TimeUnit.MILLISECONDS);
List<Future<String>> l = executor.invokeAll(listOf(a, b), 10L, TimeUnit.MILLISECONDS);
verify(a).call();
verify(b).call();
......
package net.morimekta.testing.matchers;
import com.google.common.collect.ImmutableList;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.StringDescription;
......@@ -8,6 +7,7 @@ import org.junit.Test;
import java.util.Collection;
import static net.morimekta.util.collect.UnmodifiableList.listOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
......@@ -17,11 +17,11 @@ public class AllItemsMatchTest {
Matcher<String> matcher = is("a");
Matcher<Collection<String>> sut = new AllItemsMatch<>(matcher);
assertThat(sut.matches(ImmutableList.of("a", "a")), is(true));
assertThat(sut.matches(ImmutableList.of("a", "b")), is(false));
assertThat(sut.matches(listOf("a", "a")), is(true));
assertThat(sut.matches(listOf("a", "b")), is(false));
// If no entries, all (none) items match.
assertThat(sut.matches(ImmutableList.of()), is(true));
assertThat(sut.matches(listOf()), is(true));
assertThat(sut.matches(null), is(false));
assertThat(sut.matches("a"), is(false));
......@@ -50,7 +50,7 @@ public class AllItemsMatchTest {
assertThat(description.toString(), is("not a collection: \"a\""));
description = new StringDescription();
sut.describeMismatch(ImmutableList.of("a", "b"), description);
sut.describeMismatch(listOf("a", "b"), description);
assertThat(description.toString(), is("was [\"a\", \"b\"]"));
......
package net.morimekta.testing.matchers;
import com.google.common.collect.ImmutableSet;
import org.hamcrest.StringDescription;
import org.junit.Test;
import static net.morimekta.util.collect.UnmodifiableSet.setOf;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
public class DistinctFromTest {
@Test
public void testDistinctFrom() {
DistinctFrom<Integer> m = new DistinctFrom<>(ImmutableSet.of(1, 2, 3));
DistinctFrom<Integer> m = new DistinctFrom<>(setOf(1, 2, 3));
StringDescription description = new StringDescription();
m.describeTo(description);
assertThat(description.toString(), is("distinct from [<1>, <2>, <3>]"));
description = new StringDescription();
m.describeMismatch(ImmutableSet.of(2, 4, 6), description);
m.describeMismatch(setOf(2, 4, 6), description);
assertThat(description.toString(), is("both contained [<2>]"));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment