Search in sources :

Example 1 with YamlEditor

use of org.onap.so.asdc.util.YamlEditor in project so by onap.

the class YamlTest method addParameterListWhenEmptyTest.

@Test
public void addParameterListWhenEmptyTest() throws Exception {
    InputStream input = new FileInputStream(new File("src/test/resources/resource-examples/simpleTestWithoutParam.yaml"));
    YamlEditor decoder = new YamlEditor(IOUtils.toByteArray(input));
    Set<HeatTemplateParam> newParamSet = new HashSet<>();
    HeatTemplateParam heatParam1 = new HeatTemplateParam();
    heatParam1.setHeatTemplateArtifactUuid("1");
    heatParam1.setParamName("testos1");
    heatParam1.setParamType("string");
    HeatTemplateParam heatParam2 = new HeatTemplateParam();
    heatParam2.setHeatTemplateArtifactUuid("2");
    heatParam2.setParamName("testos2");
    heatParam2.setParamType("number");
    newParamSet.add(heatParam1);
    newParamSet.add(heatParam2);
    decoder.addParameterList(newParamSet);
    Set<HeatTemplateParam> paramSet = decoder.getParameterList("123456");
    assertTrue(paramSet.size() == 2);
    assertTrue(decoder.encode().contains("testos1"));
    assertTrue(decoder.encode().contains("string"));
    assertTrue(decoder.encode().contains("testos2"));
    assertTrue(decoder.encode().contains("number"));
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) YamlEditor(org.onap.so.asdc.util.YamlEditor) File(java.io.File) FileInputStream(java.io.FileInputStream) HeatTemplateParam(org.onap.so.db.catalog.beans.HeatTemplateParam) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with YamlEditor

use of org.onap.so.asdc.util.YamlEditor in project so by onap.

the class YamlTest method addParameterListTest.

@Test
public void addParameterListTest() throws Exception {
    InputStream input = new FileInputStream(new File("src/test/resources/resource-examples/simpleTest.yaml"));
    YamlEditor decoder = new YamlEditor(IOUtils.toByteArray(input));
    Set<HeatTemplateParam> newParamSet = new HashSet<>();
    HeatTemplateParam heatParam1 = new HeatTemplateParam();
    heatParam1.setHeatTemplateArtifactUuid("1");
    heatParam1.setParamName("testos1");
    heatParam1.setParamType("string");
    HeatTemplateParam heatParam2 = new HeatTemplateParam();
    heatParam2.setHeatTemplateArtifactUuid("2");
    heatParam2.setParamName("testos2");
    heatParam2.setParamType("number");
    newParamSet.add(heatParam1);
    newParamSet.add(heatParam2);
    decoder.addParameterList(newParamSet);
    Set<HeatTemplateParam> paramSet = decoder.getParameterList("123456");
    assertTrue(paramSet.size() == 7);
    Boolean check1 = Boolean.FALSE;
    Boolean check2 = Boolean.FALSE;
    for (HeatTemplateParam param : paramSet) {
        if ("ip_port_snmp_manager".equals(param.getParamName()) || "cor_direct_net_name".equals(param.getParamName()) || "cor_direct_net_RT".equals(param.getParamName())) {
            assertFalse(param.isRequired());
        } else {
            assertTrue(param.isRequired());
        }
        if ("testos1".equals(param.getParamName()) && "string".equals(param.getParamType())) {
            check1 = Boolean.TRUE;
        }
        if ("testos2".equals(param.getParamName()) && "number".equals(param.getParamType())) {
            check2 = Boolean.TRUE;
        }
    }
    assertTrue(check1);
    assertTrue(check2);
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) YamlEditor(org.onap.so.asdc.util.YamlEditor) File(java.io.File) FileInputStream(java.io.FileInputStream) HeatTemplateParam(org.onap.so.db.catalog.beans.HeatTemplateParam) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with YamlEditor

use of org.onap.so.asdc.util.YamlEditor in project so by onap.

the class YamlTest method getYamlResourceTypeTestList.

@Test
public void getYamlResourceTypeTestList() throws Exception {
    InputStream input = new FileInputStream(new File("src/test/resources/resource-examples/simpleTest.yaml"));
    YamlEditor decoder = new YamlEditor(IOUtils.toByteArray(input));
    List<String> typeList = decoder.getYamlNestedFileResourceTypeList();
    assertTrue(typeList.size() == 1 && typeList.get(0).equals("file:///my_test.yaml"));
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) YamlEditor(org.onap.so.asdc.util.YamlEditor) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 4 with YamlEditor

use of org.onap.so.asdc.util.YamlEditor in project so by onap.

the class YamlTest method getParameterListTest.

@Test
public void getParameterListTest() throws Exception {
    InputStream input = new FileInputStream(new File("src/test/resources/resource-examples/simpleTest.yaml"));
    YamlEditor decoder = new YamlEditor(IOUtils.toByteArray(input));
    Set<HeatTemplateParam> paramSet = decoder.getParameterList("123456");
    assertTrue(paramSet.size() == 5);
    for (HeatTemplateParam param : paramSet) {
        if ("ip_port_snmp_manager".equals(param.getParamName()) || "cor_direct_net_name".equals(param.getParamName()) || "cor_direct_net_RT".equals(param.getParamName())) {
            assertTrue(param.isRequired() == false);
        } else {
            assertTrue(param.isRequired() == true);
        }
        assertTrue("string".equals(param.getParamType()));
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) YamlEditor(org.onap.so.asdc.util.YamlEditor) File(java.io.File) FileInputStream(java.io.FileInputStream) HeatTemplateParam(org.onap.so.db.catalog.beans.HeatTemplateParam) Test(org.junit.Test)

Aggregations

File (java.io.File)4 FileInputStream (java.io.FileInputStream)4 InputStream (java.io.InputStream)4 Test (org.junit.Test)4 YamlEditor (org.onap.so.asdc.util.YamlEditor)4 HeatTemplateParam (org.onap.so.db.catalog.beans.HeatTemplateParam)3 HashSet (java.util.HashSet)2