<commit_before>package ualberta.g12.adventurecreator.test;

public class CacheStoryTestCases {

    // This will be a tough one
}<commit_msg>Added cacheing test<commit_after>
package ualberta.g12.adventurecreator.test;

import android.content.Context;
import android.test.ActivityInstrumentationTestCase2;

import ualberta.g12.adventurecreator.data.Story;
import ualberta.g12.adventurecreator.tasks.CacheStoryTask;
import ualberta.g12.adventurecreator.views.FragmentViewActivity;

import java.util.concurrent.ExecutionException;

public class CacheStoryTestCases extends ActivityInstrumentationTestCase2<FragmentViewActivity> {

    private CacheStoryTask cacheTask;
    private Context context;

    public CacheStoryTestCases() {
        super(FragmentViewActivity.class);
    }

    public void testEnterActivity() throws Throwable {
        this.cacheTask = new CacheStoryTask(getInstrumentation().getContext());
        assertNotNull(cacheTask);

        final Story s = new Story("A", "A");

        runTestOnUiThread(new Runnable() {

            @Override
            public void run() {
                cacheTask.execute(new Story[] {
                        s
                });

                try {
                    if (cacheTask.get().contains("Error viewing")) {
                        // Couldn't open this activity
                        fail("Couldn't cache the story");
                    }
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (ExecutionException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                // On Post execute won't end til we end this activity
            }
        });

    }
}
{'fraction_non_alphanumeric': 0.0824235807860262, 'fraction_numerical': 0.006550218340611353, 'mean_word_length': 2.0148026315789473, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '681148', 'n_tokens_mistral': 492, 'n_tokens_neox': 450, 'n_words': 104}