Package org.ff4j.core

Examples of org.ff4j.core.Feature


    }

    @Test
    public void testFilterInvalidClient() throws ParseException {
        // Given
        Feature f1 = ff4j.getFeature(F1);
        Assert.assertNotNull(f1.getFlippingStrategy());
        ServerFilterStrategy cStra = (ServerFilterStrategy) f1.getFlippingStrategy();
        Assert.assertNotNull(cStra.getInitParams());
        Assert.assertEquals(1, cStra.getInitParams().size());
        Assert.assertTrue(f1.isEnable());

        // When (add invalid client name)
        FlippingExecutionContext fex = new FlippingExecutionContext();
        fex.addValue(ServerFilterStrategy.SERVER_HOSTNAME, FEATURE_NEW);
View Full Code Here


*/
public class FeatureTest {

    @Test(expected = IllegalArgumentException.class)
    public void testFeatureNameNull() {
        new Feature(null, false, null);
    }
View Full Code Here

        String resEntity = resHttp.getEntity(String.class);
        // Then, HTTPResponse
        Assert.assertEquals("Expected status is 200", Status.OK.getStatusCode(), resHttp.getStatus());
        Assert.assertNotNull(resEntity);
        // Then, Entity Object
        Feature f = FeatureJsonParser.parseFeature(resEntity);
        Assert.assertEquals(ff4j.getFeature(F4).toString(), f.toString());
    }
View Full Code Here

        new Feature(null, false, null);
    }

    @Test(expected = IllegalArgumentException.class)
    public void testFeatureNameEmpty() {
        new Feature("", false, null);
    }
View Full Code Here

        new Feature("", false, null);
    }

    @Test
    public void testDescriptionNull() {
        Feature f = new Feature("ok", true, null);
        Assert.assertNotNull(f.toString(), "f should be serialized even without description");
        Assert.assertTrue(f.isEnable());
    }
View Full Code Here

        Assert.assertTrue(f.isEnable());
    }

    @Test
    public void testRolesEmpty() {
        Feature f2 = new Feature("ok2", true, null, null, new HashSet<String>());
        Assert.assertNotNull(f2.toString(), "f should be serialized even without roles");
        Assert.assertTrue(f2.isEnable());
    }
View Full Code Here

    }

    @Test
    public void testFullToStringImpl() {
        List<String> auths = Arrays.asList(new String[] {"something"});
        Feature f = new Feature("ok", true, "grp1", "description", auths, new PonderationStrategy());
        Assert.assertTrue(f.toString().contains("ok"));
    }
View Full Code Here

        Assert.assertTrue(f.toString().contains("ok"));
    }

    @Test
    public void testBuildFromScratchFeature() {
        Feature empty = new Feature("abc");
        empty.setUid("abc");

        // Flipping strategy
        empty.setFlippingStrategy(new PonderationStrategy());
        Assert.assertNotNull(empty.getFlippingStrategy());

        // Authorization filling
        List<String> auths = Arrays.asList(new String[] {"something"});
        empty.setPermissions(new HashSet<String>(auths));
        Assert.assertNotNull(empty.getPermissions());

        // Description setter
        empty.setDescription("OK");
        Assert.assertNotNull(empty.getDescription());

        // Toggle to change value
        empty.setEnable(true);
        empty.toggle();
        Assert.assertFalse(empty.isEnable());
       
        // GROUP
        empty.setGroup("sampleGroup");
        Assert.assertFalse(empty.getGroup() == null);

        // To String with a whole object
        Assert.assertTrue(empty.toString().contains("OK"));
    }
View Full Code Here

        new InMemoryCacheManager().put(null);
    }

    @Test(expected = IllegalArgumentException.class)
    public void testPutNullFeatureId() {
        Feature f = new Feature("a");
        f.setUid(null);
        new InMemoryCacheManager().put(f);
    }
View Full Code Here

        new InMemoryCacheManager().put(f);
    }

    @Test(expected = IllegalArgumentException.class)
    public void testPutEmptyFeatureId() {
        Feature f = new Feature("a");
        f.setUid("");
        new InMemoryCacheManager().put(f);
    }
View Full Code Here

TOP

Related Classes of org.ff4j.core.Feature

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.