vendredi 7 juillet 2017

How to verify a line in mockito java which has function1().function2().function3();

Hi i am new to Junit & Mockito. I have code like this:

public class ABCCheckout implements Checkout
{
@Resource
public PrimeConfigService primeConfigService;
/* PrimeConfigService getter & setters  */
@Override
public String getBlackOutDays()
{
    return getPrimeConfigService().findPrimeConfigByUid(RDD_ISA).get(0).getValue();
}
}

I want to verify that this line is called:

return getPrimeConfigService().findPrimeConfigByUid(RDD_ISA).get(0).getValue();

& findPrimeConfigByUid(RDD_ISA) returns a ArrayList of type ProductModel

So how does i achieve it in my ABCCheckoutTest where i have code like this

@UnitTest
@RunWith(MockitoJUnitRunner.class)
public class ABCheckoutTest{
@InjectMocks
private ABCCheckout aBCCheckout;

@Before
    public void setUp()
    {//what should go here//}

    @Test
    public void testGetBlackOutDays()
    {//what should go here//}

}

Aucun commentaire:

Enregistrer un commentaire