I have a simple method that returns a String
.
It also creates a local List
. I want to test the value added to the local List
.
Here is an example
package com.impl;
import java.util.ArrayList;
import java.util.List;
import com.test.domain.CustomerVo;
public class ClassImpl {
public String assignGift(CustomerVo customerVo) {
List<String> listOfGift = new ArrayList<String>();
if (customerVo.getName().equals("Joe")) {
listOfGift.add("ball");
} else if ((customerVo.getName().equals("Terry"))) {
listOfGift.add("car");
} else if (customerVo.getName().equals("Merry")) {
listOfGift.add("tv");
}else {
listOfGift.add("no gift");
}
return "dummyString";
}
}
How can I test that when the customerVo.getName.equals("Terry")
, car
is added to the local List
.