<commit_before>package it.almawave.kb

import org.junit.Assert
import org.junit.Test

class FileDatastoreTest {

  @Test
  def test_local_relative_files {
    var fs = new FileDatastore("ontologies")
    Assert.assertTrue(fs.list("owl", "ttl").size > 0)
  }

  //  @Test DISABLED
  def test_remote_files {
    var fs = new FileDatastore("http://xmlns.com/foaf/spec/index.rdf")
    Assert.assertTrue(fs.list("rdf").size > 0)
  }

}<commit_msg>added idea for metadata handler on file<commit_after>package it.almawave.kb

import org.junit.Assert
import org.junit.Test
import java.net.URI
import java.nio.file.Paths
import java.nio.file.Files
import scala.io.Source
import com.typesafe.config.ConfigFactory

import scala.collection.JavaConversions._
import scala.collection.JavaConverters._

class FileDatastoreTest {

  val fs = new FileDatastore("ontologies")

  @Test
  def test_local_relative_files {
    Assert.assertTrue(fs.list("owl", "ttl").size > 0)
  }

  @Test
  def test_local_uri() {
    val foaf_local_uri = new URI("file:///C:/Users/Al.Serafini/repos/DAF/lod_manager/ontologies/foaf/foaf.rdf")
    val list = fs.list("owl", "ttl", "rdf")
    Assert.assertTrue(list.contains(foaf_local_uri))
  }

  @Test
  def test_metadata {
    val list = fs.list("owl", "ttl", "rdf")

    // trying to get metadata, with error
    val uri_no = new URI("file:///not/existing/path/file.rdf")
    val meta_no = fs.getMetadata(uri_no)
    Assert.assertEquals(ConfigFactory.empty(), meta_no)

    // get metadata
    val uri = new URI("file:///C:/Users/Al.Serafini/repos/DAF/lod_manager/ontologies/foaf/foaf.rdf")
    val meta = fs.getMetadata(uri)
    Assert.assertEquals("foaf", meta.getString("prefix"))
    Assert.assertEquals("http://xmlns.com/foaf/0.1/", meta.getString("uri"))
    Assert.assertTrue(meta.getList("contexts").unwrapped().contains("http://xmlns.com/foaf/0.1/"))

  }

}
{'fraction_non_alphanumeric': 0.14665249734325186, 'fraction_numerical': 0.0037194473963868225, 'mean_word_length': 3.878238341968912, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 3}, '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': '1204868', 'n_tokens_mistral': 688, 'n_tokens_neox': 668, 'n_words': 116}