use of org.ligoj.app.model.ParameterValue in project ligoj-api by ligoj.
the class ParameterValueResourceTest method newParameterValue.
private ParameterValue newParameterValue(final String data, final Parameter parameter) {
final ParameterValue parameterValueEntity = new ParameterValue();
parameterValueEntity.setParameter(parameter);
parameterValueEntity.setData(data);
return parameterValueEntity;
}
use of org.ligoj.app.model.ParameterValue in project ligoj-api by ligoj.
the class ParameterValueResourceTest method findBool.
@Test
public void findBool() {
final Parameter parameter = parameterRepository.findOne("c_5");
final ParameterValue parameterValueEntity = newParameterValue(Boolean.TRUE.toString(), parameter);
em.persist(parameterValueEntity);
em.flush();
final ParameterValueVo valueVo = resource.toVo(parameterValueEntity);
Assertions.assertEquals(parameter.getId(), valueVo.getParameter().getId());
Assertions.assertTrue(valueVo.getBool());
Assertions.assertNotNull(valueVo.getCreatedDate());
Assertions.assertNotNull(valueVo.getCreatedBy());
}
use of org.ligoj.app.model.ParameterValue in project ligoj-api by ligoj.
the class ParameterValueResourceTest method findDate.
@Test
public void findDate() {
final Parameter parameter = parameterRepository.findOne("c_6");
final ParameterValue parameterValueEntity = newParameterValue(String.valueOf(new Date().getTime()), parameter);
em.persist(parameterValueEntity);
em.flush();
final ParameterValueVo valueVo = resource.toVo(parameterValueEntity);
Assertions.assertEquals(parameter.getId(), valueVo.getParameter().getId());
Assertions.assertTrue(valueVo.getParameter().isMandatory());
Assertions.assertEquals(parameterValueEntity.getData(), String.valueOf(valueVo.getDate().getTime()));
Assertions.assertNotNull(valueVo.getCreatedDate());
Assertions.assertNotNull(valueVo.getCreatedBy());
}
use of org.ligoj.app.model.ParameterValue in project ligoj-api by ligoj.
the class ParameterValueResourceTest method deleteMandatoryUnused.
@Test
public void deleteMandatoryUnused() {
final ParameterValue value = newParameterValue();
Assertions.assertTrue(repository.existsById(value.getId()));
resource.delete(value.getId());
Assertions.assertFalse(repository.existsById(value.getId()));
}
use of org.ligoj.app.model.ParameterValue in project ligoj-api by ligoj.
the class ParameterValueResourceTest method createInternal.
@Test
public void createInternal() {
em.createQuery("DELETE Parameter WHERE id LIKE ?1").setParameter(1, "c_%").executeUpdate();
final List<ParameterValueCreateVo> parameters = new ArrayList<>();
final ParameterValueCreateVo parameterValueEditionVo = new ParameterValueCreateVo();
parameterValueEditionVo.setParameter(JiraBaseResource.PARAMETER_PROJECT);
parameterValueEditionVo.setInteger(10074);
parameters.add(parameterValueEditionVo);
final Node node = new Node();
node.setName("create-test");
node.setId("create-test-id");
em.persist(node);
em.flush();
em.clear();
resource.create(parameters, node);
em.flush();
em.clear();
final List<ParameterValue> values = repository.findAllBy("node.id", "create-test-id");
Assertions.assertEquals(1, values.size());
Assertions.assertEquals("10074", values.get(0).getData());
Assertions.assertEquals(JiraBaseResource.PARAMETER_PROJECT, values.get(0).getParameter().getId());
}
Aggregations