<commit_before>package tw.thoughtpos.parse;

import static java.util.Arrays.asList;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

import java.util.List;
import java.util.Map;

import org.junit.Test;

public class ParserTest {

    @Test
    public void should_return_items_given_lines() {
        List<String> lines = asList("ITEM00001", "ITEM00002-5", "ITEM00001", "ITEM00003");
        Parser parser = new Parser();
        List<Item> items = parser.parse(lines);
        assertThat(items.size(), is(4));
        assertItem(items.get(0), "ITEM00001", 1);
        assertItem(items.get(1), "ITEM00002", 5);
        assertItem(items.get(2), "ITEM00001", 1);
        assertItem(items.get(3), "ITEM00003", 1);
    }

    private void assertItem(Item item, String expectedBarcode, int expectedAmount) {
        assertThat(item.getBarcode(), is(expectedBarcode));
        assertThat(item.getAmount(), is(expectedAmount));
    }

    @Test
    public void should_return_barcode_amount_map_given_lines() {
        List<String> lines = asList("ITEM00001", "ITEM00002-5", "ITEM00001", "ITEM00003");
        Parser parser = new Parser();
        Map<String, Integer> barcodeAmountMap = parser.get_barcode_amount_map(lines);
        assertThat(barcodeAmountMap.size(), is(3));
        assertThat(barcodeAmountMap.get("ITEM00001"), is(2));
        assertThat(barcodeAmountMap.get("ITEM00002"), is(5));
        assertThat(barcodeAmountMap.get("ITEM00003"), is(1));

    }
}<commit_msg>[M001][lijun] - refactoring PaserTest<commit_after>package tw.thoughtpos.parse;

import static java.util.Arrays.asList;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

import java.util.List;
import java.util.Map;

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

public class ParserTest {

    private List<String> lines;
    private Parser parser = new Parser();

    @Before
    public void setUp() {
        lines = asList("ITEM00001", "ITEM00002-5", "ITEM00001", "ITEM00003");
    }

    @Test
    public void should_return_items_given_lines() {
        List<Item> items = parser.parse(lines);
        assertThat(items.size(), is(4));
        assertItem(items.get(0), "ITEM00001", 1);
        assertItem(items.get(1), "ITEM00002", 5);
        assertItem(items.get(2), "ITEM00001", 1);
        assertItem(items.get(3), "ITEM00003", 1);
    }

    private void assertItem(Item item, String expectedBarcode, int expectedAmount) {
        assertThat(item.getBarcode(), is(expectedBarcode));
        assertThat(item.getAmount(), is(expectedAmount));
    }

    @Test
    public void should_return_barcode_amount_map_given_lines() {
        Map<String, Integer> barcodeAmountMap = parser.get_barcode_amount_map(lines);
        assertThat(barcodeAmountMap.size(), is(3));
        assertThat(barcodeAmountMap.get("ITEM00001"), is(2));
        assertThat(barcodeAmountMap.get("ITEM00002"), is(5));
        assertThat(barcodeAmountMap.get("ITEM00003"), is(1));

    }
}
{'fraction_non_alphanumeric': 0.13967409378117726, 'fraction_numerical': 0.05387429331559694, 'mean_word_length': 3.8128, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '1209968', 'n_tokens_mistral': 1053, 'n_tokens_neox': 954, 'n_words': 179}