<commit_before>package uk.bl.wa.w3act;

import static org.junit.Assert.*;
import static play.test.Helpers.fakeApplication;
import static play.test.Helpers.inMemoryDatabase;
import static play.test.Helpers.running;

import java.io.File;
import java.io.IOException;

import org.junit.Test;

import play.Logger;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

public class W3ACTCacheTest {

	//@Test
/*
	public void testCacheLiveW3ACT() {
		running(fakeApplication(inMemoryDatabase("test")), new Runnable() {
			@Override
			public void run() {
				
				W3ACTCache cache = new W3ACTCache();

			}
		});
	}
*/

	@Test
	public void testW3ACTJsonParsing() throws JsonProcessingException, IOException {
	    
	    // Set up a test colln:
	    CollectionTree ct = new CollectionTree();
	    ct.id = 169;
	    
	    // Load collection JSON:
	    ObjectMapper m = new ObjectMapper();
	    JsonNode collectionsJson = m.readTree(new File("test/data/magna-carta-collection.json"));
	    ct.addCollectionDetails(collectionsJson);
	    
	    // Load targets:
	    JsonNode targetsJson = m.readTree(new File("test/data/magna-carta-collection-targets.json"));;
	    ct.addTargets(targetsJson);
	    
	    // Prints and tests
	    Long numTargetsTotal = ct.getNumberOfTargets(true);
	    Logger.info("GOT "+numTargetsTotal+" targets.");
	    assertEquals("Wrong number of targets!", new Long(1052),numTargetsTotal);
	    Long numOpenAccessTargetsTotal = ct.getNumberOfOpenAccessTargets(true);
	    Logger.info("GOT "+numOpenAccessTargetsTotal+" OA targets.");
	    assertEquals("Wrong number of OA targets!", new Long(5),numOpenAccessTargetsTotal);
	    
	    // Perform some data tests:
	    Target t = ct.findTarget(19273l);
	    Logger.info("Got "+t);
	    assertEquals("OA license not found!", true, t.isOpenAccess);
	    
	}
}<commit_msg>Fix up the test.<commit_after>package uk.bl.wa.w3act;

import static org.junit.Assert.*;
import static play.test.Helpers.fakeApplication;
import static play.test.Helpers.inMemoryDatabase;
import static play.test.Helpers.running;

import java.io.File;
import java.io.IOException;

import org.junit.Test;

import play.Logger;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

public class W3ACTCacheTest {

	//@Test
/*
	public void testCacheLiveW3ACT() {
		running(fakeApplication(inMemoryDatabase("test")), new Runnable() {
			@Override
			public void run() {
				
				W3ACTCache cache = new W3ACTCache();

			}
		});
	}
*/

	@Test
	public void testW3ACTJsonParsing() throws JsonProcessingException, IOException {
	    
	    // Set up a test colln:
	    CollectionTree ct = new CollectionTree();
	    ct.id = 169;
	    
	    // Load collection JSON:
	    ObjectMapper m = new ObjectMapper();
	    JsonNode collectionsJson = m.readTree(new File("test/data/magna-carta-collection.json"));
	    ct.addCollectionDetails(collectionsJson);
	    
	    // Load targets:
	    JsonNode targetsJson = m.readTree(new File("test/data/magna-carta-collection-targets.json"));
	    for( JsonNode targetJson : targetsJson) {
		ct.addTarget(targetJson);
	    }
	    
	    // Prints and tests
	    Long numTargetsTotal = ct.getNumberOfTargets(true);
	    Logger.info("GOT "+numTargetsTotal+" targets.");
	    assertEquals("Wrong number of targets!", new Long(1052),numTargetsTotal);
	    Long numOpenAccessTargetsTotal = ct.getNumberOfOpenAccessTargets(true);
	    Logger.info("GOT "+numOpenAccessTargetsTotal+" OA targets.");
	    assertEquals("Wrong number of OA targets!", new Long(5),numOpenAccessTargetsTotal);
	    
	    // Perform some data tests:
	    Target t = ct.findTarget(19273l);
	    Logger.info("Got "+t);
	    assertEquals("OA license not found!", true, t.isOpenAccess);
	    
	}
}
{'fraction_non_alphanumeric': 0.11739241151005857, 'fraction_numerical': 0.00967659791189203, 'mean_word_length': 3.7612121212121212, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '5930935', 'n_tokens_mistral': 1334, 'n_tokens_neox': 1178, 'n_words': 261}