ServerNameActivationStrategy implements ActivationStrategy { @Override public boolean isActive(FeatureState featureState, FeatureUser user) { HttpServletRequest request = getServletRequest(); if (request != null) { String allowedServerNamesParam = featureState.getParameter(PARAM_SERVER_NAMES); List<String> allowedServerNames = Strings.splitAndTrim(allowedServerNamesParam, "[\\s,]+"); return allowedServerNames.contains(request.getServerName()); } return false; }  @Override String getId(); @Override String getName(); @Override boolean isActive(FeatureState featureState, FeatureUser user); @Override Parameter[] getParameters();  }
@Test public void shouldReturnFalseForEmptyDomainList() { boolean active = strategySpy.isActive(state, user); assertThat(active).isFalse(); }
@Test public void shouldReturnTrueForFeatureOnMatchingDomainName() { state.setParameter(ServerNameActivationStrategy.PARAM_SERVER_NAMES, MATCHING_VHOST_NAME); boolean active = strategySpy.isActive(state, user); assertThat(active).isTrue(); }
@Test public void shouldReturnFalseForFeatureOnDifferentDomainName() { state.setParameter(ServerNameActivationStrategy.PARAM_SERVER_NAMES, DIFFERENT_VHOST_NAME); boolean active = strategySpy.isActive(state, user); assertThat(active).isFalse(); }
@Test public void shouldReturnTrueForFeatureOnMatchingOneDomainNameFromDomainList() { state.setParameter(ServerNameActivationStrategy.PARAM_SERVER_NAMES, format("%s,%s", MATCHING_VHOST_NAME, DIFFERENT_VHOST_NAME)); boolean active = strategySpy.isActive(state, user); assertThat(active).isTrue(); }