<commit_before>package nl.fhict.intellicloud.answers;

import android.app.Activity;
import android.content.Intent;
import android.test.ActivityInstrumentationTestCase2;
import android.widget.EditText;

import junit.framework.Assert;

import nl.fhict.intellicloud.R;
import nl.fhict.intellicloud.answers.backendcommunication.DummyBackend;
import nl.fhict.intellicloud.answers.backendcommunication.IAnswerService;
import nl.fhict.intellicloud.answers.backendcommunication.IQuestionService;

public class SendAnswerActivityTest extends ActivityInstrumentationTestCase2<SendAnswerActivity>{

    public SendAnswerActivityTest(Class<SendAnswerActivity> activityClass) {
        super(activityClass);
    }

    /**
     * Test Submitting an answer
     * @throws Throwable
     */
    public void testAddAnswer() throws Throwable {
        final IQuestionService qService = new DummyBackend();
        final IAnswerService aService = new DummyBackend();
        final Question question = qService.GetQuestion(1);
        final String answerText = "This is the test answer";
        final Answer expected = new Answer(answerText, question.getAnwserer(), AnswerState.UnderReview);

        // Create an intent
        Intent openIntent = new Intent(getActivity().getApplicationContext(), SendAnswerActivity.class);
        openIntent.putExtra("questionInt", question.getId());
        // Add the intent to the activity
        setActivityIntent(openIntent);
        // Start the activity
        Activity activity = getActivity();

        final EditText etAnswer = (EditText) activity.findViewById(R.id.etAnswer);
        activity.runOnUiThread( new Runnable() {
            @Override
            public void run() {
                etAnswer.setText(answerText);
                getActivity().addAnswer();

                Answer actual = aService.GetAnswer(question.getId());
                Assert.assertEquals(expected, actual);
            }
        });<commit_msg>Small adjustments in SendAnswerActivityTest<commit_after>package nl.fhict.intellicloud.answers;

import android.app.Activity;
import android.content.Intent;
import android.test.ActivityInstrumentationTestCase2;
import android.widget.EditText;

import junit.framework.Assert;

import nl.fhict.intellicloud.R;
import nl.fhict.intellicloud.answers.backendcommunication.DummyBackend;
import nl.fhict.intellicloud.answers.backendcommunication.IAnswerService;
import nl.fhict.intellicloud.answers.backendcommunication.IQuestionService;

public class SendAnswerActivityTest extends ActivityInstrumentationTestCase2<SendAnswerActivity>{

    public SendAnswerActivityTest(Class<SendAnswerActivity> activityClass) {
        super(activityClass);

        try {
            testAddAnswer();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
    }

    /**
     * Test Submitting an answer
     * @throws Throwable
     */
    public void testAddAnswer() throws Throwable {
        final IQuestionService qService = new DummyBackend();
        final IAnswerService aService = new DummyBackend();
        final Question question = qService.GetQuestion(1);
        final String answerText = "This is the test answer";
        final Answer expected = new Answer(answerText, question.getAnwserer(), AnswerState.UnderReview);

        // Create an intent
        Intent openIntent = new Intent(getActivity().getApplicationContext(), SendAnswerActivity.class);
        openIntent.putExtra("questionInt", question.getId());
        // Add the intent to the activity
        setActivityIntent(openIntent);
        // Start the activity
        Activity activity = getActivity();

        final EditText etAnswer = (EditText) activity.findViewById(R.id.etAnswer);
        activity.runOnUiThread( new Runnable() {
            @Override
            public void run() {
                etAnswer.setText(answerText);
                getActivity().addAnswer();

                Answer actual = aService.GetAnswer(question.getId());
                Assert.assertEquals(expected, actual);
            }
        });

        //Close the activity
        activity.finish();
        setActivity(null);
{'fraction_non_alphanumeric': 0.0881437125748503, 'fraction_numerical': 0.001437125748502994, 'mean_word_length': 3.1387512388503467, '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': '7392592', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1060, 'n_words': 236}