Search in sources :

Example 26 with ParameterValue

use of org.ligoj.app.model.ParameterValue in project ligoj-api by ligoj.

the class ParameterValueResourceTest method newParameterValue.

private ParameterValue newParameterValue(final String data, final Parameter parameter) {
    final ParameterValue parameterValueEntity = new ParameterValue();
    parameterValueEntity.setParameter(parameter);
    parameterValueEntity.setData(data);
    return parameterValueEntity;
}
Also used : ParameterValue(org.ligoj.app.model.ParameterValue)

Example 27 with ParameterValue

use of org.ligoj.app.model.ParameterValue 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());
}
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 28 with ParameterValue

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

Example 29 with ParameterValue

use of org.ligoj.app.model.ParameterValue in project ligoj-api by ligoj.

the class ParameterValueResourceTest method deleteMandatoryUnused.

@Test
public void deleteMandatoryUnused() {
    final ParameterValue value = newParameterValue();
    Assertions.assertTrue(repository.existsById(value.getId()));
    resource.delete(value.getId());
    Assertions.assertFalse(repository.existsById(value.getId()));
}
Also used : ParameterValue(org.ligoj.app.model.ParameterValue) AbstractAppTest(org.ligoj.app.AbstractAppTest) Test(org.junit.jupiter.api.Test)

Example 30 with ParameterValue

use of org.ligoj.app.model.ParameterValue in project ligoj-api by ligoj.

the class ParameterValueResourceTest method createInternal.

@Test
public void createInternal() {
    em.createQuery("DELETE Parameter WHERE id LIKE ?1").setParameter(1, "c_%").executeUpdate();
    final List<ParameterValueCreateVo> parameters = new ArrayList<>();
    final ParameterValueCreateVo parameterValueEditionVo = new ParameterValueCreateVo();
    parameterValueEditionVo.setParameter(JiraBaseResource.PARAMETER_PROJECT);
    parameterValueEditionVo.setInteger(10074);
    parameters.add(parameterValueEditionVo);
    final Node node = new Node();
    node.setName("create-test");
    node.setId("create-test-id");
    em.persist(node);
    em.flush();
    em.clear();
    resource.create(parameters, node);
    em.flush();
    em.clear();
    final List<ParameterValue> values = repository.findAllBy("node.id", "create-test-id");
    Assertions.assertEquals(1, values.size());
    Assertions.assertEquals("10074", values.get(0).getData());
    Assertions.assertEquals(JiraBaseResource.PARAMETER_PROJECT, values.get(0).getParameter().getId());
}
Also used : ParameterValue(org.ligoj.app.model.ParameterValue) Node(org.ligoj.app.model.Node) ArrayList(java.util.ArrayList) AbstractAppTest(org.ligoj.app.AbstractAppTest) Test(org.junit.jupiter.api.Test)

Aggregations

ParameterValue (org.ligoj.app.model.ParameterValue)35 Test (org.junit.jupiter.api.Test)28 AbstractAppTest (org.ligoj.app.AbstractAppTest)27 Parameter (org.ligoj.app.model.Parameter)16 ArrayList (java.util.ArrayList)7 Node (org.ligoj.app.model.Node)6 HashMap (java.util.HashMap)5 Subscription (org.ligoj.app.model.Subscription)4 Date (java.util.Date)3 List (java.util.List)3 Map (java.util.Map)3 Function (java.util.function.Function)3 Collectors (java.util.stream.Collectors)3 NodeStatus (org.ligoj.app.api.NodeStatus)3 NodeVo (org.ligoj.app.api.NodeVo)3 Collection (java.util.Collection)2 Entry (java.util.Map.Entry)2 Optional (java.util.Optional)2 BiFunction (java.util.function.BiFunction)2 CacheRemoveAll (javax.cache.annotation.CacheRemoveAll)2