Search in sources :

Example 1 with Plan

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());
}
Also used : Plan(io.gravitee.rest.api.portal.rest.model.Plan) Test(org.junit.Test)

Example 2 with Plan

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());
}
Also used : PlansResponse(io.gravitee.rest.api.portal.rest.model.PlansResponse) ErrorResponse(io.gravitee.rest.api.portal.rest.model.ErrorResponse) Response(javax.ws.rs.core.Response) PlansResponse(io.gravitee.rest.api.portal.rest.model.PlansResponse) Plan(io.gravitee.rest.api.portal.rest.model.Plan) Test(org.junit.Test)

Example 3 with Plan

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());
}
Also used : PlansResponse(io.gravitee.rest.api.portal.rest.model.PlansResponse) ErrorResponse(io.gravitee.rest.api.portal.rest.model.ErrorResponse) Response(javax.ws.rs.core.Response) PlansResponse(io.gravitee.rest.api.portal.rest.model.PlansResponse) Plan(io.gravitee.rest.api.portal.rest.model.Plan) Test(org.junit.Test)

Example 4 with Plan

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());
    }
}
Also used : PlansResponse(io.gravitee.rest.api.portal.rest.model.PlansResponse) ErrorResponse(io.gravitee.rest.api.portal.rest.model.ErrorResponse) Response(javax.ws.rs.core.Response) PlansResponse(io.gravitee.rest.api.portal.rest.model.PlansResponse) Plan(io.gravitee.rest.api.portal.rest.model.Plan) Test(org.junit.Test)

Example 5 with Plan

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;
}
Also used : Plan(io.gravitee.rest.api.portal.rest.model.Plan)

Aggregations

Plan (io.gravitee.rest.api.portal.rest.model.Plan)10 Response (javax.ws.rs.core.Response)7 Test (org.junit.Test)6 ErrorResponse (io.gravitee.rest.api.portal.rest.model.ErrorResponse)5 PlansResponse (io.gravitee.rest.api.portal.rest.model.PlansResponse)5 ApiEntity (io.gravitee.rest.api.model.api.ApiEntity)3 PlanEntity (io.gravitee.rest.api.model.PlanEntity)2 Api (io.gravitee.rest.api.portal.rest.model.Api)2 Page (io.gravitee.rest.api.portal.rest.model.Page)2 MediaType (io.gravitee.common.http.MediaType)1 PageEntity (io.gravitee.rest.api.model.PageEntity)1 PlanStatus (io.gravitee.rest.api.model.PlanStatus)1 Visibility (io.gravitee.rest.api.model.Visibility)1 ApiQuery (io.gravitee.rest.api.model.api.ApiQuery)1 API_PLAN (io.gravitee.rest.api.model.permissions.RolePermission.API_PLAN)1 READ (io.gravitee.rest.api.model.permissions.RolePermissionAction.READ)1 PlanMapper (io.gravitee.rest.api.portal.rest.mapper.PlanMapper)1 PaginationParam (io.gravitee.rest.api.portal.rest.resource.param.PaginationParam)1 RequirePortalAuth (io.gravitee.rest.api.portal.rest.security.RequirePortalAuth)1 GroupService (io.gravitee.rest.api.service.GroupService)1