use of org.ff4j.core.FlippingExecutionContext in project ff4j by ff4j.
the class FeatureTest method testFlipExecContext.
@Test
public void testFlipExecContext() {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("a", new Double(1D));
parameters.put("b", new Integer(1));
parameters.put("c", new Boolean(true));
parameters.put("d", new Date());
FlippingExecutionContext fec = new FlippingExecutionContext(parameters);
fec.getDouble("a");
fec.getInt("b");
fec.getBoolean("c");
fec.getDate("d");
}
use of org.ff4j.core.FlippingExecutionContext in project ff4j by ff4j.
the class FeatureTest method testFlipExecContext7.
@Test(expected = IllegalArgumentException.class)
public void testFlipExecContext7() {
Map<String, Object> parameters = new HashMap<String, Object>();
FlippingExecutionContext fec = new FlippingExecutionContext();
parameters.put("b", new Integer(1));
fec.getString("b");
}
use of org.ff4j.core.FlippingExecutionContext in project ff4j by ff4j.
the class ClientFilterStrategyTest method testFilterRequiredClientHostName.
@Test(expected = IllegalArgumentException.class)
public void testFilterRequiredClientHostName() {
// Given
Feature f1 = ff4j.getFeature(F1);
Assert.assertNotNull(f1.getFlippingStrategy());
org.ff4j.strategy.ClientFilterStrategy cStra = (ClientFilterStrategy) f1.getFlippingStrategy();
Assert.assertNotNull(cStra.getInitParams());
Assert.assertEquals(1, cStra.getInitParams().size());
Assert.assertTrue(f1.isEnable());
// When
FlippingExecutionContext fex = new FlippingExecutionContext();
fex.addValue(FEATURE_NEW, FEATURE_NEW);
// Then
ff4j.check(F1, fex);
}
use of org.ff4j.core.FlippingExecutionContext in project ff4j by ff4j.
the class ClientFilterStrategyTest method testFilterInvalidClient.
@Test
public void testFilterInvalidClient() throws ParseException {
// Given
Feature f1 = ff4j.getFeature(F1);
Assert.assertNotNull(f1.getFlippingStrategy());
org.ff4j.strategy.ClientFilterStrategy cStra = (ClientFilterStrategy) 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(ClientFilterStrategy.CLIENT_HOSTNAME, FEATURE_NEW);
// Then
Assert.assertFalse(ff4j.check(F1, fex));
}
use of org.ff4j.core.FlippingExecutionContext in project ff4j by ff4j.
the class ClientFilterStrategyTest method testFilterOK.
@Test
public void testFilterOK() throws ParseException {
// Given
Feature f1 = ff4j.getFeature(F1);
Assert.assertNotNull(f1.getFlippingStrategy());
org.ff4j.strategy.ClientFilterStrategy cStra = (ClientFilterStrategy) f1.getFlippingStrategy();
Assert.assertNotNull(cStra.getInitParams());
Assert.assertEquals(1, cStra.getInitParams().size());
Assert.assertTrue(f1.isEnable());
// When (add correct client name)
FlippingExecutionContext fex = new FlippingExecutionContext();
fex.addValue(ClientFilterStrategy.CLIENT_HOSTNAME, "pierre");
// Then
Assert.assertTrue(ff4j.check(F1, fex));
Assert.assertNotNull(cStra.toJson());
}
Aggregations