BAEL-587 Bi map changes in test names (#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.
This commit is contained in:
Muhammed Almas 2017-01-20 13:42:17 +05:30 committed by Eugen
parent ad63b55edb
commit 1af04dbd85
1 changed files with 20 additions and 22 deletions

View File

@ -1,10 +1,8 @@
package com.baeldung.guava;
import static org.junit.Assert.*;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import com.google.common.collect.BiMap;
import com.google.common.collect.EnumHashBiMap;
@ -13,32 +11,32 @@ import com.google.common.collect.ImmutableBiMap;
public class GuavaBiMapTest {
@Test
public void whenQueryByValue_shouldReturnKey() {
public void whenQueryByValue_returnsKey() {
final BiMap<String, String> capitalCountryBiMap = HashBiMap.create();
capitalCountryBiMap.put("New Delhi", "India");
capitalCountryBiMap.put("Washingon, D.C.", "USA");
capitalCountryBiMap.put("Moscow", "Russia");
final String countryHeadName = capitalCountryBiMap.inverse().get("India");
final String countryCapitalName = capitalCountryBiMap.inverse().get("India");
assertEquals("New Delhi", countryHeadName);
assertEquals("New Delhi", countryCapitalName);
}
@Test
public void whenCreateBiMapFromExistingMap_shouldReturnKey() {
final Map<String, String> personCountryHeadMap = new HashMap<>();
personCountryHeadMap.put("New Delhi", "India");
personCountryHeadMap.put("Washingon, D.C.", "USA");
personCountryHeadMap.put("Moscow", "Russia");
final BiMap<String, String> capitalCountryBiMap = HashBiMap.create(personCountryHeadMap);
public void whenCreateBiMapFromExistingMap_returnsKey() {
final Map<String, String> capitalCountryMap = new HashMap<>();
capitalCountryMap.put("New Delhi", "India");
capitalCountryMap.put("Washingon, D.C.", "USA");
capitalCountryMap.put("Moscow", "Russia");
final BiMap<String, String> capitalCountryBiMap = HashBiMap.create(capitalCountryMap);
final String countryHeadName = capitalCountryBiMap.inverse().get("India");
final String countryCapitalName = capitalCountryBiMap.inverse().get("India");
assertEquals("New Delhi", countryHeadName);
assertEquals("New Delhi", countryCapitalName);
}
@Test
public void whenQueryByKey_shouldReturnValue() {
public void whenQueryByKey_returnsValue() {
final BiMap<String, String> capitalCountryBiMap = HashBiMap.create();
capitalCountryBiMap.put("New Delhi", "India");
@ -49,7 +47,7 @@ public class GuavaBiMapTest {
}
@Test(expected = IllegalArgumentException.class)
public void whenSameValueIsBeingPresent_shouldThrowException() {
public void whenSameValueIsPresent_throwsException() {
final BiMap<String, String> capitalCountryBiMap = HashBiMap.create();
capitalCountryBiMap.put("New Delhi", "India");
@ -59,7 +57,7 @@ public class GuavaBiMapTest {
}
@Test
public void givenSameValueIsBeingPresent_whenForcePutIsUsed_shouldCompleteSuccessfully() {
public void givenSameValueIsPresent_whenForcePut_completesSuccessfully() {
final BiMap<String, String> capitalCountryBiMap = HashBiMap.create();
capitalCountryBiMap.put("New Delhi", "India");
@ -72,7 +70,7 @@ public class GuavaBiMapTest {
}
@Test
public void whenSameKeyIsBeingPresent_shouldReplaceAlreadyPresent() {
public void whenSameKeyIsPresent_replacesAlreadyPresent() {
final BiMap<String, String> capitalCountryBiMap = HashBiMap.create();
capitalCountryBiMap.put("New Delhi", "India");
@ -84,21 +82,21 @@ public class GuavaBiMapTest {
}
@Test
public void whenUsingImmutableBiMap_shouldAllowPutSuccessfully() {
public void whenUsingImmutableBiMap_allowsPutSuccessfully() {
final BiMap<String, String> capitalCountryBiMap = new ImmutableBiMap.Builder<String, String>().put("New Delhi", "India").put("Washingon, D.C.", "USA").put("Moscow", "Russia").build();
assertEquals("USA", capitalCountryBiMap.get("Washingon, D.C."));
}
@Test(expected = UnsupportedOperationException.class)
public void whenUsingImmutableBiMap_shouldNotAllowRemove() {
public void whenUsingImmutableBiMap_doesntAllowRemove() {
final BiMap<String, String> capitalCountryBiMap = new ImmutableBiMap.Builder<String, String>().put("New Delhi", "India").put("Washingon, D.C.", "USA").put("Moscow", "Russia").build();
capitalCountryBiMap.remove("New Delhi");
}
@Test(expected = UnsupportedOperationException.class)
public void whenUsingImmutableBiMap_shouldNotAllowPut() {
public void whenUsingImmutableBiMap_doesntAllowPut() {
final BiMap<String, String> capitalCountryBiMap = new ImmutableBiMap.Builder<String, String>().put("New Delhi", "India").put("Washingon, D.C.", "USA").put("Moscow", "Russia").build();
capitalCountryBiMap.put("New York", "USA");
@ -109,7 +107,7 @@ public class GuavaBiMapTest {
}
@Test
public void whenUsingEnumAsKeyInMap_shouldReplaceAlreadyPresent() {
public void whenUsingEnumAsKeyInMap_replacesAlreadyPresent() {
final BiMap<Operation, String> operationStringBiMap = EnumHashBiMap.create(Operation.class);
operationStringBiMap.put(Operation.ADD, "Add");
@ -119,4 +117,4 @@ public class GuavaBiMapTest {
assertEquals("Divide", operationStringBiMap.get(Operation.DIVIDE));
}
}
}