Package org.togglz.core.repository

Examples of org.togglz.core.repository.FeatureState


    public void testShouldSaveStateWithoutStrategyOrParameters() throws SQLException {

        /*
         * WHEN a feature without strategy is persisted
         */
        FeatureState state = new FeatureState(TestFeature.F1).disable();
        repository.setFeatureState(state);

        /*
         * THEN there should be a corresponding entry in the database
         */
 
View Full Code Here


    public void testShouldSaveStateStrategyAndParameters() throws SQLException {

        /*
         * WHEN a feature without strategy is persisted
         */
        FeatureState state = new FeatureState(TestFeature.F1)
            .enable()
            .setStrategyId("someId")
            .setParameter("param", "foo");
        repository.setFeatureState(state);

View Full Code Here

        update(dataSource, "INSERT INTO TOGGLZ VALUES ('F1', 0, NULL, NULL)");

        /*
         * WHEN the repository reads the state
         */
        FeatureState state = repository.getFeatureState(TestFeature.F1);

        /*
         * THEN the properties should be set like expected
         */
        assertNotNull(state);
        assertEquals(TestFeature.F1, state.getFeature());
        assertEquals(false, state.isEnabled());
        assertEquals(null, state.getStrategyId());
        assertEquals(0, state.getParameterNames().size());

    }
View Full Code Here

        update(dataSource, "INSERT INTO TOGGLZ VALUES ('F1', 1, 'myStrategy', 'param23=foobar')");

        /*
         * WHEN the repository reads the state
         */
        FeatureState state = repository.getFeatureState(TestFeature.F1);

        /*
         * THEN the properties should be set like expected
         */
        assertNotNull(state);
        assertEquals(TestFeature.F1, state.getFeature());
        assertEquals(true, state.isEnabled());
        assertEquals("myStrategy", state.getStrategyId());
        assertEquals(1, state.getParameterNames().size());
        assertEquals("foobar", state.getParameter("param23"));

    }
View Full Code Here

        assertEquals("param23=foobar", query(dataSource, "SELECT STRATEGY_PARAMS FROM TOGGLZ WHERE FEATURE_NAME = 'F1'"));

        /*
         * WHEN the repository writes new state
         */
        FeatureState state = new FeatureState(TestFeature.F1)
            .disable()
            .setStrategyId("someId")
            .setParameter("param", "foo");
        repository.setFeatureState(state);

View Full Code Here

  public void testShouldPropagateTheExceptionWhenWriteFails() throws SQLException {

    /*
     * GIVEN a feature state to persist
     */
    FeatureState state = new FeatureState(TestFeature.F1).enable();

    /**
     * AND the datasource throws an exception when we try to get a
     * connection
     */
 
View Full Code Here

    @Test
    public void shouldReturnFalseForEmptyUserlist() {

        FeatureUser user = new SimpleFeatureUser("ck", false);
        FeatureState state = new FeatureState(MyFeature.FEATURE)
            .enable()
            .setStrategyId(UsernameActivationStrategy.ID);

        boolean active = strategy.isActive(state, user);
View Full Code Here

    @Test
    public void shouldReturnFalseForUnknownUser() {

        FeatureUser user = null;
        FeatureState state = new FeatureState(MyFeature.FEATURE)
            .enable()
            .setStrategyId(UsernameActivationStrategy.ID)
            .setParameter(UsernameActivationStrategy.PARAM_USERS, "person1,ck,person2");

        boolean active = strategy.isActive(state, user);
View Full Code Here

    @Test
    public void shouldReturnFalseForDifferentUser() {

        FeatureUser user = new SimpleFeatureUser("john", false);
        FeatureState state = new FeatureState(MyFeature.FEATURE)
            .enable()
            .setStrategyId(UsernameActivationStrategy.ID)
            .setParameter(UsernameActivationStrategy.PARAM_USERS, "person1,ck,person2");

        boolean active = strategy.isActive(state, user);
View Full Code Here

    @Test
    public void shouldReturnTrueForCorrectUser() {

        FeatureUser user = new SimpleFeatureUser("ck", false);
        FeatureState state = new FeatureState(MyFeature.FEATURE)
            .enable()
            .setStrategyId(UsernameActivationStrategy.ID)
            .setParameter(UsernameActivationStrategy.PARAM_USERS, "person1,ck,person2");

        boolean active = strategy.isActive(state, user);
View Full Code Here

TOP

Related Classes of org.togglz.core.repository.FeatureState

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.