Search in sources :

Example 1 with ClientFilterStrategy

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);
}
Also used : ClientFilterStrategy(org.ff4j.strategy.ClientFilterStrategy) ClientFilterStrategy(org.ff4j.strategy.ClientFilterStrategy) Feature(org.ff4j.core.Feature) Test(org.junit.Test) AbstractFf4jTest(org.ff4j.test.AbstractFf4jTest)

Example 2 with ClientFilterStrategy

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");
}
Also used : ClientFilterStrategy(org.ff4j.strategy.ClientFilterStrategy) Test(org.junit.Test) AbstractFf4jTest(org.ff4j.test.AbstractFf4jTest)

Example 3 with ClientFilterStrategy

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);
}
Also used : ClientFilterStrategy(org.ff4j.strategy.ClientFilterStrategy) ClientFilterStrategy(org.ff4j.strategy.ClientFilterStrategy) FlippingExecutionContext(org.ff4j.core.FlippingExecutionContext) Feature(org.ff4j.core.Feature) Test(org.junit.Test) AbstractFf4jTest(org.ff4j.test.AbstractFf4jTest)

Example 4 with ClientFilterStrategy

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));
}
Also used : ClientFilterStrategy(org.ff4j.strategy.ClientFilterStrategy) ClientFilterStrategy(org.ff4j.strategy.ClientFilterStrategy) FlippingExecutionContext(org.ff4j.core.FlippingExecutionContext) Feature(org.ff4j.core.Feature) Test(org.junit.Test) AbstractFf4jTest(org.ff4j.test.AbstractFf4jTest)

Example 5 with ClientFilterStrategy

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());
}
Also used : ClientFilterStrategy(org.ff4j.strategy.ClientFilterStrategy) ClientFilterStrategy(org.ff4j.strategy.ClientFilterStrategy) FlippingExecutionContext(org.ff4j.core.FlippingExecutionContext) Feature(org.ff4j.core.Feature) Test(org.junit.Test) AbstractFf4jTest(org.ff4j.test.AbstractFf4jTest)

Aggregations

ClientFilterStrategy (org.ff4j.strategy.ClientFilterStrategy)6 AbstractFf4jTest (org.ff4j.test.AbstractFf4jTest)6 Test (org.junit.Test)6 Feature (org.ff4j.core.Feature)4 FlippingExecutionContext (org.ff4j.core.FlippingExecutionContext)4 FlippingStrategy (org.ff4j.core.FlippingStrategy)1 InMemoryFeatureStore (org.ff4j.store.InMemoryFeatureStore)1 BlackListStrategy (org.ff4j.strategy.BlackListStrategy)1 WhiteListStrategy (org.ff4j.strategy.WhiteListStrategy)1