Skip to content

Commit bc3e550

Browse files
committed
formatting
1 parent f33d9f9 commit bc3e550

1 file changed

Lines changed: 18 additions & 12 deletions

File tree

mobile-save-for-later/src/test/scala/com/gu/sfl/controller/SaveArticlesControllerSpec.scala

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,21 @@ class SaveArticlesControllerSpec extends Specification with Mockito {
3939
response.statusCode mustEqual StatusCodes.badRequest
4040
}
4141

42-
/* ==================== TEMPORARY: start of java-default-format fallback tests ====================
42+
/*
43+
* ==================== TEMPORARY: start of java-default-format fallback tests ====================
44+
*
4345
* The 3 tests below were added while we temporarily accept the java-default-format fallback
4446
* while Android fixes their bug in sending the incorrect format. These tests exist only to
4547
* document and pin down the temporary fallback behaviour, and MUST fail (or get removed) once
4648
* that fallback is gone.
4749
*/
4850
"save the articles when the date is in the java default format" in new Setup {
4951
val javaDefaultDateTimeString = "Fri Jan 01 00:00:01 GMT 2010"
50-
val json = s"""{"version":"1","articles":[{"id":"id/1","shortUrl":"p/1","date": "$javaDefaultDateTimeString","read":false}]}"""
51-
updateSavedArticles.save(any[Map[String, String]](), any[SavedArticles]()) returns Future.successful(Left(mock[SaveForLaterError]))
52+
val json =
53+
s"""{"version":"1","articles":[{"id":"id/1","shortUrl":"p/1","date": "$javaDefaultDateTimeString","read":false}]}"""
54+
55+
updateSavedArticles.save(any[Map[String, String]](), any[SavedArticles]()) returns
56+
Future.successful(Left(mock[SaveForLaterError]))
5257

5358
Await.result(controller(LambdaRequest(Some(json))), Duration.Inf)
5459

@@ -58,10 +63,12 @@ class SaveArticlesControllerSpec extends Specification with Mockito {
5863
"save the java default format date to the db as the correct parsed LocalDateTime" in new Setup {
5964
val javaDefaultDateTimeString = "Fri Jan 01 00:00:01 GMT 2010"
6065
val expectedDateTime = LocalDateTime.of(2010, 1, 1, 0, 0, 1)
61-
val json = s"""{"version":"1","articles":[{"id":"id/1","shortUrl":"p/1","date": "$javaDefaultDateTimeString","read":false}]}"""
66+
val json =
67+
s"""{"version":"1","articles":[{"id":"id/1","shortUrl":"p/1","date": "$javaDefaultDateTimeString","read":false}]}"""
6268

6369
val savedArticlesCaptor = capture[SavedArticles]
64-
updateSavedArticles.save(any[Map[String, String]](), savedArticlesCaptor) returns Future.successful(Left(mock[SaveForLaterError]))
70+
updateSavedArticles.save(any[Map[String, String]](), savedArticlesCaptor) returns
71+
Future.successful(Left(mock[SaveForLaterError]))
6572

6673
Await.result(controller(LambdaRequest(Some(json))), Duration.Inf)
6774

@@ -71,17 +78,16 @@ class SaveArticlesControllerSpec extends Specification with Mockito {
7178
"return the java default format date in the API response as an ISO SavedArticle" in new Setup {
7279
val javaDefaultDateTimeString = "Fri Jan 01 00:00:01 GMT 2010"
7380
val expectedArticle = SavedArticle("id/1", "p/1", LocalDateTime.of(2010, 1, 1, 0, 0, 1), read = false)
74-
val json = s"""{"version":"1","articles":[{"id":"id/1","shortUrl":"p/1","date": "$javaDefaultDateTimeString","read":false}]}"""
81+
val json =
82+
s"""{"version":"1","articles":[{"id":"id/1","shortUrl":"p/1","date": "$javaDefaultDateTimeString","read":false}]}"""
7583

76-
updateSavedArticles.save(any[Map[String, String]](), any[SavedArticles]()) answers {
77-
(_: Any) match {
78-
case Array(_, savedArticles: SavedArticles) => Future.successful(Right(savedArticles))
79-
}
80-
}
84+
updateSavedArticles.save(any[Map[String, String]](), any[SavedArticles]()) answers { (_: Any) match {
85+
case Array(_, savedArticles: SavedArticles) => Future.successful(Right(savedArticles))
86+
}}
8187

8288
val response = Await.result(controller(LambdaRequest(Some(json))), Duration.Inf)
83-
8489
val parsedResponse = mapper.readValue[SavedArticlesResponse](response.maybeBody.get)
90+
8591
parsedResponse.savedArticles.articles mustEqual List(expectedArticle)
8692
}
8793
/* ==================== TEMPORARY: end of java-default-format fallback tests ==================== */

0 commit comments

Comments
 (0)