[from now] 2012/10/02 00:11:25

diff --git a/core/src/main/scala/webservice/response/ichiba/IchibaItemSearchResult.scala b/core/src/main/scala/webservice/response/ichiba/IchibaItemSearchResult.scala
index 1d69069..f1d7938 100644
--- a/core/src/main/scala/webservice/response/ichiba/IchibaItemSearchResult.scala
+++ b/core/src/main/scala/webservice/response/ichiba/IchibaItemSearchResult.scala
@@ -38,7 +38,7 @@ class Item (
   ,val pointRate: Int
   ,val pointRateStartTime: Option[LocalDateTime]
   ,val pointRateEndTime: Option[LocalDateTime]
-  ,val accesptGift: Boolean
+  ,val acceptGift: Boolean
   ,val shopName: String
   ,val shopCode: String
   ,val shopUrl: String
diff --git a/core/src/test/scala/webservice/response/ichiba/ItemSpec.scala b/core/src/test/scala/webservice/response/ichiba/ItemSpec.scala
index 5aa1e03..0948758 100644
--- a/core/src/test/scala/webservice/response/ichiba/ItemSpec.scala
+++ b/core/src/test/scala/webservice/response/ichiba/ItemSpec.scala
@@ -28,12 +28,9 @@ class ItemSpec extends Specification with DataTables { def is =
       "flagが1の場合はoneMeans、0の場合は!oneMeansがsuccessで返る"                                  ! e9^
       "flagが0,1以外の場合はparamNameをmsgに含むJsonParseErrorのfailureを返す"                      ! e10^
                                                                                                     p^
-//    "parseVld"                                                                                      ^
-//      "各パラメータが正常であればItemをsuccessで返す"                                               ! e11^
-//      "不正なパラメータを含む場合、JsonParseErrorのfailureを返す"                                   ! (e12_1 and e12_2 and e12_3)^
-//                                                                                                    p^
-    "TODO"                                                                                          ^
-      "Itemのテスト作ってから、実装をIchibaItemSearchResult.scalaから別ファイルに切り出す"          ! ee^
+    "parseVld"                                                                                      ^
+      "各パラメータが正常であればItemをsuccessで返す"                                               ! e11^
+      "不正なパラメータを含む場合、JsonParseErrorのfailureを返す"                                   ! (e12_1 and e12_2 and e12_3 and e12_4)^
                                                                                                     end

   def e1 =
@@ -137,33 +134,237 @@ class ItemSpec extends Specification with DataTables { def is =
       }
     }

-//  def e11 = {
-//    val itemJson = new ItemJson (
-//       "itemName"
-//      ,"catchcopy"
-//      ,"itemCode"
-//      ,"1000"
-//      ,"itemCaption"
-//      ,"itemUrl"
-//      ,1
-//      ,0
-//      ,0
-//      ,1
-//      ,"shopName"
-//      ,"shopCode"
-//      ,"shopUrl"
-//      ,"123456"
-//      ,1
-//      ,List["small1", "small2"]
-//      ,List["medium1", "medium2"]
-//      ,"affiliateUrl"
-//      ,1
-//      ,1
-//      ,"東京都/神奈川県"
-//      ,
-//)
-//}
-
-  def ee = ko
+  def e11 = {
+    val itemJson = new ItemJson (
+       "itemName"
+      ,"catchcopy"
+      ,"itemCode"
+      ,"1000"
+      ,"itemCaption"
+      ,"itemUrl"
+      ,1
+      ,0
+      ,0
+      ,1
+      ,"shopName"
+      ,"shopCode"
+      ,"shopUrl"
+      ,"123456"
+      ,1
+      ,List("small1", "small2")
+      ,List("medium1", "medium2")
+      ,"affiliateUrl"
+      ,1
+      ,1
+      ,"ワールドワイド"
+      ,1
+      ,"12:00"
+      ,"東京都/神奈川県"
+      ,"5.5"
+      ,"2012-10-01 00:00"
+      ,"2012-10-01 23:59"
+      ,123
+      ,"4.23"
+      ,10
+      ,"2012-10-01 09:00"
+      ,"2012-10-01 12:00"
+      ,1
+    )
+    Item.parseVld(itemJson).toEither must beRight.like { case i: Item =>
+      (i.name must equalTo("itemName")) and
+      (i.catchcopy must equalTo("catchcopy")) and
+      (i.code must equalTo("itemCode")) and
+      (i.price must equalTo(1000L)) and
+      (i.caption must equalTo("itemCaption")) and
+      (i.url must equalTo("itemUrl")) and
+      (i.affiliateUrl must equalTo("affiliateUrl".some)) and
+      (i.imageStatus must equalTo(HasItemImage(List("small1", "small2"), List("medium1", "medium2")))) and
+      (i.availability must beTrue) and
+      (i.includeTax must beTrue) and
+      (i.includePostage must beTrue) and
+      (i.acceptCreditCard must beTrue) and
+      (i.shopOfTheYear must beTrue) and
+      (i.shipOverseaStatus must equalTo(AcceptShipOversea(List(AllCountry)))) and
+      (i.asurakuStatus must equalTo(AcceptAsuraku(new LocalTime(12, 0), List(Tokyo, Kanagawa)))) and
+      (i.affiliateRate must equalTo(5.5)) and
+      (i.startTime must equalTo(new LocalDateTime(2012, 10, 1, 0, 0).some)) and
+      (i.endTime must equalTo(new LocalDateTime(2012, 10, 1, 23, 59).some)) and
+      (i.reviewCount must equalTo(123)) and
+      (i.reviewAverage must equalTo(4.23)) and
+      (i.pointRate must equalTo(10)) and
+      (i.pointRateStartTime must equalTo(new LocalDateTime(2012, 10, 1, 9, 0).some)) and
+      (i.pointRateEndTime must equalTo(new LocalDateTime(2012, 10, 1, 12, 0).some)) and
+      (i.acceptGift must beTrue) and
+      (i.shopName must equalTo("shopName")) and
+      (i.shopCode must equalTo("shopCode")) and
+      (i.shopUrl must equalTo("shopUrl")) and
+      (i.genreId must equalTo(123456L))
+    }
+  }
+
+  def e12_1 = {
+    val itemJson = new ItemJson (
+       "itemName"
+      ,"catchcopy"
+      ,"itemCode"
+      ,"abcde" // <- price must be Long
+      ,"itemCaption"
+      ,"itemUrl"
+      ,1
+      ,0
+      ,0
+      ,1
+      ,"shopName"
+      ,"shopCode"
+      ,"shopUrl"
+      ,"123456"
+      ,1
+      ,List("small1", "small2")
+      ,List("medium1", "medium2")
+      ,"affiliateUrl"
+      ,1
+      ,1
+      ,"ワールドワイド"
+      ,1
+      ,"12:00"
+      ,"東京都/神奈川県"
+      ,"5.5"
+      ,"2012-10-01 00:00"
+      ,"2012-10-01 23:59"
+      ,123
+      ,"4.23"
+      ,10
+      ,"2012-10-01 09:00"
+      ,"2012-10-01 12:00"
+      ,1
+    )
+    Item.parseVld(itemJson).toEither must beLeft.like {
+      case JsonParseError(msg) => msg must contain("itemPrice")
+    }
+  }
+
+  def e12_2 = {
+    val itemJson = new ItemJson (
+       "itemName"
+      ,"catchcopy"
+      ,"itemCode"
+      ,"1000"
+      ,"itemCaption"
+      ,"itemUrl"
+      ,1
+      ,0
+      ,0
+      ,1
+      ,"shopName"
+      ,"shopCode"
+      ,"shopUrl"
+      ,"123456"
+      ,2 // <- imageFlag must be in 0, 1
+      ,List("small1", "small2")
+      ,List("medium1", "medium2")
+      ,"affiliateUrl"
+      ,1
+      ,1
+      ,"ワールドワイド"
+      ,1
+      ,"12:00"
+      ,"東京都/神奈川県"
+      ,"5.5"
+      ,"2012-10-01 00:00"
+      ,"2012-10-01 23:59"
+      ,123
+      ,"4.23"
+      ,10
+      ,"2012-10-01 09:00"
+      ,"2012-10-01 12:00"
+      ,1
+    )
+    Item.parseVld(itemJson).toEither must beLeft.like {
+      case JsonParseError(msg) => msg must contain("imageFlag")
+    }
+  }
+
+  def e12_3 = {
+    val itemJson = new ItemJson (
+       "itemName"
+      ,"catchcopy"
+      ,"itemCode"
+      ,"1000"
+      ,"itemCaption"
+      ,"itemUrl"
+      ,1
+      ,0
+      ,0
+      ,1
+      ,"shopName"
+      ,"shopCode"
+      ,"shopUrl"
+      ,"123456"
+      ,1
+      ,List("small1", "small2")
+      ,List("medium1", "medium2")
+      ,"affiliateUrl"
+      ,1
+      ,1
+      ,"hoge" // <- invalid shipOverseasArea
+      ,1
+      ,"12:00"
+      ,"東京都/神奈川県"
+      ,"5.5"
+      ,"2012-10-01 00:00"
+      ,"2012-10-01 23:59"
+      ,123
+      ,"4.23"
+      ,10
+      ,"2012-10-01 09:00"
+      ,"2012-10-01 12:00"
+      ,1
+    )
+    Item.parseVld(itemJson).toEither must beLeft.like {
+      case JsonParseError(msg) => msg must contain("shipOverseasArea")
+    }
+  }
+
+  def e12_4 = {
+    val itemJson = new ItemJson (
+       "itemName"
+      ,"catchcopy"
+      ,"itemCode"
+      ,"1000"
+      ,"itemCaption"
+      ,"itemUrl"
+      ,1
+      ,0
+      ,0
+      ,1
+      ,"shopName"
+      ,"shopCode"
+      ,"shopUrl"
+      ,"123456"
+      ,1
+      ,List("small1", "small2")
+      ,List("medium1", "medium2")
+      ,"affiliateUrl"
+      ,1
+      ,1
+      ,"ワールドワイド"
+      ,1
+      ,"dummy" // <- asurakuClosingTime must be Time
+      ,"東京都/神奈川県"
+      ,"5.5"
+      ,"2012-10-01 00:00"
+      ,"2012-10-01 23:59"
+      ,123
+      ,"4.23"
+      ,10
+      ,"2012-10-01 09:00"
+      ,"2012-10-01 12:00"
+      ,1
+    )
+    Item.parseVld(itemJson).toEither must beLeft.like {
+      case JsonParseError(msg) => msg must contain("asurakuClosingTime")
+    }
+  }
+
 }