use of org.ff4j.core.Feature in project ff4j by ff4j.
the class CoreFeatureStoreTestSupport method testUpdateFeatureCoreData.
/**
* TDD.
*/
@Test
public void testUpdateFeatureCoreData() {
// Parameters
String newDescription = "new-description";
FlippingStrategy newStrategy = new PonderationStrategy(0.12);
// Given
assertFf4j.assertThatFeatureExist(F1);
Assert.assertFalse(newDescription.equals(testedStore.read(F1).getDescription()));
// When
Feature fpBis = testedStore.read(F1);
fpBis.setDescription(newDescription);
fpBis.setFlippingStrategy(newStrategy);
testedStore.update(fpBis);
// Then
Feature updatedFeature = testedStore.read(F1);
Assert.assertTrue(newDescription.equals(updatedFeature.getDescription()));
Assert.assertNotNull(updatedFeature.getFlippingStrategy());
Assert.assertEquals(newStrategy.toString(), updatedFeature.getFlippingStrategy().toString());
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class CoreFeatureStoreTestSupport method testUpdateFeatureMoreAutorisation.
/**
* TDD.
*/
@Test
public void testUpdateFeatureMoreAutorisation() {
// Parameters
Set<String> rights2 = new HashSet<String>(Arrays.asList(new String[] { ROLE_USER, ROLE_ADMIN }));
// Given
assertFf4j.assertThatFeatureExist(F1);
assertFf4j.assertThatFeatureHasNotRole(F1, ROLE_ADMIN);
// When
Feature fpBis = testedStore.read(F1);
fpBis.setPermissions(rights2);
testedStore.update(fpBis);
// Then
assertFf4j.assertThatFeatureHasRole(F1, ROLE_USER);
assertFf4j.assertThatFeatureHasRole(F1, ROLE_ADMIN);
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class CoreFeatureStoreTestSupport method testAddFeatureAlreadyExis.
/**
* TDD.
*/
@Test(expected = FeatureAlreadyExistException.class)
public void testAddFeatureAlreadyExis() throws Exception {
// Given
assertFf4j.assertThatFeatureDoesNotExist("GOLOGOLO");
// When (first creation)
Feature fp = new Feature("GOLOGOLO", true, "description2");
testedStore.create(fp);
// Then (first creation)
assertFf4j.assertThatFeatureExist("GOLOGOLO");
// When (second creation)
Set<String> rights = new HashSet<String>(Arrays.asList(new String[] { ROLE_USER }));
Feature fp2 = new Feature("GOLOGOLO", true, G1, "description3", rights);
testedStore.create(fp2);
// Then, expected exception
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class CoreFeatureStoreTestSupport method testUpdateEditPropertyRemoveFixedValues.
/**
* TDD.
*/
@Test
@SuppressWarnings("unchecked")
public void testUpdateEditPropertyRemoveFixedValues() {
// Given
assertFf4j.assertThatFeatureExist(F1);
assertFf4j.assertThatFeatureHasProperty(F1, "regionIdentifier");
Set<String> fixValues = (Set<String>) ff4j.getFeatureStore().read(//
F1).getCustomProperties().get("regionIdentifier").getFixedValues();
Assert.assertEquals(3, fixValues.size());
// When
Feature myFeature = ff4j.getFeatureStore().read(F1);
PropertyString p1 = new PropertyString("regionIdentifier");
p1.setValue("AMER");
p1.setFixedValues(Util.set("AMER", "SSSS"));
myFeature.getCustomProperties().put(p1.getName(), p1);
testedStore.update(myFeature);
// Then
Set<Integer> fixValues2 = (Set<Integer>) ff4j.getFeatureStore().read(//
F1).getCustomProperties().get("regionIdentifier").getFixedValues();
Assert.assertEquals(2, fixValues2.size());
}
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));
}
Aggregations