How can I mock and expect in JUnit for the following code?
esGateKeeper.esGateKeeper(Mockito.anyString(), "Somethin", "Something")
my full example class:
import esGateKeeper.esGateKeeper;//external library
Class Common {
public static String getUserId(HttpServletRequest request){
Cookie[] cookies = request.getCookies();
String test = null;
for (int i = 0; i < cookies.length; i++) {
Cookie thisCookie = cookies[i];
String cookieName = thisCookie.getName();
if ("test".equals(cookieName)) {
test = thisCookie.getValue();
break;
}
}
String encrypted = esGateKeeper.esGateKeeper(test, "CSP", "PROD");///unable to mock this in mockito framework
String userId = encrypted.split("\\|")[5];
return userId;
}
}
till for loop its working while doing junit. after that i couldnt mock for the statement .