<commit_before>package io.metacake.core.common;

import org.junit.Before;
import org.junit.Test;

import java.util.*;
import java.util.concurrent.Callable;

import static junit.framework.Assert.*;
import static org.junit.Assert.fail;

/**
 * @author florence
 * @author rpless
 */
public class CustomMapTest {
    CustomizableMap<Integer,String> map;

    @Before
    public void setup(){
        this.map = new CustomizableMap<>(new HashMap<Integer, String>());
    }

    @Test
    public void testGivingOptionalDefaultReturnReturns(){
        Callable<String> res = () -> "irrelevant";

        assertEquals(map.get(0,res), "irrelevant");

        map.setOnMissing(res);
        assertEquals(map.get(0), "irrelevant");
    }

    @Test
    public void testDefaultMissingThrowsCorrectError(){
        try {
            map.get(0);
            fail("map.get did not throw exception");
        } catch (RuntimeException e){
            assertTrue("Wrong exception thrown",
                    e.getCause() instanceof NoSuchElementException);
        }
    }

    @Test
    public void canGetExistingKey(){
        map.put(0,"data");
        assertEquals("data",map.get(0));
    }

    @Test
    public void mapIteratesOverEntrySet(){
        List<Integer> elements = new LinkedList<>();

        Random r = new Random();
        for(int i = 0; i < 10; i++){
            Integer next = r.nextInt();
            elements.add(next);
            map.put(next,next.toString());
        }

        for(Map.Entry<Integer,String> e : map){
            assertNotNull(elements.remove(e.getKey()));
            assertEquals(e.getKey().toString(),e.getValue());
        }

        assertTrue(elements.isEmpty());
    }
}<commit_msg>removed finished tests<commit_after>package io.metacake.core.common;

import org.junit.Before;
import org.junit.Test;

import java.util.*;
import java.util.concurrent.Callable;

import static junit.framework.Assert.*;
import static org.junit.Assert.fail;

/**
 * @author florence
 * @author rpless
 */
public class CustomMapTest {
    CustomizableMap<Integer,String> map;

    @Test
    public void mapIteratesOverEntrySet(){
        List<Integer> elements = new LinkedList<>();

        Random r = new Random();
        for(int i = 0; i < 10; i++){
            Integer next = r.nextInt();
            elements.add(next);
            map.put(next,next.toString());
        }

        for(Map.Entry<Integer,String> e : map){
            assertNotNull(elements.remove(e.getKey()));
            assertEquals(e.getKey().toString(),e.getValue());
        }

        assertTrue(elements.isEmpty());
    }
}
{'fraction_non_alphanumeric': 0.1366412213740458, 'fraction_numerical': 0.004198473282442748, 'mean_word_length': 2.5181208053691275, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3952575', 'n_tokens_mistral': 760, 'n_tokens_neox': 740, 'n_words': 157}