Skip to content

Commit 1af04db

Browse files
eralmas7Eugen
authored andcommitted
BAEL-587 Bi map changes in test names (eugenp#1022)
* BAL-36 File size api in java and apache commons IO * BAEL-282 grep in java - fixes after code review * BAEL-519 Added support for disruptor library * BAEL-519 Added support for disruptor library * BAEL-519 Added support for disruptor library * BAEL-519 Added support for disruptor library * BAEL-519 Added support for disruptor library * BAEL-519 Added support for disruptor library * BAEL-519 Added support for disruptor * BAEL-519 Moved all supporting classes to main source * BAEL-519 Moved all supporting classes to main source * BAEL-519 Moved asserts and test classes in test folder. * BAEL-519 moved test related producer and consumer to src. * BAEL-587 Initial commit for BiMap support. * BAEL-587 Added new tests * BAEL-587 Added new tests. * BAEL-519 Removed Disruptor link from readme file. * BAEL-587 Reverted Disruptor changes * BAEL-587 reverted changes * BAEL-587 Changed test names. * BAEL-587 renamed tests.
1 parent ad63b55 commit 1af04db

1 file changed

Lines changed: 20 additions & 22 deletions

File tree

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package com.baeldung.guava;
22

33
import static org.junit.Assert.*;
4-
54
import java.util.HashMap;
65
import java.util.Map;
7-
86
import org.junit.Test;
97
import com.google.common.collect.BiMap;
108
import com.google.common.collect.EnumHashBiMap;
@@ -13,32 +11,32 @@
1311

1412
public class GuavaBiMapTest {
1513
@Test
16-
public void whenQueryByValue_shouldReturnKey() {
14+
public void whenQueryByValue_returnsKey() {
1715
final BiMap<String, String> capitalCountryBiMap = HashBiMap.create();
1816
capitalCountryBiMap.put("New Delhi", "India");
1917
capitalCountryBiMap.put("Washingon, D.C.", "USA");
2018
capitalCountryBiMap.put("Moscow", "Russia");
2119

22-
final String countryHeadName = capitalCountryBiMap.inverse().get("India");
20+
final String countryCapitalName = capitalCountryBiMap.inverse().get("India");
2321

24-
assertEquals("New Delhi", countryHeadName);
22+
assertEquals("New Delhi", countryCapitalName);
2523
}
2624

2725
@Test
28-
public void whenCreateBiMapFromExistingMap_shouldReturnKey() {
29-
final Map<String, String> personCountryHeadMap = new HashMap<>();
30-
personCountryHeadMap.put("New Delhi", "India");
31-
personCountryHeadMap.put("Washingon, D.C.", "USA");
32-
personCountryHeadMap.put("Moscow", "Russia");
33-
final BiMap<String, String> capitalCountryBiMap = HashBiMap.create(personCountryHeadMap);
26+
public void whenCreateBiMapFromExistingMap_returnsKey() {
27+
final Map<String, String> capitalCountryMap = new HashMap<>();
28+
capitalCountryMap.put("New Delhi", "India");
29+
capitalCountryMap.put("Washingon, D.C.", "USA");
30+
capitalCountryMap.put("Moscow", "Russia");
31+
final BiMap<String, String> capitalCountryBiMap = HashBiMap.create(capitalCountryMap);
3432

35-
final String countryHeadName = capitalCountryBiMap.inverse().get("India");
33+
final String countryCapitalName = capitalCountryBiMap.inverse().get("India");
3634

37-
assertEquals("New Delhi", countryHeadName);
35+
assertEquals("New Delhi", countryCapitalName);
3836
}
3937

4038
@Test
41-
public void whenQueryByKey_shouldReturnValue() {
39+
public void whenQueryByKey_returnsValue() {
4240
final BiMap<String, String> capitalCountryBiMap = HashBiMap.create();
4341

4442
capitalCountryBiMap.put("New Delhi", "India");
@@ -49,7 +47,7 @@ public void whenQueryByKey_shouldReturnValue() {
4947
}
5048

5149
@Test(expected = IllegalArgumentException.class)
52-
public void whenSameValueIsBeingPresent_shouldThrowException() {
50+
public void whenSameValueIsPresent_throwsException() {
5351
final BiMap<String, String> capitalCountryBiMap = HashBiMap.create();
5452

5553
capitalCountryBiMap.put("New Delhi", "India");
@@ -59,7 +57,7 @@ public void whenSameValueIsBeingPresent_shouldThrowException() {
5957
}
6058

6159
@Test
62-
public void givenSameValueIsBeingPresent_whenForcePutIsUsed_shouldCompleteSuccessfully() {
60+
public void givenSameValueIsPresent_whenForcePut_completesSuccessfully() {
6361
final BiMap<String, String> capitalCountryBiMap = HashBiMap.create();
6462

6563
capitalCountryBiMap.put("New Delhi", "India");
@@ -72,7 +70,7 @@ public void givenSameValueIsBeingPresent_whenForcePutIsUsed_shouldCompleteSucces
7270
}
7371

7472
@Test
75-
public void whenSameKeyIsBeingPresent_shouldReplaceAlreadyPresent() {
73+
public void whenSameKeyIsPresent_replacesAlreadyPresent() {
7674
final BiMap<String, String> capitalCountryBiMap = HashBiMap.create();
7775

7876
capitalCountryBiMap.put("New Delhi", "India");
@@ -84,21 +82,21 @@ public void whenSameKeyIsBeingPresent_shouldReplaceAlreadyPresent() {
8482
}
8583

8684
@Test
87-
public void whenUsingImmutableBiMap_shouldAllowPutSuccessfully() {
85+
public void whenUsingImmutableBiMap_allowsPutSuccessfully() {
8886
final BiMap<String, String> capitalCountryBiMap = new ImmutableBiMap.Builder<String, String>().put("New Delhi", "India").put("Washingon, D.C.", "USA").put("Moscow", "Russia").build();
8987

9088
assertEquals("USA", capitalCountryBiMap.get("Washingon, D.C."));
9189
}
9290

9391
@Test(expected = UnsupportedOperationException.class)
94-
public void whenUsingImmutableBiMap_shouldNotAllowRemove() {
92+
public void whenUsingImmutableBiMap_doesntAllowRemove() {
9593
final BiMap<String, String> capitalCountryBiMap = new ImmutableBiMap.Builder<String, String>().put("New Delhi", "India").put("Washingon, D.C.", "USA").put("Moscow", "Russia").build();
9694

9795
capitalCountryBiMap.remove("New Delhi");
9896
}
9997

10098
@Test(expected = UnsupportedOperationException.class)
101-
public void whenUsingImmutableBiMap_shouldNotAllowPut() {
99+
public void whenUsingImmutableBiMap_doesntAllowPut() {
102100
final BiMap<String, String> capitalCountryBiMap = new ImmutableBiMap.Builder<String, String>().put("New Delhi", "India").put("Washingon, D.C.", "USA").put("Moscow", "Russia").build();
103101

104102
capitalCountryBiMap.put("New York", "USA");
@@ -109,7 +107,7 @@ private enum Operation {
109107
}
110108

111109
@Test
112-
public void whenUsingEnumAsKeyInMap_shouldReplaceAlreadyPresent() {
110+
public void whenUsingEnumAsKeyInMap_replacesAlreadyPresent() {
113111
final BiMap<Operation, String> operationStringBiMap = EnumHashBiMap.create(Operation.class);
114112

115113
operationStringBiMap.put(Operation.ADD, "Add");
@@ -119,4 +117,4 @@ public void whenUsingEnumAsKeyInMap_shouldReplaceAlreadyPresent() {
119117

120118
assertEquals("Divide", operationStringBiMap.get(Operation.DIVIDE));
121119
}
122-
}
120+
}

0 commit comments

Comments
 (0)