diff options
Diffstat (limited to 'catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/ListConverterTest.java')
-rw-r--r-- | catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/ListConverterTest.java | 57 |
1 files changed, 43 insertions, 14 deletions
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/ListConverterTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/ListConverterTest.java index 0eaf10b0db..5a0c95cae0 100644 --- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/ListConverterTest.java +++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/tosca/converters/ListConverterTest.java @@ -20,29 +20,58 @@ package org.openecomp.sdc.be.model.tosca.converters; -import org.junit.Test; +import fj.data.Either; +import org.junit.jupiter.api.Test; +import org.openecomp.sdc.be.model.DataTypeDefinition; + +import java.util.HashMap; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNull; public class ListConverterTest { - private ListConverter createTestSubject() { - return new ListConverter(); - } + private ListConverter listConverter = ListConverter.getInstance(); + private Map<String, DataTypeDefinition> dataTypesMap = new HashMap<>(); - @Test - public void testGetInstance() throws Exception { - ListConverter result; + public void testConvertWithErrorResult() throws Exception { + Either<String, Boolean> result = listConverter.convertWithErrorResult(null, null, dataTypesMap); + assertNull(result.left().value()); - // default test - result = ListConverter.getInstance(); - } + result = listConverter.convertWithErrorResult("[]", "error", dataTypesMap); + assertTrue(result.isRight()); + + result = listConverter.convertWithErrorResult("[\"test\":1]", "json", dataTypesMap); + assertTrue(result.isRight()); + + result = listConverter.convertWithErrorResult("[\"\"]", "string", dataTypesMap); + assertEquals("[]", result.left().value()); + result = listConverter.convertWithErrorResult("[\"test\"]", "string", dataTypesMap); + assertEquals("[\"test\"]", result.left().value()); - + result = listConverter.convertWithErrorResult("[1, 0x01, 0o01]", "integer", dataTypesMap); + assertEquals("[1,1,1]", result.left().value()); - - + result = listConverter.convertWithErrorResult("[0.1]", "float", dataTypesMap); + assertEquals("[0.1]", result.left().value()); - + result = listConverter.convertWithErrorResult("[true]", "boolean", dataTypesMap); + assertEquals("[true]", result.left().value()); + result = listConverter.convertWithErrorResult("[{\"test\":1}]", "json", dataTypesMap); + assertEquals("[{\"test\":1}]", result.left().value()); + + result = listConverter.convertWithErrorResult("[1.1]", "version", dataTypesMap); + assertEquals("[1.1]", result.left().value()); + } + + @Test + public void testConvert() throws Exception { + assertEquals("[0.1]", listConverter.convertWithErrorResult("[0.1]", "float", dataTypesMap).left().value()); + assertNull(listConverter.convert("[]", "error", dataTypesMap)); + } } |