poc with scala xml support
Find a file
2023-11-30 18:05:17 -08:00
.github/workflows Merge pull request #39 from navicore/renovate/actions-setup-java-4.x 2023-11-30 18:05:17 -08:00
project Update dependency com.eed3si9n:sbt-assembly to v2.1.5 2023-12-01 01:47:22 +00:00
src refresh 2022-12-23 19:26:33 -08:00
.gitignore refresh 2022-12-23 19:26:33 -08:00
build.sbt Update dependency org.scalatest:scalatest to v3.2.17 2023-10-01 01:39:58 +00:00
LICENSE Create LICENSE 2022-12-23 19:43:47 -08:00
README.md rm 2022-12-23 19:30:20 -08:00
renovate.json schedule renovate 2023-03-23 06:51:34 -07:00

Not sure if I ever used this for real work - just looking at it in 2022 because a bot gave me a PR.

Lots of overhead making this work - I can't remember if I used this approach - seems insane to create so much support in the DataSupport file.

But it works and the actual code working with the data is clean and readable.


import io.circe.parser._
import io.circe.syntax._
import onextent.xml.DataSupport._
import org.scalatest.flatspec.AnyFlatSpec

class XmlSpec extends AnyFlatSpec {

  "A Pizza" should "have toppings" in {

    val p = Pizza(14, "Thin", Array(Cheese("blue"), Cheese("cheddar")))
    p.addTopping(Topping("cheese"))
    p.addTopping(Topping("sausage"))
    p.addTopping(Topping("mushroom"))

    val xml = stream.toXML(p)
    println(xml)

    val resurectedPizza: Pizza = stream.fromXML(xml).asInstanceOf[Pizza]
    println(resurectedPizza)
    println(resurectedPizza.toppings)
    assert(resurectedPizza.toppings.length == 3, "where's my stuff?!")
    assert(resurectedPizza.cheeses.length == 2, "who moved it?!")

  }