From 2ce190a1fe3e30a366c20ceb611d0f838842f82d Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Wed, 12 Aug 2020 09:02:42 +0200 Subject: Revert "Revert "Reduce the use of hamcrest when normal assertEquals/assertTrue does a…"" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yahoo/document/DocumentIdTestCase.java | 6 ++-- .../com/yahoo/document/DocumentRemoveTestCase.java | 32 ++++++++++---------- .../java/com/yahoo/document/DocumentTestCase.java | 13 +++------ .../com/yahoo/document/DocumentTypeIdTestCase.java | 34 +++++++++++----------- .../com/yahoo/document/FieldPathEntryTestCase.java | 29 +++++++++--------- .../yahoo/document/NumericDataTypeTestCase.java | 9 +++--- .../yahoo/document/TemporaryDataTypeTestCase.java | 13 ++++----- .../TemporaryStructuredDataTypeTestCase.java | 11 ++++--- .../document/annotation/Bug4475379TestCase.java | 5 ++-- .../document/annotation/DummySpanNodeTestCase.java | 25 ++++++++-------- .../annotation/IndexKeySpanTreeTestCase.java | 24 +++++++-------- .../yahoo/document/json/JsonReaderTestCase.java | 15 ++++------ .../document/select/DocumentSelectorTestCase.java | 26 +++++++++++++++-- 13 files changed, 125 insertions(+), 117 deletions(-) (limited to 'document/src/test/java/com/yahoo/document') 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 Einar M R Rosenvinge @@ -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 parsed = new ObjectMapper().readValue(json, new TypeReference>() { }); 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 Einar M R Rosenvinge @@ -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 Einar M R Rosenvinge @@ -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 Einar M R Rosenvinge @@ -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 Einar M R Rosenvinge @@ -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 Einar M R Rosenvinge @@ -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 Einar M R Rosenvinge @@ -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 Einar M R Rosenvinge @@ -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() { -- cgit v1.2.3