diff --git a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/boxViolinPlot/BoxViolinPlotQuartileFunctionSpec.scala b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/boxViolinPlot/BoxViolinPlotQuartileFunctionSpec.scala new file mode 100644 index 00000000000..4bfe6a8ea3b --- /dev/null +++ b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/boxViolinPlot/BoxViolinPlotQuartileFunctionSpec.scala @@ -0,0 +1,44 @@ +/* + * 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.texera.amber.operator.visualization.boxViolinPlot + +import org.apache.texera.amber.util.JSONUtils.objectMapper +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers + +class BoxViolinPlotQuartileFunctionSpec extends AnyFlatSpec with Matchers { + + "BoxViolinPlotQuartileFunction" should "map each constant to its wire value" in { + BoxViolinPlotQuartileFunction.LINEAR.getQuartiletype shouldBe "linear" + BoxViolinPlotQuartileFunction.INCLUSIVE.getQuartiletype shouldBe "inclusive" + BoxViolinPlotQuartileFunction.EXCLUSIVE.getQuartiletype shouldBe "exclusive" + BoxViolinPlotQuartileFunction.values() should have length 3 + } + + "BoxViolinPlotQuartileFunction" should "round-trip through Jackson using its wire value" in { + objectMapper.writeValueAsString( + BoxViolinPlotQuartileFunction.INCLUSIVE + ) shouldBe "\"inclusive\"" + objectMapper.readValue( + "\"inclusive\"", + classOf[BoxViolinPlotQuartileFunction] + ) shouldBe BoxViolinPlotQuartileFunction.INCLUSIVE + } +} diff --git a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/contourPlot/ContourPlotColoringFunctionSpec.scala b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/contourPlot/ContourPlotColoringFunctionSpec.scala new file mode 100644 index 00000000000..0e4bd0fa3e3 --- /dev/null +++ b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/contourPlot/ContourPlotColoringFunctionSpec.scala @@ -0,0 +1,42 @@ +/* + * 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.texera.amber.operator.visualization.contourPlot + +import org.apache.texera.amber.util.JSONUtils.objectMapper +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers + +class ContourPlotColoringFunctionSpec extends AnyFlatSpec with Matchers { + + "ContourPlotColoringFunction" should "map each constant to its wire value" in { + ContourPlotColoringFunction.HEATMAP.getColoringMethod shouldBe "heatmap" + ContourPlotColoringFunction.LINES.getColoringMethod shouldBe "lines" + ContourPlotColoringFunction.NONE.getColoringMethod shouldBe "none" + ContourPlotColoringFunction.values() should have length 3 + } + + "ContourPlotColoringFunction" should "round-trip through Jackson using its wire value" in { + objectMapper.writeValueAsString(ContourPlotColoringFunction.LINES) shouldBe "\"lines\"" + objectMapper.readValue( + "\"lines\"", + classOf[ContourPlotColoringFunction] + ) shouldBe ContourPlotColoringFunction.LINES + } +} diff --git a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/hierarchychart/HierarchyChartTypeSpec.scala b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/hierarchychart/HierarchyChartTypeSpec.scala new file mode 100644 index 00000000000..97e42d9e8ba --- /dev/null +++ b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/hierarchychart/HierarchyChartTypeSpec.scala @@ -0,0 +1,41 @@ +/* + * 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.texera.amber.operator.visualization.hierarchychart + +import org.apache.texera.amber.util.JSONUtils.objectMapper +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers + +class HierarchyChartTypeSpec extends AnyFlatSpec with Matchers { + + "HierarchyChartType" should "map each constant to its wire value" in { + HierarchyChartType.TREEMAP.getPlotlyExpressApiName shouldBe "treemap" + HierarchyChartType.SUNBURSTCHART.getPlotlyExpressApiName shouldBe "sunburst" + HierarchyChartType.values() should have length 2 + } + + "HierarchyChartType" should "round-trip through Jackson using its wire value" in { + objectMapper.writeValueAsString(HierarchyChartType.SUNBURSTCHART) shouldBe "\"sunburst\"" + objectMapper.readValue( + "\"sunburst\"", + classOf[HierarchyChartType] + ) shouldBe HierarchyChartType.SUNBURSTCHART + } +} diff --git a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/histogram2d/NormalizationTypeSpec.scala b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/histogram2d/NormalizationTypeSpec.scala new file mode 100644 index 00000000000..777a41b10f2 --- /dev/null +++ b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/histogram2d/NormalizationTypeSpec.scala @@ -0,0 +1,42 @@ +/* + * 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.texera.amber.operator.visualization.histogram2d + +import org.apache.texera.amber.util.JSONUtils.objectMapper +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers + +class NormalizationTypeSpec extends AnyFlatSpec with Matchers { + + "NormalizationType" should "map each constant to its wire value" in { + NormalizationType.DENSITY.getValue shouldBe "density" + NormalizationType.PROBABILITY.getValue shouldBe "probability" + NormalizationType.PERCENT.getValue shouldBe "percent" + NormalizationType.values() should have length 3 + } + + "NormalizationType" should "round-trip through Jackson using its wire value" in { + objectMapper.writeValueAsString(NormalizationType.PERCENT) shouldBe "\"percent\"" + objectMapper.readValue( + "\"percent\"", + classOf[NormalizationType] + ) shouldBe NormalizationType.PERCENT + } +} diff --git a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/lineChart/LineModeSpec.scala b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/lineChart/LineModeSpec.scala new file mode 100644 index 00000000000..676b053e7b5 --- /dev/null +++ b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/lineChart/LineModeSpec.scala @@ -0,0 +1,51 @@ +/* + * 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.texera.amber.operator.visualization.lineChart + +import org.apache.texera.amber.util.JSONUtils.objectMapper +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers + +class LineModeSpec extends AnyFlatSpec with Matchers { + + "LineMode" should "map each constant to its wire mode" in { + LineMode.LINE.getMode shouldBe "line" + LineMode.DOTS.getMode shouldBe "dots" + LineMode.LINE_WITH_DOTS.getMode shouldBe "line with dots" + LineMode.values() should have length 3 + } + + "LineMode.getModeInPlotly" should "translate to the Plotly mode string" in { + LineMode.LINE.getModeInPlotly shouldBe "lines" + LineMode.DOTS.getModeInPlotly shouldBe "markers" + LineMode.LINE_WITH_DOTS.getModeInPlotly shouldBe "lines+markers" + } + + "LineMode.fromString" should "resolve wire modes case-insensitively and reject unknowns" in { + LineMode.fromString("line with dots") shouldBe LineMode.LINE_WITH_DOTS + LineMode.fromString("DOTS") shouldBe LineMode.DOTS + intercept[IllegalArgumentException](LineMode.fromString("zigzag")) + } + + "LineMode" should "round-trip through Jackson using its wire mode" in { + objectMapper.writeValueAsString(LineMode.LINE_WITH_DOTS) shouldBe "\"line with dots\"" + objectMapper.readValue("\"dots\"", classOf[LineMode]) shouldBe LineMode.DOTS + } +} diff --git a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/radarPlot/RadarPlotLinePatternSpec.scala b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/radarPlot/RadarPlotLinePatternSpec.scala new file mode 100644 index 00000000000..5eafdfbbbff --- /dev/null +++ b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/radarPlot/RadarPlotLinePatternSpec.scala @@ -0,0 +1,42 @@ +/* + * 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.texera.amber.operator.visualization.radarPlot + +import org.apache.texera.amber.util.JSONUtils.objectMapper +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers + +class RadarPlotLinePatternSpec extends AnyFlatSpec with Matchers { + + "RadarPlotLinePattern" should "map each constant to its wire value" in { + RadarPlotLinePattern.SOLID.getLinePattern shouldBe "solid" + RadarPlotLinePattern.DASH.getLinePattern shouldBe "dash" + RadarPlotLinePattern.DOT.getLinePattern shouldBe "dot" + RadarPlotLinePattern.values() should have length 3 + } + + "RadarPlotLinePattern" should "round-trip through Jackson using its wire value" in { + objectMapper.writeValueAsString(RadarPlotLinePattern.DASH) shouldBe "\"dash\"" + objectMapper.readValue( + "\"dash\"", + classOf[RadarPlotLinePattern] + ) shouldBe RadarPlotLinePattern.DASH + } +} diff --git a/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/rangeSlider/RangeSliderHandleDuplicateFunctionSpec.scala b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/rangeSlider/RangeSliderHandleDuplicateFunctionSpec.scala new file mode 100644 index 00000000000..07787340c89 --- /dev/null +++ b/common/workflow-operator/src/test/scala/org/apache/texera/amber/operator/visualization/rangeSlider/RangeSliderHandleDuplicateFunctionSpec.scala @@ -0,0 +1,42 @@ +/* + * 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.texera.amber.operator.visualization.rangeSlider + +import org.apache.texera.amber.util.JSONUtils.objectMapper +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers + +class RangeSliderHandleDuplicateFunctionSpec extends AnyFlatSpec with Matchers { + + "RangeSliderHandleDuplicateFunction" should "map each constant to its wire value" in { + RangeSliderHandleDuplicateFunction.NOTHING.getFunctionType shouldBe "Nothing" + RangeSliderHandleDuplicateFunction.MEAN.getFunctionType shouldBe "Mean" + RangeSliderHandleDuplicateFunction.SUM.getFunctionType shouldBe "Sum" + RangeSliderHandleDuplicateFunction.values() should have length 3 + } + + "RangeSliderHandleDuplicateFunction" should "round-trip through Jackson using its wire value" in { + objectMapper.writeValueAsString(RangeSliderHandleDuplicateFunction.MEAN) shouldBe "\"Mean\"" + objectMapper.readValue( + "\"Mean\"", + classOf[RangeSliderHandleDuplicateFunction] + ) shouldBe RangeSliderHandleDuplicateFunction.MEAN + } +}