Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback #1

Open
wants to merge 2 commits into
base: feedback
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>

<dependencies>
Expand Down Expand Up @@ -92,8 +92,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>12</source>
<target>12</target>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
Expand Down
20 changes: 15 additions & 5 deletions src/test/java/com/serenitydojo/WhenWorkingWithMaps.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.serenitydojo.model.FoodType;
import org.junit.Test;

import java.util.HashMap;
import java.util.Map;

import static com.serenitydojo.model.FoodType.*;
Expand All @@ -22,7 +23,12 @@ public class WhenWorkingWithMaps {
// Maps let you associate a value with some other value
@Test
public void creatingANewSet() {
Map<String, String> countryCapitals = null;
Map<String, String> countryCapitals = new HashMap<>();

countryCapitals.put("UK","London");
countryCapitals.put("France","Paris");
countryCapitals.put("Germany","Berlin");

// TODO: Create a new map and add the following associations:
// UK -> London
// France -> Paris
Expand All @@ -36,7 +42,11 @@ public void creatingANewSet() {
// maps can work with different types, e.g. enums to strings
@Test
public void mapWithDifferentTypes() {
Map<String, FoodType> favoriteFood = null;
Map<String, FoodType> favoriteFood = new HashMap<>();

favoriteFood.put("cat", FoodType.TUNA);
favoriteFood.put("dog", FoodType.DELUXE_DOG_FOOD);
favoriteFood.put("hamster", FoodType.LETTUCE);
// TODO: Create a new map and add the following associations:
// "cat" -> TUNA
// "dog" -> DELUXE_DOG_FOOD
Expand All @@ -50,7 +60,7 @@ public void mapWithDifferentTypes() {
// We can create a map more easily with the Map.of() method
@Test
public void usingMapOf() {
Map<String, FoodType> favoriteFood = null;
Map<String, FoodType> favoriteFood = Map.of("cat",FoodType.TUNA,"dog",FoodType.DELUXE_DOG_FOOD,"hamster",FoodType.LETTUCE);
// TODO: Create a new map and add the following associations using Map.of()
// "cat" -> TUNA
// "dog" -> DELUXE_DOG_FOOD
Expand All @@ -71,7 +81,7 @@ public void containsKey() {
"hamster", LETTUCE);

// TODO: Check that the map contains a key of "dog"
boolean containsDog = false;
boolean containsDog = favoriteFood.containsKey("dog");

assertThat(containsDog).isTrue();
}
Expand All @@ -85,7 +95,7 @@ public void containsValue() {
"hamster", LETTUCE);

// TODO: Check that the map contains a value of TUNA
boolean containsTuna = false;
boolean containsTuna = favoriteFood.containsValue(TUNA);

assertThat(containsTuna).isTrue();
}
Expand Down