<commit_before>package uk.org.llgc.annotation.store.test;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.Rule;
import org.junit.Before;
import org.junit.After;
import org.junit.rules.TemporaryFolder;

import com.github.jsonldjava.utils.JsonUtils;

import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;

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

import uk.org.llgc.annotation.store.exceptions.IDConflictException;
import uk.org.llgc.annotation.store.adapters.StoreAdapter;
import uk.org.llgc.annotation.store.encoders.Mirador214;
import uk.org.llgc.annotation.store.AnnotationUtils;
import uk.org.llgc.annotation.store.StoreConfig;
import uk.org.llgc.annotation.store.exceptions.IDConflictException;

import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.riot.Lang;
import com.hp.hpl.jena.rdf.model.StmtIterator;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.vocabulary.DCTerms;
import com.hp.hpl.jena.query.* ;

import org.openrdf.repository.http.HTTPRepository;
import org.openrdf.repository.RepositoryConnection;
import org.openrdf.repository.RepositoryException;

import java.util.Properties;

public class TestMirador214 extends TestUtils {
	protected static Logger _logger = LogManager.getLogger(TestMirador214.class.getName());

	public TestMirador214() throws IOException {
		super(new Mirador214());
	}

	@Before
   public void setup() throws IOException {
		super.setup();
	}

   @After
   public void tearDown() throws IOException {
		super.tearDown();
	}

	@Test
	public void testMirador214() throws IOException, IDConflictException, InterruptedException {
		Map<String, Object> tAnnotationJSON = _annotationUtils.readAnnotaion(new FileInputStream(getClass().getResource("/jsonld/mirador-2.1.4.json").getFile()), StoreConfig.getConfig().getBaseURI(null));

		String tAnnoId = (String)tAnnotationJSON.get("@id");
		_logger.debug("ID " + tAnnoId);
		Model tModel = _store.addAnnotation(tAnnotationJSON);

		Map<String, Object> tAnnotation = _annotationUtils.createAnnotationList(tModel);

		// Require on to be an array
		assertTrue("On needs to be an array and it isn't.", tAnnotation.get("on") instanceof List);

		//System.out.println(JsonUtils.toPrettyString(tAnnotation));
		assertNotNull("Default rect present ", ((Map<String,Map<String,String>>)((List<Map<String,Object>>)tAnnotation.get("on")).get(0).get("selector")).get("default").get("value"));
	}

    @Test
    public void testPopulate() throws IOException, IDConflictException, InterruptedException {
        List<Map<String, Object>> tAnnotationListJSON = _annotationUtils.readAnnotationList(new FileInputStream(getClass().getResource("/jsonld/annos_master_version1.json").getFile()), StoreConfig.getConfig().getBaseURI(null)); //annotaiton list

        List<Model> tModel = _store.addAnnotationList(tAnnotationListJSON);

		List<Map<String, Object>> tAnnotations = _annotationUtils.createAnnotationList(tModel);

        assertEquals("Exported list was a different size to the one supplied.", tAnnotationListJSON.size(), tAnnotations.size());

        Map<String,Object> tAnno1 = tAnnotations.get(0);
		/*assertTrue("On needs to be an array and it isn't.", tAnno1.get("on") instanceof List);

        List<Map<String,Object>> tOn = (List<Map<String,Object>>)tAnno1.get("on");
        Map<String,Object> tSelector = (Map<String,Object>)tOn.get(0).get("selector");
        assertEquals("Mirador requires select is a choice but it was:", "oa:Choice",tSelector.get("@type"));
        assertNotNull("Missing default choice in selector",tSelector.get("default"));
        assertEquals("Default should be fragment selector.","oa:FragmentSelector",((Map<String,Object>)tSelector.get("default")).get("@type"));
        assertEquals("Backup needs to be svg","oa:SvgSelector",((Map<String,Object>)tSelector.get("item")).get("@type"));
        */
    }
}<commit_msg>Removing test for populate as Mirador can take historical annotation formats.<commit_after>package uk.org.llgc.annotation.store.test;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.Rule;
import org.junit.Before;
import org.junit.After;
import org.junit.rules.TemporaryFolder;

import com.github.jsonldjava.utils.JsonUtils;

import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;

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

import uk.org.llgc.annotation.store.exceptions.IDConflictException;
import uk.org.llgc.annotation.store.adapters.StoreAdapter;
import uk.org.llgc.annotation.store.encoders.Mirador214;
import uk.org.llgc.annotation.store.AnnotationUtils;
import uk.org.llgc.annotation.store.StoreConfig;
import uk.org.llgc.annotation.store.exceptions.IDConflictException;

import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.riot.Lang;
import com.hp.hpl.jena.rdf.model.StmtIterator;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.vocabulary.DCTerms;
import com.hp.hpl.jena.query.* ;

import org.openrdf.repository.http.HTTPRepository;
import org.openrdf.repository.RepositoryConnection;
import org.openrdf.repository.RepositoryException;

import java.util.Properties;

public class TestMirador214 extends TestUtils {
	protected static Logger _logger = LogManager.getLogger(TestMirador214.class.getName());

	public TestMirador214() throws IOException {
		super(new Mirador214());
	}

	@Before
   public void setup() throws IOException {
		super.setup();
	}

   @After
   public void tearDown() throws IOException {
		super.tearDown();
	}

	@Test
	public void testMirador214() throws IOException, IDConflictException, InterruptedException {
		Map<String, Object> tAnnotationJSON = _annotationUtils.readAnnotaion(new FileInputStream(getClass().getResource("/jsonld/mirador-2.1.4.json").getFile()), StoreConfig.getConfig().getBaseURI(null));

		String tAnnoId = (String)tAnnotationJSON.get("@id");
		_logger.debug("ID " + tAnnoId);
		Model tModel = _store.addAnnotation(tAnnotationJSON);

		Map<String, Object> tAnnotation = _annotationUtils.createAnnotationList(tModel);

		// Require on to be an array
		assertTrue("On needs to be an array and it isn't.", tAnnotation.get("on") instanceof List);

		//System.out.println(JsonUtils.toPrettyString(tAnnotation));
		assertNotNull("Default rect present ", ((Map<String,Map<String,String>>)((List<Map<String,Object>>)tAnnotation.get("on")).get(0).get("selector")).get("default").get("value"));
	}
}
{'fraction_non_alphanumeric': 0.1354559419075548, 'fraction_numerical': 0.00754084625052367, 'mean_word_length': 5.619223659889094, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '4045020', 'n_tokens_mistral': 2357, 'n_tokens_neox': 2275, 'n_words': 403}