All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.otto.edison.testsupport.togglz.fallback.FallbackTestFeatureManager Maven / Gradle / Ivy

There is a newer version: 3.3.3
Show newest version
package de.otto.edison.testsupport.togglz.fallback;

import de.otto.edison.testsupport.togglz.FeatureManagerSupport;
import org.togglz.core.Feature;
import org.togglz.core.manager.FeatureManager;
import org.togglz.core.metadata.EmptyFeatureMetaData;
import org.togglz.core.metadata.FeatureMetaData;
import org.togglz.core.repository.FeatureState;
import org.togglz.core.spi.ActivationStrategy;
import org.togglz.core.user.FeatureUser;
import org.togglz.core.user.SimpleFeatureUser;

import java.util.Collections;
import java.util.List;
import java.util.Set;


/**
 * Simple {@link FeatureManager} for unit tests that enables all features.
 */
public class FallbackTestFeatureManager implements FeatureManager {


    @Override
    public String getName() {
        return this.getClass().getSimpleName();
    }

    @Override
    public Set getFeatures() {
        return Collections.emptySet();
    }

    @Override
    public FeatureMetaData getMetaData(Feature feature) {
        return new EmptyFeatureMetaData(feature);
    }

    @Override
    public boolean isActive(Feature feature) {

        return FeatureManagerSupport.shouldRunInTests(feature);

    }

    @Override
    public FeatureUser getCurrentFeatureUser() {
        boolean featureAdmin = true;
        return new SimpleFeatureUser("p13n-testing-user", featureAdmin);
    }

    @Override
    public FeatureState getFeatureState(Feature feature) {
        return new FeatureState(feature, true);
    }

    @Override
    public void setFeatureState(FeatureState state) {
        throw new UnsupportedOperationException();
    }

    @Override
    public List getActivationStrategies() {
        return Collections.emptyList();
    }

    @Override
    public void enable(Feature feature) {
        throw new UnsupportedOperationException();
    }

    @Override
    public void disable(Feature feature) {
        throw new UnsupportedOperationException();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy