use of io.gravitee.rest.api.portal.rest.model.Plan in project gravitee-management-rest-api by gravitee-io.
the class PlanMapperTest method testConvertWithSubscriptions.
@Test
public void testConvertWithSubscriptions() {
Plan responsePlan = planMapper.convert(planEntity);
assertNotNull(responsePlan);
List<String> characteristics = responsePlan.getCharacteristics();
assertNotNull(characteristics);
assertEquals(1, characteristics.size());
assertEquals(PLAN_CHARACTERISTIC, characteristics.get(0));
assertEquals(PLAN_COMMENT_MESSAGE, responsePlan.getCommentQuestion());
assertTrue(responsePlan.getCommentRequired());
assertEquals(PLAN_DESCRIPTION, responsePlan.getDescription());
assertEquals(PLAN_ID, responsePlan.getId());
assertEquals(PLAN_NAME, responsePlan.getName());
assertEquals(1, responsePlan.getOrder().intValue());
assertEquals(SecurityEnum.API_KEY, responsePlan.getSecurity());
assertEquals(ValidationEnum.AUTO, responsePlan.getValidation());
}
use of io.gravitee.rest.api.portal.rest.model.Plan in project gravitee-management-rest-api by gravitee-io.
the class ApiPlansResourceTest method shouldGetApiPlansWithPrivateAPIAndReadPermission.
@Test
public void shouldGetApiPlansWithPrivateAPIAndReadPermission() {
doReturn(true).when(groupService).isUserAuthorizedToAccessApiData(any(), any(), any());
doReturn(true).when(permissionService).hasPermission(any(), any(), any());
final Response response = target(API).path("plans").request().get();
assertEquals(OK_200, response.getStatus());
PlansResponse plansResponse = response.readEntity(PlansResponse.class);
List<Plan> plans = plansResponse.getData();
assertNotNull(plans);
assertEquals(2, plans.size());
}
use of io.gravitee.rest.api.portal.rest.model.Plan in project gravitee-management-rest-api by gravitee-io.
the class ApiPlansResourceTest method shouldGetApiPlansWithPublicAPI.
@Test
public void shouldGetApiPlansWithPublicAPI() {
doReturn(true).when(groupService).isUserAuthorizedToAccessApiData(any(), any(), any());
final Response response = target(API).path("plans").request().get();
assertEquals(OK_200, response.getStatus());
PlansResponse plansResponse = response.readEntity(PlansResponse.class);
List<Plan> plans = plansResponse.getData();
assertNotNull(plans);
assertEquals(2, plans.size());
}
use of io.gravitee.rest.api.portal.rest.model.Plan in project gravitee-management-rest-api by gravitee-io.
the class ApiPlansResourceTest method shouldGetApiPlansWithPublicAPI_WithGCU.
@Test
public void shouldGetApiPlansWithPublicAPI_WithGCU() {
PageEntity page = new PageEntity();
final String PAGE_ID = "PAGE_ID_CGU";
page.setId(PAGE_ID);
page.setPublished(true);
page.setContent("Some CGU");
page.setType(PageType.MARKDOWN.name());
doReturn(page).when(pageService).findById(any(), any());
plan1.setGeneralConditions(PAGE_ID);
plan2.setGeneralConditions(PAGE_ID);
doReturn(true).when(groupService).isUserAuthorizedToAccessApiData(any(), any(), any());
final Response response = target(API).path("plans").request().get();
assertEquals(OK_200, response.getStatus());
PlansResponse plansResponse = response.readEntity(PlansResponse.class);
List<Plan> plans = plansResponse.getData();
assertNotNull(plans);
assertEquals(2, plans.size());
for (Plan plan : plans) {
assertEquals(PAGE_ID, plan.getGeneralConditions());
}
}
use of io.gravitee.rest.api.portal.rest.model.Plan in project gravitee-management-rest-api by gravitee-io.
the class PlanMapper method convert.
public Plan convert(PlanEntity plan) {
final Plan planItem = new Plan();
planItem.setCharacteristics(plan.getCharacteristics());
planItem.setCommentQuestion(plan.getCommentMessage());
planItem.setCommentRequired(plan.isCommentRequired());
planItem.setDescription(plan.getDescription());
planItem.setId(plan.getId());
planItem.setName(plan.getName());
planItem.setOrder(plan.getOrder());
planItem.setSecurity(SecurityEnum.fromValue(plan.getSecurity().name()));
planItem.setValidation(ValidationEnum.fromValue(plan.getValidation().name()));
planItem.setGeneralConditions(plan.getGeneralConditions());
return planItem;
}
Aggregations