Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
175 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
src/test/scala/com/monsanto/arch/cloudformation/model/IntrinsicFunctions_UT.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package com.monsanto.arch.cloudformation.model | ||
|
||
import com.monsanto.arch.cloudformation.model.AmazonFunctionCall._ | ||
import com.monsanto.arch.cloudformation.model._ | ||
import com.monsanto.arch.cloudformation.model.resource._ | ||
import Token._ | ||
import org.scalatest.{FunSpec, Matchers} | ||
import spray.json._ | ||
import DefaultJsonProtocol._ | ||
|
||
/** | ||
* Created by Ryan Richt on 2/26/15 | ||
*/ | ||
class IntrinsicFunctions_UT extends FunSpec with Matchers { | ||
|
||
describe("Fn::Sub"){ | ||
|
||
it("no args"){ | ||
|
||
val test: Token[String] = `Fn::Sub`(s"This is a $${test} template") | ||
|
||
val expected = JsObject( | ||
"Fn::Sub"-> JsString(s"This is a $${test} template") | ||
) | ||
|
||
test.toJson should be(expected) | ||
} | ||
|
||
it("one arg"){ | ||
|
||
val test: Token[String] = `Fn::Sub`( | ||
s"This is a $${test} template", | ||
Some(Map("test" -> "value")) | ||
) | ||
|
||
val expected = JsObject( | ||
"Fn::Sub"-> JsArray( | ||
JsString(s"This is a $${test} template"), | ||
JsObject("test" -> JsString("value")) | ||
) | ||
) | ||
|
||
test.toJson should be(expected) | ||
} | ||
|
||
it("two args"){ | ||
|
||
val test: Token[String] = `Fn::Sub`( | ||
s"This is a $${test} template", | ||
Some(Map("test" -> "value", "test2" -> "value2")) | ||
) | ||
|
||
val expected = JsObject( | ||
"Fn::Sub"-> JsArray( | ||
JsString(s"This is a $${test} template"), | ||
JsObject("test" -> JsString("value"), "test2" -> JsString("value2")) | ||
) | ||
) | ||
|
||
test.toJson should be(expected) | ||
} | ||
} | ||
|
||
describe("Fn::ImportValue") { | ||
it("should serialize with static string") { | ||
val test: Token[String] = `Fn::ImportValue`("Test-Import-Value") | ||
|
||
val expected = JsObject( | ||
"Fn::ImportValue" -> JsString("Test-Import-Value") | ||
) | ||
test.toJson should be(expected) | ||
} | ||
|
||
it("should serialize with an embedded function") { | ||
val test: Token[String] = `Fn::ImportValue`(`Fn::Join`("", Seq("str1", "str2"))) | ||
|
||
val expected = JsObject( | ||
"Fn::ImportValue" -> JsObject("Fn::Join" -> JsArray( | ||
JsString(""), | ||
JsArray(JsString("str1"), JsString("str2")) | ||
) | ||
)) | ||
test.toJson should be(expected) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters