# test_ISODataQualityLogicalConsistency.R # Author: Emmanuel Blondel # # Description: Unit tests for ISODataQualityLogicalConsistency.R #======================= require(geometa, quietly = TRUE) require(testthat) context("ISOLogicalConsistency") test_that("ISOAbstractLogicalConsistency",{ testthat::skip_on_cran() #encoding dq <- ISOAbstractLogicalConsistency$new() dq$addNameOfMeasure("measure") metaId <- ISOMetaIdentifier$new(code = "measure-id") dq$setMeasureIdentification(metaId) dq$setMeasureDescription("description") dq$setEvaluationMethodDescription("method description") dq$setEvaluationMethodType("indirect") dq$setDateTime(ISOdate(2015,1,1,12,10,49)) spec <- ISOCitation$new() spec$setTitle("specification title") spec$addAlternateTitle("specification alternate title") d <- ISODate$new() d$setDate(ISOdate(2015, 1, 1, 1)) d$setDateType("publication") spec$addDate(d) dq$setEvaluationProcedure(spec) result <- ISOConformanceResult$new() result$setSpecification(spec) result$setExplanation("some explanation about the conformance") result$setPass(TRUE) dq$addResult(result) xml <- dq$encode(validate=F) expect_is(xml, "XMLInternalNode") #decoding dq2 <- ISOAbstractLogicalConsistency$new(xml = xml) xml2 <- dq2$encode(validate=F) #identity expect_true(ISOAbstractObject$compare(dq, dq2)) }) test_that("ISOTopologicalConsistency",{ testthat::skip_on_cran() #encoding dq <- ISOTopologicalConsistency$new() dq$addNameOfMeasure("measure") metaId <- ISOMetaIdentifier$new(code = "measure-id") dq$setMeasureIdentification(metaId) dq$setMeasureDescription("description") dq$setEvaluationMethodDescription("method description") dq$setEvaluationMethodType("indirect") dq$setDateTime(ISOdate(2015,1,1,12,10,49)) spec <- ISOCitation$new() spec$setTitle("specification title") spec$addAlternateTitle("specification alternate title") d <- ISODate$new() d$setDate(ISOdate(2015, 1, 1, 1)) d$setDateType("publication") spec$addDate(d) dq$setEvaluationProcedure(spec) result <- ISOConformanceResult$new() result$setSpecification(spec) result$setExplanation("some explanation about the conformance") result$setPass(TRUE) dq$addResult(result) xml <- dq$encode(validate=F) expect_is(xml, "XMLInternalNode") #decoding dq2 <- ISOTopologicalConsistency$new(xml = xml) xml2 <- dq2$encode(validate=F) #identity expect_true(ISOAbstractObject$compare(dq, dq2)) }) test_that("ISOFormatConsistency",{ testthat::skip_on_cran() #encoding dq <- ISOFormatConsistency$new() dq$addNameOfMeasure("measure") metaId <- ISOMetaIdentifier$new(code = "measure-id") dq$setMeasureIdentification(metaId) dq$setMeasureDescription("description") dq$setEvaluationMethodDescription("method description") dq$setEvaluationMethodType("indirect") dq$setDateTime(ISOdate(2015,1,1,12,10,49)) spec <- ISOCitation$new() spec$setTitle("specification title") spec$addAlternateTitle("specification alternate title") d <- ISODate$new() d$setDate(ISOdate(2015, 1, 1, 1)) d$setDateType("publication") spec$addDate(d) dq$setEvaluationProcedure(spec) result <- ISOConformanceResult$new() result$setSpecification(spec) result$setExplanation("some explanation about the conformance") result$setPass(TRUE) dq$addResult(result) xml <- dq$encode(validate=F) expect_is(xml, "XMLInternalNode") #decoding dq2 <- ISOFormatConsistency$new(xml = xml) xml2 <- dq2$encode(validate=F) #identity expect_true(ISOAbstractObject$compare(dq, dq2)) }) test_that("ISODomainConsistency",{ testthat::skip_on_cran() #encoding dq <- ISODomainConsistency$new() dq$addNameOfMeasure("measure") metaId <- ISOMetaIdentifier$new(code = "measure-id") dq$setMeasureIdentification(metaId) dq$setMeasureDescription("description") dq$setEvaluationMethodDescription("method description") dq$setEvaluationMethodType("indirect") dq$setDateTime(ISOdate(2015,1,1,12,10,49)) spec <- ISOCitation$new() spec$setTitle("specification title") spec$addAlternateTitle("specification alternate title") d <- ISODate$new() d$setDate(ISOdate(2015, 1, 1, 1)) d$setDateType("publication") spec$addDate(d) dq$setEvaluationProcedure(spec) result <- ISOConformanceResult$new() result$setSpecification(spec) result$setExplanation("some explanation about the conformance") result$setPass(TRUE) dq$addResult(result) xml <- dq$encode(validate=F) expect_is(xml, "XMLInternalNode") #decoding dq2 <- ISODomainConsistency$new(xml = xml) xml2 <- dq2$encode(validate=F) #identity expect_true(ISOAbstractObject$compare(dq, dq2)) }) test_that("ISOConceptualConsistency",{ testthat::skip_on_cran() #encoding dq <- ISOConceptualConsistency$new() dq$addNameOfMeasure("measure") metaId <- ISOMetaIdentifier$new(code = "measure-id") dq$setMeasureIdentification(metaId) dq$setMeasureDescription("description") dq$setEvaluationMethodDescription("method description") dq$setEvaluationMethodType("indirect") dq$setDateTime(ISOdate(2015,1,1,12,10,49)) spec <- ISOCitation$new() spec$setTitle("specification title") spec$addAlternateTitle("specification alternate title") d <- ISODate$new() d$setDate(ISOdate(2015, 1, 1, 1)) d$setDateType("publication") spec$addDate(d) dq$setEvaluationProcedure(spec) result <- ISOConformanceResult$new() result$setSpecification(spec) result$setExplanation("some explanation about the conformance") result$setPass(TRUE) dq$addResult(result) xml <- dq$encode(validate=F) expect_is(xml, "XMLInternalNode") #decoding dq2 <- ISOConceptualConsistency$new(xml = xml) xml2 <- dq2$encode(validate=F) #identity expect_true(ISOAbstractObject$compare(dq, dq2)) })