fwbrasil / activate

Abandoned: Pluggable persistence in Scala
GNU Lesser General Public License v2.1
299 stars 46 forks source link

ActivatePlayTest issue in Play 2.3.2 #151

Closed ThijsBroersen closed 10 years ago

ThijsBroersen commented 10 years ago

Hi,

I am a thankful user of the Activate Framework and am using it with Play. Currently I migrated to Play 2.3.2 but it looks like ActivatePlayTest is not yet migrated for Play 2.3.x. Play23 migration: Java JUnit superclasses Can anyone confirm or do I have some misconfiguration?

I am getting the next error when executing 'activator test'.

[error] NoSuchMethodError: : play.api.test.Helpers$.running(Lplay/api/test/FakeApplication;Lscala/Function0;)Ljava/lang/Object; (ActivatePlayTest.scala:31) [error] net.fwbrasil.activate.play.ActivatePlayTest$DSL$$anonfun$inActivate$1.apply(ActivatePlayTest.scala:31)

Regards, Thijs

fwbrasil commented 10 years ago

Hi @ThijsBroersen,

Activate needs to be compiled against Play 2.3.2, the current "official" supported version is 2.2.1. I probably won't have time to work on this in the short time, could you try to send a pull request?

Cheers,

ThijsBroersen commented 10 years ago

Hi @fwbrasil ,

Time is also not on my side :(. I am trying to spend more time on my projects and I really want to get to know Activate (and Scala) a lot better. I will try if I can compile it against 2.3.2 when and if I am able to.

Thanks

fwbrasil commented 10 years ago

@ThijsBroersen No problem! Maybe @felipeko can help us here. :)

felipeko commented 10 years ago

Yes!

But also short on time!

But i will try to take time during the week for this to happen

On Mon, Jul 28, 2014 at 6:56 PM, Flavio W. Brasil notifications@github.com wrote:

@ThijsBroersen https://github.com/ThijsBroersen No problem! Maybe @felipeko https://github.com/felipeko can help us here. :)

— Reply to this email directly or view it on GitHub https://github.com/fwbrasil/activate/issues/151#issuecomment-50407949.

ThijsBroersen commented 10 years ago

Hi @fwbrasil @felipeko Just made a clone of the git-repository and compiled it, :+1: Now, from the tests only 185 of 257 are passing. I chose the in-memory database when I got the database popup, is this OK? Are there any other preconditions that need to be met in order to pass all tests? Or do different tests need different settings? Are you not testing them all at once?

Thanks

fwbrasil commented 10 years ago

@ThijsBroersen Could you send a pull request with your modifications? I can take a look at the failing tests.

ThijsBroersen commented 10 years ago

@fwbrasil I did not make any changes there, just builded and testing the repo as-is.

ThijsBroersen commented 10 years ago

@fwbrasil @felipeko I have Activate compiled with sbt 13.5, Play 2.3.2 and Scala 2.10.4. I compiled it without activate.play.entityform because there is a change in FormError (Play 2.3.2) which I cannot solve). The rest of the code has been left untouched, it just compiled, even more tests passed (247 out of 256). I am not using EntityForm at the moment. In FormError the 'message' parameter is now Seq[String] instead of String. Old Play code:

/**
 * A form error.
 *
 * @param key The error key (should be associated with a field using the same key).
 * @param message The form message (often a simple message key needing to be translated).
 * @param args Arguments used to format the message.
 */
case class FormError(key: String, message: String, args: Seq[Any] = Nil) {

  /**
   * Copy this error with a new Message.
   *
   * @param message The new message.
   */
  def withMessage(message: String): FormError = FormError(key, message)

}

New Play code:

/**
 * A form error.
 *
 * @param key The error key (should be associated with a field using the same key).
 * @param message The form message (often a simple message key needing to be translated).
 * @param args Arguments used to format the message.
 */
case class FormError(key: String, messages: Seq[String], args: Seq[Any] = Nil) {

  def this(key: String, message: String) = this(key, Seq(message), Nil)

  def this(key: String, message: String, args: Seq[Any]) = this(key, Seq(message), args)

  lazy val message = messages.last

  /**
   * Copy this error with a new Message.
   *
   * @param message The new message.
   */
  def withMessage(message: String): FormError = FormError(key, message)
}

object FormError {

  def apply(key: String, message: String) = new FormError(key, message)

  def apply(key: String, message: String, args: Seq[Any]) = new FormError(key, message, args)

}

Activate.Play.EntityForm code where the error is:

def unbind(value: MutableEntityMap[T]) = {
        val data = value.values
        val res =
            (for ((key, value) <- data)
                yield properties.find(_.key == key).map(_.asInstanceOf[Mapping[Any]].unbind(value))).flatten
        res.foldLeft(
            (Map[String, String](), Seq[FormError]()))(
                (t1, t2) => (t1._1 ++ t2._1, t1._2 ++ t2._2))
    }
felipeko commented 10 years ago

Hi Thijs, i've found and fixed this compile error. I will be sending a pull request to Flavio soon

On Tue, Jul 29, 2014 at 7:48 AM, Thijs notifications@github.com wrote:

@fwbrasil https://github.com/fwbrasil @felipeko https://github.com/felipeko I have Activate compiled with sbt 13.5, Play 2.3.2 and Scala 2.10.4. I compiled it without activate.play.entityform because there is a change in FormError (Play 2.3.2) which I cannot solve). The rest of the code has been left untouched, it just compiled, even more tests passed (247 out of 256). I am not using EntityForm at the moment. In FormError the 'message' parameter is now Seq[String] instead of String. Old Play code:

/**

  • A form error. *
  • @param key The error key (should be associated with a field using the same key).
  • @param message The form message (often a simple message key needing to be translated).
  • @param args Arguments used to format the message. */ case class FormError(key: String, message: String, args: Seq[Any] = Nil) {

    /**

    • Copy this error with a new Message.
    • @param message The new message. */ def withMessage(message: String): FormError = FormError(key, message)

}

New Play code:

/**

  • A form error. *
  • @param key The error key (should be associated with a field using the same key).
  • @param message The form message (often a simple message key needing to be translated).
  • @param args Arguments used to format the message. */ case class FormError(key: String, messages: Seq[String], args: Seq[Any] = Nil) {

    def this(key: String, message: String) = this(key, Seq(message), Nil)

    def this(key: String, message: String, args: Seq[Any]) = this(key, Seq(message), args)

    lazy val message = messages.last

    /**

    • Copy this error with a new Message.
    • @param message The new message. */ def withMessage(message: String): FormError = FormError(key, message) }

object FormError {

def apply(key: String, message: String) = new FormError(key, message)

def apply(key: String, message: String, args: Seq[Any]) = new FormError(key, message, args)

}

Activate.Play.EntityForm code where the error is:

def unbind(value: MutableEntityMap[T]) = { val data = value.values val res = (for ((key, value) <- data) yield properties.find(.key == key).map(.asInstanceOf[Mapping[Any]].unbind(value))).flatten res.foldLeft( (Map[String, String](), Seq[FormError]()))( (t1, t2) => (t1._1 ++ t2._1, t1._2 ++ t2._2)) }

— Reply to this email directly or view it on GitHub https://github.com/fwbrasil/activate/issues/151#issuecomment-50461251.