Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import scala.jdk.CollectionConverters.IteratorHasAsScala

class JSONLScanSourceOpDesc extends ScanSourceOpDesc {

@JsonProperty(required = true)
@JsonProperty(required = true, defaultValue = "false")
@JsonPropertyDescription("flatten nested objects and arrays")
var flatten: Boolean = false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class DumbbellPlotOpDesc extends PythonOperatorDescriptor {
@JsonProperty(value = "dots", required = false)
var dots: util.List[DumbbellDotConfig] = _

@JsonProperty(value = "showLegends", required = false)
@JsonProperty(value = "showLegends", required = false, defaultValue = "false")
@JsonSchemaTitle("Show Legends?")
@JsonPropertyDescription("whether to show legends in the graph")
var showLegends: Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class FilledAreaPlotOpDesc extends PythonOperatorDescriptor {
@AutofillAttributeName
var color: EncodableString = ""

@JsonProperty(required = true)
@JsonProperty(required = true, defaultValue = "false")
@JsonSchemaTitle("Split Plot by Line Group")
@JsonPropertyDescription("Do you want to split the graph")
var facetColumn: Boolean = false
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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.metadata

import org.apache.texera.amber.operator.LogicalOp
import org.apache.texera.amber.operator.source.scan.json.JSONLScanSourceOpDesc
import org.apache.texera.amber.operator.visualization.dumbbellPlot.DumbbellPlotOpDesc
import org.apache.texera.amber.operator.visualization.filledAreaPlot.FilledAreaPlotOpDesc
import org.scalatest.flatspec.AnyFlatSpec

class OperatorBooleanDefaultSpec extends AnyFlatSpec {

private def assertFalseDefault(
opDescClass: Class[_ <: LogicalOp],
propertyName: String
): Unit = {
val propertySchema =
OperatorMetadataGenerator
.generateOperatorJsonSchema(opDescClass)
.path("properties")
.path(propertyName)

assert(propertySchema.path("type").asText() == "boolean")
assert(propertySchema.has("default"))
assert(!propertySchema.path("default").asBoolean())
}

"Operator metadata generation" should "emit false defaults for visualization checkbox fields" in {
assertFalseDefault(classOf[FilledAreaPlotOpDesc], "facetColumn")
assertFalseDefault(classOf[DumbbellPlotOpDesc], "showLegends")
}

it should "emit a false default for JSONL flattening" in {
assertFalseDefault(classOf[JSONLScanSourceOpDesc], "flatten")
}
}
Loading