<commit_before><commit_msg>RP-3: added test for FileParser<commit_after>package io.github.zwieback.relef.parsers;

import io.github.zwieback.relef.configs.DatabaseConfig;
import io.github.zwieback.relef.configs.ParserConfig;
import io.github.zwieback.relef.configs.ServiceConfig;
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {
        DatabaseConfig.class,
        ParserConfig.class,
        ServiceConfig.class
})
public class FileParserTest {

    @SuppressWarnings("unused")
    @Autowired
    private FileParser fileParser;


    @Test(expected = UncheckedIOException.class)
    public void test_parseInputStream_should_throws_exception() throws IOException {
        fileParser.parseInputStream(getInputStreamThatThrowsIOException());
    }

    @NotNull
    private static InputStream getInputStreamThatThrowsIOException() {
        return new InputStream() {
            @Override
            public int read() throws IOException {
                throw new IOException();
            }
        };
    }
}
{'fraction_non_alphanumeric': 0.08741258741258741, 'fraction_numerical': 0.002797202797202797, 'mean_word_length': 4.129032258064516, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5831867', 'n_tokens_mistral': 389, 'n_tokens_neox': 384, 'n_words': 68}