use of io.gravitee.rest.api.portal.rest.model.PlansResponse 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.PlansResponse 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.PlansResponse 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.PlansResponse in project gravitee-management-rest-api by gravitee-io.
the class ApiPlansResourceTest method shouldGetNoApiPlan.
@Test
public void shouldGetNoApiPlan() {
doReturn(false).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(0, plans.size());
}
use of io.gravitee.rest.api.portal.rest.model.PlansResponse in project gravitee-management-rest-api by gravitee-io.
the class ApiPlansResourceTest method shouldGetEmptyListPrivateAPIAndNoReadPermission.
@Test
public void shouldGetEmptyListPrivateAPIAndNoReadPermission() {
doReturn(false).when(permissionService).hasPermission(any(), any(), any());
ApiEntity mockApi = new ApiEntity();
mockApi.setId(API);
mockApi.setVisibility(Visibility.PRIVATE);
doReturn(mockApi).when(apiService).findById(API);
Set<ApiEntity> mockApis = new HashSet<>(Arrays.asList(mockApi));
doReturn(mockApis).when(apiService).findPublishedByUser(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(0, plans.size());
}
Aggregations