use of org.ligoj.app.model.ParameterValue in project ligoj-api by ligoj.
the class ParameterValueResourceTest method createSecured.
@Test
public void createSecured() {
final ParameterValueCreateVo parameterValue = new ParameterValueCreateVo();
parameterValue.setParameter(parameterRepository.findOne("service:bt:jira:jdbc-url").getId());
parameterValue.setText("value");
final ParameterValue entity = resource.createInternal(parameterValue);
Assertions.assertTrue(entity.toString().startsWith("ParameterValue(parameter=AbstractBusinessEntity(id=service:bt:jira:jdbc-url), data="));
Assertions.assertEquals(parameterValue.getParameter(), entity.getParameter().getId());
Assertions.assertNotEquals("value", entity.getData());
Assertions.assertEquals("value", encryptor.decrypt(entity.getData()));
}
use of org.ligoj.app.model.ParameterValue in project ligoj-api by ligoj.
the class ParameterValueResourceTest method createDate.
@Test
public void createDate() {
final ParameterValueCreateVo parameterValue = new ParameterValueCreateVo();
parameterValue.setParameter(parameterRepository.findOne("c_6").getId());
parameterValue.setDate(new Date());
final ParameterValue entity = resource.createInternal(parameterValue);
Assertions.assertEquals(parameterValue.getParameter(), entity.getParameter().getId());
Assertions.assertEquals(String.valueOf(parameterValue.getDate().getTime()), entity.getData());
}
use of org.ligoj.app.model.ParameterValue in project ligoj-api by ligoj.
the class ParameterValueResourceTest method createTextPattern.
@Test
public void createTextPattern() {
final ParameterValueCreateVo parameterValue = new ParameterValueCreateVo();
parameterValue.setParameter(parameterRepository.findOne("c_17").getId());
parameterValue.setText("va-l-u-9e");
final ParameterValue entity = resource.createInternal(parameterValue);
Assertions.assertEquals(parameterValue.getParameter(), entity.getParameter().getId());
Assertions.assertEquals("va-l-u-9e", entity.getData());
}
use of org.ligoj.app.model.ParameterValue in project ligoj-api by ligoj.
the class ParameterValueResourceTest method findInvalidJSonData.
@Test
public void findInvalidJSonData() {
final Parameter parameter = parameterRepository.findOne("c_22");
final ParameterValue parameterValueEntity = newParameterValue("'", parameter);
Assertions.assertThrows(TechnicalException.class, () -> {
resource.toVo(parameterValueEntity);
});
}
use of org.ligoj.app.model.ParameterValue in project ligoj-api by ligoj.
the class ParameterValueResourceTest method findInteger.
@Test
public void findInteger() {
final Parameter parameter = parameterRepository.findOne("c_4");
final ParameterValue parameterValueEntity = newParameterValue("1", parameter);
em.persist(parameterValueEntity);
em.flush();
final ParameterValueVo valueVo = resource.toVo(parameterValueEntity);
Assertions.assertEquals(parameter.getId(), valueVo.getParameter().getId());
Assertions.assertEquals(1, valueVo.getInteger().intValue());
Assertions.assertNotNull(valueVo.getCreatedDate());
Assertions.assertNotNull(valueVo.getCreatedBy());
}
Aggregations