Search in sources :

Example 21 with Form

use of io.gravitee.am.model.Form in project gravitee-access-management by gravitee-io.

the class FormResourceTest method shouldUpdate.

@Test
@Ignore
public void shouldUpdate() {
    final String formId = "form-1";
    final String domainId = "domain-1";
    final Domain mockDomain = new Domain();
    mockDomain.setId(domainId);
    UpdateForm updateForm = new UpdateForm();
    updateForm.setContent("content");
    doReturn(Maybe.just(mockDomain)).when(domainService).findById(domainId);
    doReturn(Single.just(new Form())).when(formService).update(eq(domainId), eq(formId), any(), any(User.class));
    final Response response = target("domains").path(domainId).path("forms").path(formId).request().put(Entity.json(updateForm));
    assertEquals(HttpStatusCode.OK_200, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) User(io.gravitee.am.identityprovider.api.User) UpdateForm(io.gravitee.am.service.model.UpdateForm) Form(io.gravitee.am.model.Form) UpdateForm(io.gravitee.am.service.model.UpdateForm) Domain(io.gravitee.am.model.Domain) Ignore(org.junit.Ignore) Test(org.junit.Test) JerseySpringTest(io.gravitee.am.management.handlers.management.api.JerseySpringTest)

Example 22 with Form

use of io.gravitee.am.model.Form in project gravitee-access-management by gravitee-io.

the class FormsResourceTest method shouldGetForm.

@Test
public void shouldGetForm() throws IOException {
    final String domainId = "domain-1";
    final Domain mockDomain = new Domain();
    mockDomain.setId(domainId);
    final Form mockForm = new Form();
    mockForm.setId("form-1-id");
    mockForm.setTemplate(Template.LOGIN.template());
    mockForm.setReferenceType(ReferenceType.DOMAIN);
    mockForm.setReferenceId(domainId);
    doReturn(Maybe.just(mockForm)).when(formService).findByDomainAndTemplate(domainId, Template.LOGIN.template());
    final Response response = target("domains").path(domainId).path("forms").queryParam("template", Template.LOGIN).request().get();
    assertEquals(HttpStatusCode.OK_200, response.getStatus());
    final Form responseEntity = readEntity(response, Form.class);
    assertTrue(responseEntity.getId().equals("form-1-id"));
}
Also used : Response(javax.ws.rs.core.Response) Form(io.gravitee.am.model.Form) NewForm(io.gravitee.am.service.model.NewForm) Domain(io.gravitee.am.model.Domain) Test(org.junit.Test) JerseySpringTest(io.gravitee.am.management.handlers.management.api.JerseySpringTest)

Aggregations

Form (io.gravitee.am.model.Form)22 Test (org.junit.Test)15 AbstractManagementTest (io.gravitee.am.repository.management.AbstractManagementTest)8 User (io.gravitee.am.identityprovider.api.User)5 NewForm (io.gravitee.am.service.model.NewForm)5 List (java.util.List)5 Response (javax.ws.rs.core.Response)5 JerseySpringTest (io.gravitee.am.management.handlers.management.api.JerseySpringTest)3 Domain (io.gravitee.am.model.Domain)3 ReferenceType (io.gravitee.am.model.ReferenceType)3 Template (io.gravitee.am.model.Template)3 FormService (io.gravitee.am.service.FormService)3 Maybe (io.reactivex.Maybe)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 AbstractResource (io.gravitee.am.management.handlers.management.api.resources.AbstractResource)2 Acl (io.gravitee.am.model.Acl)2 Event (io.gravitee.am.model.common.event.Event)2 Permission (io.gravitee.am.model.permissions.Permission)2 DomainService (io.gravitee.am.service.DomainService)2 DomainNotFoundException (io.gravitee.am.service.exception.DomainNotFoundException)2