use of org.ligoj.app.model.Parameter in project ligoj-api by ligoj.
the class ParameterValueResourceTest method toMapValues.
@Test
public void toMapValues() {
final List<ParameterValue> values = new ArrayList<>();
final Parameter p1 = new Parameter();
p1.setId("p1");
final Parameter p2 = new Parameter();
p2.setId("p2");
values.add(newParameterValue("u1", p1));
values.add(newParameterValue("u2", p2));
final Map<String, String> valuesAsMap = resource.toMapValues(values);
Assertions.assertEquals(2, valuesAsMap.size());
Assertions.assertEquals("u1", valuesAsMap.get("p1"));
Assertions.assertEquals("u2", valuesAsMap.get("p2"));
}
use of org.ligoj.app.model.Parameter 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.Parameter 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.Parameter in project ligoj-api by ligoj.
the class ParameterValueResourceTest method findIntegerNoData.
@Test
public void findIntegerNoData() {
final Parameter parameter = parameterRepository.findOne("c_4");
parameter.setData(null);
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());
}
use of org.ligoj.app.model.Parameter in project ligoj-api by ligoj.
the class SubscriptionResourceTest method checkMandatoryParametersMandatoryNotMode.
@Test
public void checkMandatoryParametersMandatoryNotMode() {
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);
resource.checkMandatoryParameters(parameters, acceptedParameters, SubscriptionMode.LINK);
}
Aggregations