<commit_before>package org.motechproject.demo;

import com.google.gson.reflect.TypeToken;
import org.apache.commons.lang.StringUtils;
import org.apache.http.impl.client.BasicResponseHandler;
import org.motechproject.commons.api.json.MotechJsonReader;
import org.motechproject.decisiontree.core.DecisionTreeService;
import org.motechproject.decisiontree.core.model.Tree;
import org.motechproject.testing.osgi.BaseOsgiIT;
import org.motechproject.testing.utils.PollingHttpClient;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

public class DemoBundleIT extends BaseOsgiIT {

    public void testTreesController() throws IOException, InterruptedException {
        DecisionTreeService decisionTreeService =
                (DecisionTreeService) verifyServiceAvailable(DecisionTreeService.class.getName());

        Tree tree = new Tree();
        tree.setName("testTree");
        tree.setDescription("testDesc");

        decisionTreeService.saveDecisionTree(tree);

        PollingHttpClient httpClient = new PollingHttpClient();

        String response = httpClient.get("http://localhost:8080/demo/api/trees", new BasicResponseHandler());

        assertNotNull(response);

        MotechJsonReader motechJsonReader = new MotechJsonReader();
        List<Tree> trees  = (List<Tree>) motechJsonReader.readFromString(response,
                new TypeToken<List<Tree>>() { }.getType());<commit_msg>pgesek | Clean up ServerBundleIT, increase timeout in DemoBundleIT<commit_after>package org.motechproject.demo;

import com.google.gson.reflect.TypeToken;
import org.apache.commons.lang.StringUtils;
import org.apache.http.impl.client.BasicResponseHandler;
import org.apache.http.impl.client.DefaultHttpClient;
import org.motechproject.commons.api.json.MotechJsonReader;
import org.motechproject.decisiontree.core.DecisionTreeService;
import org.motechproject.decisiontree.core.model.Tree;
import org.motechproject.testing.osgi.BaseOsgiIT;
import org.motechproject.testing.utils.PollingHttpClient;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

public class DemoBundleIT extends BaseOsgiIT {

    public void testTreesController() throws IOException, InterruptedException {
        DecisionTreeService decisionTreeService =
                (DecisionTreeService) verifyServiceAvailable(DecisionTreeService.class.getName());

        Tree tree = new Tree();
        tree.setName("testTree");
        tree.setDescription("testDesc");

        decisionTreeService.saveDecisionTree(tree);

        PollingHttpClient httpClient = new PollingHttpClient(new DefaultHttpClient(), 60);

        String response = httpClient.get("http://localhost:8080/demo/api/trees", new BasicResponseHandler());

        assertNotNull(response);

        MotechJsonReader motechJsonReader = new MotechJsonReader();
        List<Tree> trees  = (List<Tree>) motechJsonReader.readFromString(response,
                new TypeToken<List<Tree>>() { }.getType());
{'fraction_non_alphanumeric': 0.1, 'fraction_numerical': 0.0033444816053511705, 'mean_word_length': 4.601123595505618, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3754083', 'n_tokens_mistral': 868, 'n_tokens_neox': 809, 'n_words': 144}