-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from hmrc/SAR-345
Sar 345
- Loading branch information
Showing
9 changed files
with
388 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2017 HM Revenue & Customs | ||
* | ||
* 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 models.gg | ||
|
||
import play.api.libs.json.Json | ||
|
||
|
||
case class EnrolRequest(portalId: String, | ||
serviceName: String, | ||
friendlyName: String, | ||
knownFacts: List[String]) | ||
|
||
object EnrolRequest { | ||
implicit val format = Json.format[EnrolRequest] | ||
} |
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,29 @@ | ||
/* | ||
* Copyright 2017 HM Revenue & Customs | ||
* | ||
* 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 models.gg | ||
|
||
import play.api.libs.json.Json | ||
|
||
|
||
case class EnrolResponse(serviceName: String, | ||
state: String, | ||
friendlyName: String, | ||
identifiers: List[TypeValuePair]) | ||
|
||
object EnrolResponse { | ||
implicit val format = Json.format[EnrolResponse] | ||
} |
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,26 @@ | ||
/* | ||
* Copyright 2017 HM Revenue & Customs | ||
* | ||
* 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 models.gg | ||
|
||
import play.api.libs.json.Json | ||
|
||
|
||
case class KnownFactsRequest(facts: List[TypeValuePair]) | ||
|
||
object KnownFactsRequest { | ||
implicit val formats = Json.format[KnownFactsRequest] | ||
} |
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,25 @@ | ||
/* | ||
* Copyright 2017 HM Revenue & Customs | ||
* | ||
* 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 models.gg | ||
|
||
import play.api.libs.json.Json | ||
|
||
case class TypeValuePair(`type`: String, value: String) | ||
|
||
object TypeValuePair { | ||
implicit val format = Json.format[TypeValuePair] | ||
} |
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,49 @@ | ||
/* | ||
* Copyright 2017 HM Revenue & Customs | ||
* | ||
* 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 unit.models.gg | ||
|
||
import models.gg.EnrolRequest | ||
import play.api.libs.json.JsValue | ||
import uk.gov.hmrc.play.test.UnitSpec | ||
import utils.JsonUtils._ | ||
import utils.TestConstants.GG.EnrolRequestExamples | ||
|
||
class EnrolRequestSpec extends UnitSpec { | ||
|
||
import EnrolRequestExamples._ | ||
|
||
"EnrolRequest" should { | ||
"Provide the correct writer for EnrolRequest" in { | ||
val request: JsValue = EnrolRequest( | ||
portalId, | ||
serviceName, | ||
friendlyName, | ||
List(knownFact1, knownFact2) | ||
) | ||
|
||
val expected: JsValue = jsonEnrolRequest( | ||
portalId, | ||
serviceName, | ||
friendlyName, | ||
List(knownFact1, knownFact2) | ||
) | ||
|
||
request shouldBe 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright 2017 HM Revenue & Customs | ||
* | ||
* 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 unit.models.gg | ||
|
||
import models.gg.{EnrolResponse, TypeValuePair} | ||
import play.api.libs.json.JsValue | ||
import uk.gov.hmrc.play.test.UnitSpec | ||
import utils.JsonUtils._ | ||
import utils.TestConstants.GG.EnrolResponseExamples | ||
|
||
class EnrolResponseSpec extends UnitSpec { | ||
|
||
import EnrolResponseExamples._ | ||
|
||
"EnrolResponse" should { | ||
"Provide the correct reader for EnrolResponse" in { | ||
val response: JsValue = EnrolResponse( | ||
serviceName, | ||
state, | ||
friendlyName, | ||
List( | ||
TypeValuePair(testType1, testValue1), | ||
TypeValuePair(testType2, testValue2) | ||
) | ||
) | ||
|
||
val expected = jsonEnrolResponse( | ||
serviceName, | ||
state, | ||
friendlyName, | ||
List( | ||
TypeValuePair(testType1, testValue1), | ||
TypeValuePair(testType2, testValue2) | ||
) | ||
) | ||
|
||
response shouldBe 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2017 HM Revenue & Customs | ||
* | ||
* 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 unit.models.gg | ||
|
||
import models.gg.{KnownFactsRequest, TypeValuePair} | ||
import play.api.libs.json.{JsValue, Json} | ||
import uk.gov.hmrc.play.test.UnitSpec | ||
import utils.JsonUtils._ | ||
import utils.TestConstants.GG.TypeValuePairExamples | ||
|
||
class KnownFactsRequestSpec extends UnitSpec { | ||
|
||
import TypeValuePairExamples._ | ||
|
||
"KnownFactsRequest" should { | ||
"Provide the correct writer for KnownFactsRequest" in { | ||
val knownFact1 = TypeValuePair( | ||
`type` = testType1, | ||
value = testValue1 | ||
) | ||
val knownFact2 = TypeValuePair( | ||
`type` = testType2, | ||
value = testValue2 | ||
) | ||
val knownFactsRequest = KnownFactsRequest(List(knownFact1, knownFact2)) | ||
|
||
val request: JsValue = Json.toJson(knownFactsRequest) | ||
val expected = Json.fromJson[KnownFactsRequest]( | ||
s"""{ | ||
| "facts": [ | ||
| ${jsonTypeValuePair(testType1, testValue1).get}, | ||
| ${jsonTypeValuePair(testType2, testValue2).get}] | ||
| }""".stripMargin).get | ||
val actual = Json.fromJson[KnownFactsRequest](request).get | ||
|
||
actual shouldBe 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2017 HM Revenue & Customs | ||
* | ||
* 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 unit.models.gg | ||
|
||
import models.gg.TypeValuePair | ||
import play.api.libs.json.{JsValue, Json} | ||
import uk.gov.hmrc.play.test.UnitSpec | ||
import utils.TestConstants.GG.TypeValuePairExamples | ||
|
||
class TypeValuePairSpec extends UnitSpec { | ||
|
||
import TypeValuePairExamples._ | ||
|
||
"TypeValuePair" should { | ||
"Provide the correct writer for TypeValuePair" in { | ||
val knownFact = TypeValuePair( | ||
`type` = testType1, | ||
value = testValue1 | ||
) | ||
|
||
val request: JsValue = Json.toJson(knownFact) | ||
val expected = Json.fromJson[TypeValuePair](jsonTypeValuePair(testType1,testValue1)).get | ||
val actual = Json.fromJson[TypeValuePair](request).get | ||
|
||
actual shouldBe expected | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.