Search in sources :

Example 1 with ParameterValueCreateVo

use of org.ligoj.app.resource.node.ParameterValueCreateVo in project ligoj-api by ligoj.

the class SubscriptionResourceTest method checkMandatoryParametersMandatoryMode.

@Test
public void checkMandatoryParametersMandatoryMode() {
    final List<ParameterValueCreateVo> parameters = new ArrayList<>();
    final List<Parameter> acceptedParameters = new ArrayList<>();
    final Parameter parameter = new Parameter();
    parameter.setId("p");
    parameter.setMandatory(true);
    parameter.setMode(SubscriptionMode.CREATE);
    acceptedParameters.add(parameter);
    Assertions.assertThrows(ValidationJsonException.class, () -> {
        resource.checkMandatoryParameters(parameters, acceptedParameters, SubscriptionMode.CREATE);
    });
}
Also used : ParameterValueCreateVo(org.ligoj.app.resource.node.ParameterValueCreateVo) ArrayList(java.util.ArrayList) Parameter(org.ligoj.app.model.Parameter) Test(org.junit.jupiter.api.Test) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest)

Example 2 with ParameterValueCreateVo

use of org.ligoj.app.resource.node.ParameterValueCreateVo in project ligoj-api by ligoj.

the class SubscriptionResourceTest method newCreateVoBadParameters.

private SubscriptionEditionVo newCreateVoBadParameters() {
    em.createQuery("DELETE Parameter WHERE id LIKE ?1").setParameter(1, "c_%").executeUpdate();
    final Project project = new Project();
    project.setName("TEST");
    project.setPkey("test");
    project.setTeamLeader(getAuthenticationName());
    em.persist(project);
    em.flush();
    em.clear();
    final SubscriptionEditionVo vo = new SubscriptionEditionVo();
    final List<ParameterValueCreateVo> parameters = new ArrayList<>();
    final ParameterValueCreateVo parameterValueEditionVo = new ParameterValueCreateVo();
    parameterValueEditionVo.setParameter("service:bt:jira:project");
    parameterValueEditionVo.setInteger(1007400);
    parameters.add(parameterValueEditionVo);
    vo.setParameters(parameters);
    vo.setNode("service:bt:jira:4");
    vo.setProject(project.getId());
    return vo;
}
Also used : Project(org.ligoj.app.model.Project) ParameterValueCreateVo(org.ligoj.app.resource.node.ParameterValueCreateVo) ArrayList(java.util.ArrayList)

Example 3 with ParameterValueCreateVo

use of org.ligoj.app.resource.node.ParameterValueCreateVo in project ligoj-api by ligoj.

the class SubscriptionResourceTest method checkMandatoryParameters.

@Test
public void checkMandatoryParameters() {
    final List<ParameterValueCreateVo> parameters = new ArrayList<>();
    final List<Parameter> acceptedParameters = new ArrayList<>();
    final ParameterValueCreateVo parameterValue = new ParameterValueCreateVo();
    parameterValue.setParameter("p");
    parameters.add(parameterValue);
    final Parameter parameter = new Parameter();
    parameter.setId("p");
    acceptedParameters.add(parameter);
    resource.checkMandatoryParameters(parameters, acceptedParameters, null);
}
Also used : ParameterValueCreateVo(org.ligoj.app.resource.node.ParameterValueCreateVo) ArrayList(java.util.ArrayList) Parameter(org.ligoj.app.model.Parameter) Test(org.junit.jupiter.api.Test) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest)

Example 4 with ParameterValueCreateVo

use of org.ligoj.app.resource.node.ParameterValueCreateVo in project ligoj-api by ligoj.

the class SubscriptionResourceTest method createCreateBase.

private int createCreateBase(final String parent, final String group) throws Exception {
    em.createQuery("DELETE Parameter WHERE id LIKE ?1").setParameter(1, "c_%").executeUpdate();
    final SubscriptionEditionVo vo = new SubscriptionEditionVo();
    final List<ParameterValueCreateVo> parameters = new ArrayList<>();
    final ParameterValueCreateVo parameterValueEditionVo = new ParameterValueCreateVo();
    parameterValueEditionVo.setParameter(IdentityResource.PARAMETER_OU);
    parameterValueEditionVo.setText("gfi");
    parameters.add(parameterValueEditionVo);
    final ParameterValueCreateVo parameterValueEditionVo2 = new ParameterValueCreateVo();
    parameterValueEditionVo2.setParameter(IdentityResource.PARAMETER_PARENT_GROUP);
    parameterValueEditionVo2.setText(parent);
    parameters.add(parameterValueEditionVo2);
    final ParameterValueCreateVo parameterValueEditionVo3 = new ParameterValueCreateVo();
    parameterValueEditionVo3.setParameter(IdentityResource.PARAMETER_GROUP);
    parameterValueEditionVo3.setText(group);
    parameters.add(parameterValueEditionVo3);
    vo.setMode(SubscriptionMode.CREATE);
    vo.setParameters(parameters);
    vo.setNode("service:id:ldap:dig");
    vo.setProject(em.createQuery("SELECT id FROM Project WHERE name='gStack'", Integer.class).getSingleResult());
    em.flush();
    em.clear();
    initSpringSecurityContext(DEFAULT_USER);
    final int subscription = resource.create(vo);
    em.flush();
    em.clear();
    Assertions.assertEquals(group, parameterValueRepository.getSubscriptionParameterValue(subscription, IdentityResource.PARAMETER_GROUP));
    Assertions.assertEquals("gfi", parameterValueRepository.getSubscriptionParameterValue(subscription, IdentityResource.PARAMETER_OU));
    return subscription;
}
Also used : ParameterValueCreateVo(org.ligoj.app.resource.node.ParameterValueCreateVo) ArrayList(java.util.ArrayList)

Example 5 with ParameterValueCreateVo

use of org.ligoj.app.resource.node.ParameterValueCreateVo in project ligoj-api by ligoj.

the class SubscriptionResourceTest method newCreateVo.

private SubscriptionEditionVo newCreateVo() {
    em.createQuery("DELETE Parameter WHERE id LIKE ?1").setParameter(1, "c_%").executeUpdate();
    final SubscriptionEditionVo vo = new SubscriptionEditionVo();
    final List<ParameterValueCreateVo> parameters = new ArrayList<>();
    final ParameterValueCreateVo parameterValueEditionVo = new ParameterValueCreateVo();
    parameterValueEditionVo.setParameter(JiraBaseResource.PARAMETER_PROJECT);
    parameterValueEditionVo.setInteger(10074);
    parameters.add(parameterValueEditionVo);
    final ParameterValueCreateVo parameterValueEditionVo2 = new ParameterValueCreateVo();
    parameterValueEditionVo2.setParameter(JiraBaseResource.PARAMETER_PKEY);
    parameterValueEditionVo2.setText("MDA");
    parameters.add(parameterValueEditionVo2);
    vo.setParameters(parameters);
    vo.setNode("service:bt:jira:4");
    vo.setProject(em.createQuery("SELECT id FROM Project WHERE name='gStack'", Integer.class).getSingleResult());
    // Ensure LDAP cache is loaded
    em.flush();
    em.clear();
    return vo;
}
Also used : ParameterValueCreateVo(org.ligoj.app.resource.node.ParameterValueCreateVo) ArrayList(java.util.ArrayList)

Aggregations

ParameterValueCreateVo (org.ligoj.app.resource.node.ParameterValueCreateVo)8 ArrayList (java.util.ArrayList)7 Test (org.junit.jupiter.api.Test)5 AbstractOrgTest (org.ligoj.app.resource.AbstractOrgTest)5 Parameter (org.ligoj.app.model.Parameter)4 Project (org.ligoj.app.model.Project)1 ValidationJsonException (org.ligoj.bootstrap.core.validation.ValidationJsonException)1