use of org.ff4j.core.Feature in project ff4j by ff4j.
the class FeatureResourcePutUpdateGroup1TestIT method testPutUpsertUpdateAddGroup.
/**
* TDD, update by adding in the authorization
*/
@Test
public void testPutUpsertUpdateAddGroup() throws Exception {
// Given
assertFF4J.assertThatFeatureExist(AWESOME);
assertFF4J.assertThatFeatureNotInGroup(AWESOME, "g2");
// When
Feature f1 = ff4j.getFeature(AWESOME);
f1.setGroup("g2");
WebResource webResFeat = resourceFeatures().path(AWESOME);
ClientResponse res = //
webResFeat.type(//
MediaType.APPLICATION_JSON).put(ClientResponse.class, toJson(new FeatureApiBean(f1)));
// Then HTTPResponse
Assert.assertEquals(Status.NO_CONTENT.getStatusCode(), res.getStatus());
// Then Object Entity : null
// Then
assertFF4J.assertThatFeatureIsInGroup(AWESOME, "g2");
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class GroupResourceTestIT method testGet_readGroup.
/**
* TDD
*/
@Test
public void testGet_readGroup() {
// Given
assertFF4J.assertThatGroupExist(G1);
assertFF4J.assertThatGroupHasSize(2, G1);
assertFF4J.assertThatFeatureIsInGroup(F3, G1);
assertFF4J.assertThatFeatureIsInGroup(F4, G1);
// When
WebResource wrsc = resourceGroups().path(G1);
ClientResponse resHttp = wrsc.get(ClientResponse.class);
String resEntity = resHttp.getEntity(String.class);
// Then, HTTPResponse
Assert.assertEquals("Expected status is 200", Status.OK.getStatusCode(), resHttp.getStatus());
// Then, Entity Object
Assert.assertNotNull(resEntity);
Feature[] f = parseFeatureArray(resEntity);
Set<String> features = new HashSet<String>();
for (Feature feature : f) {
features.add(feature.getUid());
}
Assert.assertEquals(2, features.size());
Assert.assertTrue(features.contains(F3));
Assert.assertTrue(features.contains(F4));
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class FeatureJsonParserTest method testMarshaling.
@Test
public void testMarshaling() throws Exception {
Map<String, Feature> features = ff4j.getFeatures();
for (String key : features.keySet()) {
// Check serialised
assertMarshalling(features.get(key));
Feature f1 = FeatureJsonParser.parseFeature(features.get(key).toJson());
assertMarshalling(f1);
}
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class FeatureJsonParserTest method testSerialisation.
@Test
public void testSerialisation() {
Feature[] features = { new Feature("f1"), new Feature("f2") };
Assert.assertNotNull(FeatureJsonParser.featureArrayToJson(features));
Assert.assertNotNull(FeatureJsonParser.featureArrayToJson(null));
}
use of org.ff4j.core.Feature in project ff4j by ff4j.
the class FeatureStoreCassandra method readAll.
/**
* {@inheritDoc}
*/
@Override
public Map<String, Feature> readAll() {
Map<String, Feature> features = new HashMap<String, Feature>();
ResultSet resultSet = conn.getSession().execute(getBuilder().selectAllFeatures());
for (Row row : resultSet.all()) {
Feature f = CassandraMapper.mapFeature(row);
features.put(f.getUid(), f);
}
return features;
}
Aggregations