### Question:
IPvXCondition extends EntitlementConditionAdaptor { @SuppressWarnings("unchecked") public String getRequestIp(Map env) { String ip = null; final Object requestIp = env.get(REQUEST_IP); if (requestIp instanceof Set) { Set<String> requestIpSet = (Set<String>) requestIp; if (!requestIpSet.isEmpty()) { if (requestIpSet.size() > 1) { debugWarning("Environment map {0} cardinality > 1. Using first from: {1}", REQUEST_IP, requestIpSet); } ip = requestIpSet.iterator().next(); } } else if (requestIp instanceof String) { ip = (String) requestIp; } if (StringUtils.isBlank(ip)) { debugWarning("Environment map {0} is null or empty", REQUEST_IP); } return ip; } protected  IPvXCondition(Debug debug, T initialStartIp, T initialEndIp, IPVersion version); protected  IPvXCondition(Debug debug, T initialStartIp, T initialEndIp, IPVersion version,
                            String startIp, String endIp, List<String> ipRange, List<String> dnsName); @Override void setState(String state); String getStartIp(); String getEndIp(); void setStartIpAndEndIp(String startIp, String endIp); List<String> getDnsName(); void setDnsName(List<String> dnsName); @Deprecated List<String> getIpRange(); @Deprecated void setIpRange(List<String> ipRanges); @Override String getState(); @Override void validate(); @Override ConditionDecision evaluate(String realm, Subject subject, String resourceName, Map<String, Set<String>> env); @SuppressWarnings("unchecked") String getRequestIp(Map env); String getSessionIp(Subject subject); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode();  }### Answer:
@Test public void shouldReturnRequestIpValueString() { String input = "192.168.0.1"; Map testMap = new HashMap(); testMap.put(REQUEST_IP, input); String result = condition.getRequestIp(testMap); assertEquals(input, result); }
@Test public void shouldReturnRequestIpValueSet() { Set<String> input = new HashSet<String>(); input.add("192.168.0.1"); Map testMap = new HashMap(); testMap.put(REQUEST_IP, input); String result = condition.getRequestIp(testMap); assertEquals("192.168.0.1", result); }
@Test public void shouldReturnRequestIpValueSetFirstEntry() { Set<String> input = new LinkedHashSet<String>(); input.add("192.168.0.1"); input.add("192.168.0.2"); Map testMap = new HashMap(); testMap.put(REQUEST_IP, input); String result = condition.getRequestIp(testMap); assertEquals("192.168.0.1", result); }