public void DataPublishError() { ShapesConfigMockService shapesConfigMockService = new ShapesConfigMockService(); RepositoriesConfigMockService repositoriesConfigMockService = new RepositoriesConfigMockService(); ConfigSparql configSparql = new ConfigSparql(); configSparql.Endpoint = ""; etlController etlController = new etlController(repositoriesConfigMockService, shapesConfigMockService, configSparql); try { var response = etlController.dataPublish(null); if (response is BadRequestObjectResult) { Assert.True(true); } else { Assert.True(false); } } catch (Exception) { Assert.True(true); } }
public void DataValidate() { ShapesConfigMockService shapesConfigMockService = new ShapesConfigMockService(); RepositoriesConfigMockService repositoriesConfigMockService = new RepositoriesConfigMockService(); ConfigSparql configSparql = new ConfigSparql(); configSparql.Endpoint = ""; etlController etlController = new etlController(repositoriesConfigMockService, shapesConfigMockService, configSparql); var stream = new MemoryStream(); var writer = new StreamWriter(stream); writer.Write(rdfFile); writer.Flush(); stream.Position = 0; var file = new FormFile(stream, 0, stream.Length, null, "rdf.xml"); ShapeReport report = (ShapeReport)((OkObjectResult)etlController.dataValidate(file, new Guid("390cde26-b39d-41c8-89e0-b87c207d8cf2"))).Value; if (!report.conforms && report.results.Count > 0) { Assert.True(true); } else { Assert.True(false); } }
public void ModifyConfigShapeError() { ShapesConfigMockService shapesConfigMockService = new ShapesConfigMockService(); ValidationController validationController = new ValidationController(shapesConfigMockService); ShapeConfig shapeConfig = ((List <ShapeConfig>)(((OkObjectResult)validationController.GetShape()).Value))[0]; var stream = new MemoryStream(); var writer = new StreamWriter(stream); writer.Write("ShapeError"); writer.Flush(); stream.Position = 0; var file = new FormFile(stream, 0, stream.Length, null, "rdf.xml"); try { var response = validationController.ModifyShape(shapeConfig.ShapeConfigID, shapeConfig.Name, shapeConfig.RepositoryID, file); if (response is BadRequestObjectResult) { Assert.True(true); } else { Assert.True(false); } } catch (Exception) { Assert.True(true); } }
public void GetShape() { ShapesConfigMockService shapesConfigMockService = new ShapesConfigMockService(); ValidationController validationController = new ValidationController(shapesConfigMockService); List <ShapeConfig> listaRepositorios = (List <ShapeConfig>)(((OkObjectResult)validationController.GetShape()).Value); Assert.True(listaRepositorios.Count > 0); }
public void DeleteConfigShape() { ShapesConfigMockService shapesConfigMockService = new ShapesConfigMockService(); ValidationController validationController = new ValidationController(shapesConfigMockService); ShapeConfig shapeConfig = ((List <ShapeConfig>)(((OkObjectResult)validationController.GetShape()).Value))[0]; validationController.DeleteShape(shapeConfig.ShapeConfigID); shapeConfig = (ShapeConfig)(((OkObjectResult)validationController.GetShape(shapeConfig.ShapeConfigID)).Value); Assert.Null(shapeConfig); }
public void GetShapeByID() { ShapesConfigMockService shapesConfigMockService = new ShapesConfigMockService(); ValidationController validationController = new ValidationController(shapesConfigMockService); List <ShapeConfig> listaRepositorios = (List <ShapeConfig>)(((OkObjectResult)validationController.GetShape()).Value); if (listaRepositorios.Count > 0) { ShapeConfig shapeConfig = listaRepositorios[0]; ShapeConfig shapeConfigGetByID = (ShapeConfig)(((OkObjectResult)validationController.GetShape(shapeConfig.ShapeConfigID)).Value); Assert.True(shapeConfig.Name.Equals(shapeConfigGetByID.Name)); } }
public void TestListSets() { ShapesConfigMockService shapesConfigMockService = new ShapesConfigMockService(); RepositoriesConfigMockService repositoriesConfigMockService = new RepositoriesConfigMockService(); etlController etlController = new etlController(repositoriesConfigMockService, shapesConfigMockService, null); FileContentResult resultesponse = (FileContentResult)etlController.ListSets(new Guid("5efac0ad-ec4e-467d-bbf5-ce3f64edb46a")); string respuesta = Encoding.Default.GetString(resultesponse.FileContents); XDocument respuestaXML = XDocument.Parse(respuesta.Substring(respuesta.IndexOf("<OAI-PMH "))); XNamespace nameSpace = respuestaXML.Root.GetDefaultNamespace(); string ListSets = respuestaXML.Root.Element(nameSpace + "ListSets").ToString(); Assert.True(!string.IsNullOrEmpty(ListSets)); }
public void GetOntology() { ShapesConfigMockService shapesConfigMockService = new ShapesConfigMockService(); RepositoriesConfigMockService repositoriesConfigMockService = new RepositoriesConfigMockService(); ConfigSparql configSparql = new ConfigSparql(null); configSparql.Endpoint = ""; DiscoverItemMockService discoverItemService = new DiscoverItemMockService(); etlController etlController = new etlController(discoverItemService, repositoriesConfigMockService, shapesConfigMockService, configSparql, null, null, null, null); etlController.GetOntology(); Assert.True(true); }
public void ModifyConfigShapeError2() { ShapesConfigMockService shapesConfigMockService = new ShapesConfigMockService(); ValidationController validationController = new ValidationController(shapesConfigMockService); StringBuilder personShape = new StringBuilder(); personShape.AppendLine("@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>."); personShape.AppendLine("@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>."); personShape.AppendLine("@prefix xsd: <http://www.w3.org/2001/XMLSchema#>."); personShape.AppendLine("@prefix xml: <http://www.w3.org/XML/1998/namespace>."); personShape.AppendLine("@prefix ns: <http://www.w3.org/2003/06/sw-vocab-status/ns#>."); personShape.AppendLine("@prefix sh: <http://www.w3.org/ns/shacl#>."); personShape.AppendLine("@prefix roh: <http://purl.org/roh#>."); personShape.AppendLine("@prefix foaf: <http://purl.org/roh/mirror/foaf#>."); personShape.AppendLine("roh:foaf_PersonShape"); personShape.AppendLine(" a sh:NodeShape ;"); personShape.AppendLine(" sh:targetClass foaf:Person ;"); personShape.AppendLine(" sh:property roh:someValuesDataType__foaf__Person__foaf__firstName."); personShape.AppendLine("roh:someValuesDataType__foaf__Person__foaf__firstName "); personShape.AppendLine(" sh:severity sh:Violation;"); personShape.AppendLine(" sh:path foaf:firstName;"); personShape.AppendLine(" sh:qualifiedMinCount 1;"); personShape.AppendLine(" sh:qualifiedValueShape ["); personShape.AppendLine(" sh:datatype xsd:string;"); personShape.AppendLine(" ]."); var stream = new MemoryStream(); var writer = new StreamWriter(stream); writer.Write(personShape.ToString()); writer.Flush(); stream.Position = 0; var file = new FormFile(stream, 0, stream.Length, null, "rdf.xml"); try { var response = validationController.ModifyShape(Guid.NewGuid(), "name", Guid.NewGuid(), file); if (response is BadRequestObjectResult) { Assert.True(true); } else { Assert.True(false); } } catch (Exception) { Assert.True(true); } }
public void DataPublish() { ShapesConfigMockService shapesConfigMockService = new ShapesConfigMockService(); RepositoriesConfigMockService repositoriesConfigMockService = new RepositoriesConfigMockService(); ConfigSparql configSparql = new ConfigSparql(); configSparql.Endpoint = ""; etlController etlController = new etlController(repositoriesConfigMockService, shapesConfigMockService, configSparql); var stream = new MemoryStream(); var writer = new StreamWriter(stream); writer.Write(rdfFile); writer.Flush(); stream.Position = 0; var file = new FormFile(stream, 0, stream.Length, null, "rdf.xml"); etlController.dataPublish(file); Assert.True(true); }
public void GetHash() { ShapesConfigMockService shapesConfigMockService = new ShapesConfigMockService(); RepositoriesConfigMockService repositoriesConfigMockService = new RepositoriesConfigMockService(); ConfigSparql configSparql = new ConfigSparql(null); configSparql.Endpoint = ""; DiscoverItemMockService discoverItemService = new DiscoverItemMockService(); etlController etlController = new etlController(discoverItemService, repositoriesConfigMockService, shapesConfigMockService, configSparql, null, null, null, null); using (SHA256 sha256Hash = SHA256.Create()) { string ontologyFile = File.ReadAllText("Config/Ontology/roh-v2.owl"); var response = etlController.GetHash(sha256Hash, ontologyFile); if (response != null) { Assert.True(true); } } }
public void ModifyConfigShape() { ShapesConfigMockService shapesConfigMockService = new ShapesConfigMockService(); ValidationController validationController = new ValidationController(shapesConfigMockService); ShapeConfig shapeConfig = ((List <ShapeConfig>)(((OkObjectResult)validationController.GetShape()).Value))[0]; StringBuilder personShape = new StringBuilder(); personShape.AppendLine("@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>."); personShape.AppendLine("@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>."); personShape.AppendLine("@prefix xsd: <http://www.w3.org/2001/XMLSchema#>."); personShape.AppendLine("@prefix xml: <http://www.w3.org/XML/1998/namespace>."); personShape.AppendLine("@prefix ns: <http://www.w3.org/2003/06/sw-vocab-status/ns#>."); personShape.AppendLine("@prefix sh: <http://www.w3.org/ns/shacl#>."); personShape.AppendLine("@prefix roh: <http://purl.org/roh#>."); personShape.AppendLine("@prefix foaf: <http://purl.org/roh/mirror/foaf#>."); personShape.AppendLine("roh:foaf_PersonShape"); personShape.AppendLine(" a sh:NodeShape ;"); personShape.AppendLine(" sh:targetClass foaf:Person ;"); personShape.AppendLine(" sh:property roh:someValuesDataType__foaf__Person__foaf__firstName."); personShape.AppendLine("roh:someValuesDataType__foaf__Person__foaf__firstName "); personShape.AppendLine(" sh:severity sh:Violation;"); personShape.AppendLine(" sh:path foaf:firstName;"); personShape.AppendLine(" sh:qualifiedMinCount 1;"); personShape.AppendLine(" sh:qualifiedValueShape ["); personShape.AppendLine(" sh:datatype xsd:string;"); personShape.AppendLine(" ]."); var stream = new MemoryStream(); var writer = new StreamWriter(stream); writer.Write(personShape.ToString()); writer.Flush(); stream.Position = 0; var file = new FormFile(stream, 0, stream.Length, null, "rdf.xml"); validationController.ModifyShape(shapeConfig.ShapeConfigID, shapeConfig.Name, shapeConfig.RepositoryID, file); ShapeConfig updatedshapeConfig = (ShapeConfig)((OkObjectResult)validationController.GetShape(shapeConfig.ShapeConfigID)).Value; Assert.True(updatedshapeConfig.Shape.Equals(personShape.ToString())); }
public void AddConfigShapeError() { ShapesConfigMockService shapesConfigMockService = new ShapesConfigMockService(); ValidationController validationController = new ValidationController(shapesConfigMockService); var stream = new MemoryStream(); var writer = new StreamWriter(stream); writer.Write("ShapeError".ToString()); writer.Flush(); stream.Position = 0; var file = new FormFile(stream, 0, stream.Length, null, "rdf.xml"); try { Guid identifierAdded = (Guid)(((OkObjectResult)validationController.AddShape("Shape Name", Guid.NewGuid(), file)).Value); Assert.True(false); } catch (Exception) { Assert.True(true); } }