<commit_before>package org.devgateway.ocds.web.rest.controller;

import com.mongodb.DBObject;
import org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author idobre
 * @since 9/13/16
 *
 * @see {@link AbstractEndPointControllerTest}
 */
public class TopTenControllerTest extends AbstractEndPointControllerTest {
    @Autowired
    private TopTenController topTenController;

    @Test
    public void topTenLargestAwards() throws Exception {
        final List<DBObject> topTenLargestAwards = topTenController
                .topTenLargestAwards(new YearFilterPagingRequest());

        logger.error(topTenLargestAwards);
    }

    @Test
    public void topTenLargestTenders() throws Exception {
        final List<DBObject> topTenLargestTenders = topTenController
                .topTenLargestTenders(new YearFilterPagingRequest());

        logger.error(topTenLargestTenders);
    }
}
<commit_msg>OCE-64 - added testes for TopTenController.<commit_after>package org.devgateway.ocds.web.rest.controller;

import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
import org.devgateway.ocds.web.rest.controller.request.YearFilterPagingRequest;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @author idobre
 * @since 9/13/16
 *
 * @see {@link AbstractEndPointControllerTest}
 */
public class TopTenControllerTest extends AbstractEndPointControllerTest {
    @Autowired
    private TopTenController topTenController;

    @Test
    public void topTenLargestAwards() throws Exception {
        final List<DBObject> topTenLargestAwards = topTenController
                .topTenLargestAwards(new YearFilterPagingRequest());

        Assert.assertEquals(2, topTenLargestAwards.size());

        final DBObject first = topTenLargestAwards.get(0);
        BasicDBObject awards = (BasicDBObject) first.get("awards");
        BasicDBObject value = (BasicDBObject) awards.get("value");
        double amount = (double) value.get("amount");
        Assert.assertEquals(6000000.0, amount, 0);

        final DBObject second = topTenLargestAwards.get(1);
        awards = (BasicDBObject) second.get("awards");
        value = (BasicDBObject) awards.get("value");
        amount = (double) value.get("amount");
        Assert.assertEquals(40000.0, amount, 0);
    }

    @Test
    public void topTenLargestTenders() throws Exception {
        final List<DBObject> topTenLargestTenders = topTenController
                .topTenLargestTenders(new YearFilterPagingRequest());

        Assert.assertEquals(3, topTenLargestTenders.size());

        final DBObject first = topTenLargestTenders.get(0);
        BasicDBObject tender = (BasicDBObject) first.get("tender");
        BasicDBObject value = (BasicDBObject) tender.get("value");
        double amount = (double) value.get("amount");
        Assert.assertEquals(600000.0, amount, 0);

        final DBObject second = topTenLargestTenders.get(1);
        tender = (BasicDBObject) second.get("tender");
        value = (BasicDBObject) tender.get("value");
        amount = (double) value.get("amount");
        Assert.assertEquals(400000.0, amount, 0);

        final DBObject third = topTenLargestTenders.get(2);
        tender = (BasicDBObject) third.get("tender");
        value = (BasicDBObject) tender.get("value");
        amount = (double) value.get("amount");
        Assert.assertEquals(9000.0, amount, 0);
    }
}

{'fraction_non_alphanumeric': 0.10815307820299501, 'fraction_numerical': 0.015806988352745424, 'mean_word_length': 3.6481958762886597, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3754904', 'n_tokens_mistral': 1097, 'n_tokens_neox': 1049, 'n_words': 204}