<commit_before>package com.drumonii.loltrollbuild.model.builder;

import com.drumonii.loltrollbuild.model.Item;
import com.drumonii.loltrollbuild.model.SummonerSpell;
import com.drumonii.loltrollbuild.model.TrollBuild;
import com.drumonii.loltrollbuild.test.json.JsonTestFilesUtil;
import com.drumonii.loltrollbuild.util.RandomizeUtil;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.json.JsonTest;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.Consumer;

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

@JsonTest
class TrollBuildBuilderTest {

    @Autowired
    private ObjectMapper objectMapper;

    private List<Item> items;
    private List<SummonerSpell> summonerSpells;

    @BeforeEach
    void beforeEach() {
        JsonTestFilesUtil jsonTestFilesUtil = new JsonTestFilesUtil(objectMapper);

        items = new ArrayList<>(jsonTestFilesUtil.getItemsResponse().getItems().values());
        summonerSpells = new ArrayList<>(jsonTestFilesUtil.getSummonerSpellsResponse().getSummonerSpells().values());
    }

    @Test
    void buildsTrollBuild() {
        Collection<Item> boots = RandomizeUtil.getRandoms(items, 2); // get some "boots" (don't care they aren't actually boots)
        items.removeAll(boots);

        TrollBuild trollBuild = new TrollBuildBuilder()
                .withItems(items)
                .withBoots(boots)
                .withSummonerSpells(summonerSpells)
                .withTrinket(items)
                .build();

        assertThat(trollBuild).satisfies(new FullTrollBuild(boots));
    }

    @Test
    void buildsTrollBuildWithoutBoots() {
        TrollBuild trollBuild = new TrollBuildBuilder()
                .withBoots(null)
                .build();

        assertThat(trollBuild).satisfies(new EmptyTrollBuild());

        trollBuild = new TrollBuildBuilder()
                .withBoots(new ArrayList<>())
                .build();

        assertThat(trollBuild).satisfies(new EmptyTrollBuild());
    }

    @Test
    void buildsTrollBuildWithoutItems() {
        TrollBuild trollBuild = new TrollBuildBuilder()
                .withItems(null)
                .build();

        assertThat(trollBuild).satisfies(new EmptyTrollBuild());

        trollBuild = new TrollBuildBuilder()
                .withItems(new ArrayList<>())
                .build();

        assertThat(trollBuild).satisfies(new EmptyTrollBuild());
    }

    @Test
    void buildsTrollBuildWithoutSummonerSpells() {
        TrollBuild trollBuild = new TrollBuildBuilder()
                .withSummonerSpells(null)
                .build();

        assertThat(trollBuild).satisfies(new EmptyTrollBuild());

        trollBuild = new TrollBuildBuilder()
                .withSummonerSpells(new ArrayList<>())
                .build();

        assertThat(trollBuild).satisfies(new EmptyTrollBuild());
    }

    @Test
    void buildsTrollBuildWithoutTrinket() {
        TrollBuild trollBuild = new TrollBuildBuilder()
                .withTrinket(null)
                .build();

        assertThat(trollBuild).satisfies(new EmptyTrollBuild());

        trollBuild = new TrollBuildBuilder()
                .withTrinket(new ArrayList<>())
                .build();

        assertThat(trollBuild).satisfies(new EmptyTrollBuild());
    }

    private class EmptyTrollBuild implements Consumer<TrollBuild> {

        @Override
        public void accept(TrollBuild trollBuild) {
            assertThat(trollBuild.getItems()).isEmpty();<commit_msg>Use ParameterizedTest to test null and empty scenarios<commit_after>package com.drumonii.loltrollbuild.model.builder;

import com.drumonii.loltrollbuild.model.Item;
import com.drumonii.loltrollbuild.model.SummonerSpell;
import com.drumonii.loltrollbuild.model.TrollBuild;
import com.drumonii.loltrollbuild.test.json.JsonTestFilesUtil;
import com.drumonii.loltrollbuild.util.RandomizeUtil;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.NullAndEmptySource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.json.JsonTest;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.Consumer;

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

@JsonTest
class TrollBuildBuilderTest {

    @Autowired
    private ObjectMapper objectMapper;

    private List<Item> items;
    private List<SummonerSpell> summonerSpells;

    @BeforeEach
    void beforeEach() {
        JsonTestFilesUtil jsonTestFilesUtil = new JsonTestFilesUtil(objectMapper);

        items = new ArrayList<>(jsonTestFilesUtil.getItemsResponse().getItems().values());
        summonerSpells = new ArrayList<>(jsonTestFilesUtil.getSummonerSpellsResponse().getSummonerSpells().values());
    }

    @Test
    void buildsTrollBuild() {
        Collection<Item> boots = RandomizeUtil.getRandoms(items, 2); // get some "boots" (don't care they aren't actually boots)
        items.removeAll(boots);

        TrollBuild trollBuild = new TrollBuildBuilder()
                .withItems(items)
                .withBoots(boots)
                .withSummonerSpells(summonerSpells)
                .withTrinket(items)
                .build();

        assertThat(trollBuild).satisfies(new FullTrollBuild(boots));
    }

    @NullAndEmptySource
    @ParameterizedTest(name = "boots=''{0}''")
    void buildsTrollBuildWithoutBoots(List<Item> boots) {
        TrollBuild trollBuild = new TrollBuildBuilder()
                .withBoots(boots)
                .build();

        assertThat(trollBuild).satisfies(new EmptyTrollBuild());
    }

    @NullAndEmptySource
    @ParameterizedTest(name = "items=''{0}''")
    void buildsTrollBuildWithoutItems(List<Item> items) {
        TrollBuild trollBuild = new TrollBuildBuilder()
                .withItems(items)
                .build();

        assertThat(trollBuild).satisfies(new EmptyTrollBuild());
    }

    @NullAndEmptySource
    @ParameterizedTest(name = "summonerSpells=''{0}''")
    void buildsTrollBuildWithoutSummonerSpells(List<SummonerSpell> summonerSpells) {
        TrollBuild trollBuild = new TrollBuildBuilder()
                .withSummonerSpells(summonerSpells)
                .build();

        assertThat(trollBuild).satisfies(new EmptyTrollBuild());
    }

    @NullAndEmptySource
    @ParameterizedTest(name = "trinkets=''{0}''")
    void buildsTrollBuildWithoutTrinket(List<Item> trinkets) {
        TrollBuild trollBuild = new TrollBuildBuilder()
                .withTrinket(trinkets)
                .build();

        assertThat(trollBuild).satisfies(new EmptyTrollBuild());
    }

    private class EmptyTrollBuild implements Consumer<TrollBuild> {

        @Override
        public void accept(TrollBuild trollBuild) {
            assertThat(trollBuild.getItems()).isEmpty();
{'fraction_non_alphanumeric': 0.10208592347009256, 'fraction_numerical': 0.0008288437629506838, 'mean_word_length': 3.1253561253561255, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '3145370', 'n_tokens_mistral': 2182, 'n_tokens_neox': 2096, 'n_words': 338}