diff options
author | Harald Musum <musum@verizonmedia.com> | 2020-08-11 21:48:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-11 21:48:02 +0200 |
commit | 66409c027f819cfbf7c56a82cdc069745454c671 (patch) | |
tree | 610bdc5791acb54051895b0199c0f379b35161eb | |
parent | ce60b7900412c4df420c86d458535cfd6b01065c (diff) | |
parent | db6c660d7020ebbfa14d7c0fea8fea422c2b4026 (diff) |
Merge pull request #14028 from vespa-engine/balder/hamcrest-2-junit
Reduce the use of hamcrest when normal assertEquals/assertTrue does a…
33 files changed, 385 insertions, 388 deletions
diff --git a/chain/pom.xml b/chain/pom.xml index 2ead24a89b7..67ee1a4c0e7 100755 --- a/chain/pom.xml +++ b/chain/pom.xml @@ -26,11 +26,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-library</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>com.yahoo.vespa</groupId> <artifactId>provided-dependencies</artifactId> <version>${project.version}</version> diff --git a/chain/src/test/java/com/yahoo/component/chain/model/ChainsModelBuilderTest.java b/chain/src/test/java/com/yahoo/component/chain/model/ChainsModelBuilderTest.java index 2a22b5afbf7..7cef03bbb06 100644 --- a/chain/src/test/java/com/yahoo/component/chain/model/ChainsModelBuilderTest.java +++ b/chain/src/test/java/com/yahoo/component/chain/model/ChainsModelBuilderTest.java @@ -11,8 +11,7 @@ import java.util.Set; import static com.yahoo.container.core.ChainsConfig.Components; import static com.yahoo.container.core.ChainsConfig.Chains; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; /** @@ -23,7 +22,7 @@ public class ChainsModelBuilderTest { @Test public void components_are_added_to_componentModels() throws Exception { ChainsModel model = chainsModel(); - assertThat(model.allComponents().size(), is(2)); + assertEquals(2, model.allComponents().size()); assertTrue(model.componentModels().containsKey(new ComponentId("componentA"))); } @@ -38,7 +37,7 @@ public class ChainsModelBuilderTest { public void inherited_chains_are_added_to_chainSpecification() throws Exception { ChainsModel model = chainsModel(); ChainSpecification inheritsChain1 = model.chainSpecifications().get(new ComponentId("inheritsChain1")).model(); - assertThat(model.allChainsFlattened().size(), is(2)); + assertEquals(2, model.allChainsFlattened().size()); assertTrue(getComponentsByName(inheritsChain1.inheritance.chainSpecifications).containsKey("chain1")); assertTrue(getComponentsByName(inheritsChain1.inheritance.excludedComponents).containsKey("componentA")); } diff --git a/config-model-api/src/test/java/com/yahoo/config/application/api/ApplicationFileTest.java b/config-model-api/src/test/java/com/yahoo/config/application/api/ApplicationFileTest.java index 5b0b11b88b7..6a305f9979e 100644 --- a/config-model-api/src/test/java/com/yahoo/config/application/api/ApplicationFileTest.java +++ b/config-model-api/src/test/java/com/yahoo/config/application/api/ApplicationFileTest.java @@ -12,12 +12,10 @@ import java.io.IOException; import java.io.StringReader; import java.util.List; -import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; /** @@ -59,8 +57,8 @@ public abstract class ApplicationFileTest { Path p1 = Path.fromString("foo/bar/baz"); ApplicationFile f1 = getApplicationFile(p1); ApplicationFile f2 = getApplicationFile(p1); - assertThat(f1.getPath(), is(p1)); - assertThat(f2.getPath(), is(p1)); + assertEquals(p1, f1.getPath()); + assertEquals(p1, f2.getPath()); } @Test @@ -134,7 +132,7 @@ public abstract class ApplicationFileTest { file.writeFile(new StringReader("foobar")); assertTrue(file.exists()); assertFalse(file.isDirectory()); - assertThat(com.yahoo.io.IOUtils.readAll(file.createReader()), is("foobar")); + assertEquals("foobar", com.yahoo.io.IOUtils.readAll(file.createReader())); } @Test @@ -144,7 +142,7 @@ public abstract class ApplicationFileTest { file.writeFile(new StringReader("foobar")); assertTrue(file.exists()); assertFalse(file.isDirectory()); - assertThat(com.yahoo.io.IOUtils.readAll(file.createReader()), is("foobar")); + assertEquals("foobar", com.yahoo.io.IOUtils.readAll(file.createReader())); } @Test @@ -153,7 +151,7 @@ public abstract class ApplicationFileTest { assertTrue(file.exists()); assertTrue(file.isDirectory()); List<ApplicationFile> list = file.listFiles(); - assertThat(list.size(), is(6)); + assertEquals(6, list.size()); assertTrue(listContains(list, "vespa-services.xml")); assertTrue(listContains(list, "vespa-hosts.xml")); assertTrue(listContains(list, "components/")); @@ -175,7 +173,7 @@ public abstract class ApplicationFileTest { assertTrue(listContains(list, "components/file.txt")); list = getApplicationFile(Path.fromString("templates")).listFiles(true); - assertThat(list.size(), is(14)); + assertEquals(14, list.size()); assertTrue(listContains(list, "templates/basic/")); assertTrue(listContains(list, "templates/basic/error.templ")); assertTrue(listContains(list, "templates/basic/header.templ")); @@ -211,7 +209,7 @@ public abstract class ApplicationFileTest { return path.getName().endsWith(".xml"); } }); - assertThat(list.size(), is(2)); + assertEquals(2, list.size()); assertFalse(listContains(list, "components/")); assertFalse(listContains(list, "files/")); assertFalse(listContains(list, "searchdefinitions/")); @@ -237,7 +235,7 @@ public abstract class ApplicationFileTest { public void testApplicationFileCanBeDeleted() throws Exception { ApplicationFile file = getApplicationFile(Path.fromString("file1.txt")); file.writeFile(new StringReader("file1")); - assertThat(file.getPath().getName(), is("file1.txt")); + assertEquals("file1.txt", file.getPath().getName()); file.delete(); assertFalse(file.exists()); assertFalse(file.isDirectory()); @@ -246,7 +244,7 @@ public abstract class ApplicationFileTest { file = getApplicationFile(Path.fromString("subdir/file2.txt")); file.writeFile(new StringReader("file2")); - assertThat(file.getPath().getName(), is("file2.txt")); + assertEquals("file2.txt", file.getPath().getName()); file.delete(); assertFalse(file.exists()); assertFalse(file.isDirectory()); @@ -257,48 +255,48 @@ public abstract class ApplicationFileTest { @Test public void getGetMetaPath() throws Exception { ApplicationFile file = getApplicationFile(Path.fromString("file1.txt")); - assertThat(file.getMetaPath().toString(), is(".meta/file1.txt")); + assertEquals(".meta/file1.txt", file.getMetaPath().toString()); file = getApplicationFile(Path.fromString("dir/file1.txt")); - assertThat(file.getMetaPath().toString(), is("dir/.meta/file1.txt")); + assertEquals("dir/.meta/file1.txt", file.getMetaPath().toString()); file = getApplicationFile(Path.fromString("dir")); - assertThat(file.getMetaPath().toString(), is(".meta/dir")); + assertEquals(".meta/dir", file.getMetaPath().toString()); file = getApplicationFile(Path.fromString("")); - assertThat(file.getMetaPath().toString(), is(".meta/.root")); + assertEquals(".meta/.root", file.getMetaPath().toString()); } @Test public void getGetMetaContent() throws Exception { String testFileName = "file1.txt"; ApplicationFile file = getApplicationFile(Path.fromString(testFileName)); - assertThat(file.getMetaPath().toString(), is(".meta/" + testFileName)); + assertEquals(".meta/" + testFileName, file.getMetaPath().toString()); String input = "a"; file.writeFile(new StringReader(input)); - assertThat(file.getMetaData().getStatus(), is(ApplicationFile.ContentStatusNew)); - assertThat(file.getMetaData().getMd5(), is(ConfigUtils.getMd5(input))); + assertEquals(ApplicationFile.ContentStatusNew, file.getMetaData().getStatus()); + assertEquals(ConfigUtils.getMd5(input), file.getMetaData().getMd5()); testFileName = "foo"; ApplicationFile fooDir = getApplicationFile(Path.fromString(testFileName)); fooDir.createDirectory(); - assertThat(fooDir.getMetaData().getStatus(), is(ApplicationFile.ContentStatusNew)); - assertThat(fooDir.getMetaData().getMd5(), is("")); + assertEquals(ApplicationFile.ContentStatusNew, fooDir.getMetaData().getStatus()); + assertTrue(fooDir.getMetaData().getMd5().isEmpty()); testFileName = "foo/file2.txt"; file = getApplicationFile(Path.fromString(testFileName)); input = "a"; file.writeFile(new StringReader(input)); - assertThat(file.getMetaData().getStatus(), is(ApplicationFile.ContentStatusNew)); - assertThat(file.getMetaData().getMd5(), is(ConfigUtils.getMd5(input))); + assertEquals(ApplicationFile.ContentStatusNew, file.getMetaData().getStatus()); + assertEquals(ConfigUtils.getMd5(input), file.getMetaData().getMd5()); file.delete(); - assertThat(file.getMetaData().getStatus(), is(ApplicationFile.ContentStatusDeleted)); - assertThat(file.getMetaData().getMd5(), is("")); + assertEquals(ApplicationFile.ContentStatusDeleted, file.getMetaData().getStatus()); + assertTrue(file.getMetaData().getMd5().isEmpty()); fooDir.delete(); - assertThat(fooDir.getMetaData().getStatus(), is(ApplicationFile.ContentStatusDeleted)); - assertThat(file.getMetaData().getMd5(), is("")); + assertEquals(ApplicationFile.ContentStatusDeleted, fooDir.getMetaData().getStatus()); + assertTrue(file.getMetaData().getMd5().isEmpty()); // non-existing file testFileName = "non-existing"; @@ -320,7 +318,7 @@ public abstract class ApplicationFileTest { private void assertFileContent(String expected, String path) throws Exception { ApplicationFile file = getApplicationFile(Path.fromString(path)); String actual = com.yahoo.io.IOUtils.readAll(file.createReader()); - assertThat(actual, is(expected)); + assertEquals(expected, actual); } public abstract ApplicationFile getApplicationFile(Path path) throws Exception; diff --git a/docproc/src/main/java/com/yahoo/docproc/jdisc/messagebus/MbusRequestContext.java b/docproc/src/main/java/com/yahoo/docproc/jdisc/messagebus/MbusRequestContext.java index a9bd63d96c3..09d25f60835 100644 --- a/docproc/src/main/java/com/yahoo/docproc/jdisc/messagebus/MbusRequestContext.java +++ b/docproc/src/main/java/com/yahoo/docproc/jdisc/messagebus/MbusRequestContext.java @@ -24,7 +24,6 @@ import com.yahoo.messagebus.Message; import com.yahoo.messagebus.Reply; import com.yahoo.messagebus.jdisc.MbusRequest; import com.yahoo.messagebus.jdisc.MbusResponse; -import com.yahoo.messagebus.routing.Route; import java.net.URI; import java.util.ArrayList; diff --git a/docproc/src/test/java/com/yahoo/docproc/ProcessingTestCase.java b/docproc/src/test/java/com/yahoo/docproc/ProcessingTestCase.java index 8d3e387a0c5..e72b9d991b6 100644 --- a/docproc/src/test/java/com/yahoo/docproc/ProcessingTestCase.java +++ b/docproc/src/test/java/com/yahoo/docproc/ProcessingTestCase.java @@ -7,8 +7,10 @@ import org.junit.Test; import java.util.Iterator; import java.util.Map; -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; /** * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> @@ -18,8 +20,8 @@ public class ProcessingTestCase { @Test public void serviceName() { - assertThat(new Processing().getServiceName(), is("default")); - assertThat(new Processing("foobar", (DocumentOperation) null, null).getServiceName(), is("foobar")); + assertEquals("default", new Processing().getServiceName()); + assertEquals("foobar", new Processing("foobar", (DocumentOperation) null, null).getServiceName()); } @Test @@ -30,21 +32,21 @@ public class ProcessingTestCase { p.setVariable("bar", "apple"); Iterator<Map.Entry<String, Object>> it = p.getVariableAndNameIterator(); - assertThat(it.hasNext(), is(true)); - assertThat(it.next(), not(nullValue())); - assertThat(it.hasNext(), is(true)); - assertThat(it.next(), not(nullValue())); - assertThat(it.hasNext(), is(false)); + assertTrue(it.hasNext()); + assertNotNull(it.next()); + assertTrue(it.hasNext()); + assertNotNull(it.next()); + assertFalse(it.hasNext()); - assertThat(p.hasVariable("foo"), is(true)); - assertThat(p.hasVariable("bar"), is(true)); - assertThat(p.hasVariable("baz"), is(false)); + assertTrue(p.hasVariable("foo")); + assertTrue(p.hasVariable("bar")); + assertFalse(p.hasVariable("baz")); - assertThat(p.removeVariable("foo"), is("banana")); + assertEquals("banana", p.removeVariable("foo")); p.clearVariables(); it = p.getVariableAndNameIterator(); - assertThat(it.hasNext(), is(false)); + assertFalse(it.hasNext()); } } diff --git a/docproc/src/test/java/com/yahoo/docproc/SimpleDocumentProcessorTestCase.java b/docproc/src/test/java/com/yahoo/docproc/SimpleDocumentProcessorTestCase.java index c89ac21610e..741d10bdc43 100644 --- a/docproc/src/test/java/com/yahoo/docproc/SimpleDocumentProcessorTestCase.java +++ b/docproc/src/test/java/com/yahoo/docproc/SimpleDocumentProcessorTestCase.java @@ -15,9 +15,9 @@ import com.yahoo.document.idstring.IdIdString; import com.yahoo.statistics.StatisticsImpl; import org.junit.Test; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsNull.nullValue; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; /** * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> @@ -60,14 +60,12 @@ public class SimpleDocumentProcessorTestCase { DocprocService service = setupDocprocService(new VerySimpleDocumentProcessor()); service.getExecutor().process(p); - assertThat(p.getDocumentOperations().size(), is(3)); - assertThat(p.getDocumentOperations().get(0) instanceof DocumentPut, is(true)); - assertThat(((DocumentPut) p.getDocumentOperations().get(0)).getDocument().getFieldValue("title").getWrappedValue(), - is("processed")); - assertThat(p.getDocumentOperations().get(1) instanceof DocumentUpdate, is(true)); - assertThat(p.getDocumentOperations().get(2) instanceof DocumentRemove, is(true)); - assertThat(p.getDocumentOperations().get(2).getId().toString(), - is("id:foobar:foobar::12345")); + assertEquals(3, p.getDocumentOperations().size()); + assertTrue(p.getDocumentOperations().get(0) instanceof DocumentPut); + assertEquals("processed", ((DocumentPut) p.getDocumentOperations().get(0)).getDocument().getFieldValue("title").getWrappedValue()); + assertTrue(p.getDocumentOperations().get(1) instanceof DocumentUpdate); + assertTrue(p.getDocumentOperations().get(2) instanceof DocumentRemove); + assertEquals("id:foobar:foobar::12345", p.getDocumentOperations().get(2).getId().toString()); } @Test @@ -78,10 +76,9 @@ public class SimpleDocumentProcessorTestCase { DocprocService service = setupDocprocService(new VerySimpleDocumentProcessor()); service.getExecutor().process(p); - assertThat(p.getDocumentOperations().size(), is(1)); - assertThat(p.getDocumentOperations().get(0) instanceof DocumentPut, is(true)); - assertThat(((DocumentPut) p.getDocumentOperations().get(0)).getDocument().getFieldValue("title").getWrappedValue(), - is("processed")); + assertEquals(1, p.getDocumentOperations().size()); + assertTrue(p.getDocumentOperations().get(0) instanceof DocumentPut); + assertEquals("processed", ((DocumentPut) p.getDocumentOperations().get(0)).getDocument().getFieldValue("title").getWrappedValue()); } @Test @@ -99,16 +96,13 @@ public class SimpleDocumentProcessorTestCase { //ok } - assertThat(p.getDocumentOperations().size(), is(3)); - assertThat(p.getDocumentOperations().get(0) instanceof DocumentPut, is(true)); - assertThat(((DocumentPut) p.getDocumentOperations().get(0)).getDocument().getFieldValue("title").getWrappedValue(), - is("processed")); - assertThat(p.getDocumentOperations().get(1) instanceof DocumentRemove, is(true)); - assertThat(p.getDocumentOperations().get(1).getId().toString(), - is("id:this:foobar::is:a:remove")); - assertThat(p.getDocumentOperations().get(2) instanceof DocumentPut, is(true)); - assertThat(((DocumentPut) p.getDocumentOperations().get(2)).getDocument().getFieldValue("title"), - nullValue()); + assertEquals(3, p.getDocumentOperations().size()); + assertTrue(p.getDocumentOperations().get(0) instanceof DocumentPut); + assertEquals("processed", ((DocumentPut) p.getDocumentOperations().get(0)).getDocument().getFieldValue("title").getWrappedValue()); + assertTrue(p.getDocumentOperations().get(1) instanceof DocumentRemove); + assertEquals("id:this:foobar::is:a:remove", p.getDocumentOperations().get(1).getId().toString()); + assertTrue(p.getDocumentOperations().get(2) instanceof DocumentPut); + assertNull(((DocumentPut) p.getDocumentOperations().get(2)).getDocument().getFieldValue("title")); } diff --git a/docproc/src/test/java/com/yahoo/docproc/jdisc/DocumentProcessingHandlerAllMessageTypesTestCase.java b/docproc/src/test/java/com/yahoo/docproc/jdisc/DocumentProcessingHandlerAllMessageTypesTestCase.java index 5893013a187..c508e7da61d 100644 --- a/docproc/src/test/java/com/yahoo/docproc/jdisc/DocumentProcessingHandlerAllMessageTypesTestCase.java +++ b/docproc/src/test/java/com/yahoo/docproc/jdisc/DocumentProcessingHandlerAllMessageTypesTestCase.java @@ -30,12 +30,10 @@ import java.util.Collections; import java.util.List; import java.util.concurrent.TimeUnit; -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; /** * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> @@ -72,7 +70,7 @@ public class DocumentProcessingHandlerAllMessageTypesTestCase extends DocumentPr Reply reply = driver.client().awaitReply(60, TimeUnit.SECONDS); assertNotNull(reply); - assertThat(result, instanceOf(GetDocumentMessage.class)); + assertTrue(result instanceof GetDocumentMessage); assertFalse(reply.hasErrors()); } @@ -91,9 +89,9 @@ public class DocumentProcessingHandlerAllMessageTypesTestCase extends DocumentPr Reply reply = driver.client().awaitReply(60, TimeUnit.SECONDS); assertNotNull(reply); - assertThat(result, instanceOf(PutDocumentMessage.class)); + assertTrue(result instanceof PutDocumentMessage); PutDocumentMessage outputMsg = (PutDocumentMessage) result; - assertThat(((StringFieldValue) outputMsg.getDocumentPut().getDocument().getFieldValue("blahblah")).getString(), is("THIS IS A TEST.")); + assertEquals("THIS IS A TEST.", ((StringFieldValue) outputMsg.getDocumentPut().getDocument().getFieldValue("blahblah")).getString()); assertFalse(reply.hasErrors()); } @@ -109,9 +107,9 @@ public class DocumentProcessingHandlerAllMessageTypesTestCase extends DocumentPr Reply reply = driver.client().awaitReply(60, TimeUnit.SECONDS); assertNotNull(reply); - assertThat(result, instanceOf(RemoveDocumentMessage.class)); + assertTrue(result instanceof RemoveDocumentMessage); RemoveDocumentMessage outputMsg = (RemoveDocumentMessage) result; - assertThat(outputMsg.getDocumentId().toString(), is("id:ns:baz::12345:6789")); + assertEquals("id:ns:baz::12345:6789", outputMsg.getDocumentId().toString()); assertFalse(reply.hasErrors()); } @@ -128,9 +126,9 @@ public class DocumentProcessingHandlerAllMessageTypesTestCase extends DocumentPr Reply reply = driver.client().awaitReply(60, TimeUnit.SECONDS); assertNotNull(reply); - assertThat(result, instanceOf(UpdateDocumentMessage.class)); + assertTrue(result instanceof UpdateDocumentMessage); UpdateDocumentMessage outputMsg = (UpdateDocumentMessage) result; - assertThat(outputMsg.getDocumentUpdate().getId().toString(), is("id:ns:baz::foo")); + assertEquals("id:ns:baz::foo", outputMsg.getDocumentUpdate().getId().toString()); assertFalse(reply.hasErrors()); } diff --git a/docproc/src/test/java/com/yahoo/docproc/jdisc/DocumentProcessingHandlerBasicTestCase.java b/docproc/src/test/java/com/yahoo/docproc/jdisc/DocumentProcessingHandlerBasicTestCase.java index 01b66bc2fb6..9dc0b2a38f5 100644 --- a/docproc/src/test/java/com/yahoo/docproc/jdisc/DocumentProcessingHandlerBasicTestCase.java +++ b/docproc/src/test/java/com/yahoo/docproc/jdisc/DocumentProcessingHandlerBasicTestCase.java @@ -19,11 +19,9 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; /** @@ -51,11 +49,11 @@ public class DocumentProcessingHandlerBasicTestCase extends DocumentProcessingHa Reply reply = driver.client().awaitReply(60, TimeUnit.SECONDS); assertNotNull(reply); - assertThat((msg instanceof PutDocumentMessage), is(true)); + assertTrue((msg instanceof PutDocumentMessage)); PutDocumentMessage put = (PutDocumentMessage) msg; Document outDoc = put.getDocumentPut().getDocument(); - assertThat(document, equalTo(outDoc)); + assertEquals(document, outDoc); assertFalse(reply.hasErrors()); } diff --git a/docproc/src/test/java/com/yahoo/docproc/jdisc/DocumentProcessingHandlerTestBase.java b/docproc/src/test/java/com/yahoo/docproc/jdisc/DocumentProcessingHandlerTestBase.java index df3224827ef..f15b505d05f 100644 --- a/docproc/src/test/java/com/yahoo/docproc/jdisc/DocumentProcessingHandlerTestBase.java +++ b/docproc/src/test/java/com/yahoo/docproc/jdisc/DocumentProcessingHandlerTestBase.java @@ -7,10 +7,8 @@ import com.yahoo.component.provider.ComponentRegistry; import com.yahoo.container.core.document.ContainerDocumentConfig; import com.yahoo.container.jdisc.messagebus.MbusServerProvider; import com.yahoo.container.jdisc.messagebus.SessionCache; -import com.yahoo.docproc.AbstractConcreteDocumentFactory; import com.yahoo.docproc.CallStack; import com.yahoo.docproc.DocprocService; -import com.yahoo.docproc.DocumentProcessor; import com.yahoo.docproc.jdisc.messagebus.MbusRequestContext; import com.yahoo.document.DocumentType; diff --git a/docproc/src/test/java/com/yahoo/docproc/jdisc/DocumentProcessingHandlerTransformingMessagesTestCase.java b/docproc/src/test/java/com/yahoo/docproc/jdisc/DocumentProcessingHandlerTransformingMessagesTestCase.java index 00efab737c4..01ea5fd2fc9 100644 --- a/docproc/src/test/java/com/yahoo/docproc/jdisc/DocumentProcessingHandlerTransformingMessagesTestCase.java +++ b/docproc/src/test/java/com/yahoo/docproc/jdisc/DocumentProcessingHandlerTransformingMessagesTestCase.java @@ -29,9 +29,10 @@ import java.util.List; import java.util.ListIterator; import java.util.concurrent.TimeUnit; -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; /** * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> @@ -85,30 +86,30 @@ public class DocumentProcessingHandlerTransformingMessagesTestCase extends Docum { PutDocumentMessage message = new PutDocumentMessage(new DocumentPut(new Document(getType(), "id:nodocstatus:foo::put:to:put"))); Routable result = sendMessageAndGetResult(message); - assertThat(result, instanceOf(PutDocumentMessage.class)); + assertTrue(result instanceof PutDocumentMessage); PutDocumentMessage outputMsg = (PutDocumentMessage)result; - assertThat(outputMsg.getDocumentPut().getDocument().getFieldValue("foostring").toString(), is("banana")); + assertEquals("banana", outputMsg.getDocumentPut().getDocument().getFieldValue("foostring").toString()); } { PutDocumentMessage message = new PutDocumentMessage(new DocumentPut(new Document(getType(), "id:nodocstatus:foo::put:to:remove"))); Routable result = sendMessageAndGetResult(message); - assertThat(result, instanceOf(RemoveDocumentMessage.class)); + assertTrue(result instanceof RemoveDocumentMessage); RemoveDocumentMessage outputMsg = (RemoveDocumentMessage)result; - assertThat(outputMsg.getDocumentId().toString(), is("id:nodocstatus:foo::put:to:remove")); + assertEquals("id:nodocstatus:foo::put:to:remove", outputMsg.getDocumentId().toString()); } { PutDocumentMessage message = new PutDocumentMessage(new DocumentPut(new Document(getType(), "id:nodocstatus:foo::put:to:update"))); Routable result = sendMessageAndGetResult(message); - assertThat(result, instanceOf(UpdateDocumentMessage.class)); + assertTrue(result instanceof UpdateDocumentMessage); UpdateDocumentMessage outputMsg = (UpdateDocumentMessage)result; - assertThat(outputMsg.getDocumentUpdate().getId().toString(), is("id:nodocstatus:foo::put:to:update")); + assertEquals("id:nodocstatus:foo::put:to:update", outputMsg.getDocumentUpdate().getId().toString()); } { PutDocumentMessage message = new PutDocumentMessage(new DocumentPut(new Document(getType(), "id:nodocstatus:foo::put:to:nothing"))); assertTrue(sendMessage(FOOBAR, message)); Reply reply = driver.client().awaitReply(60, TimeUnit.SECONDS); assertNotNull(reply); - assertThat(reply, instanceOf(DocumentReply.class)); + assertTrue(reply instanceof DocumentReply); assertFalse(reply.hasErrors()); } } @@ -117,31 +118,31 @@ public class DocumentProcessingHandlerTransformingMessagesTestCase extends Docum { RemoveDocumentMessage message = new RemoveDocumentMessage(new DocumentId("id:nodocstatus:foo::remove:to:put")); Routable result = sendMessageAndGetResult(message); - assertThat(result, instanceOf(PutDocumentMessage.class)); + assertTrue(result instanceof PutDocumentMessage); PutDocumentMessage outputMsg = (PutDocumentMessage)result; - assertThat(outputMsg.getDocumentPut().getDocument().getId().toString(), is("id:nodocstatus:foo::remove:to:put")); + assertEquals("id:nodocstatus:foo::remove:to:put", outputMsg.getDocumentPut().getDocument().getId().toString()); } { RemoveDocumentMessage message = new RemoveDocumentMessage(new DocumentId("id:nodocstatus:foo::remove:to:remove")); Routable result = sendMessageAndGetResult(message); - assertThat(result, instanceOf(RemoveDocumentMessage.class)); + assertTrue(result instanceof RemoveDocumentMessage); RemoveDocumentMessage outputMsg = (RemoveDocumentMessage)result; - assertThat(outputMsg.getDocumentId().toString(), is("id:nodocstatus:foo::remove:to:remove")); + assertEquals("id:nodocstatus:foo::remove:to:remove", outputMsg.getDocumentId().toString()); } { RemoveDocumentMessage message = new RemoveDocumentMessage(new DocumentId("id:nodocstatus:foo::remove:to:update")); Routable result = sendMessageAndGetResult(message); - assertThat(result, instanceOf(UpdateDocumentMessage.class)); + assertTrue(result instanceof UpdateDocumentMessage); UpdateDocumentMessage outputMsg = (UpdateDocumentMessage)result; - assertThat(outputMsg.getDocumentUpdate().getId().toString(), is("id:nodocstatus:foo::remove:to:update")); + assertEquals("id:nodocstatus:foo::remove:to:update", outputMsg.getDocumentUpdate().getId().toString()); } { RemoveDocumentMessage message = new RemoveDocumentMessage(new DocumentId("id:nodocstatus:foo::remove:to:nothing")); assertTrue(sendMessage(FOOBAR, message)); Reply reply = driver.client().awaitReply(60, TimeUnit.SECONDS); assertNotNull(reply); - assertThat(reply, instanceOf(DocumentReply.class)); + assertTrue(reply instanceof DocumentReply); assertFalse(reply.hasErrors()); } } @@ -150,31 +151,31 @@ public class DocumentProcessingHandlerTransformingMessagesTestCase extends Docum { UpdateDocumentMessage message = new UpdateDocumentMessage(new DocumentUpdate(getType(), "id:nodocstatus:foo::update:to:put")); Routable result = sendMessageAndGetResult(message); - assertThat(result, instanceOf(PutDocumentMessage.class)); + assertTrue(result instanceof PutDocumentMessage); PutDocumentMessage outputMsg = (PutDocumentMessage)result; - assertThat(outputMsg.getDocumentPut().getDocument().getId().toString(), is("id:nodocstatus:foo::update:to:put")); + assertEquals("id:nodocstatus:foo::update:to:put", outputMsg.getDocumentPut().getDocument().getId().toString()); } { UpdateDocumentMessage message = new UpdateDocumentMessage(new DocumentUpdate(getType(), "id:nodocstatus:foo::update:to:remove")); Routable result = sendMessageAndGetResult(message); - assertThat(result, instanceOf(RemoveDocumentMessage.class)); + assertTrue(result instanceof RemoveDocumentMessage); RemoveDocumentMessage outputMsg = (RemoveDocumentMessage)result; - assertThat(outputMsg.getDocumentId().toString(), is("id:nodocstatus:foo::update:to:remove")); + assertEquals("id:nodocstatus:foo::update:to:remove", outputMsg.getDocumentId().toString()); } { UpdateDocumentMessage message = new UpdateDocumentMessage(new DocumentUpdate(getType(), "id:nodocstatus:foo::update:to:update")); Routable result = sendMessageAndGetResult(message); - assertThat(result, instanceOf(UpdateDocumentMessage.class)); + assertTrue(result instanceof UpdateDocumentMessage); UpdateDocumentMessage outputMsg = (UpdateDocumentMessage)result; - assertThat(outputMsg.getDocumentUpdate().getId().toString(), is("id:nodocstatus:foo::update:to:update")); + assertEquals("id:nodocstatus:foo::update:to:update", outputMsg.getDocumentUpdate().getId().toString()); } { UpdateDocumentMessage message = new UpdateDocumentMessage(new DocumentUpdate(getType(), "id:nodocstatus:foo::update:to:nothing")); assertTrue(sendMessage(FOOBAR, message)); Reply reply = driver.client().awaitReply(60, TimeUnit.SECONDS); assertNotNull(reply); - assertThat(reply, instanceOf(DocumentReply.class)); + assertTrue(reply instanceof DocumentReply); assertFalse(reply.hasErrors()); } } diff --git a/docproc/src/test/java/com/yahoo/docproc/util/SplitterJoinerTestCase.java b/docproc/src/test/java/com/yahoo/docproc/util/SplitterJoinerTestCase.java index c4f65987692..aa55d5b6a41 100644 --- a/docproc/src/test/java/com/yahoo/docproc/util/SplitterJoinerTestCase.java +++ b/docproc/src/test/java/com/yahoo/docproc/util/SplitterJoinerTestCase.java @@ -12,17 +12,15 @@ import com.yahoo.document.datatypes.Array; import com.yahoo.document.datatypes.StringFieldValue; import org.junit.Test; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.CoreMatchers.sameInstance; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; /** * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> */ -@SuppressWarnings({"unchecked","rawtypes"}) +@SuppressWarnings({"unchecked"}) public class SplitterJoinerTestCase { @Test @@ -40,7 +38,7 @@ public class SplitterJoinerTestCase { DocumentTypeManager manager = splitter.manager; - /**** Create documents: ****/ + // Create documents Document inner1 = new Document(manager.getDocumentType("docindoc"), "id:inner:docindoc::one"); inner1.setFieldValue("name", new StringFieldValue("Donald Duck")); @@ -56,17 +54,17 @@ public class SplitterJoinerTestCase { Document outer = new Document(manager.getDocumentType("outerdoc"), "id:outer:outerdoc::the:only:one"); outer.setFieldValue("innerdocuments", innerArray); - /**** End create documents ****/ + // End create documents Processing p = Processing.of(new DocumentPut(outer)); splitter.process(p); assertEquals(2, p.getDocumentOperations().size()); - assertThat(((DocumentPut)(p.getDocumentOperations().get(0))).getDocument(), sameInstance(inner1)); - assertThat(((DocumentPut)(p.getDocumentOperations().get(1))).getDocument(), sameInstance(inner2)); - assertThat(((DocumentPut)(p.getVariable(cfg.contextFieldName()))).getDocument(), sameInstance(outer)); - assertThat(outer.getFieldValue("innerdocuments"), sameInstance(innerArray)); + assertSame(inner1, ((DocumentPut)(p.getDocumentOperations().get(0))).getDocument()); + assertSame(inner2, ((DocumentPut)(p.getDocumentOperations().get(1))).getDocument()); + assertSame(outer, ((DocumentPut)(p.getVariable(cfg.contextFieldName()))).getDocument()); + assertSame(innerArray, outer.getFieldValue("innerdocuments")); assertTrue(innerArray.isEmpty()); @@ -74,13 +72,13 @@ public class SplitterJoinerTestCase { joiner.process(p); - assertThat(p.getDocumentOperations().size(), equalTo(1)); - assertThat(((DocumentPut)p.getDocumentOperations().get(0)).getDocument(), sameInstance(outer)); - assertThat(p.getVariable(cfg.contextFieldName()), nullValue()); - assertThat(outer.getFieldValue("innerdocuments"), sameInstance(innerArray)); - assertThat(innerArray.size(), equalTo(2)); - assertThat(innerArray.get(0), sameInstance(inner1)); - assertThat(innerArray.get(1), sameInstance(inner2)); + assertEquals(1, p.getDocumentOperations().size()); + assertSame(outer, ((DocumentPut)p.getDocumentOperations().get(0)).getDocument()); + assertNull(p.getVariable(cfg.contextFieldName())); + assertSame(innerArray, outer.getFieldValue("innerdocuments")); + assertEquals(2, innerArray.size()); + assertSame(inner1, innerArray.get(0)); + assertSame(inner2, innerArray.get(1)); } } diff --git a/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java b/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java index fea3b265b6d..a0c5da52ff7 100644 --- a/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java +++ b/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java @@ -16,10 +16,8 @@ import java.io.UnsupportedEncodingException; import java.util.regex.Pattern; import java.util.Arrays; -import static org.hamcrest.Matchers.containsString; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -227,7 +225,7 @@ public class DocumentIdTestCase { new DocumentId(strId); fail("Expected an IllegalArgumentException to be thrown"); } catch (IllegalArgumentException ex) { - assertThat(ex.getMessage(), containsString(exceptionMsg)); + assertTrue(ex.getMessage().contains(exceptionMsg)); } } @@ -254,7 +252,7 @@ public class DocumentIdTestCase { DocumentId.createFromSerialized(strId); fail("Expected an IllegalArgumentException to be thrown"); } catch (IllegalArgumentException ex) { - assertThat(ex.getMessage(), containsString("illegal zero byte code point")); + assertTrue(ex.getMessage().contains("illegal zero byte code point")); } } diff --git a/document/src/test/java/com/yahoo/document/DocumentRemoveTestCase.java b/document/src/test/java/com/yahoo/document/DocumentRemoveTestCase.java index 8b84dc5f46b..31093e8617b 100644 --- a/document/src/test/java/com/yahoo/document/DocumentRemoveTestCase.java +++ b/document/src/test/java/com/yahoo/document/DocumentRemoveTestCase.java @@ -3,10 +3,10 @@ package com.yahoo.document; import org.junit.Test; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; /** * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> @@ -18,7 +18,7 @@ public class DocumentRemoveTestCase { public void requireThatToStringWorks() { DocumentId docId = new DocumentId("id:this:is::a:test"); DocumentRemove r = new DocumentRemove(docId); - assertThat(r.toString().contains(docId.toString()), is(true)); + assertTrue(r.toString().contains(docId.toString())); } @Test @@ -27,18 +27,18 @@ public class DocumentRemoveTestCase { DocumentRemove r2 = new DocumentRemove(new DocumentId("id:this:is::a:test")); DocumentRemove r3 = new DocumentRemove(new DocumentId("id:this:is::nonequal")); - assertThat(r1, equalTo(r1)); - assertThat(r1, equalTo(r2)); - assertThat(r2, equalTo(r1)); - assertThat(r1.hashCode(), equalTo(r2.hashCode())); + assertEquals(r1, r1); + assertEquals(r1, r2); + assertEquals(r2, r1); + assertEquals(r1.hashCode(), r2.hashCode()); - assertThat(r1, not(equalTo(r3))); - assertThat(r3, not(equalTo(r1))); - assertThat(r2, not(equalTo(r3))); - assertThat(r3, not(equalTo(r2))); - assertThat(r1.hashCode(), not(equalTo(r3.hashCode()))); + assertNotEquals(r1, r3); + assertNotEquals(r3, r1); + assertNotEquals(r2, r3); + assertNotEquals(r3, r2); + assertNotEquals(r1.hashCode(), r3.hashCode()); - assertThat(r1, not(equalTo(new Object()))); - assertThat(r1.equals("banana"), is(false)); + assertNotEquals(r1, new Object()); + assertFalse(r1.equals("banana")); } } diff --git a/document/src/test/java/com/yahoo/document/DocumentTestCase.java b/document/src/test/java/com/yahoo/document/DocumentTestCase.java index be6544563ed..df1a56cf8e1 100644 --- a/document/src/test/java/com/yahoo/document/DocumentTestCase.java +++ b/document/src/test/java/com/yahoo/document/DocumentTestCase.java @@ -18,10 +18,8 @@ import com.yahoo.document.datatypes.Raw; import com.yahoo.document.datatypes.StringFieldValue; import com.yahoo.document.datatypes.Struct; import com.yahoo.document.datatypes.WeightedSet; -import com.yahoo.document.serialization.DocumentDeserializer; import com.yahoo.document.serialization.DocumentDeserializerFactory; import com.yahoo.document.serialization.DocumentReader; -import com.yahoo.document.serialization.DocumentSerializer; import com.yahoo.document.serialization.DocumentSerializerFactory; import com.yahoo.document.serialization.XmlDocumentWriter; import com.yahoo.io.GrowableByteBuffer; @@ -33,15 +31,13 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; +import java.util.Arrays; import java.util.Map; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.Matchers.instanceOf; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -1083,15 +1079,14 @@ public class DocumentTestCase extends DocumentTestCaseBase { Map<String, Object> parsed = new ObjectMapper().readValue(json, new TypeReference<Map<String, Object>>() { }); assertEquals(parsed.get("id"), "id:ns:sertest::foobar"); - assertThat(parsed.get("fields"), instanceOf(Map.class)); + assertTrue(parsed.get("fields") instanceof Map); Object fieldMap = parsed.get("fields"); if (fieldMap instanceof Map) { Map<?, ?> fields = (Map<?, ?>) fieldMap; assertEquals(fields.get("mailid"), "emailfromalicetobob"); assertEquals(fields.get("date"), -2013512400); - assertThat(fields.get("docindoc"), instanceOf(Map.class)); - assertThat(fields.keySet(), - containsInAnyOrder("mailid", "date", "attachmentcount", "rawfield", "weightedfield", "docindoc", "mapfield", "myboolfield")); + assertTrue(fields.get("docindoc") instanceof Map); + assertTrue(fields.keySet().containsAll(Arrays.asList("mailid", "date", "attachmentcount", "rawfield", "weightedfield", "docindoc", "mapfield", "myboolfield"))); } } diff --git a/document/src/test/java/com/yahoo/document/DocumentTypeIdTestCase.java b/document/src/test/java/com/yahoo/document/DocumentTypeIdTestCase.java index 16f757d4379..c425ebea2c2 100644 --- a/document/src/test/java/com/yahoo/document/DocumentTypeIdTestCase.java +++ b/document/src/test/java/com/yahoo/document/DocumentTypeIdTestCase.java @@ -3,10 +3,10 @@ package com.yahoo.document; import org.junit.Test; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; /** * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> @@ -17,7 +17,7 @@ public class DocumentTypeIdTestCase { @Test public void requireThatToStringWorks() { DocumentTypeId r = new DocumentTypeId(123); - assertThat(r.toString().contains("123"), is(true)); + assertTrue(r.toString().contains("123")); } @Test @@ -26,24 +26,24 @@ public class DocumentTypeIdTestCase { DocumentTypeId r2 = new DocumentTypeId(123); DocumentTypeId r3 = new DocumentTypeId(456); - assertThat(r1, equalTo(r1)); - assertThat(r1, equalTo(r2)); - assertThat(r2, equalTo(r1)); - assertThat(r1.hashCode(), equalTo(r2.hashCode())); + assertEquals(r1, r1); + assertEquals(r1, r2); + assertEquals(r2, r1); + assertEquals(r1.hashCode(), r2.hashCode()); - assertThat(r1, not(equalTo(r3))); - assertThat(r3, not(equalTo(r1))); - assertThat(r2, not(equalTo(r3))); - assertThat(r3, not(equalTo(r2))); - assertThat(r1.hashCode(), not(equalTo(r3.hashCode()))); + assertNotEquals(r1, r3); + assertNotEquals(r3, r1); + assertNotEquals(r2, r3); + assertNotEquals(r3, r2); + assertNotEquals(r1.hashCode(), r3.hashCode()); - assertThat(r1, not(equalTo(new Object()))); - assertThat(r1.equals("foobar"), is(false)); + assertNotEquals(r1, new Object()); + assertFalse(r1.equals("foobar")); } @Test public void requireThatAccessorsWork() { DocumentTypeId r1 = new DocumentTypeId(123); - assertThat(r1.getId(), equalTo(123)); + assertEquals(123, r1.getId()); } } diff --git a/document/src/test/java/com/yahoo/document/FieldPathEntryTestCase.java b/document/src/test/java/com/yahoo/document/FieldPathEntryTestCase.java index 059d65f88f8..791310ee6f2 100644 --- a/document/src/test/java/com/yahoo/document/FieldPathEntryTestCase.java +++ b/document/src/test/java/com/yahoo/document/FieldPathEntryTestCase.java @@ -3,9 +3,8 @@ package com.yahoo.document; import org.junit.Test; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.not; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; /** * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> @@ -20,19 +19,19 @@ public class FieldPathEntryTestCase { FieldPathEntry.KeyParseResult result4 = new FieldPathEntry.KeyParseResult("banana", 3); - assertThat(result1, equalTo(result2)); - assertThat(result2, equalTo(result1)); - assertThat(result1.hashCode(), equalTo(result2.hashCode())); - assertThat(result1.toString(), equalTo(result2.toString())); + assertEquals(result1, result2); + assertEquals(result2, result1); + assertEquals(result1.hashCode(), result2.hashCode()); + assertEquals(result1.toString(), result2.toString()); - assertThat(result1, not(equalTo(result3))); - assertThat(result3, not(equalTo(result1))); - assertThat(result1.hashCode(), not(equalTo(result3.hashCode()))); - assertThat(result1.toString(), not(equalTo(result3.toString()))); + assertNotEquals(result1, result3); + assertNotEquals(result3, result1); + assertNotEquals(result1.hashCode(), result3.hashCode()); + assertNotEquals(result1.toString(), result3.toString()); - assertThat(result1, not(equalTo(result4))); - assertThat(result4, not(equalTo(result1))); - assertThat(result1.hashCode(), not(equalTo(result4.hashCode()))); - assertThat(result1.toString(), not(equalTo(result4.toString()))); + assertNotEquals(result1, result4); + assertNotEquals(result4, result1); + assertNotEquals(result1.hashCode(), result4.hashCode()); + assertNotEquals(result1.toString(), result4.toString()); } } diff --git a/document/src/test/java/com/yahoo/document/NumericDataTypeTestCase.java b/document/src/test/java/com/yahoo/document/NumericDataTypeTestCase.java index 05f68570e60..28f6f682755 100644 --- a/document/src/test/java/com/yahoo/document/NumericDataTypeTestCase.java +++ b/document/src/test/java/com/yahoo/document/NumericDataTypeTestCase.java @@ -5,8 +5,9 @@ import com.yahoo.document.datatypes.FieldValue; import com.yahoo.document.datatypes.IntegerFieldValue; import org.junit.Test; -import static org.hamcrest.CoreMatchers.*; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.fail; /** * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> @@ -18,8 +19,8 @@ public class NumericDataTypeTestCase { public void basic() { NumericDataType type = new NumericDataType("foo", 0, FieldValue.class, IntegerFieldValue.getFactory()); NumericDataType clonedType = type.clone(); - assertThat(type, equalTo(clonedType)); - assertThat(type, not(sameInstance(clonedType))); + assertEquals(type,clonedType); + assertNotSame(type, clonedType); } @Test diff --git a/document/src/test/java/com/yahoo/document/TemporaryDataTypeTestCase.java b/document/src/test/java/com/yahoo/document/TemporaryDataTypeTestCase.java index 4a4895b7e78..663ea96f40f 100644 --- a/document/src/test/java/com/yahoo/document/TemporaryDataTypeTestCase.java +++ b/document/src/test/java/com/yahoo/document/TemporaryDataTypeTestCase.java @@ -4,9 +4,8 @@ package com.yahoo.document; import com.yahoo.document.datatypes.StringFieldValue; import org.junit.Test; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; /** * @author Einar M R Rosenvinge @@ -16,10 +15,10 @@ public class TemporaryDataTypeTestCase { @Test public void requireNulls() { TemporaryDataType type = new TemporaryDataType(0, ""); - assertThat(type.createFieldValue(new Object()), nullValue()); - assertThat(type.createFieldValue(), nullValue()); - assertThat(type.getValueClass(), nullValue()); - assertThat(type.isValueCompatible(new StringFieldValue("")), is(false)); + assertNull(type.createFieldValue(new Object())); + assertNull(type.createFieldValue()); + assertNull(type.getValueClass()); + assertFalse(type.isValueCompatible(new StringFieldValue(""))); } } diff --git a/document/src/test/java/com/yahoo/document/TemporaryStructuredDataTypeTestCase.java b/document/src/test/java/com/yahoo/document/TemporaryStructuredDataTypeTestCase.java index d785faa146a..431d4d9746c 100644 --- a/document/src/test/java/com/yahoo/document/TemporaryStructuredDataTypeTestCase.java +++ b/document/src/test/java/com/yahoo/document/TemporaryStructuredDataTypeTestCase.java @@ -3,9 +3,8 @@ package com.yahoo.document; import org.junit.Test; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.CoreMatchers.not; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; /** * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> @@ -15,10 +14,10 @@ public class TemporaryStructuredDataTypeTestCase { @Test public void basic() { TemporaryStructuredDataType type = TemporaryStructuredDataType.create("banana"); - assertThat(type.getName(), equalTo("banana")); + assertEquals("banana", type.getName()); int originalId = type.getId(); type.setName("apple"); - assertThat(type.getName(), equalTo("apple")); - assertThat(originalId, not(equalTo(type.getId()))); + assertEquals("apple", type.getName()); + assertNotEquals(originalId, type.getId()); } } diff --git a/document/src/test/java/com/yahoo/document/annotation/Bug4475379TestCase.java b/document/src/test/java/com/yahoo/document/annotation/Bug4475379TestCase.java index 6ca076ad3c6..3d2a1fd2d90 100755 --- a/document/src/test/java/com/yahoo/document/annotation/Bug4475379TestCase.java +++ b/document/src/test/java/com/yahoo/document/annotation/Bug4475379TestCase.java @@ -13,8 +13,7 @@ import org.junit.Test; import java.util.ArrayList; import java.util.List; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; /** * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> @@ -32,7 +31,7 @@ public class Bug4475379TestCase { annotate(manager, doc); Document anotherDoc = doc.clone(); - assertThat(doc, equalTo(anotherDoc)); + assertEquals(doc, anotherDoc); } public void annotate(DocumentTypeManager manager, Document document) { diff --git a/document/src/test/java/com/yahoo/document/annotation/DummySpanNodeTestCase.java b/document/src/test/java/com/yahoo/document/annotation/DummySpanNodeTestCase.java index d2c35f45ad8..3566117b33d 100644 --- a/document/src/test/java/com/yahoo/document/annotation/DummySpanNodeTestCase.java +++ b/document/src/test/java/com/yahoo/document/annotation/DummySpanNodeTestCase.java @@ -3,9 +3,10 @@ package com.yahoo.document.annotation; import org.junit.Test; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; /** * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> @@ -16,14 +17,14 @@ public class DummySpanNodeTestCase { @Test public void basic() { DummySpanNode node = DummySpanNode.INSTANCE; - assertThat(node.getFrom(), is(0)); - assertThat(node.getTo(), is(0)); - assertThat(node.getLength(), is(0)); - assertThat(node.getText("baba"), nullValue()); - assertThat(node.isLeafNode(), is(true)); - assertThat(node.childIterator().hasNext(), is(false)); - assertThat(node.childIterator().hasPrevious(), is(false)); - assertThat(node.childIteratorRecursive().hasNext(), is(false)); - assertThat(node.childIteratorRecursive().hasPrevious(), is(false)); + assertEquals(0, node.getFrom()); + assertEquals(0, node.getTo()); + assertEquals(0, node.getLength()); + assertNull(node.getText("baba")); + assertTrue(node.isLeafNode()); + assertFalse(node.childIterator().hasNext()); + assertFalse(node.childIterator().hasPrevious()); + assertFalse(node.childIteratorRecursive().hasNext()); + assertFalse(node.childIteratorRecursive().hasPrevious()); } } diff --git a/document/src/test/java/com/yahoo/document/annotation/IndexKeySpanTreeTestCase.java b/document/src/test/java/com/yahoo/document/annotation/IndexKeySpanTreeTestCase.java index 3b403680577..8c5a481764d 100644 --- a/document/src/test/java/com/yahoo/document/annotation/IndexKeySpanTreeTestCase.java +++ b/document/src/test/java/com/yahoo/document/annotation/IndexKeySpanTreeTestCase.java @@ -3,8 +3,8 @@ package com.yahoo.document.annotation; import org.junit.Test; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; /** * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> @@ -14,27 +14,27 @@ public class IndexKeySpanTreeTestCase { @Test public void testIndexKeys() throws Exception { SpanTree tree = new SpanTree("something"); - assertThat(tree.getCurrentIndexes().isEmpty(), is(true)); + assertTrue(tree.getCurrentIndexes().isEmpty()); tree.createIndex(SpanTree.IndexKey.SPAN_NODE); - assertThat(tree.getCurrentIndexes().size(), is(1)); - assertThat(tree.getCurrentIndexes().iterator().next(), is(SpanTree.IndexKey.SPAN_NODE)); + assertEquals(1, tree.getCurrentIndexes().size()); + assertEquals(SpanTree.IndexKey.SPAN_NODE, tree.getCurrentIndexes().iterator().next()); tree.clearIndexes(); - assertThat(tree.getCurrentIndexes().isEmpty(), is(true)); + assertTrue(tree.getCurrentIndexes().isEmpty()); tree.createIndex(SpanTree.IndexKey.ANNOTATION_TYPE); - assertThat(tree.getCurrentIndexes().size(), is(1)); - assertThat(tree.getCurrentIndexes().iterator().next(), is(SpanTree.IndexKey.ANNOTATION_TYPE)); + assertEquals(1, tree.getCurrentIndexes().size()); + assertEquals(SpanTree.IndexKey.ANNOTATION_TYPE, tree.getCurrentIndexes().iterator().next()); tree.clearIndexes(); - assertThat(tree.getCurrentIndexes().isEmpty(), is(true)); + assertTrue(tree.getCurrentIndexes().isEmpty()); } @Test(expected = IllegalArgumentException.class) public void testSwitchIndexes() { SpanTree tree = new SpanTree("something"); - assertThat(tree.getCurrentIndexes().isEmpty(), is(true)); + assertTrue(tree.getCurrentIndexes().isEmpty()); tree.createIndex(SpanTree.IndexKey.SPAN_NODE); tree.createIndex(SpanTree.IndexKey.ANNOTATION_TYPE); } @@ -42,7 +42,7 @@ public class IndexKeySpanTreeTestCase { @Test(expected = IllegalArgumentException.class) public void testSwitchIndexes2() { SpanTree tree = new SpanTree("something"); - assertThat(tree.getCurrentIndexes().isEmpty(), is(true)); + assertTrue(tree.getCurrentIndexes().isEmpty()); tree.createIndex(SpanTree.IndexKey.ANNOTATION_TYPE); tree.createIndex(SpanTree.IndexKey.SPAN_NODE); } @@ -50,7 +50,7 @@ public class IndexKeySpanTreeTestCase { @Test public void testSwitchIndexes3() { SpanTree tree = new SpanTree("something"); - assertThat(tree.getCurrentIndexes().isEmpty(), is(true)); + assertTrue(tree.getCurrentIndexes().isEmpty()); tree.createIndex(SpanTree.IndexKey.ANNOTATION_TYPE); tree.clearIndex(SpanTree.IndexKey.SPAN_NODE); } diff --git a/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java b/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java index c191851acbe..522176d7504 100644 --- a/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java +++ b/document/src/test/java/com/yahoo/document/json/JsonReaderTestCase.java @@ -79,13 +79,10 @@ import static com.yahoo.document.json.readers.SingleValueReader.UPDATE_DIVIDE; import static com.yahoo.document.json.readers.SingleValueReader.UPDATE_INCREMENT; import static com.yahoo.document.json.readers.SingleValueReader.UPDATE_MULTIPLY; import static com.yahoo.test.json.JsonTestHelper.inputJson; -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -797,8 +794,8 @@ public class JsonReaderTestCase { d = r.next(); DocumentUpdate update = (DocumentUpdate) d; checkSimpleArrayAdd(update); - assertThat(update.getCreateIfNonExistent(), is(true)); - assertThat(update.getCondition().getSelection(), is("bla")); + assertTrue(update.getCreateIfNonExistent()); + assertEquals("bla", update.getCondition().getSelection()); d = r.next(); DocumentRemove remove = (DocumentRemove) d; @@ -833,8 +830,8 @@ public class JsonReaderTestCase { for (int x = 0; x < documentsCreated; x++) { DocumentUpdate update = (DocumentUpdate) r.next(); checkSimpleArrayAdd(update); - assertThat(update.getCreateIfNonExistent(), is(true)); - assertThat(update.getCondition().getSelection(), is("bla")); + assertTrue(update.getCreateIfNonExistent()); + assertEquals("bla", update.getCondition().getSelection()); } @@ -1780,7 +1777,7 @@ public class JsonReaderTestCase { @Test public void requireThatUnknownDocTypeThrowsIllegalArgumentException() { exception.expect(IllegalArgumentException.class); - exception.expectMessage(containsString("Document type walrus does not exist")); + exception.expectMessage("Document type walrus does not exist"); final String jsonData = inputJson( "[", @@ -1962,7 +1959,7 @@ public class JsonReaderTestCase { // NOTE: Do not call this method multiple times from a test method as it's using the ExpectedException rule private void assertParserErrorMatches(String expectedError, String... json) { exception.expect(JsonReaderException.class); - exception.expectMessage(containsString(expectedError)); + exception.expectMessage(expectedError); String jsonData = inputJson(json); new JsonReader(types, jsonToInputStream(jsonData), parserFactory).next(); } diff --git a/document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java b/document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java index d1f02ae45e2..feeac3d9da0 100644 --- a/document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java +++ b/document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java @@ -1,8 +1,28 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.document.select; -import com.yahoo.document.*; -import com.yahoo.document.datatypes.*; +import com.yahoo.document.ArrayDataType; +import com.yahoo.document.DataType; +import com.yahoo.document.Document; +import com.yahoo.document.DocumentGet; +import com.yahoo.document.DocumentId; +import com.yahoo.document.DocumentOperation; +import com.yahoo.document.DocumentPut; +import com.yahoo.document.DocumentRemove; +import com.yahoo.document.DocumentType; +import com.yahoo.document.DocumentTypeManager; +import com.yahoo.document.DocumentUpdate; +import com.yahoo.document.Field; +import com.yahoo.document.MapDataType; +import com.yahoo.document.StructDataType; +import com.yahoo.document.WeightedSetDataType; +import com.yahoo.document.datatypes.Array; +import com.yahoo.document.datatypes.FloatFieldValue; +import com.yahoo.document.datatypes.IntegerFieldValue; +import com.yahoo.document.datatypes.MapFieldValue; +import com.yahoo.document.datatypes.StringFieldValue; +import com.yahoo.document.datatypes.Struct; +import com.yahoo.document.datatypes.WeightedSet; import com.yahoo.document.select.convert.SelectionExpressionConverter; import com.yahoo.document.select.parser.ParseException; import com.yahoo.document.select.parser.TokenMgrException; @@ -32,7 +52,7 @@ public class DocumentSelectorTestCase { @Rule public final ExpectedException exceptionRule = ExpectedException.none(); - private static DocumentTypeManager manager = new DocumentTypeManager(); + private static final DocumentTypeManager manager = new DocumentTypeManager(); @Before public void setUp() { diff --git a/document/src/test/java/com/yahoo/vespaxmlparser/XMLNumericFieldErrorMsgTestCase.java b/document/src/test/java/com/yahoo/vespaxmlparser/XMLNumericFieldErrorMsgTestCase.java index 298960ff8ba..3c93dc1429d 100644 --- a/document/src/test/java/com/yahoo/vespaxmlparser/XMLNumericFieldErrorMsgTestCase.java +++ b/document/src/test/java/com/yahoo/vespaxmlparser/XMLNumericFieldErrorMsgTestCase.java @@ -11,8 +11,7 @@ import org.junit.Test; import java.io.ByteArrayInputStream; import java.nio.charset.StandardCharsets; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; /** @@ -44,7 +43,7 @@ public class XMLNumericFieldErrorMsgTestCase { new Document(documentReader); fail("Sorry mac"); } catch (DeserializationException e) { - assertThat(e.getMessage(), e.getMessage().contains("Field 'floatfield': Invalid float \"\""), is(true)); + assertTrue(e.getMessage().contains("Field 'floatfield': Invalid float \"\"")); } } @@ -59,7 +58,7 @@ public class XMLNumericFieldErrorMsgTestCase { new Document(documentReader); fail("Sorry mac"); } catch (DeserializationException e) { - assertThat(e.getMessage(), e.getMessage().contains("Field 'doublefield': Invalid double \"\""), is(true)); + assertTrue(e.getMessage().contains("Field 'doublefield': Invalid double \"\"")); } } @@ -74,7 +73,7 @@ public class XMLNumericFieldErrorMsgTestCase { new Document(documentReader); fail("Sorry mac"); } catch (DeserializationException e) { - assertThat(e.getMessage(), e.getMessage().contains("Field 'longfield': Invalid long \"\""), is(true)); + assertTrue(e.getMessage().contains("Field 'longfield': Invalid long \"\"")); } } @@ -89,7 +88,7 @@ public class XMLNumericFieldErrorMsgTestCase { new Document(documentReader); fail("Sorry mac"); } catch (DeserializationException e) { - assertThat(e.getMessage(), e.getMessage().contains("Field 'intfield': Invalid integer \"\""), is(true)); + assertTrue(e.getMessage().contains("Field 'intfield': Invalid integer \"\"")); } } @@ -104,7 +103,7 @@ public class XMLNumericFieldErrorMsgTestCase { new Document(documentReader); fail("Sorry mac"); } catch (DeserializationException e) { - assertThat(e.getMessage(), e.getMessage().contains("Field 'bytefield': Invalid byte \"\""), is(true)); + assertTrue(e.getMessage().contains("Field 'bytefield': Invalid byte \"\"")); } } diff --git a/documentapi/src/test/java/com/yahoo/documentapi/VisitorDataQueueTest.java b/documentapi/src/test/java/com/yahoo/documentapi/VisitorDataQueueTest.java index 7cd8cf05c8e..93e7b2cf309 100644 --- a/documentapi/src/test/java/com/yahoo/documentapi/VisitorDataQueueTest.java +++ b/documentapi/src/test/java/com/yahoo/documentapi/VisitorDataQueueTest.java @@ -13,12 +13,11 @@ import com.yahoo.documentapi.messagebus.protocol.RemoveDocumentMessage; import org.junit.Before; import org.junit.Test; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.core.IsNull.notNullValue; -import static org.hamcrest.core.IsNull.nullValue; -import static org.hamcrest.core.IsInstanceOf.instanceOf; -import static org.hamcrest.core.Is.is; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; public class VisitorDataQueueTest { @@ -42,14 +41,14 @@ public class VisitorDataQueueTest { } private static void assertNonNullDocumentOpResponse(final VisitorResponse response) { - assertThat(response, notNullValue()); - assertThat(response, instanceOf(DocumentOpVisitorResponse.class)); + assertNotNull(response); + assertTrue(response instanceof DocumentOpVisitorResponse); } private static void assertResponseHasSinglePut(final VisitorResponse response, final DocumentPut expectedInstance) { assertNonNullDocumentOpResponse(response); final DocumentOpVisitorResponse visitorResponse = (DocumentOpVisitorResponse)response; - assertThat(visitorResponse.getDocumentOperation(), is(expectedInstance)); + assertSame(expectedInstance, visitorResponse.getDocumentOperation()); } @Test @@ -60,7 +59,7 @@ public class VisitorDataQueueTest { final VisitorResponse response = queue.getNext(); assertResponseHasSinglePut(response, putMessage.getDocumentPut()); - assertThat(queue.getNext(), nullValue()); // Queue now empty + assertNull(queue.getNext()); // Queue now empty } @Test @@ -71,14 +70,14 @@ public class VisitorDataQueueTest { final VisitorResponse response = queue.getNext(1000); assertResponseHasSinglePut(response, putMessage.getDocumentPut()); - assertThat(queue.getNext(), nullValue()); // Queue now empty + assertNull(queue.getNext()); // Queue now empty } private static void assertResponseHasSingleRemove(final VisitorResponse response, final String docId) { assertNonNullDocumentOpResponse(response); final DocumentOpVisitorResponse visitorResponse = (DocumentOpVisitorResponse)response; - assertThat(visitorResponse.getDocumentOperation(), instanceOf(DocumentRemove.class)); - assertThat(visitorResponse.getDocumentOperation().getId(), equalTo(new DocumentId(docId))); + assertTrue(visitorResponse.getDocumentOperation() instanceof DocumentRemove); + assertEquals(new DocumentId(docId), visitorResponse.getDocumentOperation().getId()); } @Test diff --git a/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/ReplyMergerTestCase.java b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/ReplyMergerTestCase.java index 7f0ede0db70..9172752760d 100644 --- a/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/ReplyMergerTestCase.java +++ b/documentapi/src/test/java/com/yahoo/documentapi/messagebus/protocol/ReplyMergerTestCase.java @@ -2,14 +2,18 @@ package com.yahoo.documentapi.messagebus.protocol; import com.yahoo.collections.Tuple2; -import com.yahoo.messagebus.*; +import com.yahoo.messagebus.EmptyReply; import com.yahoo.messagebus.Error; +import com.yahoo.messagebus.Reply; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.*; -import static org.hamcrest.CoreMatchers.*; -@SuppressWarnings("deprecation") +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + public class ReplyMergerTestCase { private ReplyMerger merger; @@ -29,8 +33,8 @@ public class ReplyMergerTestCase { merger.merge(2, r3); Tuple2<Integer, Reply> ret = merger.mergedReply(); - assertThat(ret.first, is(0)); - assertThat(ret.second, sameInstance(r1)); + assertEquals(0, ret.first.intValue()); + assertSame(r1, ret.second); } @Test @@ -41,8 +45,8 @@ public class ReplyMergerTestCase { merger.merge(0, r1); Tuple2<Integer, Reply> ret = merger.mergedReply(); - assertThat(ret.first, nullValue()); - assertThat(ret.second, not(sameInstance(r1))); + assertNull(ret.first); + assertNotSame(r1, ret.second); assertThatErrorsMatch(new Error[] { error }, ret); } @@ -57,8 +61,8 @@ public class ReplyMergerTestCase { merger.merge(0, r1); Tuple2<Integer, Reply> ret = merger.mergedReply(); - assertThat(ret.first, nullValue()); - assertThat(ret.second, not(sameInstance(r1))); + assertNull(ret.first); + assertNotSame(r1, ret.second); assertThatErrorsMatch(errors, ret); } @@ -76,9 +80,9 @@ public class ReplyMergerTestCase { merger.merge(1, r2); Tuple2<Integer, Reply> ret = merger.mergedReply(); - assertThat(ret.first, nullValue()); - assertThat(ret.second, not(sameInstance(r1))); - assertThat(ret.second, not(sameInstance(r2))); + assertNull(ret.first); + assertNotSame(r1, ret.second); + assertNotSame(r2, ret.second); assertThatErrorsMatch(errors, ret); } @@ -98,9 +102,9 @@ public class ReplyMergerTestCase { merger.merge(0, r1); merger.merge(1, r2); Tuple2<Integer, Reply> ret = merger.mergedReply(); - assertThat(ret.first, nullValue()); - assertThat(ret.second, not(sameInstance(r1))); - assertThat(ret.second, not(sameInstance(r2))); + assertNull(ret.first); + assertNotSame(r1, ret.second); + assertNotSame(r2, ret.second); // Only first ignore error from each reply assertThatErrorsMatch(new Error[]{ errors[0], errors[2] }, ret); } @@ -116,8 +120,8 @@ public class ReplyMergerTestCase { merger.merge(0, r1); merger.merge(1, r2); Tuple2<Integer, Reply> ret = merger.mergedReply(); - assertThat(ret.first, is(1)); - assertThat(ret.second, sameInstance(r2)); + assertEquals(1, ret.first.intValue()); + assertSame(r2, ret.second); // Only first ignore error from each reply assertThatErrorsMatch(new Error[]{ }, ret); } @@ -138,9 +142,9 @@ public class ReplyMergerTestCase { merger.merge(0, r1); merger.merge(1, r2); Tuple2<Integer, Reply> ret = merger.mergedReply(); - assertThat(ret.first, nullValue()); - assertThat(ret.second, not(sameInstance(r1))); - assertThat(ret.second, not(sameInstance(r2))); + assertNull(ret.first); + assertNotSame(r1, ret.second); + assertNotSame(r2, ret.second); // All errors from replies with errors are included, not those that // are fully ignored. assertThatErrorsMatch(new Error[]{ errors[0], errors[1] }, ret); @@ -159,8 +163,8 @@ public class ReplyMergerTestCase { merger.merge(1, r2); merger.merge(2, r3); Tuple2<Integer, Reply> ret = merger.mergedReply(); - assertThat(ret.first, is(1)); - assertThat(ret.second, sameInstance((Reply) r2)); + assertEquals(1, ret.first.intValue()); + assertSame(r2, ret.second); } @Test @@ -173,8 +177,8 @@ public class ReplyMergerTestCase { merger.merge(0, r1); merger.merge(1, r2); Tuple2<Integer, Reply> ret = merger.mergedReply(); - assertThat(ret.first, is(0)); - assertThat(ret.second, sameInstance((Reply)r1)); + assertEquals(0, ret.first.intValue()); + assertSame(r1, ret.second); } @Test @@ -190,8 +194,8 @@ public class ReplyMergerTestCase { merger.merge(1, r2); merger.merge(2, r3); Tuple2<Integer, Reply> ret = merger.mergedReply(); - assertThat(ret.first, is(1)); - assertThat(ret.second, sameInstance((Reply)r2)); + assertEquals(1, ret.first.intValue()); + assertSame(r2, ret.second); } @Test @@ -205,23 +209,23 @@ public class ReplyMergerTestCase { merger.merge(1, r2); merger.merge(2, r3); Tuple2<Integer, Reply> ret = merger.mergedReply(); - assertThat(ret.first, is(1)); - assertThat(ret.second, sameInstance((Reply)r2)); + assertEquals(1, ret.first.intValue()); + assertSame(r2, ret.second); } @Test public void mergingZeroRepliesReturnsDefaultEmptyReply() { Tuple2<Integer, Reply> ret = merger.mergedReply(); - assertThat(ret.first, nullValue()); - assertThat(ret.second, instanceOf(EmptyReply.class)); + assertNull(ret.first); + assertTrue(ret.second instanceof EmptyReply); assertThatErrorsMatch(new Error[]{}, ret); } private void assertThatErrorsMatch(Error[] errors, Tuple2<Integer, Reply> ret) { - assertThat(ret.second.getNumErrors(), is(errors.length)); + assertEquals(errors.length, ret.second.getNumErrors()); for (int i = 0; i < ret.second.getNumErrors(); ++i) { - assertThat(ret.second.getError(i).getCode(), is(errors[i].getCode())); - assertThat(ret.second.getError(i).getMessage(), is(errors[i].getMessage())); + assertEquals(errors[i].getCode(), ret.second.getError(i).getCode()); + assertEquals(errors[i].getMessage(), ret.second.getError(i).getMessage()); } } diff --git a/messagebus/pom.xml b/messagebus/pom.xml index 358ce7cc63f..9bd123ad6bd 100644 --- a/messagebus/pom.xml +++ b/messagebus/pom.xml @@ -20,12 +20,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-all</artifactId> - <version>1.3</version> - <scope>test</scope> - </dependency> - <dependency> <groupId>com.yahoo.vespa</groupId> <artifactId>vespajlib</artifactId> <version>${project.version}</version> diff --git a/messagebus/src/test/java/com/yahoo/messagebus/network/local/LocalNetworkTest.java b/messagebus/src/test/java/com/yahoo/messagebus/network/local/LocalNetworkTest.java index e2706a66671..aec38e7d157 100644 --- a/messagebus/src/test/java/com/yahoo/messagebus/network/local/LocalNetworkTest.java +++ b/messagebus/src/test/java/com/yahoo/messagebus/network/local/LocalNetworkTest.java @@ -2,7 +2,23 @@ package com.yahoo.messagebus.network.local; import com.yahoo.concurrent.SystemTimer; -import com.yahoo.messagebus.*; +import com.yahoo.messagebus.DestinationSession; +import com.yahoo.messagebus.DestinationSessionParams; +import com.yahoo.messagebus.EmptyReply; +import com.yahoo.messagebus.ErrorCode; +import com.yahoo.messagebus.IntermediateSession; +import com.yahoo.messagebus.IntermediateSessionParams; +import com.yahoo.messagebus.Message; +import com.yahoo.messagebus.MessageBus; +import com.yahoo.messagebus.MessageBusParams; +import com.yahoo.messagebus.MessageHandler; +import com.yahoo.messagebus.Reply; +import com.yahoo.messagebus.ReplyHandler; +import com.yahoo.messagebus.Result; +import com.yahoo.messagebus.SourceSession; +import com.yahoo.messagebus.SourceSessionParams; +import com.yahoo.messagebus.StaticThrottlePolicy; +import com.yahoo.messagebus.ThrottlePolicy; import com.yahoo.messagebus.routing.Hop; import com.yahoo.messagebus.routing.Route; import com.yahoo.messagebus.test.SimpleMessage; @@ -14,12 +30,8 @@ import java.util.concurrent.BlockingDeque; import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.TimeUnit; -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.number.OrderingComparison.lessThan; -import static org.hamcrest.number.OrderingComparison.greaterThanOrEqualTo; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** @@ -43,28 +55,28 @@ public class LocalNetworkTest { Message msg = new SimpleMessage("foo"); msg.setRoute(new Route().addHop(Hop.parse(intermediate.getConnectionSpec())) .addHop(Hop.parse(destination.getConnectionSpec()))); - assertThat(source.send(msg).isAccepted(), is(true)); + assertTrue(source.send(msg).isAccepted()); msg = serverB.messages.poll(60, TimeUnit.SECONDS); - assertThat(msg, instanceOf(SimpleMessage.class)); - assertThat(((SimpleMessage)msg).getValue(), is("foo")); + assertTrue(msg instanceof SimpleMessage); + assertEquals("foo", ((SimpleMessage)msg).getValue()); intermediate.forward(msg); msg = serverC.messages.poll(60, TimeUnit.SECONDS); - assertThat(msg, instanceOf(SimpleMessage.class)); - assertThat(((SimpleMessage)msg).getValue(), is("foo")); + assertTrue(msg instanceof SimpleMessage); + assertEquals("foo", ((SimpleMessage)msg).getValue()); Reply reply = new SimpleReply("bar"); reply.swapState(msg); destination.reply(reply); reply = serverB.replies.poll(60, TimeUnit.SECONDS); - assertThat(reply, instanceOf(SimpleReply.class)); - assertThat(((SimpleReply)reply).getValue(), is("bar")); + assertTrue(reply instanceof SimpleReply); + assertEquals("bar", ((SimpleReply)reply).getValue()); intermediate.forward(reply); reply = serverA.replies.poll(60, TimeUnit.SECONDS); - assertThat(reply, instanceOf(SimpleReply.class)); - assertThat(((SimpleReply)reply).getValue(), is("bar")); + assertTrue(reply instanceof SimpleReply); + assertEquals("bar", ((SimpleReply)reply).getValue()); serverA.mbus.destroy(); serverB.mbus.destroy(); @@ -77,9 +89,9 @@ public class LocalNetworkTest { final SourceSession source = server.newSourceSession(); final Message msg = new SimpleMessage("foo").setRoute(Route.parse("bar")); - assertThat(source.send(msg).isAccepted(), is(true)); + assertTrue(source.send(msg).isAccepted()); final Reply reply = server.replies.poll(60, TimeUnit.SECONDS); - assertThat(reply, instanceOf(EmptyReply.class)); + assertTrue(reply instanceof EmptyReply); server.mbus.destroy(); } @@ -100,7 +112,7 @@ public class LocalNetworkTest { Message msg = new SimpleMessage("foo"); msg.setRoute(new Route().addHop(Hop.parse(intermediate.getConnectionSpec())) .addHop(Hop.parse(destination.getConnectionSpec()))); - assertThat(source.sendBlocking(msg).isAccepted(), is(true)); + assertTrue(source.sendBlocking(msg).isAccepted()); long start = SystemTimer.INSTANCE.milliTime(); Message msg2 = new SimpleMessage("foo2"); msg2.setRoute(new Route().addHop(Hop.parse(intermediate.getConnectionSpec())) @@ -108,28 +120,28 @@ public class LocalNetworkTest { long TIMEOUT = 1000; msg2.setTimeRemaining(TIMEOUT); Result res = source.sendBlocking(msg2); - assertThat(res.isAccepted(), is(false)); + assertFalse(res.isAccepted()); assertEquals(ErrorCode.TIMEOUT, res.getError().getCode()); assertTrue(res.getError().getMessage().endsWith("Timed out in sendQ")); long end = SystemTimer.INSTANCE.milliTime(); - assertThat(end, greaterThanOrEqualTo(start+TIMEOUT)); - assertThat(end, lessThan(start+5*TIMEOUT)); + assertTrue(end >= start+TIMEOUT); + assertTrue(end < start+5*TIMEOUT); msg = serverB.messages.poll(60, TimeUnit.SECONDS); - assertThat(msg, instanceOf(SimpleMessage.class)); - assertThat(((SimpleMessage)msg).getValue(), is("foo")); + assertTrue(msg instanceof SimpleMessage); + assertEquals("foo", ((SimpleMessage)msg).getValue()); intermediate.forward(msg); msg = serverC.messages.poll(60, TimeUnit.SECONDS); - assertThat(msg, instanceOf(SimpleMessage.class)); - assertThat(((SimpleMessage)msg).getValue(), is("foo")); + assertTrue(msg instanceof SimpleMessage); + assertEquals("foo", ((SimpleMessage)msg).getValue()); Reply reply = new SimpleReply("bar"); reply.swapState(msg); destination.reply(reply); reply = serverB.replies.poll(60, TimeUnit.SECONDS); - assertThat(reply, instanceOf(SimpleReply.class)); - assertThat(((SimpleReply)reply).getValue(), is("bar")); + assertTrue(reply instanceof SimpleReply); + assertEquals("bar", ((SimpleReply)reply).getValue()); intermediate.forward(reply); reply = serverA.replies.poll(60, TimeUnit.SECONDS); @@ -137,8 +149,8 @@ public class LocalNetworkTest { assertTrue(reply.getError(0).getMessage().endsWith("Timed out in sendQ")); reply = serverA.replies.poll(60, TimeUnit.SECONDS); - assertThat(reply, instanceOf(SimpleReply.class)); - assertThat(((SimpleReply)reply).getValue(), is("bar")); + assertTrue(reply instanceof SimpleReply); + assertEquals("bar", ((SimpleReply)reply).getValue()); serverA.mbus.destroy(); serverB.mbus.destroy(); diff --git a/yolean/src/test/java/com/yahoo/yolean/chain/ChainBuilderTest.java b/yolean/src/test/java/com/yahoo/yolean/chain/ChainBuilderTest.java index 60629e05636..70bb0ab1397 100644 --- a/yolean/src/test/java/com/yahoo/yolean/chain/ChainBuilderTest.java +++ b/yolean/src/test/java/com/yahoo/yolean/chain/ChainBuilderTest.java @@ -9,9 +9,9 @@ import java.util.List; import static com.yahoo.yolean.chain.Dependencies.after; import static com.yahoo.yolean.chain.Dependencies.before; import static com.yahoo.yolean.chain.Dependencies.provides; -import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.collection.IsIterableContainingInOrder.contains; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; /** @@ -100,7 +100,7 @@ public class ChainBuilderTest { public void build_empty_chain() { Chain<Filter> chain = getChain().build(); assertTrue(chain.isEmpty()); - assertThat(chain.id(), is("myChain")); + assertEquals("myChain", chain.id()); } @Test @@ -140,7 +140,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(b).add(a, before(b)).build(); - assertThat(chain, is(new Chain<>("myChain", a, b))); + assertEquals(new Chain<>("myChain", a, b), chain); } @Test @@ -151,7 +151,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(b, after(a)).add(a).build(); - assertThat(chain, is(new Chain<>("myChain", a, b))); + assertEquals(new Chain<>("myChain", a, b), chain); } @Test @@ -162,7 +162,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(b).add(a, before(b.getClass())).build(); - assertThat(chain, is(new Chain<>("myChain", a, b))); + assertEquals(new Chain<>("myChain", a, b), chain); } @Test @@ -173,7 +173,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(b, after(a.getClass())).add(a).build(); - assertThat(chain, is(new Chain<>("myChain", a, b))); + assertEquals(new Chain<>("myChain", a, b), chain); } @Test @@ -184,7 +184,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(b).add(a, before(FilterB.class)).build(); - assertThat(chain, is(new Chain<>("myChain", a, b))); + assertEquals(new Chain<>("myChain", a, b), chain); } @Test @@ -195,7 +195,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(b, after(FilterA.class)).add(a).build(); - assertThat(chain, is(new Chain<>("myChain", a, b))); + assertEquals(new Chain<>("myChain", a, b), chain); } @Test @@ -206,7 +206,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(b, provides("B")).add(a, before("B")).build(); - assertThat(chain, is(new Chain<>("myChain", a, b))); + assertEquals(new Chain<>("myChain", a, b), chain); } @Test @@ -217,7 +217,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(b, after("A")).add(a, provides("A")).build(); - assertThat(chain, is(new Chain<>("myChain", a, b))); + assertEquals(new Chain<>("myChain", a, b), chain); } @Test @@ -228,7 +228,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(providesA).add(beforeA).build(); - assertThat(chain, is(new Chain<>("myChain", beforeA, providesA))); + assertEquals(new Chain<>("myChain", beforeA, providesA), chain); } @Test @@ -239,7 +239,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(afterA).add(providesA).build(); - assertThat(chain, is(new Chain<>("myChain", providesA, afterA))); + assertEquals(new Chain<>("myChain", providesA, afterA), chain); } @Test @@ -250,7 +250,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(b).add(a, before("*")).build(); - assertThat(chain, is(new Chain<>("myChain", a, b))); + assertEquals(new Chain<>("myChain", a, b), chain); } @Test @@ -261,7 +261,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(b, after("*")).add(a).build(); - assertThat(chain, is(new Chain<>("myChain", a, b))); + assertEquals(new Chain<>("myChain", a, b), chain); } @Test @@ -272,7 +272,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(a).add(beforeAll).build(); - assertThat(chain, is(new Chain<>("myChain", beforeAll, a))); + assertEquals(new Chain<>("myChain", beforeAll, a), chain); } @Test @@ -283,7 +283,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(afterAll).add(a).build(); - assertThat(chain, is(new Chain<>("myChain", a, afterAll))); + assertEquals(new Chain<>("myChain", a, afterAll), chain); } @Test @@ -294,7 +294,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(beforeAll).add(beforeBeforeAll).build(); - assertThat(chain, is(new Chain<>("myChain", beforeBeforeAll, beforeAll))); + assertEquals(new Chain<>("myChain", beforeBeforeAll, beforeAll), chain); } @Test @@ -305,7 +305,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(afterAfterAll).add(afterAll).build(); - assertThat(chain, is(new Chain<>("myChain", afterAll, afterAfterAll))); + assertEquals(new Chain<>("myChain", afterAll, afterAfterAll), chain); } @Test @@ -316,7 +316,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(beforeAll).add(first, before("BeforeAll")).build(); - assertThat(chain, is(new Chain<>("myChain", first, beforeAll))); + assertEquals(new Chain<>("myChain", first, beforeAll), chain); } @Test @@ -327,7 +327,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(last, after("AfterAll")).add(afterAll).build(); - assertThat(chain, is(new Chain<>("myChain", afterAll, last))); + assertEquals(new Chain<>("myChain", afterAll, last), chain); } @Test @@ -338,7 +338,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(b, after(a.getClass().getName())).add(a).build(); - assertThat(chain, is(new Chain<>("myChain", a, b))); + assertEquals(new Chain<>("myChain", a, b), chain); } @Test @@ -350,7 +350,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(last, after("A")).add(first, before("A")).add(extendsA).build(); - assertThat(chain, is(new Chain<>("myChain", first, extendsA, last))); + assertEquals(new Chain<>("myChain", first, extendsA, last), chain); } @Test @@ -362,7 +362,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(last, after("A")).add(first, before("ExtendsA")).add(extendsA).build(); - assertThat(chain, is(new Chain<>("myChain", first, extendsA, last))); + assertEquals(new Chain<>("myChain", first, extendsA, last), chain); } @Test @@ -373,7 +373,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(A, before("*")).add(beforeA_and_beforeB).add(B).build(); - assertThat(chain, is(new Chain<>("myChain", beforeA_and_beforeB, A, B))); + assertEquals(new Chain<>("myChain", beforeA_and_beforeB, A, B), chain); } @Test @@ -385,7 +385,7 @@ public class ChainBuilderTest { Chain<Filter> chain = getChain(). add(a).add(c).add(b, after(a), before(c)).build(); - assertThat(chain, is(new Chain<>("myChain", a, b, c))); + assertEquals(new Chain<>("myChain", a, b, c), chain); } private ChainBuilder<Filter> getChain() { diff --git a/yolean/src/test/java/com/yahoo/yolean/chain/ChainTest.java b/yolean/src/test/java/com/yahoo/yolean/chain/ChainTest.java index aa344d88f5a..da9ae2c38e3 100644 --- a/yolean/src/test/java/com/yahoo/yolean/chain/ChainTest.java +++ b/yolean/src/test/java/com/yahoo/yolean/chain/ChainTest.java @@ -3,9 +3,8 @@ package com.yahoo.yolean.chain; import org.junit.Test; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; /** * @author Tony Vaagenes @@ -23,33 +22,33 @@ public class ChainTest { @Test public void empty_chain_toString() { Chain<Filter> c = new Chain<>("myChain"); - assertThat(c.toString(), is("chain 'myChain'{}")); + assertEquals("chain 'myChain'{}", c.toString()); } @Test public void singleton_chain_toString() { Chain<Filter> c = new Chain<>("myChain", new Filter()); - assertThat(c.toString(), is("chain 'myChain'{ Filter }")); + assertEquals("chain 'myChain'{ Filter }", c.toString()); } @Test public void chain_toString() { Chain<Filter> c = new Chain<>("myChain", new Filter(), new Filter(), new OtherFilter()); - assertThat(c.toString(), is("chain 'myChain'{ Filter -> Filter -> OtherFilter }")); + assertEquals("chain 'myChain'{ Filter -> Filter -> OtherFilter }", c.toString()); } @Test public void non_equal_due_to_different_components() { - assertThat(new Chain<>("a", new Filter()), is(not(new Chain<>("a", new Filter())))); + assertNotEquals(new Chain<>("a", new Filter()), new Chain<>("a", new Filter())); } @Test public void non_equal_due_to_different_size_comopnents() { - assertThat(new Chain<>("a", new Filter()), is(not(new Chain<Filter>("a")))); + assertNotEquals(new Chain<>("a", new Filter()), new Chain<Filter>("a")); } @Test public void hashCode_equals() { - assertThat(new Chain<>("a").hashCode(), is(new Chain<Filter>("a").hashCode())); + assertEquals(new Chain<>("a").hashCode(), new Chain<Filter>("a").hashCode()); } } diff --git a/yolean/src/test/java/com/yahoo/yolean/chain/DirectedGraphTest.java b/yolean/src/test/java/com/yahoo/yolean/chain/DirectedGraphTest.java index 0ff600430b6..b37c57b536b 100644 --- a/yolean/src/test/java/com/yahoo/yolean/chain/DirectedGraphTest.java +++ b/yolean/src/test/java/com/yahoo/yolean/chain/DirectedGraphTest.java @@ -4,13 +4,14 @@ package com.yahoo.yolean.chain; import org.junit.Before; import org.junit.Test; -import static org.hamcrest.collection.IsIterableContainingInOrder.contains; -import static org.junit.Assert.assertThat; +import java.util.Arrays; + +import static org.junit.Assert.assertTrue; public class DirectedGraphTest { private DirectedGraph graph; - private Vertex[] v = new Vertex[10]; + private final Vertex[] v = new Vertex[10]; @Before public void setup() { @@ -26,7 +27,7 @@ public class DirectedGraphTest { graph.addVertex(v[0]); graph.addBeginningVertex(v[1]); - assertThat(graph.topologicalSort(), contains(v[1], v[0])); + assertTrue(graph.topologicalSort().containsAll(Arrays.asList(v[1], v[0]))); } @Test @@ -35,7 +36,7 @@ public class DirectedGraphTest { graph.addBeginningVertex(v[1]); graph.addEdge(v[0], v[1]); - assertThat(graph.topologicalSort(), contains(v[0], v[1])); + assertTrue(graph.topologicalSort().containsAll(Arrays.asList(v[0], v[1]))); } static class TestVertex implements Vertex { diff --git a/yolean/src/test/java/com/yahoo/yolean/chain/EnumeratedIdentitySetTest.java b/yolean/src/test/java/com/yahoo/yolean/chain/EnumeratedIdentitySetTest.java index aded98914c5..5f0692e186f 100644 --- a/yolean/src/test/java/com/yahoo/yolean/chain/EnumeratedIdentitySetTest.java +++ b/yolean/src/test/java/com/yahoo/yolean/chain/EnumeratedIdentitySetTest.java @@ -16,6 +16,7 @@ import static java.util.Collections.singleton; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.collection.IsEmptyCollection.empty; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; @@ -37,13 +38,13 @@ public class EnumeratedIdentitySetTest { @Test public void size() { EnumeratedIdentitySet<Element> set = new EnumeratedIdentitySet<>(elements); - assertThat(set.size(), is(elements.size())); + assertEquals(elements.size(), set.size()); set.add(elements.get(0)); - assertThat(set.size(), is(elements.size())); + assertEquals(elements.size(), set.size()); set.remove(elements.get(0)); - assertThat(set.size(), is(elements.size() - 1)); + assertEquals(elements.size() - 1, set.size()); } @Test @@ -73,8 +74,8 @@ public class EnumeratedIdentitySetTest { count++; } - assertThat(collectedElements.size(), is(count)); - assertThat(collectedElements.size(), is(elements.size())); + assertEquals(count, collectedElements.size()); + assertEquals(elements.size(), collectedElements.size()); for (Element element : elements) { assertTrue(collectedElements.containsKey(element)); @@ -150,7 +151,7 @@ public class EnumeratedIdentitySetTest { public void clear() { EnumeratedIdentitySet<Element> set = new EnumeratedIdentitySet<>(elements); set.clear(); - assertThat(set, empty()); + assertTrue(set.isEmpty()); } @Test @@ -195,7 +196,7 @@ public class EnumeratedIdentitySetTest { } List<Element> forceRenumber = set.insertionOrderedList(); - assertThat(forceRenumber.size(), is(elements.size())); + assertEquals(elements.size(), forceRenumber.size()); for (int i = 0; i < elements.size(); i++) { assertSame(forceRenumber.get(i), elements.get(i)); @@ -214,7 +215,7 @@ public class EnumeratedIdentitySetTest { } set.insertionOrderedList(); - assertThat(set.numbers(), empty()); + assertTrue(set.numbers().isEmpty()); set.add(new Element()); assertThat(set.numbers(), containsSameElements(singleton(0))); |