use of org.ligoj.app.model.Parameter 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.Parameter 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.Parameter in project ligoj-api by ligoj.
the class ParameterValueResourceTest method findText.
@Test
public void findText() {
final Parameter parameter = parameterRepository.findOne("c_2");
final ParameterValue parameterValueEntity = newParameterValue("value", parameter);
em.persist(parameterValueEntity);
em.flush();
final ParameterValueVo valueVo = resource.toVo(parameterValueEntity);
Assertions.assertEquals(parameter.getId(), valueVo.getParameter().getId());
Assertions.assertEquals(parameterValueEntity.getData(), valueVo.getText());
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 checkOwnershipDisjunction.
@Test
public void checkOwnershipDisjunction() {
final Node node = new Node();
node.setId("service:id");
final Parameter parameter = new Parameter();
parameter.setOwner(node);
final Node node2 = new Node();
node2.setId("service:other");
final Node node3 = new Node();
node3.setId("service:other:sub");
node3.setRefined(node2);
Assertions.assertThrows(BusinessException.class, () -> {
resource.checkOwnership(parameter, node3);
});
}
use of org.ligoj.app.model.Parameter in project ligoj-api by ligoj.
the class ParameterValueResourceTest method findSelectJSonError.
@Test
public void findSelectJSonError() {
final Parameter parameter = parameterRepository.findOne("c_4");
parameter.setData("'{");
final ParameterValue parameterValueEntity = newParameterValue("'", parameter);
Assertions.assertThrows(TechnicalException.class, () -> {
resource.toVo(parameterValueEntity);
});
}
Aggregations