From 21300b403b0f86a0bf447f1eaf0d367fdc7709f0 Mon Sep 17 00:00:00 2001 From: Emil <39118431+emilpaw@users.noreply.github.com> Date: Tue, 23 Jan 2024 18:29:49 +0100 Subject: [PATCH] fix missing enum import --- .../_entityPackage_/_partials/defaults.ejs | 13 +++++++------ .../_package_/_entityPackage_/_partials/imports.ejs | 3 +++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/generators/quarkus/templates/src/test/java/_package_/_entityPackage_/_partials/defaults.ejs b/generators/quarkus/templates/src/test/java/_package_/_entityPackage_/_partials/defaults.ejs index ae8657e8..8c00b878 100644 --- a/generators/quarkus/templates/src/test/java/_package_/_entityPackage_/_partials/defaults.ejs +++ b/generators/quarkus/templates/src/test/java/_package_/_entityPackage_/_partials/defaults.ejs @@ -49,10 +49,10 @@ let enumValue1; let enumValue2; if (isEnum) { - const values = field.fieldValues.replace(/\s/g, '').split(','); - enumValue1 = values[0]; - if (values.length > 1) { - enumValue2 = values[1]; + const enumValues = field.enumValues; + enumValue1 = enumValues[0]; + if (enumValues.length > 1) { + enumValue2 = enumValues[1]; } else { enumValue2 = enumValue1; } @@ -149,8 +149,9 @@ updatedValue = 'ByteBuffer.wrap(TestUtil.createByteArray(1, "1"))'; } } else if (isEnum) { - defaultValue = enumValue1; - updatedValue = enumValue2; + const enumFieldType = `${fieldType}.`; + defaultValue = enumFieldType + enumValue1.name; + updatedValue = enumFieldType + enumValue2.name; } _%> private static final <%= fieldType %> <%= defaultValueName %> = <%- defaultValue %>; diff --git a/generators/quarkus/templates/src/test/java/_package_/_entityPackage_/_partials/imports.ejs b/generators/quarkus/templates/src/test/java/_package_/_entityPackage_/_partials/imports.ejs index 851d2ec3..c4d69829 100644 --- a/generators/quarkus/templates/src/test/java/_package_/_entityPackage_/_partials/imports.ejs +++ b/generators/quarkus/templates/src/test/java/_package_/_entityPackage_/_partials/imports.ejs @@ -38,6 +38,9 @@ import <%= packageName %>.domain.<%= entityClass %>; <%_ } else { _%> import <%= packageName %>.service.dto.<%= dtoClass %>; <%_ } _%> +<%_ for (const enumField of fields.filter(field => !field.transient && field.fieldIsEnum)) { _%> +import <%= packageName %>.domain.enumeration.<%= enumField.fieldType %>; +<%_ } _%> import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; import io.restassured.common.mapper.TypeRef;