use of org.ff4j.web.api.resources.domain.FeatureApiBean in project ff4j by ff4j.
the class FeatureResourceGetTestIT method testGetRead.
/**
* TDD.
*/
@Test
public void testGetRead() {
// Given
assertFF4J.assertThatFeatureExist(F4);
// When
WebResource wResf4 = resourceFeatures().path(F4);
ClientResponse resHttp = wResf4.get(ClientResponse.class);
FeatureApiBean resEntity = resHttp.getEntity(FeatureApiBean.class);
// Then
Assert.assertEquals("Expected status is 200", Status.OK.getStatusCode(), resHttp.getStatus());
Assert.assertNotNull(resEntity);
Assert.assertNotNull(F4, resEntity.getUid());
}
use of org.ff4j.web.api.resources.domain.FeatureApiBean 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.web.api.resources.domain.FeatureApiBean in project ff4j by ff4j.
the class FeatureResource2GetTestIT method testGet_read.
/**
* TDD.
*/
@Test
public void testGet_read() {
// Given
assertFF4J.assertThatFeatureExist(F4);
// When
WebTarget wResf4 = resourceFeatures().path(F4);
Response resHttp = wResf4.request().get();
FeatureApiBean resEntity = resHttp.readEntity(FeatureApiBean.class);
// Then
Assert.assertEquals("Expected status is 200", Status.OK.getStatusCode(), resHttp.getStatus());
Assert.assertNotNull(resEntity);
Assert.assertNotNull(F4, resEntity.getUid());
}
use of org.ff4j.web.api.resources.domain.FeatureApiBean in project ff4j by ff4j.
the class FeatureResource2PutCreateTestIT method testPut_upsertIfNotExistCreateIt.
/**
* TDD.
*/
@Test
public void testPut_upsertIfNotExistCreateIt() {
// Given
assertFF4J.assertThatFeatureDoesNotExist(FEATURE_X);
// When
Feature f = new Feature(FEATURE_X);
WebTarget webResFeat = resourceFeatures().path(FEATURE_X);
Response res = //
webResFeat.request(//
MediaType.APPLICATION_JSON).put(Entity.entity(new FeatureApiBean(f), MediaType.APPLICATION_JSON), Response.class);
// Then HTTPResponse
Assert.assertEquals(Status.CREATED.getStatusCode(), res.getStatus());
Assert.assertNotNull(res.getHeaders().getFirst(LOCATION));
// Then, testing target store
assertFF4J.assertThatFeatureExist(FEATURE_X);
res.close();
}
use of org.ff4j.web.api.resources.domain.FeatureApiBean in project ff4j by ff4j.
the class FeatureResource2PutUpdateGroup1TestIT method testPut_upsertUpdateAddGroup.
/**
* TDD, update by adding in the authorization
*/
@Test
public void testPut_upsertUpdateAddGroup() throws Exception {
// Given
assertFF4J.assertThatFeatureExist(F1);
assertFF4J.assertThatFeatureNotInGroup(F1, "g2");
// When
Feature f1 = ff4j.getFeature(F1);
f1.setGroup("g2");
WebTarget webResFeat = resourceFeatures().path(F1);
Response res = //
webResFeat.request(//
MediaType.APPLICATION_JSON).put(Entity.entity(new FeatureApiBean(f1), MediaType.APPLICATION_JSON), Response.class);
// Then HTTPResponse
Assert.assertEquals(Status.NO_CONTENT.getStatusCode(), res.getStatus());
// Then Object Entity : null
// Then
assertFF4J.assertThatFeatureIsInGroup(F1, "g2");
}
Aggregations