Mockito matchers, scala value class and NullPointerException

后端 未结 6 1936
遇见更好的自我
遇见更好的自我 2020-12-15 04:16

I\'m using mockito with scalatest. I have following problem when using matcher with value class.

import org.scalat         


        
6条回答
  •  旧巷少年郎
    2020-12-15 05:21

    My class also extended AnyVal

    case class ApplicationKey(value: String) extends AnyVal {
      override def toString: String = value
    }
    

    and this worked for me:

       when(waterfallLogicEventWriter.writeAuctionEvents(            
         Eq(waterfallRequest.auctionId), Eq(waterfallRequest.ip),
         ApplicationKey(any[String]),                                
         any()).thenReturn(waterfallEvents) 
    

提交回复
热议问题