<commit_before>package es.tid.cosmos.mobility.labelling.secondhomes;

import static java.util.Arrays.asList;

import com.twitter.elephantbird.mapreduce.io.ProtobufWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.mrunit.mapreduce.ReduceDriver;
import org.junit.Before;
import org.junit.Test;

import es.tid.cosmos.mobility.data.MobDataUtil;
import es.tid.cosmos.mobility.data.MobProtocol.MobData;
import es.tid.cosmos.mobility.data.MobProtocol.TwoInt;
import es.tid.cosmos.mobility.data.PoiPosUtil;
import es.tid.cosmos.mobility.data.TwoIntUtil;

/**
 *
 * @author dmicol
 */
public class GetPairsSechomePoisReducerTest {
    private ReduceDriver<LongWritable, ProtobufWritable<MobData>,
            ProtobufWritable<TwoInt>, ProtobufWritable<MobData>> driver;
    
    @Before
    public void setUp() {
        this.driver = new ReduceDriver<LongWritable, ProtobufWritable<MobData>,
                ProtobufWritable<TwoInt>, ProtobufWritable<MobData>>(
                        new GetPairsSechomePoisReducer());
    }

    @Test
    public void shouldProduceOutput() {
        final LongWritable key = new LongWritable(57L);
        final ProtobufWritable<MobData> value1 = MobDataUtil.createAndWrap(
                PoiPosUtil.create(1, 2, 3, 4, 5, 1, 7, 8, 9, 10, 11));
        final ProtobufWritable<MobData> value2 = MobDataUtil.createAndWrap(
                PoiPosUtil.create(10, 20, 6, 40000.0D, 40000.0D, 0, 70, 80, 90,
                                  100, 110));
        final ProtobufWritable<TwoInt> outKey = TwoIntUtil.createAndWrap(2, 20);
        final ProtobufWritable<MobData> outValue = MobDataUtil.createAndWrap(
                1L);
        this.driver
                .withInput(key, asList(value1, value2))
                .withOutput(outKey, outValue)
                .runTest();
    }

    @Test
    public void shouldNotProduceOutputDueToDistance() {
        {
            final LongWritable key = new LongWritable(57L);
            final ProtobufWritable<MobData> value1 = MobDataUtil.createAndWrap(
                    PoiPosUtil.create(1, 2, 3, 4, 5, 1, 7, 8, 9, 10, 11));
            final ProtobufWritable<MobData> value2 = MobDataUtil.createAndWrap(
                    PoiPosUtil.create(10, 20, 6, 4000.0D, 4000.0D, 0, 70, 80,
                                      90, 100, 110));
            this.driver
                    .withInput(key, asList(value1, value2))
                    .runTest();
        }

        {
            final LongWritable key = new LongWritable(57L);
            final ProtobufWritable<MobData> value1 = MobDataUtil.createAndWrap(
                    PoiPosUtil.create(1, 2, 3, 10000.0D, 10000.0D, 1, 7, 8, 9,
                                      10, 11));
            final ProtobufWritable<MobData> value2 = MobDataUtil.createAndWrap(
                    PoiPosUtil.create(10, 20, 6, 40000.0D, 40000.0D, 0, 70, 80,
                                      90, 100, 110));
            this.driver
                    .withInput(key, asList(value1, value2))
                    .runTest();
        }
    }

    @Test
    public void shouldNotProduceOutputDueToLabelIds() {
        {
            final LongWritable key = new LongWritable(57L);
            final ProtobufWritable<MobData> value1 = MobDataUtil.createAndWrap(
                    PoiPosUtil.create(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11));
            final ProtobufWritable<MobData> value2 = MobDataUtil.createAndWrap(
                    PoiPosUtil.create(10, 20, 6, 40000.0D, 40000.0D, 0, 70, 80,
                                      90, 100, 110));
            this.driver
                    .withInput(key, asList(value1, value2))
                    .runTest();
        }

        {
            final LongWritable key = new LongWritable(57L);
            final ProtobufWritable<MobData> value1 = MobDataUtil.createAndWrap(
                    PoiPosUtil.create(1, 2, 3, 4, 5, 1, 7, 8, 9, 10, 11));
            final ProtobufWritable<MobData> value2 = MobDataUtil.createAndWrap(
                    PoiPosUtil.create(10, 20, 30, 40000.0D, 40000.0D, 0, 70, 80,
                                      90, 100, 110));
            this.driver
                    .withInput(key, asList(value1, value2))
                    .runTest();
        }
    }
}
<commit_msg>Split all tests into their methods so that setUp is called every time.<commit_after>package es.tid.cosmos.mobility.labelling.secondhomes;

import static java.util.Arrays.asList;

import com.twitter.elephantbird.mapreduce.io.ProtobufWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.mrunit.mapreduce.ReduceDriver;
import org.junit.Before;
import org.junit.Test;

import es.tid.cosmos.mobility.data.MobDataUtil;
import es.tid.cosmos.mobility.data.MobProtocol.MobData;
import es.tid.cosmos.mobility.data.MobProtocol.TwoInt;
import es.tid.cosmos.mobility.data.PoiPosUtil;
import es.tid.cosmos.mobility.data.TwoIntUtil;

/**
 *
 * @author dmicol
 */
public class GetPairsSechomePoisReducerTest {
    private ReduceDriver<LongWritable, ProtobufWritable<MobData>,
            ProtobufWritable<TwoInt>, ProtobufWritable<MobData>> driver;
    
    @Before
    public void setUp() {
        this.driver = new ReduceDriver<LongWritable, ProtobufWritable<MobData>,
                ProtobufWritable<TwoInt>, ProtobufWritable<MobData>>(
                        new GetPairsSechomePoisReducer());
    }

    @Test
    public void shouldProduceOutput() {
        final LongWritable key = new LongWritable(57L);
        final ProtobufWritable<MobData> value1 = MobDataUtil.createAndWrap(
                PoiPosUtil.create(1, 2, 3, 4, 5, 1, 7, 8, 9, 10, 11));
        final ProtobufWritable<MobData> value2 = MobDataUtil.createAndWrap(
                PoiPosUtil.create(10, 20, 6, 40000.0D, 40000.0D, 0, 70, 80, 90,
                                  100, 110));
        final ProtobufWritable<TwoInt> outKey = TwoIntUtil.createAndWrap(2, 20);
        final ProtobufWritable<MobData> outValue = MobDataUtil.createAndWrap(
                1L);
        this.driver
                .withInput(key, asList(value1, value2))
                .withOutput(outKey, outValue)
                .runTest();
    }

    @Test
    public void shouldNotProduceOutputDueToDistance() {
        final LongWritable key = new LongWritable(57L);
        final ProtobufWritable<MobData> value1 = MobDataUtil.createAndWrap(
                PoiPosUtil.create(1, 2, 3, 10000.0D, 10000.0D, 1, 7, 8, 9, 10,
                                  11));
        final ProtobufWritable<MobData> value2 = MobDataUtil.createAndWrap(
                PoiPosUtil.create(10, 20, 6, 40000.0D, 40000.0D, 0, 70, 80, 90,
                                  100, 110));
        this.driver
                .withInput(key, asList(value1, value2))
                .runTest();
    }
    
    @Test
    public void shouldNotProduceOutputDueToDistanceOneBeingZero() {
        final LongWritable key = new LongWritable(57L);
        final ProtobufWritable<MobData> value1 = MobDataUtil.createAndWrap(
                PoiPosUtil.create(1, 2, 3, 4, 5, 1, 7, 8, 9, 10, 11));
        final ProtobufWritable<MobData> value2 = MobDataUtil.createAndWrap(
                PoiPosUtil.create(10, 20, 6, 4000.0D, 4000.0D, 0, 70, 80, 90,
                                  100, 110));
        this.driver
                .withInput(key, asList(value1, value2))
                .runTest();
    }

    @Test
    public void shouldNotProduceOutputDueToLabelIdsInFirstValue() {
        final LongWritable key = new LongWritable(57L);
        final ProtobufWritable<MobData> value1 = MobDataUtil.createAndWrap(
                PoiPosUtil.create(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11));
        final ProtobufWritable<MobData> value2 = MobDataUtil.createAndWrap(
                PoiPosUtil.create(10, 20, 6, 40000.0D, 40000.0D, 0, 70, 80,
                                    90, 100, 110));
        this.driver
                .withInput(key, asList(value1, value2))
                .runTest();
    }

    @Test
    public void shouldNotProduceOutputDueToLabelIdsInSecondValue() {
        final LongWritable key = new LongWritable(57L);
        final ProtobufWritable<MobData> value1 = MobDataUtil.createAndWrap(
                PoiPosUtil.create(1, 2, 3, 4, 5, 1, 7, 8, 9, 10, 11));
        final ProtobufWritable<MobData> value2 = MobDataUtil.createAndWrap(
                PoiPosUtil.create(10, 20, 30, 40000.0D, 40000.0D, 0, 70, 80,
                                    90, 100, 110));
        this.driver
                .withInput(key, asList(value1, value2))
                .runTest();
    }
}

{'fraction_non_alphanumeric': 0.10381944444444445, 'fraction_numerical': 0.059722222222222225, 'mean_word_length': 2.0641843971631206, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 19, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3529644', 'n_tokens_mistral': 3228, 'n_tokens_neox': 2711, 'n_words': 564}