Ho creato un test delle specifiche per convalidare l'analisi JSON. Sebbene il test funzioni perfettamente, sembra piuttosto rumoroso.C'è un verificatore di specifiche che cancellerà l'opzione e O
Mi chiedo se esiste un codice esistente in Specifiche per annullare l'opzione e l'opzione?
"twitter json to Scala class mapper" should {
"parsing a tweet" in {
TwitterJsonMapper.tweetP(tweetS) match {
case Right(t: Tweet) => {
implicit def unOption[T](t: Option[T]): T = t.get
implicit def unEither[T](t: Either[T,Throwable]): T = t match {case Left(left) => left ;case Right(t) => throw t}
"test id" in {
true must_== (t.id.get == 228106060337135617l)
}
"test id_str" in {
true must_== (t.id_str.get == "228106060337135617")
}
"test time" in {
true must_== (t.created_at.getHours == 13)
}
}
case Left((pe: JsonParseException, reason: String)) => fail(reason + "\n" + pe)
}
}
}
//The Tweet is produced from JSON using Fasterxml's Jackson-Scala library.
//I want to use Option or Either monads over all child attributes - for the usual reasons.
case class Tweet(
@BeanProperty contributors: Option[String],
@BeanProperty coordinates: Option[String],
@BeanProperty @JsonDeserialize (
using = classOf[TwitterDateDeserializer]
) created_at: Either[Date,Throwable],
@BeanProperty favorited: Boolean = false,
//elided etc etc
@BeanProperty id_str: Option[String]
}
Sì, vedere la guida matchers: http://etorreborre.github.com/specs2/guide/org.specs2.guide.Matchers.html#Matchers –
Ah, ok. Ho dimenticato di dire che sono ancora sulle specifiche 1. Ho solo tanto tempo da dedicare all'aggiornamento delle mie librerie. La funzione non è nelle specifiche 1? –
È davvero difficile ottenere una scala affidabile/maven/eclipse/specifiche - toolchain - attiva e funzionante. Ho avuto le specifiche per lavorare con Eclipse e ho congelato quella sezione delle mie dipendenze. –