### Question:
AuthenticateToServiceCondition extends EntitlementConditionAdaptor { @Override public ConditionDecision evaluate(String realm, Subject subject, String resourceName, Map<String, Set<String>> env) throws EntitlementException { if (StringUtils.isBlank(authenticateToService)) { if (debug.errorEnabled()) { debug.error("AuthenticateToServiceCondition.evaluate(): property value not defined, " + AUTHENTICATE_TO_SERVICE); } throw new EntitlementException(PROPERTY_VALUE_NOT_DEFINED, new Object[]{AUTHENTICATE_TO_SERVICE}, null); } boolean allowed = false; Set<String> requestAuthnServices = new HashSet<String>(); if (env.get(REQUEST_AUTHENTICATED_TO_SERVICES) != null) { requestAuthnServices.addAll(env.get(REQUEST_AUTHENTICATED_TO_SERVICES)); if (debug.messageEnabled()) { debug.message("At AuthenticateToServiceCondition.evaluate(): requestAuthnServices " + "from request = " + requestAuthnServices); } } else if (subject != null){ SSOToken token = (SSOToken) subject.getPrivateCredentials().iterator().next(); Set<String> authenticatedServices = entitlementCoreWrapper.getRealmQualifiedAuthenticatedServices(token); if (authenticatedServices != null) { requestAuthnServices.addAll(authenticatedServices); } if (debug.messageEnabled()) { debug.message("At AuthenticateToServiceCondition.evaluate(): requestAuthnServices from " + "ssoToken = " + requestAuthnServices); } } if (requestAuthnServices.contains(authenticateToService)) { allowed = true; } else if (realmEmpty) { for (String requestAuthnService : requestAuthnServices) { String service = coreWrapper.getDataFromRealmQualifiedData(requestAuthnService); if (authenticateToService.equals(service)) { allowed = true; break; } } } Map<String, Set<String>> advices = new HashMap<String, Set<String>>(); final String realmAwareService = getRealmAwareService(authenticateToService, realm); if (!allowed) { Set<String> adviceMessages = new HashSet<String>(1); adviceMessages.add(realmAwareService); advices.put(AUTHENTICATE_TO_SERVICE_CONDITION_ADVICE, adviceMessages); if (debug.messageEnabled()) { debug.message("At AuthenticateToServiceCondition.evaluate():authenticateToService not " + "satisfied = " + realmAwareService); } } if (debug.messageEnabled()) { debug.message("At AuthenticateToServiceCondition.evaluate():authenticateToService = " + realmAwareService + "," + " requestAuthnServices = " + requestAuthnServices + ", " + " allowed = " + allowed); } return new ConditionDecision(allowed, advices); } AuthenticateToServiceCondition();   AuthenticateToServiceCondition(Debug debug, CoreWrapper coreWrapper, EntitlementCoreWrapper entitlementCoreWrapper); @Override void setState(String state); @Override String getState(); @Override ConditionDecision evaluate(String realm, Subject subject, String resourceName, Map<String, Set<String>> env); @Override String toString(); String getAuthenticateToService(); void setAuthenticateToService(String authenticateToService); @Override void validate(); @Override boolean equals(Object obj); @Override int hashCode();  }### Answer:
@Test(expectedExceptions = EntitlementException.class) public void conditionShouldThrowEntitlementExceptionWhenEvaluatingWithNoAuthenticateToServiceSet() throws EntitlementException { String realm = "REALM"; Subject subject = new Subject(); String resourceName = "RESOURCE_NAME"; Map<String, Set<String>> env = new HashMap<String, Set<String>>(); condition.evaluate(realm, subject, resourceName, env); }