Search in sources :

Example 66 with Feature

use of org.ff4j.core.Feature in project ff4j by ff4j.

the class FeatureJsonMarshallTest method marshallOfficeHourFlippingStrategy.

/**
 * TDD.
 */
@Test
@Ignore
public void marshallOfficeHourFlippingStrategy() throws Exception {
    // When-Then
    Feature f = new FF4j(new XmlParser(), "test-strategy-officehour.xml").getFeature("first");
    assertMarshalling(f);
}
Also used : XmlParser(org.ff4j.conf.XmlParser) FF4j(org.ff4j.FF4j) TestConstantsFF4j(org.ff4j.test.TestConstantsFF4j) Feature(org.ff4j.core.Feature) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 67 with Feature

use of org.ff4j.core.Feature in project ff4j by ff4j.

the class CoreFeatureStoreTestSupport method testReadAllFeatures.

/**
 * TDD.
 */
@Test
public void testReadAllFeatures() {
    // Given
    assertFf4j.assertThatFeatureExist(F4);
    assertFf4j.assertThatStoreHasSize(EXPECTED_FEATURES_NUMBERS);
    // When
    Map<String, Feature> features = testedStore.readAll();
    // Then
    Assert.assertEquals(EXPECTED_FEATURES_NUMBERS, features.size());
    // Then testing whole structure
    Feature f = features.get(F4);
    Assert.assertEquals(F4 + " does not exist", f.getUid(), F4);
    Assert.assertTrue("no description", f.getDescription() != null && !"".equals(f.getDescription()));
    Assert.assertTrue("no authorizations", f.getPermissions() != null && !f.getPermissions().isEmpty());
    assertFf4j.assertThatFeatureHasRole(F4, ROLE_ADMIN);
    assertFf4j.assertThatFeatureIsInGroup(F4, G1);
}
Also used : PropertyString(org.ff4j.property.PropertyString) Feature(org.ff4j.core.Feature) Test(org.junit.Test)

Example 68 with Feature

use of org.ff4j.core.Feature in project ff4j by ff4j.

the class CoreFeatureStoreTestSupport method testUpdateAddProperty.

/**
 * TDD.
 */
@Test
public void testUpdateAddProperty() {
    // Given
    assertFf4j.assertThatFeatureExist(F2);
    assertFf4j.assertThatFeatureHasNotProperty(F2, "p1");
    // When
    Feature myFeature = ff4j.getFeatureStore().read(F2);
    PropertyString p1 = new PropertyString("p1", "v1");
    myFeature.getCustomProperties().put(p1.getName(), p1);
    testedStore.update(myFeature);
    // Then
    assertFf4j.assertThatFeatureHasProperty(F2, "p1");
}
Also used : PropertyString(org.ff4j.property.PropertyString) Feature(org.ff4j.core.Feature) Test(org.junit.Test)

Example 69 with Feature

use of org.ff4j.core.Feature in project ff4j by ff4j.

the class CoreFeatureStoreTestSupport method testUpdateEditPropertyValue.

/**
 * TDD.
 */
@Test
public void testUpdateEditPropertyValue() {
    // Given
    assertFf4j.assertThatFeatureExist(F1);
    assertFf4j.assertThatFeatureHasProperty(F1, "ppstring");
    Assert.assertEquals("hello", // 
    ff4j.getFeatureStore().read(F1).getCustomProperties().get(// 
    "ppstring").asString());
    // When
    Feature myFeature = ff4j.getFeatureStore().read(F1);
    PropertyString p1 = new PropertyString("ppstring", "goodbye");
    myFeature.getCustomProperties().put(p1.getName(), p1);
    testedStore.update(myFeature);
    // Then
    Assert.assertEquals("goodbye", // 
    ff4j.getFeatureStore().read(F1).getCustomProperties().get(// 
    "ppstring").asString());
}
Also used : PropertyString(org.ff4j.property.PropertyString) Feature(org.ff4j.core.Feature) Test(org.junit.Test)

Example 70 with Feature

use of org.ff4j.core.Feature in project ff4j by ff4j.

the class ReleaseDateFlipStrategyTest method testPastDayOK.

@Test
public void testPastDayOK() throws ParseException {
    Feature f = ff4j.getFeature("past1");
    ReleaseDateFlipStrategy rds = (ReleaseDateFlipStrategy) f.getFlippingStrategy();
    Assert.assertTrue(rds.evaluate("past1", null, null));
}
Also used : ReleaseDateFlipStrategy(org.ff4j.strategy.time.ReleaseDateFlipStrategy) Feature(org.ff4j.core.Feature) Test(org.junit.Test) AbstractFf4jTest(org.ff4j.test.AbstractFf4jTest)

Aggregations

Feature (org.ff4j.core.Feature)295 Test (org.junit.Test)144 PropertyString (org.ff4j.property.PropertyString)53 HashMap (java.util.HashMap)38 HashSet (java.util.HashSet)27 PonderationStrategy (org.ff4j.strategy.PonderationStrategy)19 Property (org.ff4j.property.Property)16 LinkedHashMap (java.util.LinkedHashMap)15 GroupNotFoundException (org.ff4j.exception.GroupNotFoundException)15 Map (java.util.Map)14 XmlParser (org.ff4j.conf.XmlParser)14 AbstractFf4jTest (org.ff4j.test.AbstractFf4jTest)14 FeatureAccessException (org.ff4j.exception.FeatureAccessException)13 InputStream (java.io.InputStream)11 FeatureApiBean (org.ff4j.web.api.resources.domain.FeatureApiBean)11 Set (java.util.Set)10 Response (javax.ws.rs.core.Response)10 FlippingStrategy (org.ff4j.core.FlippingStrategy)10 CouchDbFeature (org.ff4j.couchdb.document.CouchDbFeature)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9