Search in sources :

Example 11 with FlippingExecutionContext

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

the class FeatureTest method testFlipExecContext6.

@Test(expected = IllegalArgumentException.class)
public void testFlipExecContext6() {
    FlippingExecutionContext fec = new FlippingExecutionContext();
    fec.getValue("DONOT", true);
}
Also used : FlippingExecutionContext(org.ff4j.core.FlippingExecutionContext) Test(org.junit.Test)

Example 12 with FlippingExecutionContext

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

the class ClientFilterStrategyTest method testInitialisationProgramServer.

@Test
public void testInitialisationProgramServer() {
    FlippingStrategy fs = new ServerFilterStrategy("serv1,serv2");
    fs.init("f1", null);
    fs.init("f1", new HashMap<String, String>());
    FlippingExecutionContext context = new FlippingExecutionContext();
    fs.evaluate("f1", new InMemoryFeatureStore(), context);
}
Also used : ServerFilterStrategy(org.ff4j.strategy.ServerFilterStrategy) InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) FlippingStrategy(org.ff4j.core.FlippingStrategy) FlippingExecutionContext(org.ff4j.core.FlippingExecutionContext) Test(org.junit.Test) AbstractFf4jTest(org.ff4j.test.AbstractFf4jTest)

Example 13 with FlippingExecutionContext

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

the class OfficeHourStrategyTest method testOfficeHourEmptyExpression.

@Test
public void testOfficeHourEmptyExpression() {
    OfficeHourStrategy ohs = new OfficeHourStrategy();
    ohs.parseIntervalsExpression(null);
    ohs.parseIntervalsExpression("");
    ohs.matches(Calendar.getInstance(), null);
    ohs.evaluate("f1", new InMemoryFeatureStore(), null);
    ohs.evaluate("f1", new InMemoryFeatureStore(), new FlippingExecutionContext());
}
Also used : InMemoryFeatureStore(org.ff4j.store.InMemoryFeatureStore) OfficeHourStrategy(org.ff4j.strategy.time.OfficeHourStrategy) FlippingExecutionContext(org.ff4j.core.FlippingExecutionContext) Test(org.junit.Test) AbstractFf4jTest(org.ff4j.test.AbstractFf4jTest)

Example 14 with FlippingExecutionContext

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

the class OfficeHourStrategyTest method overrideDate.

private FlippingExecutionContext overrideDate(int year, int month, int day, int hour) {
    FlippingExecutionContext fec = new FlippingExecutionContext();
    Calendar c = Calendar.getInstance();
    c.set(Calendar.YEAR, year);
    c.set(Calendar.MONTH, month);
    c.set(Calendar.DAY_OF_MONTH, day);
    c.set(Calendar.HOUR_OF_DAY, hour);
    c.set(Calendar.MINUTE, 0);
    fec = new FlippingExecutionContext();
    fec.addValue(OfficeHourStrategy.OVERRIDE_DATE, c);
    return fec;
}
Also used : Calendar(java.util.Calendar) FlippingExecutionContext(org.ff4j.core.FlippingExecutionContext)

Example 15 with FlippingExecutionContext

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

the class ServerFilterStrategyTest method testFilterInvalidClient.

@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);
    // Then
    Assert.assertFalse(ff4j.check(F1, fex));
}
Also used : ServerFilterStrategy(org.ff4j.strategy.ServerFilterStrategy) FlippingExecutionContext(org.ff4j.core.FlippingExecutionContext) Feature(org.ff4j.core.Feature) Test(org.junit.Test) AbstractFf4jTest(org.ff4j.test.AbstractFf4jTest)

Aggregations

FlippingExecutionContext (org.ff4j.core.FlippingExecutionContext)28 Test (org.junit.Test)21 AbstractFf4jTest (org.ff4j.test.AbstractFf4jTest)8 HashMap (java.util.HashMap)6 Feature (org.ff4j.core.Feature)6 PropertyString (org.ff4j.property.PropertyString)6 Map (java.util.Map)4 FlippingStrategy (org.ff4j.core.FlippingStrategy)4 ClientFilterStrategy (org.ff4j.strategy.ClientFilterStrategy)4 InMemoryFeatureStore (org.ff4j.store.InMemoryFeatureStore)3 ServerFilterStrategy (org.ff4j.strategy.ServerFilterStrategy)3 Date (java.util.Date)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 Calendar (java.util.Calendar)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 FF4j (org.ff4j.FF4j)1