<commit_before>package edu.kit.ipd.crowdcontrol.objectservice.crowdworking.mturk;

import edu.kit.ipd.crowdcontrol.objectservice.crowdworking.mturk.command.GetHIT;
import edu.kit.ipd.crowdcontrol.objectservice.crowdworking.mturk.command.PublishHIT;
import edu.kit.ipd.crowdcontrol.objectservice.crowdworking.mturk.command.UnpublishHIT;
import edu.kit.ipd.crowdcontrol.objectservice.crowdworking.mturk.mturk.HIT;
import edu.kit.ipd.crowdcontrol.objectservice.crowdworking.mturk.mturk.HITStatus;
import org.junit.Before;
import org.junit.Test;

import java.io.FileInputStream;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Properties;

import static org.junit.Assert.*;

/**
 * Created by marcel on 01.02.16.
 */
public class MTurkRestApiTest {
    private MTurkConnection connection;
    @Before
    public void setUp() throws Exception {
        Properties properties = new Properties();
        properties.load(new FileInputStream("src/integration-test/resources/mturk.properties"));
        connection = new MTurkConnection(
                properties.getProperty("User"),
                properties.getProperty("Password"),
                "https://mechanicalturk.sandbox.amazonaws.com/");
    }

    @Test
    public void testPublishHIT() throws Exception {
        String id = new PublishHIT(connection,"Title1", "Description2",
                0.20,60,2000,"test,for,everything",
                2,2000000,"data").get();

        assertNotEquals(id, null);

        HIT hit = new GetHIT(connection,id).get();

        assertEquals(hit.getTitle(), "Title1");
        assertEquals(hit.getDescription(), "Description2");
        assertTrue(hit.getReward().getAmount().subtract(new BigDecimal(0.20)).doubleValue() < 0.0001);
        assertEquals(hit.getAssignmentDurationInSeconds(), new Long(60));
        //FIXME check the lifetime
        assertEquals(hit.getKeywords(), "test,for,everything");
        assertEquals(hit.getMaxAssignments(), new Integer(2));
        assertEquals(hit.getAutoApprovalDelayInSeconds(), new Long(2000000));
        assertEquals(hit.getRequesterAnnotation(), "data");

        assertTrue(new UnpublishHIT(connection,id,"").get());

        assertEquals(new GetHIT(connection,id).get().getHITStatus(), HITStatus.DISPOSED);

    }
}<commit_msg>fix tests<commit_after>package edu.kit.ipd.crowdcontrol.objectservice.crowdworking.mturk;

import edu.kit.ipd.crowdcontrol.objectservice.crowdworking.mturk.command.GetHIT;
import edu.kit.ipd.crowdcontrol.objectservice.crowdworking.mturk.command.PublishHIT;
import edu.kit.ipd.crowdcontrol.objectservice.crowdworking.mturk.command.UnpublishHIT;
import edu.kit.ipd.crowdcontrol.objectservice.crowdworking.mturk.mturk.HIT;
import edu.kit.ipd.crowdcontrol.objectservice.crowdworking.mturk.mturk.HITStatus;
import org.junit.Before;
import org.junit.Test;

import java.io.FileInputStream;
import java.math.BigDecimal;
import java.util.Properties;

import static org.junit.Assert.*;

/**
 * Created by marcel on 01.02.16.
 */
public class MTurkRestApiTest {
    private MTurkConnection connection;
    @Before
    public void setUp() throws Exception {
        Properties properties = new Properties();
        properties.load(new FileInputStream("src/integration-test/resources/mturk.properties"));
        connection = new MTurkConnection(
                properties.getProperty("User"),
                properties.getProperty("Password"),
                "https://mechanicalturk.sandbox.amazonaws.com/");
    }

    @Test
    public void testPublishHIT() throws Exception {
        String id = new PublishHIT(connection,"Title1", "Description2",
                0.20,60,2000,"test,for,everything",
                2,2000000,"data").get();

        assertNotEquals(id, null);

        HIT hit = new GetHIT(connection,id).get();

        assertEquals(hit.getTitle(), "Title1");
        assertEquals(hit.getDescription(), "Description2");
        assertTrue(hit.getReward().getAmount().subtract(new BigDecimal(0.20)).doubleValue() < 0.0001);
        assertEquals(hit.getAssignmentDurationInSeconds(), new Long(60));
        //FIXME check the lifetime
        assertEquals(hit.getKeywords(), "test,for,everything");
        assertEquals(hit.getMaxAssignments(), new Integer(2));
        assertEquals(hit.getAutoApprovalDelayInSeconds(), new Long(2000000));
        assertEquals(hit.getRequesterAnnotation(), "data");

        assertTrue(new UnpublishHIT(connection,id).get());

        assertEquals(new GetHIT(connection,id).get().getHITStatus(), HITStatus.DISPOSED);

    }
}
{'fraction_non_alphanumeric': 0.12746386333771353, 'fraction_numerical': 0.01971090670170828, 'mean_word_length': 3.8073684210526317, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '6083161', 'n_tokens_mistral': 1445, 'n_tokens_neox': 1355, 'n_words': 207}