lundi 23 novembre 2015

How to make Mockito verify work with Enumeration

I have following error in a unit test:

Argument(s) are different! Wanted:
userService.registerPro(
    "newpro@gmail.com",
    "name",
    "name",
    "123",
    "test",
    "",
    List(),
    tier1,
    "encryptedpassword",
    inactive,
    0,
    List(POLYGON ((1 1, 1 2, 2 2, 2 1, 1 1)))
);

Actual invocation has different arguments:
userService.registerPro(
    "newpro@gmail.com",
    "name",
    "name",
    "123",
    "test",
    "",
    List(),
    tier1,
    "encryptedpassword",
    inactive,
    0,
    List(POLYGON ((1 1, 1 2, 2 2, 2 1, 1 1)))
);

Although the message says that they are different, they'r actually identical. Note that, tier1 and inactive are enum:

object UserSubscriptionTiers extends Enumeration {
  type UserSubscriptionTier = Value
  val TIER0 = Value("tier0") 
  val TIER1 = Value("tier1") 
  val TIER2 = Value("tier2") 
  val TIER3 = Value("tier3") 
  val TIERA = Value("tierA") 
}

object UserStatuses extends Enumeration{
  type UserStatus = Value
  def ACTIVE = Value("active")
  def INACTIVE = Value("inactive")
}

And it seem that mockito does not work properly with enum.

Aucun commentaire:

Enregistrer un commentaire