<commit_before>package uk.ac.ebi.quickgo.client.service.loader.presets.assignedby;

import uk.ac.ebi.quickgo.client.model.presets.impl.CompositePresetImpl;
import uk.ac.ebi.quickgo.client.service.loader.presets.ff.RawNamedPreset;

import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.springframework.batch.item.ItemWriter;

/**
 * @author <NAME>
 * Date: 02/08/2017
 * Time: 17:06
 * Created with IntelliJ IDEA.
 */
public class AssignedByPresetsConfigTest {
    private CompositePresetImpl presetBuilder;

    @Before
    public void setUp() {
        presetBuilder = new CompositePresetImpl();
    }

    @Test(expected = IllegalArgumentException.class)
    public void avoidsNullPointerExceptionIfNameIsNull() throws Exception {
        AssignedByPresetsConfig config = new AssignedByPresetsConfig();

        List<RawNamedPreset> rawNamedPresets = new ArrayList<>();
        final RawNamedPreset raw1 = new RawNamedPreset();
        raw1.name = null;
        raw1.id = null;
        raw1.relevancy = 1;
        rawNamedPresets.add(raw1);

        ItemWriter<RawNamedPreset> writer = config.rawPresetWriter(presetBuilder);
        writer.write(rawNamedPresets);
    }
}<commit_msg>As per test on master.<commit_after>package uk.ac.ebi.quickgo.client.service.loader.presets.assignedby;

import uk.ac.ebi.quickgo.client.service.loader.presets.ff.RawNamedPreset;

import org.junit.Before;
import org.junit.Test;
import org.springframework.batch.item.ItemProcessor;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.IsNull.notNullValue;

/**
 * @author <NAME>
 * Date: 02/08/2017
 * Time: 17:06
 * Created with IntelliJ IDEA.
 */
public class AssignedByPresetsConfigTest {

    private AssignedByPresetsConfig assignedByPresetsConfig;

    @Before
    public void setup() {
        assignedByPresetsConfig = new AssignedByPresetsConfig();
    }

    @Test
    public void preventDuplicates() throws Exception {
        final ItemProcessor<RawNamedPreset, RawNamedPreset> itemProcessor =
                assignedByPresetsConfig.duplicateChecker();
        RawNamedPreset rawNamedPreset1 = new RawNamedPreset();
        rawNamedPreset1.name = "AgBase";
        RawNamedPreset rawNamedPreset2 = new RawNamedPreset();
        rawNamedPreset2.name = "AspGD";
        RawNamedPreset rawNamedPreset3 = new RawNamedPreset();
        rawNamedPreset3.name = "ASPGD";
        RawNamedPreset rawNamedPreset4 = new RawNamedPreset();
        rawNamedPreset4.name = "Alzheimers_University_of_Toronto";

        assertThat(itemProcessor.process(rawNamedPreset1), notNullValue());
        assertThat(itemProcessor.process(rawNamedPreset2), notNullValue());
        assertThat(itemProcessor.process(rawNamedPreset3), nullValue());
        assertThat(itemProcessor.process(rawNamedPreset4), notNullValue());
    }
}
{'fraction_non_alphanumeric': 0.09846678023850085, 'fraction_numerical': 0.014310051107325384, 'mean_word_length': 3.9847198641765704, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '1799905', 'n_tokens_mistral': 916, 'n_tokens_neox': 891, 'n_words': 159}