category.runSafe { ... } ?

-------------------------------------
Ferdinand Chan<[email protected]> wrote:

Hi,

I'm writing a unit test for a utility class that will make use of
information of a Model class. Here is the sample code for the model
class

class Category extends LongKeyedMapper[Category] with IdPK{

  def getSingleton = Category

  object parentCategoryId extends MappedLong(this)

  object name extends MappedPoliteString(this,255) {
    override def validations = valMinLen(1, "Category cannot be
empty") _ :: super.validations
  }
}

In my scala test, I need to create a Category and then pass it to the
utility class. Then make sure the utility class is producing result as
expected.

But the problem is that I can't set the ID of the Category , here is
my test code

"Model photographer " should "be able to take snapshot of Category" in
{
    val category = Category.create
    category.id(1)  // <- This line will fail !!
    category.parentCategoryId(-1)
    category.name("Food")

    //Some assertion code here .........
  }

I don't want to use something like DB unit to create dummy Model
object based on temp table.

Anyone have solution to this??

Cheers,

Ferdinand
-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.


Reply via email to