Search in sources :

Example 1 with NewPageEntity

use of io.gravitee.rest.api.model.NewPageEntity in project gravitee-management-rest-api by gravitee-io.

the class PortalPagesResourceAdminTest method shouldNotCreateSystemFolder.

@Test
public void shouldNotCreateSystemFolder() {
    NewPageEntity newPageEntity = new NewPageEntity();
    newPageEntity.setType(PageType.SYSTEM_FOLDER);
    final Response response = envTarget().request().post(Entity.json(newPageEntity));
    assertEquals(BAD_REQUEST_400, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) NewPageEntity(io.gravitee.rest.api.model.NewPageEntity) Test(org.junit.Test)

Example 2 with NewPageEntity

use of io.gravitee.rest.api.model.NewPageEntity in project gravitee-management-rest-api by gravitee-io.

the class PortalPagesResourceAdminTest method shouldCreatePortalPage.

@Test
public void shouldCreatePortalPage() {
    reset(pageService);
    NewPageEntity newPageEntity = new NewPageEntity();
    newPageEntity.setName("my-page-name");
    newPageEntity.setType(PageType.MARKDOWN);
    newPageEntity.setVisibility(Visibility.PUBLIC);
    PageEntity returnedPage = new PageEntity();
    returnedPage.setId("my-beautiful-page");
    doReturn(returnedPage).when(pageService).createPage(any(), eq(GraviteeContext.getCurrentEnvironment()));
    doReturn(0).when(pageService).findMaxPortalPageOrder(eq(GraviteeContext.getCurrentEnvironment()));
    final Response response = envTarget().request().post(Entity.json(newPageEntity));
    assertEquals(HttpStatusCode.CREATED_201, response.getStatus());
    assertEquals(envTarget().path("my-beautiful-page").getUri().toString(), response.getHeaders().getFirst(HttpHeaders.LOCATION));
}
Also used : PageEntity(io.gravitee.rest.api.model.PageEntity) UpdatePageEntity(io.gravitee.rest.api.model.UpdatePageEntity) NewPageEntity(io.gravitee.rest.api.model.NewPageEntity) Response(javax.ws.rs.core.Response) NewPageEntity(io.gravitee.rest.api.model.NewPageEntity) Test(org.junit.Test)

Aggregations

NewPageEntity (io.gravitee.rest.api.model.NewPageEntity)2 Response (javax.ws.rs.core.Response)2 Test (org.junit.Test)2 PageEntity (io.gravitee.rest.api.model.PageEntity)1 UpdatePageEntity (io.gravitee.rest.api.model.UpdatePageEntity)1