use of org.ff4j.web.api.resources.domain.FeatureApiBean in project ff4j by ff4j.
the class FeatureResource2PutUpdateAuth2TestIT method testPut_upsertUpdateRemoveAuthorization.
/**
* TDD, update by adding in the authorization
*/
@Test
public void testPut_upsertUpdateRemoveAuthorization() {
// Given
assertFF4J.assertThatFeatureExist(F1);
ff4j.getFeatureStore().grantRoleOnFeature(F1, ROLE_USER);
assertFF4J.assertThatFeatureHasRole(F1, ROLE_USER);
// When
Feature fNew = ff4j.getFeature(F1);
fNew.getPermissions().remove(ROLE_USER);
WebTarget webResFeat = resourceFeatures().path(F1);
Response res = //
webResFeat.request(//
MediaType.APPLICATION_JSON).put(Entity.entity(new FeatureApiBean(fNew), MediaType.APPLICATION_JSON), Response.class);
// Then HTTPResponse
Assert.assertEquals(Status.NO_CONTENT.getStatusCode(), res.getStatus());
// Then Object Entity : null
// Then
assertFF4J.assertThatFeatureHasNotRole(F1, ROLE_USER);
}
use of org.ff4j.web.api.resources.domain.FeatureApiBean in project ff4j by ff4j.
the class FeatureResourcePutUpdateAuth1TestIT method testPutUpsertUpdateAddAuthorization.
/**
* TDD, update by adding in the authorization
*/
@Test
public void testPutUpsertUpdateAddAuthorization() {
// Given
assertFF4J.assertThatFeatureExist(F1);
ff4j.getFeatureStore().removeRoleFromFeature(F1, ROLE_NEW);
assertFF4J.assertThatFeatureHasNotRole(F1, ROLE_NEW);
// When
Feature fNew = ff4j.getFeature(F1);
fNew.getPermissions().add(ROLE_NEW);
WebResource webResFeat = resourceFeatures().path(F1);
ClientResponse res = //
webResFeat.type(//
MediaType.APPLICATION_JSON).put(ClientResponse.class, new FeatureApiBean(fNew));
// Then HTTPResponse
Assert.assertEquals(Status.NO_CONTENT.getStatusCode(), res.getStatus());
// Then Object Entity : null
// Then
assertFF4J.assertThatFeatureHasRole(F1, ROLE_NEW);
}
use of org.ff4j.web.api.resources.domain.FeatureApiBean in project ff4j by ff4j.
the class FeatureResourcePutUpdateAuth2TestIT method testPutUpsertUpdateRemoveAuthorization.
/**
* TDD, update by adding in the authorization
*/
@Test
public void testPutUpsertUpdateRemoveAuthorization() {
// Given
assertFF4J.assertThatFeatureExist(F1);
ff4j.getFeatureStore().grantRoleOnFeature(F1, ROLE_USER);
assertFF4J.assertThatFeatureHasRole(F1, ROLE_USER);
// When
Feature fNew = ff4j.getFeature(F1);
fNew.getPermissions().remove(ROLE_USER);
WebResource webResFeat = resourceFeatures().path(F1);
ClientResponse res = //
webResFeat.type(//
MediaType.APPLICATION_JSON).put(ClientResponse.class, new FeatureApiBean(fNew));
// Then HTTPResponse
Assert.assertEquals(Status.NO_CONTENT.getStatusCode(), res.getStatus());
// Then Object Entity : null
// Then
assertFF4J.assertThatFeatureHasNotRole(F1, ROLE_USER);
}
use of org.ff4j.web.api.resources.domain.FeatureApiBean in project ff4j by ff4j.
the class FeatureResourcePutUpdateGroup2TestIT method testPutUpsertUpdateAddGroup.
/**
* TDD, update by adding in the authorization
*/
@Test
public void testPutUpsertUpdateAddGroup() {
// Given
assertFF4J.assertThatFeatureExist(F3);
assertFF4J.assertThatFeatureIsInGroup(F3, G1);
// When
Feature f3 = ff4j.getFeature(F3);
f3.setGroup("");
WebResource webResFeat = resourceFeatures().path(F3);
ClientResponse res = //
webResFeat.type(//
MediaType.APPLICATION_JSON).put(ClientResponse.class, toJson(new FeatureApiBean(f3)));
// Then HTTPResponse
Assert.assertEquals(Status.NO_CONTENT.getStatusCode(), res.getStatus());
// Then Object Entity : null
// Then
assertFF4J.assertThatFeatureNotInGroup(F3, G1);
}
use of org.ff4j.web.api.resources.domain.FeatureApiBean in project ff4j by ff4j.
the class FeaturesResourceTestIT method testGet.
/**
* TDD.
*/
@Test
public void testGet() {
// Given
// When
WebResource wResFeatures = resourceFeatures();
ClientResponse httpResponse = wResFeatures.get(ClientResponse.class);
List<FeatureApiBean> fList = httpResponse.getEntity(new GenericType<List<FeatureApiBean>>() {
});
// Then, HTTPResponse
Assert.assertEquals("Expected status is 200", Status.OK.getStatusCode(), httpResponse.getStatus());
Assert.assertNotNull(fList);
// Then, Entity Object
Assert.assertFalse(fList.isEmpty());
}
Aggregations