Search in sources :

Example 16 with ParameterValue

use of org.ligoj.app.model.ParameterValue 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 17 with ParameterValue

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

the class ParameterValueResourceTest method createAlreadySecured.

@Test
public void createAlreadySecured() {
    final ParameterValueCreateVo parameterValue = new ParameterValueCreateVo();
    parameterValue.setParameter(parameterRepository.findOne("service:bt:jira:jdbc-url").getId());
    parameterValue.setText(encryptor.encrypt("value"));
    final ParameterValue entity = resource.createInternal(parameterValue);
    Assertions.assertEquals(parameterValue.getParameter(), entity.getParameter().getId());
    Assertions.assertNotEquals("value", entity.getData());
    Assertions.assertEquals(parameterValue.getText(), entity.getData());
    Assertions.assertEquals("value", encryptor.decrypt(entity.getData()));
}
Also used : ParameterValue(org.ligoj.app.model.ParameterValue) AbstractAppTest(org.ligoj.app.AbstractAppTest) Test(org.junit.jupiter.api.Test)

Example 18 with ParameterValue

use of org.ligoj.app.model.ParameterValue 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)

Example 19 with ParameterValue

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

the class ParameterValueResourceTest method findSelect.

@Test
public void findSelect() {
    final Parameter parameter = parameterRepository.findOne("c_3");
    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.getIndex().intValue());
    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 20 with ParameterValue

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

the class ParameterValueResourceTest method createTags.

@Test
public void createTags() {
    final ParameterValueCreateVo parameterValue = new ParameterValueCreateVo();
    parameterValue.setParameter(parameterRepository.findOne("c_22").getId());
    final List<String> tags = new ArrayList<>();
    tags.add("value1");
    tags.add("valueX");
    parameterValue.setTags(tags);
    final ParameterValue entity = resource.createInternal(parameterValue);
    Assertions.assertEquals(parameterValue.getParameter(), entity.getParameter().getId());
    Assertions.assertEquals("[\"VALUE1\",\"VALUEX\"]", entity.getData());
}
Also used : ParameterValue(org.ligoj.app.model.ParameterValue) 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