<commit_before>package de.uni_potsdam.hpi.bpt.bp2014.jcore;

import javax.ws.rs.core.Application;

import de.uni_potsdam.hpi.bpt.bp2014.database.DbObject;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;

import static org.junit.Assert.*;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.IOException;

public class RestConnection2Test extends JerseyTest {

    /* #############################################################################
     *
     * TEST SETUP
     *
     * #############################################################################
     */
    
    @Before
    public void setUpDatabase() {
        DbObject dbObject = new DbObject();
        dbObject.executeUpdateStatement("DROP DATABASE JEngineV2");
        dbObject.executeUpdateStatement("CREATE DATABASE JEngineV2");
        Document sqlFile = getDocumentFromSQLFile(new File("src/main/resources/JEngineV2.sql"));

    }

    @Override
    protected Application configure() {
        return new ResourceConfig(de.uni_potsdam.hpi.bpt.bp2014.jcore.RestConnection.class);

    }

    /* #############################################################################
     *
     * HTTP GET REQUEST
     *
     * #############################################################################
     */

    @Test
    public void testGetAllScenarios(){
        final Response test = target("/interface/v1/en/scenario/0/").request().get();
        assertEquals("{\"ids\":[1,2,3,100,101,103,105,111,113,114,115,116,117,118,134]}", test.readEntity(String.class));
    }

    @Test
    public void testGetScenarioInstances(){
        final Response test = target("/interface/v1/en/scenario/1/instance/0/").request().get();
        assertEquals("{\"ids\":[1,2,3,100,101,103,105,111,113,114,115,116,117,118,134]}", test.readEntity(String.class));
    }

    @Test
    public void testGetAllActivitiesForScenarioInstance(){
        final Response test = target("/interface/v1/en/scenario/0/").request().get();
        assertEquals("{\"ids\":[1,2,3,100,101,103,105,111,113,114,115,116,117,118,134]}", test.readEntity(String.class));
    }

    @Test
    public void testGetAllDataobjectForScenarioInstance(){
        final Response test = target("/interface/v1/en/scenario/0/").request().get();
        assertEquals("{\"ids\":[1,2,3,100,101,103,105,111,113,114,115,116,117,118,134]}", test.readEntity(String.class));
    }

    /* #############################################################################
     *
     * HTTP POST REQUEST
     *
     * #############################################################################
     */

    @Test
    public void testPostActivityStatusUpdate(){
        //final Response test = target("/interface/v1/en/scenario/1/instance/0/activityinstance/319/?status=enabled").request().post();
        //assertEquals("true", test.readEntity(String.class));
    }

    @Test
    public void testPostNewInstanceForScenario(){
        //final Response test = target("/interface/v1/en/scenario/1/").request().post();
        //assertEquals("123", test.readEntity(String.class));
    }

    private Document getDocumentFromSQLFile(final File sql) {
        try {
            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
            Document doc = dBuilder.parse(sql);
            doc.getDocumentElement().normalize();
            return doc;
        } catch (SAXException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ParserConfigurationException e) {
            e.printStackTrace();
        }
        return null;
    }

}
<commit_msg>correcting response strings for RestConnection2Test.java<commit_after>package de.uni_potsdam.hpi.bpt.bp2014.jcore;

import javax.ws.rs.core.Application;

import de.uni_potsdam.hpi.bpt.bp2014.database.DbObject;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;

import static org.junit.Assert.*;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.File;
import java.io.IOException;

public class RestConnection2Test extends JerseyTest {

    /* #############################################################################
     *
     * TEST SETUP
     *
     * #############################################################################
     */

    @Before
    public void setUpDatabase() {
        DbObject dbObject = new DbObject();
        dbObject.executeUpdateStatement("DROP DATABASE JEngineV2");
        dbObject.executeUpdateStatement("CREATE DATABASE JEngineV2");
        Document sqlFile = getDocumentFromSQLFile(new File("src/main/resources/JEngineV2.sql"));

    }

    @Override
    protected Application configure() {
        return new ResourceConfig(de.uni_potsdam.hpi.bpt.bp2014.jcore.RestConnection.class);

    }

    /* #############################################################################
     *
     * HTTP GET REQUEST
     *
     * #############################################################################
     */

    @Test
    public void testGetAllScenarios(){
        final Response test = target("/interface/v1/en/scenario/0/").request().get();
        assertEquals("{\"ids\":[1,2,3,100,101,103,105,111,113,114,115,116,117,118,134]}", test.readEntity(String.class));
    }

    @Test
    public void testGetScenarioInstances(){
        final Response test = target("/interface/v1/en/scenario/1/instance/0/").request().get();
        assertEquals("{\"ids\":[47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,92,94,95,97,99,101,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,212,214,215,216,217,218,219,220,221,222,223,224,226,228,244,246,248,250,252,255,257,259,261,262,263,265,266,270,279,281,282,284,285,286,294,296,309,310,312,313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,333,334,346,348,349,351,353,356,358,359,361,363,365,366,367,369,370,371,372,373,374,375,376,377,378,379,380,381,383,385,386,387,388,390,392,394,396,398,400,402,404,406,408,409,410,411,412,413,415,416,417,418,419,420,421,422,430,433,438,441,444,445,446,448,449,452,456,459,460,461,464,467,470,473,476,479,482,485,488,491,492,493,494,497,505,515,519,527,531,552,561,563,572,582,590,598,605,612,614,621,628,635,642,649,656,663,670,677,684,691,698,705,712,719,726,733,740,747,754,756,763,770,777,784,791]}", test.readEntity(String.class));
    }

    @Test
    public void testGetAllActivitiesForScenarioInstance(){
        final Response test = target("/interface/v1/en/scenario/1/instance/47/activityinstance/0/").request().get();
        assertEquals("{\"ids\":[1,2,3,100,101,103,105,111,113,114,115,116,117,118,134]}", test.readEntity(String.class));
    }

    @Test
    public void testGetAllDataobjectForScenarioInstance(){
        final Response test = target("/interface/v1/en/scenario/0/").request().get();
        assertEquals("{\"ids\":[1,2,3,100,101,103,105,111,113,114,115,116,117,118,134]}", test.readEntity(String.class));
    }

    /* #############################################################################
     *
     * HTTP POST REQUEST
     *
     * #############################################################################
     */

    @Test
    public void testPostActivityStatusUpdate(){
        //final Response test = target("/interface/v1/en/scenario/1/instance/0/activityinstance/319/?status=enabled").request().post();
        //assertEquals("true", test.readEntity(String.class));
    }

    @Test
    public void testPostNewInstanceForScenario(){
        //final Response test = target("/interface/v1/en/scenario/1/").request().post();
        //assertEquals("123", test.readEntity(String.class));
    }

    private Document getDocumentFromSQLFile(final File sql) {
        try {
            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
            Document doc = dBuilder.parse(sql);
            doc.getDocumentElement().normalize();
            return doc;
        } catch (SAXException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ParserConfigurationException e) {
            e.printStackTrace();
        }
        return null;
    }

}

{'fraction_non_alphanumeric': 0.24023706212297596, 'fraction_numerical': 0.1380040215895862, 'mean_word_length': 4.332957110609481, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '5109276', 'n_tokens_mistral': 3789, 'n_tokens_neox': 2910, 'n_words': 334}