Examples of FeatureDescriptor


Examples of com.tacitknowledge.flip.model.FeatureDescriptor

*/
@FlipProperty(priority=2)
public class TestPropertyReader implements PropertyReader {

    public FeatureDescriptor getFeatureDescriptor(String name) {
        FeatureDescriptor result = new FeatureDescriptor();
        result.setName("feature-1");
        return result;
    }
View Full Code Here

Examples of com.tacitknowledge.flip.model.FeatureDescriptor

        propertyManager = new PropertyManager(environment);
    }
   
    @Test
    public void testFindPropertyReaders() {
        FeatureDescriptor result = propertyManager.getFeatureDescriptor("feature-1");
        assertNotNull(result);
        assertEquals("feature-1", result.getName());
    }
View Full Code Here

Examples of com.tacitknowledge.flip.model.FeatureDescriptor

   
    @Test
    public void testFindFeatureDescriptor() {
        props.setProperty(XmlPropertyReader.CONFIG_PROPERTY, CONFIG_FILE1);
        propertyReader.initialize(props);
        FeatureDescriptor featureDescriptor = propertyReader.getFeatureDescriptor("test");
       
        assertNotNull(featureDescriptor);
        assertEquals("test", featureDescriptor.getName());
        assertEquals(FeatureState.ENABLED, featureDescriptor.getState());
       
        assertNotNull(featureDescriptor.getRules());
        assertEquals(2, featureDescriptor.getRules().length);
        assertNotNull(featureDescriptor.getRules()[0]);
        assertEquals(FeatureState.ENABLED, featureDescriptor.getRules()[0].getState());
        assertNotNull(featureDescriptor.getRules()[0].getConditions());
        assertEquals(2, featureDescriptor.getRules()[0].getConditions().length);
        assertNotNull(featureDescriptor.getRules()[0].getConditions()[0]);
        assertEquals("a", featureDescriptor.getRules()[0].getConditions()[0].getContext());
        assertEquals("prop", featureDescriptor.getRules()[0].getConditions()[0].getName());
        assertEquals(FeatureOperation.EQUALS, featureDescriptor.getRules()[0].getConditions()[0].getOperation());
        assertEquals("1", featureDescriptor.getRules()[0].getConditions()[0].getValue());

        assertNotNull(featureDescriptor.getRules()[1]);
        assertEquals(FeatureState.DISABLED, featureDescriptor.getRules()[1].getState());
        assertNull(featureDescriptor.getRules()[1].getConditions());
    }
View Full Code Here

Examples of com.tacitknowledge.flip.model.FeatureDescriptor

   
    @Test
    public void testFindFeatureWithJexlConditionDescriptor() {
        props.setProperty(XmlPropertyReader.CONFIG_PROPERTY, CONFIG_FILE1);
        propertyReader.initialize(props);
        FeatureDescriptor featureDescriptor = propertyReader.getFeatureDescriptor("test");
       
        assertNotNull(featureDescriptor);
        assertEquals("test", featureDescriptor.getName());
        assertEquals(FeatureState.ENABLED, featureDescriptor.getState());
       
        assertNotNull(featureDescriptor.getRules());
       
        Date expirationDate = featureDescriptor.getExpirationDate();
        assertNotNull(expirationDate);
        Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
        calendar.setTime(expirationDate);
        assertEquals(2012, calendar.get(Calendar.YEAR));
        assertEquals(11, calendar.get(Calendar.MONTH));
        assertEquals(21, calendar.get(Calendar.DATE));
        assertEquals(10, calendar.get(Calendar.HOUR_OF_DAY));
        assertEquals(21, calendar.get(Calendar.MINUTE));
       
        assertEquals(2, featureDescriptor.getRules().length);
        assertNotNull(featureDescriptor.getRules()[0]);
        assertEquals(FeatureState.ENABLED, featureDescriptor.getRules()[0].getState());
        assertNotNull(featureDescriptor.getRules()[0].getConditions());
        assertEquals(2, featureDescriptor.getRules()[0].getConditions().length);
        assertNotNull(featureDescriptor.getRules()[0].getConditions()[0]);
        assertEquals("a = 1", featureDescriptor.getRules()[0].getConditions()[1].getExpression());
        assertEquals("a", featureDescriptor.getRules()[0].getConditions()[0].getContext());
        assertEquals("prop", featureDescriptor.getRules()[0].getConditions()[0].getName());
        assertEquals(FeatureOperation.EQUALS, featureDescriptor.getRules()[0].getConditions()[0].getOperation());
        assertEquals("1", featureDescriptor.getRules()[0].getConditions()[0].getValue());

        assertNotNull(featureDescriptor.getRules()[1]);
        assertEquals(FeatureState.DISABLED, featureDescriptor.getRules()[1].getState());
        assertNull(featureDescriptor.getRules()[1].getConditions());
    }
View Full Code Here

Examples of com.tacitknowledge.flip.model.FeatureDescriptor

    @Test
    public void testFindInvalidFeatureDescriptor() {
        props.setProperty(XmlPropertyReader.CONFIG_PROPERTY, CONFIG_FILE1);
        propertyReader.initialize(props);
        FeatureDescriptor featureDescriptor = propertyReader.getFeatureDescriptor("test1");
       
        assertNull(featureDescriptor);
    }
View Full Code Here

Examples of com.tacitknowledge.flip.model.FeatureDescriptor

        FeatureDescriptorsMap sessionFeatureMap = new FeatureDescriptorsMap();
        when(session.getAttribute(FlipOverrideFilter.SESSION_FEATURES_KEY)).thenReturn(sessionFeatureMap);

        filter.doFilter(request, response, filterChain);
       
        FeatureDescriptor featureDescriptor = sessionFeatureMap.get("featureName");
        assertEquals("featureName", featureDescriptor.getName());
        assertEquals(FeatureState.ENABLED, featureDescriptor.getState());
    }
View Full Code Here

Examples of com.tacitknowledge.flip.model.FeatureDescriptor

    }
   
    @Test
    public void testGetFeatureState() {
       
        sessionFeaturesMap.put("featureName", new FeatureDescriptor() {{
            setName("fetureName");
            setState(FeatureState.DISABLED);
        }});
       
        FeatureDescriptor featureDescriptor = reader.getFeatureDescriptor("featureName");
        assertEquals(FeatureState.DISABLED, featureDescriptor.getState());
    }
View Full Code Here

Examples of com.tacitknowledge.flip.model.FeatureDescriptor

            try
            {
                final FeatureState state = FeatureState.valueOf(value[0].toUpperCase());

                final FeatureDescriptor featureDescriptor = new FeatureDescriptor();
                featureDescriptor.setName(key.replaceFirst("^" + Pattern.quote(requestParameterPrefix), ""));
                featureDescriptor.setState(state);
                return featureDescriptor;
            }
            catch (final IllegalArgumentException e)
            {
                return null;
View Full Code Here

Examples of com.tacitknowledge.flip.model.FeatureDescriptor

        FlipWebContext.setFeatureDescriptors(featureDescriptors);
    }
   
    @Test
    public void testListFeatures() throws JspException {
        featureDescriptors.put("featureName", new FeatureDescriptor(){{
            setName("featureName");
            setState(FeatureState.ENABLED);
        }});
       
        tag.doStartTag();
View Full Code Here

Examples of com.tinkerpop.gremlin.structure.util.FeatureDescriptor

    private static boolean chooseFeatureMethod(Method m) {
        return m.getName().startsWith(FEATURE_METHOD_PREFIX) && !m.getName().equals(FEATURE_METHOD_PREFIX);
    }

    private static void assertFeatureConvention(final Method m) {
        final FeatureDescriptor annotation = m.getAnnotation(FeatureDescriptor.class);
        final Class featuresClass = m.getDeclaringClass();

        // all "features" need an annotation
        assertNotNull(annotation);

        // needs to match pattern of "support" followed by "name" value in annotation
        assertEquals(m.getName(), FEATURE_METHOD_PREFIX + annotation.name());

        try {
            final Field f = featuresClass.getField(FEATURE_FIELD_PREFIX + convertToUnderscore(annotation.name()).toUpperCase());
            assertEquals(annotation.name(), f.get(null));
        } catch (Exception e) {
            fail(String.format(ERROR_FIELD, annotation.name()));
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.