Skip to content

Commit

Permalink
Merge pull request #110 from geirolz/remove-scalatic-from-prod
Browse files Browse the repository at this point in the history
Remove scalactic from production code.
  • Loading branch information
geirolz authored Aug 28, 2020
2 parents 349e698 + 5e29d66 commit 0f80aa4
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 83 deletions.
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ object Dependencies {
lazy val all: Seq[ModuleID] = Seq(
//SCALA
"org.typelevel" %% "cats-core" % "2.1.1" cross CrossVersion.binary,
"org.scalactic" %% "scalactic" % "3.2.2" cross CrossVersion.binary,
//XML
"org.scala-lang.modules" %% "scala-xml" % "2.0.0-M1" cross CrossVersion.binary,
//TEST
"org.scalactic" %% "scalactic" % "3.2.2" % Test cross CrossVersion.binary,
"org.typelevel" %% "discipline-scalatest" % "2.0.1" % Test,
"org.typelevel" %% "cats-laws" % "2.1.1" % Test cross CrossVersion.binary,
"org.scalatest" %% "scalatest" % "3.2.2" % Test cross CrossVersion.binary,
Expand Down
8 changes: 0 additions & 8 deletions src/main/scala/advxml/syntax/XmlNormalizerSyntax.scala
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
package advxml.syntax

import advxml.core.XmlNormalizer
import org.scalactic.Equality

import scala.util.Try
import scala.xml.NodeSeq

private[syntax] trait XmlNormalizerSyntax {

implicit def streamlinedXmlNormalizedEquality[T <: NodeSeq]: Equality[T] =
(a: T, b: Any) =>
Try(
XmlNormalizer.normalizedEquals(a, b.asInstanceOf[NodeSeq])
).getOrElse(false)

implicit class NodeSeqNormalizationAndEqualityOps(ns: NodeSeq) {

def normalize: NodeSeq =
Expand Down
10 changes: 5 additions & 5 deletions src/test/scala/advxml/instances/XmlPredicateTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class XmlPredicateTest extends AnyFunSuite {

val result: NodeSeq = data \ "Person" filter text(_ == "Simone")

assert(result === <Person>Simone</Person>)
assert(result |==| <Person>Simone</Person>)
}

test("Filter by label") {
Expand All @@ -34,7 +34,7 @@ class XmlPredicateTest extends AnyFunSuite {

val result: NodeSeq = data.child filter label(_ == "Person3")

assert(result === <Person3>Simone</Person3>)
assert(result |==| <Person3>Simone</Person3>)
}

test("Filter by attrs") {
Expand All @@ -51,7 +51,7 @@ class XmlPredicateTest extends AnyFunSuite {
"B" -> (_ == "C")
)

assert(result === <Person A="3" B="C">Simone</Person>)
assert(result |==| <Person A="3" B="C">Simone</Person>)
}

test("Filter by strict equality") {
Expand All @@ -65,7 +65,7 @@ class XmlPredicateTest extends AnyFunSuite {

val result: NodeSeq = data \ "Person" filter strictEqualsTo(<Person A="3"></Person>)

assert(result === <Person A="3"></Person>)
assert(result |==| <Person A="3"></Person>)
}

test("Filter by strict equality - minimized empty") {
Expand All @@ -79,6 +79,6 @@ class XmlPredicateTest extends AnyFunSuite {

val result: NodeSeq = data \ "Person" filter strictEqualsTo(<Person A="3"/>)

assert(result === <Person A="3"></Person>)
assert(result |==| <Person A="3"></Person>)
}
}
138 changes: 69 additions & 69 deletions src/test/scala/advxml/syntax/XmlTransformerSyntaxTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ class XmlTransformerSyntaxTest extends AnyFunSuite {
<test Id="1"><newNode value="x"/></test>
</bar>
</data>
===
<data>
|==|
<data>
<foo>
<test Id="1"/>
</foo>
<bar>
<test Id="1"/>
</bar>
</data>
.transform(
(root \ "bar" \ "test" filter attrs("Id" -> (_ == "1")))
==> Append(<newNode value="x"/>)
)
.get
.transform(
(root \ "bar" \ "test" filter attrs("Id" -> (_ == "1")))
==> Append(<newNode value="x"/>)
)
.get
)
}

Expand All @@ -66,19 +66,19 @@ class XmlTransformerSyntaxTest extends AnyFunSuite {
<OrderLine PrimeLineNo="4"/>
</OrderLines>
</Order>
===
<Order>
|==|
<Order>
<OrderLines>
<OrderLine PrimeLineNo="4"/>
</OrderLines>
</Order>
.transform(
(root \ "OrderLines")
==> Prepend(<OrderLine PrimeLineNo="3"/>)
==> Prepend(<OrderLine PrimeLineNo="2"/>)
==> Prepend(<OrderLine PrimeLineNo="1"/>)
)
.get
.transform(
(root \ "OrderLines")
==> Prepend(<OrderLine PrimeLineNo="3"/>)
==> Prepend(<OrderLine PrimeLineNo="2"/>)
==> Prepend(<OrderLine PrimeLineNo="1"/>)
)
.get
)
}

Expand All @@ -92,19 +92,19 @@ class XmlTransformerSyntaxTest extends AnyFunSuite {
<OrderLine PrimeLineNo="4"/>
</OrderLines>
</Order>
===
<Order>
|==|
<Order>
<OrderLines>
<OrderLine PrimeLineNo="1"/>
</OrderLines>
</Order>
.transform(
(root \ "OrderLines")
==> Append(<OrderLine PrimeLineNo="2"/>)
==> Append(<OrderLine PrimeLineNo="3"/>)
==> Append(<OrderLine PrimeLineNo="4"/>)
)
.get
.transform(
(root \ "OrderLines")
==> Append(<OrderLine PrimeLineNo="2"/>)
==> Append(<OrderLine PrimeLineNo="3"/>)
==> Append(<OrderLine PrimeLineNo="4"/>)
)
.get
)
}

Expand All @@ -117,19 +117,19 @@ class XmlTransformerSyntaxTest extends AnyFunSuite {
<OrderLine PrimeLineNo="3" />
</OrderLines>
</Order>
===
<Order>
|==|
<Order>
<OrderLines>
<OrderLine PrimeLineNo="1"/>
<OrderLine PrimeLineNo="2"/>
<OrderLine PrimeLineNo="3"/>
</OrderLines>
</Order>
.transform(
(root \ "OrderLines" \ "OrderLine" | attrs("PrimeLineNo" -> (_ == "1")))
==> Replace(_ => <OrderLine PrimeLineNo="3"/>)
)
.get
.transform(
(root \ "OrderLines" \ "OrderLine" | attrs("PrimeLineNo" -> (_ == "1")))
==> Replace(_ => <OrderLine PrimeLineNo="3"/>)
)
.get
)
}

Expand All @@ -139,7 +139,7 @@ class XmlTransformerSyntaxTest extends AnyFunSuite {
(root \ "B") ==> Replace(_ => <B>1</B>)
)

assert(result.get === <A><B>1</B></A>)
assert(result.get |==| <A><B>1</B></A>)
}

test("RemoveNode") {
Expand All @@ -149,18 +149,18 @@ class XmlTransformerSyntaxTest extends AnyFunSuite {
<OrderLine PrimeLineNo="1" />
</OrderLines>
</Order>
===
<Order>
|==|
<Order>
<OrderLines>
<OrderLine PrimeLineNo="1"/>
<OrderLine PrimeLineNo="2"/>
</OrderLines>
</Order>
.transform(
(root \ "OrderLines" \ "OrderLine" | attrs("PrimeLineNo" -> (_ == "2")))
==> Remove
)
.get
.transform(
(root \ "OrderLines" \ "OrderLine" | attrs("PrimeLineNo" -> (_ == "2")))
==> Remove
)
.get
)
}

Expand All @@ -180,12 +180,12 @@ class XmlTransformerSyntaxTest extends AnyFunSuite {
<OrderLines>
<OrderLine PrimeLineNo="1"/>
</OrderLines>
===
<OrderLines/>
.transform[Try](
root ==> Append(<OrderLine PrimeLineNo="1"/>)
)
.get
|==|
<OrderLines/>
.transform[Try](
root ==> Append(<OrderLine PrimeLineNo="1"/>)
)
.get
)
}

Expand All @@ -194,24 +194,24 @@ class XmlTransformerSyntaxTest extends AnyFunSuite {
<Order>
<OrderLines A1="1" A2="2" A3="3"/>
</Order>
===
<Order>
|==|
<Order>
<OrderLines/>
</Order>
.transform(
root \ "OrderLines" ==> SetAttrs("A1" := "1", "A2" := "2", "A3" := "3")
)
.get
.transform(
root \ "OrderLines" ==> SetAttrs("A1" := "1", "A2" := "2", "A3" := "3")
)
.get
)
}

test("SetAttribute to root") {
assert(
<Order A1="1" A2="2" A3="3"/> === <Order/>
.transform(
root ==> SetAttrs("A1" := "1", "A2" := "2", "A3" := "3")
)
.get
<Order A1="1" A2="2" A3="3"/> |==| <Order/>
.transform(
root ==> SetAttrs("A1" := "1", "A2" := "2", "A3" := "3")
)
.get
)
}

Expand All @@ -222,16 +222,16 @@ class XmlTransformerSyntaxTest extends AnyFunSuite {
<OrderLine PrimeLineNo="1"></OrderLine>
</OrderLines>
</Order>
===
<Order>
|==|
<Order>
<OrderLines T1="1">
<OrderLine PrimeLineNo="1"></OrderLine>
</OrderLines>
</Order>
.transform(
root \ "OrderLines" ==> SetAttrs("T1" := "EDITED")
)
.get
.transform(
root \ "OrderLines" ==> SetAttrs("T1" := "EDITED")
)
.get
)
}

Expand All @@ -242,16 +242,16 @@ class XmlTransformerSyntaxTest extends AnyFunSuite {
<OrderLine PrimeLineNo="1"></OrderLine>
</OrderLines>
</Order>
===
<Order>
|==|
<Order>
<OrderLines T1="1">
<OrderLine PrimeLineNo="1"></OrderLine>
</OrderLines>
</Order>
.transform(
root \ "OrderLines" ==> RemoveAttrs(_.key == "T1")
)
.get
.transform(
root \ "OrderLines" ==> RemoveAttrs(_.key == "T1")
)
.get
)
}
}

0 comments on commit 0f80aa4

Please sign in to comment.