Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import org.msgpack.value.Value;
import org.msgpack.value.ValueFactory;

import java.util.Objects;

/**
* Represents a field with empty value which serializes to {@code msgpack.NULL}
*
Expand Down Expand Up @@ -44,6 +42,6 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return super.hashCode();
return TarantoolNullField.class.hashCode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,43 @@ public void test_hashCode_shouldReturnHashCode() {
}

@Test
public void test_AddNullFieldsToHashSet_shouldCreateHashSetWithTwoElements() {
public void test_toString_shouldReturnString() {
// given
TarantoolNullField nullField = new TarantoolNullField();

// when
String str = nullField.toString();

// then
assertNotNull(str);
assertFalse(str.isEmpty());
assertEquals(str, nullField.toString());
}

@Test
public void test_equals_shouldReturnTrue() {
// given
TarantoolNullField nullField1 = new TarantoolNullField();
TarantoolNullField nullField2 = new TarantoolNullField();

// then
assertEquals(nullField1, nullField1);
assertEquals(nullField1, nullField2);
}

@Test
public void test_equals_shouldReturnFalse() {
// given
TarantoolNullField nullField = new TarantoolNullField();
Object dummyObject = new Object() { };

// then
assertNotEquals(nullField, null);
assertNotEquals(nullField, dummyObject);
}

@Test
public void test_AddNullFieldsToHashSet_shouldCreateHashSetWithOneElements() {
// given
TarantoolNullField nullField1 = new TarantoolNullField();
TarantoolNullField nullField2 = new TarantoolNullField();
Expand All @@ -31,7 +67,7 @@ public void test_AddNullFieldsToHashSet_shouldCreateHashSetWithTwoElements() {
fieldsSet.add(nullField2);

// then
assertEquals(2, fieldsSet.size());
assertEquals(1, fieldsSet.size());
assertTrue(fieldsSet.contains(nullField1));
assertTrue(fieldsSet.contains(nullField2));
}
Expand Down