package ca.recrown.islandsurvivalcraft;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.ArrayList;
import java.util.HashMap;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.TestInstance.Lifecycle;

/**
 * Unit test for simple App.
 */
@TestInstance(Lifecycle.PER_CLASS)
public class UtilitiesTest {
    /**
     * Basic hashmap inversion test.
     */
    @Test
    public void testInvertHashMap()
    {
        HashMap<String, Integer> hashMap = new HashMap<>();
        hashMap.put("a", 1);
        hashMap.put("b", 1);
        hashMap.put("c", 2);
        hashMap.put("d", 2);

        HashMap<Integer, ArrayList<String>> res = Utilities.invertHashMap(hashMap);
        ArrayList<String> first = res.get(1);
        ArrayList<String> expectedFirst = new ArrayList<>();
        expectedFirst.add("a");
        expectedFirst.add("b");

        ArrayList<String> second = res.get(2);
        ArrayList<String> expectedSecond = new ArrayList<>();
        expectedSecond.add("c");
        expectedSecond.add("d");
        assertEquals(first, expectedFirst);
        assertEquals(second, expectedSecond);
    }
}
