Junit mock a HTTP Session object
Hello,
We have a requirement where we need to set some attributes to the session object through out the user journey and finally, we need to read the session attribute names and will read each attribute name.
Can someone suggest how I can mock these values:
Here is the sample code:
Fields fields= new Fields();
if (session != null) {
Enumeration<String> attributeNames = session.getAttributeNames();
List<FieldItems> positiveList = new ArrayList<>();
List<FieldItems> negativeList = new ArrayList<>();
while (attributeNames.hasMoreElements()) {
String attributeName = attributeNames.nextElement();
if (attributeName.startsWith(PAGE_PATH)) {
String attributeValue = session.getAttribute(attributeName).toString();