use of org.ff4j.strategy.ClientFilterStrategy in project ff4j by ff4j.
the class ClientFilterStrategyTest method testFilterRequiredContext.
@Test(expected = IllegalArgumentException.class)
public void testFilterRequiredContext() {
// 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());
// Then FeatureContext is requires
ff4j.check(F1);
}
use of org.ff4j.strategy.ClientFilterStrategy in project ff4j by ff4j.
the class ClientFilterStrategyTest method testInitialisationProgram2.
@Test(expected = IllegalArgumentException.class)
public void testInitialisationProgram2() {
ClientFilterStrategy fs = new ClientFilterStrategy("Pierre, Paul, Jacques");
fs.init("f1", null);
fs.init("f1", new HashMap<String, String>());
Assert.assertFalse(fs.getInitParams().containsKey("f2"));
fs.assertRequiredParameter("f2");
}
use of org.ff4j.strategy.ClientFilterStrategy 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.strategy.ClientFilterStrategy 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.strategy.ClientFilterStrategy 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