}
@Test
+ // This test is based on using different references
+ @SuppressWarnings("RedundantStringConstructorCall")
public void testPresentKey() {
final String key1 = new String("abcd");
final String key2 = new String("abcd");
}
@Test
+ // This test is based on using different references
+ @SuppressWarnings("RedundantStringConstructorCall")
public void testMultipleReferences() {
final String s1 = "abcd";
final String s2 = new String(s1);
"my-other-leaf");
@Test
+ // This test is based on using different references; we're testing equals()
+ @SuppressWarnings({"RedundantStringConstructorCall", "EqualsWithItself"})
public void equalsByteTest() {
- byte[] valueNull = null;
- byte[] equalValueNull = null;
-
LeafNode<byte[]> leafNodeNull = ImmutableNodes.leafNode(LEAF_QNAME,
- valueNull);
+ null);
LeafNode<byte[]> equalLeafNodeNull = ImmutableNodes.leafNode(
- SAME_LEAF_QNAME, equalValueNull);
+ SAME_LEAF_QNAME, null);
assertTrue(leafNodeNull.equals(leafNodeNull));
assertTrue(leafNodeNull.equals(equalLeafNodeNull));
assertTrue(leafNode6.equals(equalLeafNode6));
assertTrue(equalLeafNode6.equals(leafNode6));
- String value5 = new String("test");
+ String value5 = "test";
String equalValue5 = new String("test");
LeafNode<String> leafNode5 = ImmutableNodes
}
@Test
+ // We're testing equals()
+ @SuppressWarnings({"ObjectEqualsNull", "EqualsBetweenInconvertibleTypes"})
public void notEqualByteTest() {
byte[] value = "test".getBytes();
assertFalse(leafNode6.equals(otherLeafNode6));
assertFalse(otherLeafNode6.equals(leafNode6));
- String value5 = new String("test");
- String otherValue5 = new String("test2");
+ String value5 = "test";
+ String otherValue5 = "test2";
LeafNode<String> leafNode5 = ImmutableNodes
.leafNode(LEAF_QNAME, value5);
assertFalse(leafNode4.equals(leafNode5));
assertFalse(leafNode6.equals(leafNode5));
- byte[] valueNull = null;
-
LeafNode<byte[]> leafNodeNull = ImmutableNodes.leafNode(
- SAME_LEAF_QNAME, valueNull);
+ SAME_LEAF_QNAME, null);
assertFalse(leafNodeNull.equals(leafNode));
assertFalse(leafNode.equals(leafNodeNull));
- byte[] byteValue = new byte[] { new Byte("1").byteValue(),
- new Byte("1").byteValue() };
+ byte[] byteValue = new byte[] { 1, 1 };
LeafNode<byte[]> byteLeafNode = ImmutableNodes.leafNode(
SAME_LEAF_QNAME, byteValue);
}
@Test
+ // We're testing equals()
+ @SuppressWarnings({"EqualsWithItself", "EqualsBetweenInconvertibleTypes"})
public void equalsOtherTypesTest() {
char[] valueChar = "test".toCharArray();
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.net.URI;
import java.net.URISyntaxException;
public class BitImplTest {
@Test
+ // We're testing equals()
+ @SuppressWarnings({"ObjectEqualsNull", "EqualsBetweenInconvertibleTypes"})
public void test() {
// hashCode method test
URI uriB = null;
URI uriB1 = null;
URI uriB2 = null;
- boolean urisInitiallized = false;
try {
uriA = new URI("some:uriA");
uriA1 = new URI("some:uriA1");
uriB = new URI("some:uriB");
uriB1 = new URI("some:uriB1");
uriB2 = new URI("some:uriB2");
- urisInitiallized = true;
-
} catch (URISyntaxException e) {
- e.printStackTrace();
- assertTrue("Not all required uri variables were instantiated.", urisInitiallized);
-
+ fail("Not all required uri variables were instantiated.");
}
QName qnameA = QName.create(uriA, new Date(5000000), "some name");
qnamesB.add(qnameB2);
SchemaPath schemaPathB = SchemaPath.create(qnamesB, true);
- BitImpl biB = null;
+ BitImpl biB;
BitImpl biA = new BitImpl(55L, qnameA, schemaPathA, "description", "reference", Status.CURRENT, null);
assertEquals("biA should equals to itsefl", biA, biA);
assertFalse("biA shouldn't equal to null", biA.equals(null));
- assertFalse("biA shouldn't equal to object of other type", biA.equals(new String("str")));
+ assertFalse("biA shouldn't equal to object of other type", biA.equals("str"));
biA = new BitImpl(55L, qnameB, schemaPathA, "description", "reference", Status.CURRENT, null);
biB = new BitImpl(55L, qnameB, schemaPathA, "description", "reference", Status.CURRENT, null);
public class MustDefinitionImplTest {
@Test
+ // We're testing equals()
+ @SuppressWarnings({"ObjectEqualsNull", "EqualsBetweenInconvertibleTypes"})
public void test() {
MustDefinitionImpl mdiA;
MustDefinitionImpl mdiB;
assertEquals("mdiA should equals to itsefl", mdiA, mdiA);
assertFalse("mdiA shouldn't equal to null", mdiA.equals(null));
- assertFalse("mdiA shouldn't equal to object of other type", mdiA.equals(new String("str")));
+ assertFalse("mdiA shouldn't equal to object of other type", mdiA.equals("str"));
// test of equals method