FeatureContext { public Feature addFeature(String key) { if(key == null || "".equals(key.trim())) { throw new IllegalArgumentException("key argument must be a value"); } if(hasFeature(key)) { throw new FeatureAlreadyExistsException("feature with name " + key +" already exists."); } Feature feature = new Feature(key, config.enabledStatus); featureMap.put(key, feature); return feature; } FeatureContext(Configuration config); Feature addFeature(String key); Feature addFeature(Feature feature); boolean hasFeature(String key); boolean featureHasStatus(String key, FeatureStatus status); void clear(); int size(); Configuration getConfig();  }
@Test public void addFeature_WithString_FeatureAddedWithEnabledStatus() throws Exception { Feature feature = context.addFeature("test.feature"); assertThat(feature.getName(), Is.is("test.feature")); assertThat(feature.getStatus(), Is.is(options.enabledStatus)); }
@Test(expected=IllegalArgumentException.class) public void addFeature_WithNullString_ThrowsException() { Feature feature = context.addFeature((String)null); }
@Test(expected=IllegalArgumentException.class) public void addFeature_WithEmptyString_ThrowsException() { Feature feature = context.addFeature(""); }
@Test(expected=FeatureAlreadyExistsException.class) public void addFeature_WithAlreadyAddedString_ThrowsException() { context.addFeature("test.feature"); context.addFeature("test.feature"); }
@Test public void addFeature_WithFeature_FeatureAdded() { Feature feature = new Feature("test.feature", options.enabledStatus); assertSame(feature, context.addFeature(feature)); }
@Test(expected=IllegalArgumentException.class) public void addFeature_WithoutFeature_ThrowsException() { context.addFeature((Feature)null); }
@Test(expected=FeatureAlreadyExistsException.class) public void addFeature_WithAlreadyAddedFeature_ThrowsException() { Feature feature = new Feature("test.feature", options.enabledStatus); context.addFeature(feature); context.addFeature(feature); }