blob: 29968ecf94771c69ca9be398d33a281f6367349a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package com.vaadin.data.util.sqlcontainer;
import org.junit.Assert;
import org.junit.Test;
public class ReadOnlyRowIdTest {
@Test
public void getRowNum_shouldReturnRowNumGivenInConstructor() {
int rowNum = 1337;
ReadOnlyRowId rid = new ReadOnlyRowId(rowNum);
Assert.assertEquals(rowNum, rid.getRowNum());
}
@Test
public void hashCode_shouldBeEqualToHashCodeOfRowNum() {
int rowNum = 1337;
ReadOnlyRowId rid = new ReadOnlyRowId(rowNum);
Assert.assertEquals(Integer.valueOf(rowNum).hashCode(), rid.hashCode());
}
@Test
public void equals_compareWithNull_shouldBeFalse() {
ReadOnlyRowId rid = new ReadOnlyRowId(1337);
Assert.assertFalse(rid.equals(null));
}
@Test
public void equals_compareWithSameInstance_shouldBeTrue() {
ReadOnlyRowId rid = new ReadOnlyRowId(1337);
ReadOnlyRowId rid2 = rid;
Assert.assertTrue(rid.equals(rid2));
}
@Test
public void equals_compareWithOtherType_shouldBeFalse() {
ReadOnlyRowId rid = new ReadOnlyRowId(1337);
Assert.assertFalse(rid.equals(new Object()));
}
@Test
public void equals_compareWithOtherRowId_shouldBeFalse() {
ReadOnlyRowId rid = new ReadOnlyRowId(1337);
ReadOnlyRowId rid2 = new ReadOnlyRowId(42);
Assert.assertFalse(rid.equals(rid2));
}
@Test
public void toString_rowNumberIsReturned() {
int i = 1;
ReadOnlyRowId rowId = new ReadOnlyRowId(i);
Assert.assertEquals("Unexpected toString value", String.valueOf(i),
rowId.toString());
}
}
|