use of org.ff4j.core.Feature in project ff4j by ff4j.
the class JdbcFeatureStoreErrorTest method testUpdateKO.
@Test(expected = FeatureAccessException.class)
public void testUpdateKO() throws SQLException {
DataSource mockDS = Mockito.mock(DataSource.class);
doThrow(new SQLException()).when(mockDS).getConnection();
JdbcFeatureStore jrepo = new JdbcFeatureStore(mockDS);
jrepo.setDataSource(mockDS);
jrepo.update(new Feature("f1", true));
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class JdbcFeatureStoreErrorTest method testCreateKO.
@Test(expected = FeatureAccessException.class)
public void testCreateKO() throws SQLException {
DataSource mockDS = Mockito.mock(DataSource.class);
doThrow(new SQLException()).when(mockDS).getConnection();
JdbcFeatureStore jrepo = new JdbcFeatureStore(mockDS);
jrepo.setDataSource(mockDS);
jrepo.create(new Feature("U1", true));
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class JdbcFeatureStoreSchemaTest method testworkWithSchema.
@Test
public void testworkWithSchema() {
// Given
testedStore.createSchema();
Assert.assertFalse(testedStore.exist("fx"));
// When
Feature fullFeature = new Feature("fx", true);
fullFeature.setPermissions(Util.set("toto", "tata"));
fullFeature.setFlippingStrategy(new PonderationStrategy(0.5d));
Map<String, Property<?>> customProperties = new HashMap<String, Property<?>>();
fullFeature.setCustomProperties(customProperties);
testedStore.create(fullFeature);
// Then
Assert.assertTrue(testedStore.exist("fx"));
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class JdbcFeatureStoreSchemaTest method testCreateCustomProperties.
@SuppressWarnings("unchecked")
@Test
public void testCreateCustomProperties() {
testedStore.createSchema();
// When
Feature fullFeature = new Feature("fx", true);
fullFeature.setPermissions(Util.set("toto", "tata"));
fullFeature.setFlippingStrategy(new PonderationStrategy(0.5d));
Map<String, Property<?>> customProperties = new HashMap<String, Property<?>>();
fullFeature.setCustomProperties(customProperties);
testedStore.create(fullFeature);
testedStore.createCustomProperties("fx", null);
Property<?> p1 = new PropertyString("p1");
p1.setFixedValues(null);
Property<String> p2 = new PropertyString("p2");
p2.setFixedValues(Util.set("v1", "v3"));
testedStore.createCustomProperties("fx", Arrays.asList(p2, p1));
testedStore.createCustomProperties("fx", null);
}
use of org.ff4j.core.Feature 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);
}
Aggregations