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);
});
}
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;
}
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);
}
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;
}
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;
}
Aggregations