use of org.ligoj.app.model.ParameterValue in project ligoj-api by ligoj.
the class ParameterValueResourceTest method newParameterValue.
/**
* Create a new {@link ParameterValue} linked to a new {@link Node} without subscription.
*/
private ParameterValue newParameterValue() {
final Node node = new Node();
node.setName("create-test");
node.setId("service:kpi:sonar:temp");
node.setRefined(em.find(Node.class, "service:kpi:sonar"));
em.persist(node);
final ParameterValue value = new ParameterValue();
value.setParameter(em.find(Parameter.class, "service:kpi:sonar:user"));
value.setData("user");
value.setNode(node);
em.persist(value);
em.flush();
em.clear();
return value;
}
use of org.ligoj.app.model.ParameterValue in project ligoj-api by ligoj.
the class ParameterValueResourceTest method findWithNode.
@Test
public void findWithNode() {
final Parameter parameter = parameterRepository.findOne("c_20");
final ParameterValue parameterValueEntity = newParameterValue("true", parameter);
parameterValueEntity.setNode(em.find(Node.class, "service:bt:jira:6"));
em.persist(parameterValueEntity);
em.flush();
final ParameterValueVo valueVo = resource.toVo(parameterValueEntity);
Assertions.assertEquals(parameter.getId(), valueVo.getParameter().getId());
Assertions.assertEquals("service:bt:jira:6", valueVo.getNode().getId());
}
use of org.ligoj.app.model.ParameterValue in project ligoj-api by ligoj.
the class ParameterValueResourceTest method findTags.
@Test
public void findTags() {
final Parameter parameter = parameterRepository.findOne("c_22");
final ParameterValue parameterValueEntity = newParameterValue("[\"A\",\"B\"]", parameter);
em.persist(parameterValueEntity);
em.flush();
final ParameterValueVo valueVo = resource.toVo(parameterValueEntity);
Assertions.assertEquals(parameter.getId(), valueVo.getParameter().getId());
Assertions.assertEquals("[A, B]", valueVo.getTags().toString());
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 createInteger.
@Test
public void createInteger() {
final ParameterValueCreateVo parameterValue = new ParameterValueCreateVo();
parameterValue.setParameter(parameterRepository.findOne("c_4").getId());
parameterValue.setInteger(1);
final ParameterValue entity = resource.createInternal(parameterValue);
Assertions.assertEquals(parameterValue.getParameter(), entity.getParameter().getId());
Assertions.assertEquals("1", entity.getData());
}
use of org.ligoj.app.model.ParameterValue in project ligoj-api by ligoj.
the class ParameterValueResourceTest method createMultiple.
@Test
public void createMultiple() {
final ParameterValueCreateVo parameterValue = new ParameterValueCreateVo();
parameterValue.setParameter(parameterRepository.findOne("c_23").getId());
final List<Integer> tags = new ArrayList<>();
tags.add(1);
tags.add(2);
parameterValue.setSelections(tags);
final ParameterValue entity = resource.createInternal(parameterValue);
Assertions.assertEquals(parameterValue.getParameter(), entity.getParameter().getId());
Assertions.assertEquals("[1,2]", entity.getData());
}
Aggregations