<commit_before>package pl.touk.throwing;

import org.junit.Test;
import pl.touk.throwing.exception.WrappedException;

import java.io.IOException;
import java.util.Optional;

import static org.assertj.core.api.Assertions.assertThat;

public class ThrowingSupplierTest {

    @Test
    public void shouldGet() throws Exception {
        // given
        final ThrowingSupplier<Integer, IOException> supplier = () -> 42;

        // when
        final Integer result = supplier.get();

        // then
        assertThat(result).isEqualTo(42);
    }

    @Test
    public void shouldGetAsFunction() throws Exception {
        // given
        final ThrowingSupplier<Integer, IOException> supplier = () -> 42;

        // when
        final ThrowingFunction<Void, Integer, IOException> result = supplier.asFunction();

        // then
        assertThat(result.apply(null)).isEqualTo(42);
    }

    @Test
    public void shouldLiftAndGet() throws Exception {
        // given
        final ThrowingSupplier<Integer, IOException> supplier = () -> 42;

        // when
        final Optional<Integer> result = supplier.lift().get();

        // then
        assertThat(result).isPresent();
    }

    @Test
    public void shouldLiftAndGetEmpty() throws Exception {
        // given
        final ThrowingSupplier<Integer, IOException> supplier = () -> { throw new IOException(); };

        // when
        final Optional<Integer> result = supplier.lift().get();

        // then
        assertThat(result).isEmpty();
    }

    @Test(expected = WrappedException.class)
    public void shouldGetUnchecked() throws Exception {
        // given
        final ThrowingSupplier<Integer, IOException> supplier = () -> { throw new IOException(); };

        // when
        supplier.unchecked().get();

        // then exception is thrown
    }
}<commit_msg>ThrowingSupplier missing tests<commit_after>package pl.touk.throwing;

import org.junit.Test;
import pl.touk.throwing.exception.WrappedException;

import java.io.IOException;
import java.util.Optional;

import static org.assertj.core.api.Assertions.assertThat;

public class ThrowingSupplierTest {

    @Test
    public void shouldGet() throws Exception {
        // given
        final ThrowingSupplier<Integer, IOException> supplier = () -> 42;

        // when
        final Integer result = supplier.get();

        // then
        assertThat(result).isEqualTo(42);
    }

    @Test
    public void shouldGetAsFunction() throws Exception {
        // given
        final ThrowingSupplier<Integer, IOException> supplier = () -> 42;

        // when
        final ThrowingFunction<Void, Integer, IOException> result = supplier.asFunction();

        // then
        assertThat(result.apply(null)).isEqualTo(42);
    }

    @Test
    public void shouldLiftAndGet() throws Exception {
        // given
        final ThrowingSupplier<Integer, IOException> supplier = () -> 42;

        // when
        final Optional<Integer> result = supplier.lift().get();

        // then
        assertThat(result).isPresent();
    }

    @Test
    public void shouldLiftAndGetEmpty() throws Exception {
        // given
        final ThrowingSupplier<Integer, IOException> supplier = () -> { throw new IOException(); };

        // when
        final Optional<Integer> result = supplier.lift().get();

        // then
        assertThat(result).isEmpty();
    }

    @Test(expected = WrappedException.class)
    public void shouldGetUnchecked() throws Exception {
        // given
        final ThrowingSupplier<Integer, IOException> supplier = () -> { throw new IOException(); };

        // when
        supplier.unchecked().get();

        // then exception is thrown
    }

    @Test(expected = WrappedException.class)
    public void shouldGetUncheckedWithUtilsFunction() throws Exception {
        // given
        final ThrowingSupplier<Integer, IOException> supplier = () -> { throw new IOException(); };

        // when
        ThrowingSupplier.unchecked(supplier).get();

        // then exception is thrown
    }

    @Test
    public void shouldLiftAndGetWithUtilsFunction() throws Exception {
        // given
        final ThrowingSupplier<Integer, IOException> supplier = () -> 42;

        // when
        final Optional<Integer> result = ThrowingSupplier.lifted(supplier).get();

        // then
        assertThat(result).isPresent();
    }
}
{'fraction_non_alphanumeric': 0.11191992720655142, 'fraction_numerical': 0.005004549590536852, 'mean_word_length': 2.4111714507370055, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 34, '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': '4666788', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1124, 'n_words': 276}