Repository: incubator-griffin Updated Branches: refs/heads/master 060fc28b8 -> 89959d9f4
add config reader test spec Author: William Guo <[email protected]> Closes #298 from guoyuepeng/2018_06_13_testcases. Project: http://git-wip-us.apache.org/repos/asf/incubator-griffin/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-griffin/commit/89959d9f Tree: http://git-wip-us.apache.org/repos/asf/incubator-griffin/tree/89959d9f Diff: http://git-wip-us.apache.org/repos/asf/incubator-griffin/diff/89959d9f Branch: refs/heads/master Commit: 89959d9f42a70f77432492b32133396b6237de43 Parents: 060fc28 Author: William Guo <[email protected]> Authored: Wed Jun 13 15:58:41 2018 +0800 Committer: Lionel Liu <[email protected]> Committed: Wed Jun 13 15:58:41 2018 +0800 ---------------------------------------------------------------------- .../missingrule_accuracy_batch_sparksql.json | 32 ++++++++++++ .../griffin/measure/ApplicationTest.scala | 18 +++++++ .../params/reader/ParamFileReaderSpec.scala | 55 ++++++++++++++++++++ 3 files changed, 105 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/89959d9f/measure/src/test/resources/invalidconfigs/missingrule_accuracy_batch_sparksql.json ---------------------------------------------------------------------- diff --git a/measure/src/test/resources/invalidconfigs/missingrule_accuracy_batch_sparksql.json b/measure/src/test/resources/invalidconfigs/missingrule_accuracy_batch_sparksql.json new file mode 100644 index 0000000..d75ae93 --- /dev/null +++ b/measure/src/test/resources/invalidconfigs/missingrule_accuracy_batch_sparksql.json @@ -0,0 +1,32 @@ +{ + "name": "accu_batch", + + "process.type": "batch", + + "data.sources": [ + { + "name": "source", + "baseline": true, + "connectors": [ + { + "type": "avro", + "version": "1.7", + "config": { + "file.name": "src/test/resources/users_info_src.avro" + } + } + ] + }, { + "name": "target", + "connectors": [ + { + "type": "avro", + "version": "1.7", + "config": { + "file.name": "src/test/resources/users_info_target.avro" + } + } + ] + } + ] +} http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/89959d9f/measure/src/test/scala/org/apache/griffin/measure/ApplicationTest.scala ---------------------------------------------------------------------- diff --git a/measure/src/test/scala/org/apache/griffin/measure/ApplicationTest.scala b/measure/src/test/scala/org/apache/griffin/measure/ApplicationTest.scala index 7576969..9ad9d9e 100644 --- a/measure/src/test/scala/org/apache/griffin/measure/ApplicationTest.scala +++ b/measure/src/test/scala/org/apache/griffin/measure/ApplicationTest.scala @@ -1,3 +1,21 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ package org.apache.griffin.measure import org.junit.runner.RunWith http://git-wip-us.apache.org/repos/asf/incubator-griffin/blob/89959d9f/measure/src/test/scala/org/apache/griffin/measure/configuration/params/reader/ParamFileReaderSpec.scala ---------------------------------------------------------------------- diff --git a/measure/src/test/scala/org/apache/griffin/measure/configuration/params/reader/ParamFileReaderSpec.scala b/measure/src/test/scala/org/apache/griffin/measure/configuration/params/reader/ParamFileReaderSpec.scala new file mode 100644 index 0000000..1126cc7 --- /dev/null +++ b/measure/src/test/scala/org/apache/griffin/measure/configuration/params/reader/ParamFileReaderSpec.scala @@ -0,0 +1,55 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +package org.apache.griffin.measure.configuration.params.reader +import org.apache.griffin.measure.configuration.params.DQConfig +import org.scalatest._ + + +import scala.util.{Failure, Success} + +class ParamFileReaderSpec extends FlatSpec with Matchers{ + + + "params " should "be parsed from a valid file" in { + val reader :ParamReader = ParamFileReader(getClass.getResource("/_accuracy-batch-sparksql.json").getFile) + val params = reader.readConfig[DQConfig] + params match { + case Success(v) => + v.evaluateRule.getRules(0).dslType should === ("spark-sql") + v.evaluateRule.getRules(0).name should === ("missRecords") + case Failure(_) => + fail("it should not happen") + } + + } + + it should "fail for an invalid file" in { + val reader :ParamReader = ParamFileReader(getClass.getResource("/invalidconfigs/missingrule_accuracy_batch_sparksql.json").getFile) + val params = reader.readConfig[DQConfig] + params match { + case Success(_) => + fail("it is an invalid config file") + case Failure(e) => + e.getMessage contains ("evaluate.rule should not be null") + } + + } + +}
