wankunde commented on a change in pull request #558: Enum based configs URL: https://github.com/apache/griffin/pull/558#discussion_r358227082
########## File path: measure/src/test/scala/org/apache/griffin/measure/configuration/dqdefinition/reader/ParamEnumReaderSpec.scala ########## @@ -0,0 +1,212 @@ +/* + * 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.dqdefinition.reader + +import org.scalatest.{FlatSpec, Matchers} + +import org.apache.griffin.measure.configuration.dqdefinition.{DQConfig, EvaluateRuleParam, RuleOutputParam, RuleParam} + + +class ParamEnumReaderSpec extends FlatSpec with Matchers { + import org.apache.griffin.measure.configuration.enums.DslType._ + "dsltype" should "be parsed to predefined set of values" in { + val validDslSparkSqlValues = + Seq("spark-sql", "spark-SQL", "SPARK-SQL", "sparksql") + validDslSparkSqlValues foreach { x => + val ruleParam = new RuleParam(x, "accuracy") + ruleParam.getDslType should ===(SparkSql) + } + val invalidDslSparkSqlValues = Seq("spark", "sql", "") + invalidDslSparkSqlValues foreach { x => + val ruleParam = new RuleParam(x, "accuracy") + ruleParam.getDslType should not be (SparkSql) + } + + val validDslGriffinValues = + Seq("griffin-dsl", "griffindsl", "griFfin-dsl", "") + validDslGriffinValues foreach { x => + val ruleParam = new RuleParam(x, "accuracy") + ruleParam.getDslType should ===(GriffinDsl) + } + + val validDslDfOpsValues = Seq( + "df-ops", + "dfops", + "DFOPS", + "df-opr", + "dfopr", + "df-operations", + "dfoperations" + ) + validDslDfOpsValues foreach { x => + val ruleParam = new RuleParam(x, "accuracy") + ruleParam.getDslType should ===(DataFrameOpsType) + } + + val invalidDslDfOpsValues = Seq("df-oprts", "-") + invalidDslDfOpsValues foreach { x => + val ruleParam = new RuleParam(x, "accuracy") + ruleParam.getDslType should not be (DataFrameOpsType) + } + } + + "griffindsl" should "be returned as default dsl type" in { + import org.apache.griffin.measure.configuration.enums.DslType._ + val dslGriffinDslValues = Seq("griffin", "dsl") + dslGriffinDslValues foreach { x => + val ruleParam = new RuleParam(x, "accuracy") + ruleParam.getDslType should be(GriffinDsl) + } + } + + "dqtype" should "be parsed to predefined set of values" in { + import org.apache.griffin.measure.configuration.enums.DqType._ + var ruleParam = new RuleParam("griffin-dsl", "accuracy") + ruleParam.getDqType should be(Accuracy) + ruleParam = new RuleParam("griffin-dsl", "accu") + ruleParam.getDqType should not be (Accuracy) Review comment: I'm sorry , I means we should change all the `should not be` to `should be`, and it will be clear what is returned. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
