From 1c99073481872e7a968d98f0f5bbccfc3eb1ff01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20G=C3=BCrtler?= Date: Wed, 3 Apr 2024 11:02:28 +0200 Subject: [PATCH 1/4] Cosmetics: Updated instructions for running test --- tests/generators/test_javaFuncs.py | 2 +- tests/model/test_modelFunc.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/generators/test_javaFuncs.py b/tests/generators/test_javaFuncs.py index fb38dc4..b534e50 100644 --- a/tests/generators/test_javaFuncs.py +++ b/tests/generators/test_javaFuncs.py @@ -21,7 +21,7 @@ def getExampleType(): return modelTypes[0] -# For executing these tests run: python -m unittest -v tests/generators/test_javaFuncs.py +# For executing these tests run: python3 -m unittest -v tests/generators/test_javaFuncs.py class TestJavaFuncs (unittest.TestCase): def testIsDouble(self): diff --git a/tests/model/test_modelFunc.py b/tests/model/test_modelFunc.py index b7d19ad..65bed3b 100644 --- a/tests/model/test_modelFunc.py +++ b/tests/model/test_modelFunc.py @@ -46,7 +46,7 @@ def getComplexTypeWithBase(): return myType -# For executing these test run: python -m unittest -v tests/model/test_modelFunc.py +# For executing these test run: python3 -m unittest -v tests/model/test_modelFunc.py class TestModelFuncs (unittest.TestCase): def testHasPropertyOfTypeNoBaseType(self): From c6c99a67d2db121ce06def031a116c08c4df101a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20G=C3=BCrtler?= Date: Wed, 3 Apr 2024 11:12:42 +0200 Subject: [PATCH 2/4] Extended testgetJavaTypes in test_javaFuncs.py --- tests/generators/test_javaFuncs.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/tests/generators/test_javaFuncs.py b/tests/generators/test_javaFuncs.py index b534e50..328ad95 100644 --- a/tests/generators/test_javaFuncs.py +++ b/tests/generators/test_javaFuncs.py @@ -5,8 +5,8 @@ import yacg.model.model as model from yacg.model.model import IntegerType, IntegerTypeFormatEnum, NumberType, NumberTypeFormatEnum -# from yacg.model.model import StringType, UuidType -# from yacg.model.model import EnumType, DateTimeType, TimeType +from yacg.model.model import StringType, EnumType #, DictionaryType +from yacg.model.model import DateType, TimeType, DateTimeType, UuidType from yacg.model.model import ComplexType, BytesType, ObjectType import yacg.generators.helper.javaFuncs as javaFuncs import yacg.model.modelFuncs as modelFuncs @@ -131,6 +131,14 @@ def testgetJavaTypes(self): self.assertEqual('Double', javaFuncs.getJavaType(numberType, False)) self.assertEqual('java.util.List', javaFuncs.getJavaType(numberType, True)) + stringType = StringType() + self.assertEqual('String', javaFuncs.getJavaType(stringType, False)) + self.assertEqual('java.util.List', javaFuncs.getJavaType(stringType, True)) + + uuidType = UuidType() + self.assertEqual('java.util.UUID', javaFuncs.getJavaType(uuidType, False)) + self.assertEqual('java.util.List', javaFuncs.getJavaType(uuidType, True)) + objectType = ObjectType() self.assertEqual('Object', javaFuncs.getJavaType(objectType, False)) self.assertEqual('java.util.List', javaFuncs.getJavaType(objectType, True)) @@ -139,6 +147,22 @@ def testgetJavaTypes(self): self.assertEqual('byte[]', javaFuncs.getJavaType(bytesType, False)) self.assertEqual('java.util.List', javaFuncs.getJavaType(bytesType, True)) + dateType = DateType() + self.assertEqual('java.time.LocalDate', javaFuncs.getJavaType(dateType, False)) + self.assertEqual('java.util.List', javaFuncs.getJavaType(dateType, True)) + + timeType = TimeType() + self.assertEqual('java.time.LocalTime', javaFuncs.getJavaType(timeType, False)) + self.assertEqual('java.util.List', javaFuncs.getJavaType(timeType, True)) + + dateTimeType = DateTimeType() + self.assertEqual('java.time.LocalDateTime', javaFuncs.getJavaType(dateTimeType, False)) + self.assertEqual('java.util.List', javaFuncs.getJavaType(dateTimeType, True)) + + enumType = EnumType() + enumType.name = 'Foo' + self.assertEqual('Foo', javaFuncs.getJavaType(enumType, False)) + self.assertEqual('java.util.List', javaFuncs.getJavaType(enumType, True)) def testJavaFuncs(self): myType = getExampleType() From d71205e1ff1591c21e8891ecb7f43fe95c2c7c77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20G=C3=BCrtler?= Date: Wed, 3 Apr 2024 11:35:35 +0200 Subject: [PATCH 3/4] Handle arrays of DictionaryType in javaFuncs.getJavaType() --- CHANGELOG.md | 3 +++ tests/generators/test_javaFuncs.py | 7 ++++++- yacg/generators/helper/javaFuncs.py | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60cc138..8634346 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 6.5.1 +* Handle arrays of DictionaryType in javaFuncs.getJavaType() + # 6.5.0 * Introduce 'format' attribute to StringType diff --git a/tests/generators/test_javaFuncs.py b/tests/generators/test_javaFuncs.py index 328ad95..9f4f007 100644 --- a/tests/generators/test_javaFuncs.py +++ b/tests/generators/test_javaFuncs.py @@ -5,7 +5,7 @@ import yacg.model.model as model from yacg.model.model import IntegerType, IntegerTypeFormatEnum, NumberType, NumberTypeFormatEnum -from yacg.model.model import StringType, EnumType #, DictionaryType +from yacg.model.model import StringType, EnumType, DictionaryType from yacg.model.model import DateType, TimeType, DateTimeType, UuidType from yacg.model.model import ComplexType, BytesType, ObjectType import yacg.generators.helper.javaFuncs as javaFuncs @@ -164,6 +164,11 @@ def testgetJavaTypes(self): self.assertEqual('Foo', javaFuncs.getJavaType(enumType, False)) self.assertEqual('java.util.List', javaFuncs.getJavaType(enumType, True)) + dictType = DictionaryType() + dictType.valueType = UuidType() + self.assertEqual('java.util.Map', javaFuncs.getJavaType(dictType, False)) + self.assertEqual('java.util.List>', javaFuncs.getJavaType(dictType, True)) + def testJavaFuncs(self): myType = getExampleType() self.assertEqual('ExampleType', myType.name) diff --git a/yacg/generators/helper/javaFuncs.py b/yacg/generators/helper/javaFuncs.py index 6f1b169..62aff8a 100644 --- a/yacg/generators/helper/javaFuncs.py +++ b/yacg/generators/helper/javaFuncs.py @@ -45,7 +45,7 @@ def getJavaType(typeObj, isArray): elif isinstance(typeObj, model.DateTimeType): return 'java.time.LocalDateTime' if not isArray else 'java.util.List' elif isinstance(typeObj, model.DictionaryType): - return 'java.util.Map'.format(getJavaType(typeObj.valueType, False)) + return 'java.util.Map'.format(getJavaType(typeObj.valueType, False)) if not isArray else 'java.util.List>'.format(getJavaType(typeObj.valueType, False)) elif isinstance(typeObj, model.ComplexType): return typeObj.name if not isArray else 'java.util.List<{}>'.format(typeObj.name) else: From ecc360761a09ce73c19580e2ec08c07158274f28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20G=C3=BCrtler?= Date: Wed, 3 Apr 2024 14:08:07 +0200 Subject: [PATCH 4/4] Bumped version: 6.5.1 --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index f22d756..a194c18 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -6.5.0 +6.5.1