Skip to content

Commit

Permalink
Create ActionSerializerSuite.scala
Browse files Browse the repository at this point in the history
  • Loading branch information
scottsand-db committed Oct 31, 2024
1 parent ba61062 commit ab8f364
Showing 1 changed file with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (2024) The Delta Lake Project Authors.
*
* Licensed 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 io.delta.kernel.defaults;

import io.delta.kernel.defaults.internal.json.JsonUtils
import io.delta.kernel.internal.actions.Protocol
import org.scalatest.funsuite.AnyFunSuite

import java.util.Collections
import scala.collection.JavaConverters._

// TODO: this class should actually write the actions to a json file and read them back
// TODO: do this for all action types
class ActionSerializerSuite extends AnyFunSuite {
test("protocol to json") {
{
val protocol = new Protocol(1, 2, Collections.emptySet(), Collections.emptySet())
val json = JsonUtils.rowToJson(protocol.toRow)
assert(json === """{"minReaderVersion":1,"minWriterVersion":2}""")
}
{
val protocol = new Protocol(3, 7, Collections.emptySet(), Collections.emptySet())
val json = JsonUtils.rowToJson(protocol.toRow)
// scalastyle:off line.size.limit
assert(json === """{"minReaderVersion":3,"minWriterVersion":7,"readerFeatures":[],"writerFeatures":[]}""")
// scalastyle:on line.size.limit
}
{
val protocol = new Protocol(3, 7, Set("columnMapping").asJava, Set("appendOnly").asJava)
val json = JsonUtils.rowToJson(protocol.toRow)
// scalastyle:off line.size.limit
assert(json === """{"minReaderVersion":3,"minWriterVersion":7,"readerFeatures":["columnMapping"],"writerFeatures":["appendOnly"]}""")
// scalastyle:on line.size.limit
}
}
}

0 comments on commit ab8f364

Please sign in to comment.