Search in sources :

Example 11 with Form

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

the class FormServiceTest method shouldFindAll.

@Test
public void shouldFindAll() {
    Form form = new Form();
    when(formRepository.findAll(ReferenceType.ORGANIZATION)).thenReturn(Flowable.just(form));
    TestSubscriber<Form> obs = formService.findAll(ReferenceType.ORGANIZATION).test();
    obs.awaitTerminalEvent();
    obs.assertComplete();
    obs.assertValue(form);
}
Also used : Form(io.gravitee.am.model.Form) Test(org.junit.Test)

Example 12 with Form

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

the class FormManagerImpl method removeForm.

private void removeForm(String formId) {
    logger.info("Domain {} has received form event, delete form {}", domain.getName(), formId);
    Form deletedForm = forms.remove(formId);
    if (deletedForm != null) {
        ((DomainBasedTemplateResolver) templateResolver).removeForm(getTemplateName(deletedForm));
    }
}
Also used : DomainBasedTemplateResolver(io.gravitee.am.gateway.handler.vertx.view.thymeleaf.DomainBasedTemplateResolver) Form(io.gravitee.am.model.Form)

Example 13 with Form

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

the class FormRepositoryTest method shouldFindById_withRef.

@Test
public void shouldFindById_withRef() {
    Form form = buildForm();
    Form createdForm = repository.create(form).blockingGet();
    TestObserver<Form> testObserver = repository.findById(createdForm.getReferenceType(), createdForm.getReferenceId(), createdForm.getId()).test();
    testObserver.awaitTerminalEvent();
    testObserver.assertComplete();
    testObserver.assertNoErrors();
    assertEqualsTo(form, createdForm.getId(), testObserver);
}
Also used : Form(io.gravitee.am.model.Form) Test(org.junit.Test) AbstractManagementTest(io.gravitee.am.repository.management.AbstractManagementTest)

Example 14 with Form

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

the class FormRepositoryTest method shouldFindAllByReference.

@Test
public void shouldFindAllByReference() {
    final int loop = 10;
    for (int i = 0; i < loop; i++) {
        final Form form = buildForm();
        form.setReferenceId(FIXED_REF_ID);
        repository.create(form).blockingGet();
    }
    for (int i = 0; i < loop; i++) {
        // random ref id
        repository.create(buildForm()).blockingGet();
    }
    TestObserver<List<Form>> testObserver = repository.findAll(ReferenceType.DOMAIN, FIXED_REF_ID).toList().test();
    testObserver.awaitTerminalEvent();
    testObserver.assertNoErrors();
    testObserver.assertValue(l -> l.size() == loop);
    testObserver.assertValue(l -> l.stream().map(Form::getId).distinct().count() == loop);
}
Also used : Form(io.gravitee.am.model.Form) List(java.util.List) Test(org.junit.Test) AbstractManagementTest(io.gravitee.am.repository.management.AbstractManagementTest)

Example 15 with Form

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

the class FormRepositoryTest method buildForm.

protected Form buildForm() {
    Form form = new Form();
    String randomString = UUID.randomUUID().toString();
    form.setClient("client" + randomString);
    form.setContent("content" + randomString);
    form.setReferenceId("ref" + randomString);
    form.setReferenceType(ReferenceType.DOMAIN);
    form.setTemplate("tpl" + randomString);
    form.setAssets("assets" + randomString);
    form.setEnabled(true);
    form.setCreatedAt(new Date());
    form.setUpdatedAt(new Date());
    return form;
}
Also used : Form(io.gravitee.am.model.Form) Date(java.util.Date)

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