Skip to content

Commit 5fe5887

Browse files
lor6pivovarit
authored andcommitted
add simpleentry test (eugenp#2654)
1 parent 16b6e08 commit 5fe5887

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.baeldung.pairs;
2+
3+
import static org.junit.Assert.*;
4+
5+
import java.util.AbstractMap;
6+
7+
import org.junit.Test;
8+
9+
public class CoreJavaSimpleEntryUnitTest {
10+
11+
@Test
12+
public void givenSimpleEntry_whenGetValue_thenOk() {
13+
AbstractMap.SimpleEntry<Integer, String> entry = new AbstractMap.SimpleEntry<Integer, String>(1, "one");
14+
Integer key = entry.getKey();
15+
String value = entry.getValue();
16+
17+
assertEquals(key.intValue(), 1);
18+
assertEquals(value, "one");
19+
}
20+
21+
@Test(expected = UnsupportedOperationException.class)
22+
public void givenSimpleImmutableEntry_whenSetValue_thenException() {
23+
AbstractMap.SimpleImmutableEntry<Integer, String> entry = new AbstractMap.SimpleImmutableEntry<Integer, String>(1, "one");
24+
25+
entry.setValue("two");
26+
27+
}
28+
29+
@Test
30+
public void givenSimpleImmutableEntry_whenGetValue_thenOk() {
31+
AbstractMap.SimpleImmutableEntry<Integer, String> entry = new AbstractMap.SimpleImmutableEntry<Integer, String>(1, "one");
32+
Integer key = entry.getKey();
33+
String value = entry.getValue();
34+
35+
assertEquals(key.intValue(), 1);
36+
assertEquals(value, "one");
37+
}
38+
39+
}

0 commit comments

Comments
 (0)