Search in sources :

Example 1 with FeatureApiBean

use of org.ff4j.services.domain.FeatureApiBean in project ff4j by ff4j.

the class FeatureStoreServices method getAllFeatures.

public Collection<FeatureApiBean> getAllFeatures() {
    List<FeatureApiBean> features;
    Map<String, Feature> featureMap = ff4j.getFeatureStore().readAll();
    if (CollectionUtils.isEmpty(featureMap)) {
        features = new ArrayList<FeatureApiBean>(0);
    } else {
        features = new ArrayList<FeatureApiBean>(featureMap.size());
        for (Feature feature : featureMap.values()) {
            features.add(new FeatureApiBean(feature));
        }
    }
    return features;
}
Also used : FeatureApiBean(org.ff4j.services.domain.FeatureApiBean) Feature(org.ff4j.core.Feature)

Example 2 with FeatureApiBean

use of org.ff4j.services.domain.FeatureApiBean in project ff4j by ff4j.

the class GroupServices method getFeaturesByGroup.

public Collection<FeatureApiBean> getFeaturesByGroup(String groupName) {
    featureValidator.assertGroupExist(groupName);
    Collection<Feature> features = ff4j.getFeatureStore().readGroup(groupName).values();
    Collection<FeatureApiBean> featureApiBeans = new ArrayList<FeatureApiBean>();
    if (!CollectionUtils.isEmpty(features)) {
        for (Feature feature : features) {
            featureApiBeans.add(new FeatureApiBean(feature));
        }
    }
    return featureApiBeans;
}
Also used : FeatureApiBean(org.ff4j.services.domain.FeatureApiBean) ArrayList(java.util.ArrayList) Feature(org.ff4j.core.Feature)

Example 3 with FeatureApiBean

use of org.ff4j.services.domain.FeatureApiBean in project ff4j by ff4j.

the class FeatureStepDef method the_user_gets_the_response_with_response_code_as_and_content_as_and.

@Then("^the user gets the response with response code as (\\d+) and content as \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\" and \"([^\"]*)\"$")
public void the_user_gets_the_response_with_response_code_as_and_content_as_and(int responseCode, String expectedUid, String expectedEnabled, String expectedDescription, String expectedGroup, String expectedPermissions) throws Throwable {
    assertStatus(responseCode);
    FeatureApiBean featureApiBean = new FeatureApiBean();
    featureApiBean.setUid(expectedUid);
    featureApiBean.setEnable(Boolean.valueOf(expectedEnabled));
    featureApiBean.setDescription(expectedDescription);
    featureApiBean.setGroup(expectedGroup);
    featureApiBean.setPermissions(Arrays.asList(expectedPermissions.split(",")));
    assertJsonResponse(new Gson().toJson(featureApiBean));
}
Also used : FeatureApiBean(org.ff4j.services.domain.FeatureApiBean) Gson(com.google.gson.Gson) Then(cucumber.api.java.en.Then)

Example 4 with FeatureApiBean

use of org.ff4j.services.domain.FeatureApiBean in project ff4j by ff4j.

the class FeatureServicesStepDef method the_user_gets_the_response_as_and.

@Then("^the user gets the response as \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\", \"([^\"]*)\" and \"([^\"]*)\"$")
public void the_user_gets_the_response_as_and(String expectedUid, String expectedEnabled, String expectedDescription, String expectedGroup, String expectedPermissions) throws Throwable {
    Feature expectedFeature = new Feature(expectedUid, Boolean.valueOf(expectedEnabled), expectedDescription, expectedGroup, Arrays.asList(expectedPermissions.split(",")));
    FeatureApiBean expectedFeatureApiBean = new FeatureApiBean(expectedFeature);
    assertThat(actualResponse).isEqualToComparingFieldByField(expectedFeatureApiBean);
}
Also used : FeatureApiBean(org.ff4j.services.domain.FeatureApiBean) Feature(org.ff4j.core.Feature) Then(cucumber.api.java.en.Then)

Example 5 with FeatureApiBean

use of org.ff4j.services.domain.FeatureApiBean in project ff4j by ff4j.

the class FeatureServicesStepDef method the_user_gets_the_response_as.

@Then("^the user gets the response as$")
public void the_user_gets_the_response_as(String expectedResponse) throws Throwable {
    FeatureApiBean featureApiBean = GSON.fromJson(expectedResponse, FeatureApiBean.class);
    assertThat(actualResponse).isEqualToComparingOnlyGivenFields(featureApiBean);
}
Also used : FeatureApiBean(org.ff4j.services.domain.FeatureApiBean) Then(cucumber.api.java.en.Then)

Aggregations

FeatureApiBean (org.ff4j.services.domain.FeatureApiBean)5 Then (cucumber.api.java.en.Then)3 Feature (org.ff4j.core.Feature)3 Gson (com.google.gson.Gson)1 ArrayList (java.util.ArrayList)1