Search in sources :

Example 6 with Parameter

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());
}
Also used : ParameterValue(org.ligoj.app.model.ParameterValue) Node(org.ligoj.app.model.Node) Parameter(org.ligoj.app.model.Parameter) AbstractAppTest(org.ligoj.app.AbstractAppTest) Test(org.junit.jupiter.api.Test)

Example 7 with Parameter

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());
}
Also used : ParameterValue(org.ligoj.app.model.ParameterValue) Parameter(org.ligoj.app.model.Parameter) AbstractAppTest(org.ligoj.app.AbstractAppTest) Test(org.junit.jupiter.api.Test)

Example 8 with Parameter

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());
}
Also used : ParameterValue(org.ligoj.app.model.ParameterValue) Parameter(org.ligoj.app.model.Parameter) AbstractAppTest(org.ligoj.app.AbstractAppTest) Test(org.junit.jupiter.api.Test)

Example 9 with Parameter

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);
    });
}
Also used : Node(org.ligoj.app.model.Node) Parameter(org.ligoj.app.model.Parameter) AbstractAppTest(org.ligoj.app.AbstractAppTest) Test(org.junit.jupiter.api.Test)

Example 10 with Parameter

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);
    });
}
Also used : ParameterValue(org.ligoj.app.model.ParameterValue) Parameter(org.ligoj.app.model.Parameter) AbstractAppTest(org.ligoj.app.AbstractAppTest) Test(org.junit.jupiter.api.Test)

Aggregations

Parameter (org.ligoj.app.model.Parameter)22 Test (org.junit.jupiter.api.Test)20 AbstractAppTest (org.ligoj.app.AbstractAppTest)15 ParameterValue (org.ligoj.app.model.ParameterValue)14 ArrayList (java.util.ArrayList)7 Node (org.ligoj.app.model.Node)6 AbstractOrgTest (org.ligoj.app.resource.AbstractOrgTest)4 ParameterValueCreateVo (org.ligoj.app.resource.node.ParameterValueCreateVo)4 Subscription (org.ligoj.app.model.Subscription)3 Date (java.util.Date)2 HashMap (java.util.HashMap)2 POST (javax.ws.rs.POST)2 NodeVo (org.ligoj.app.api.NodeVo)2 Collection (java.util.Collection)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Optional (java.util.Optional)1 BiFunction (java.util.function.BiFunction)1 Function (java.util.function.Function)1