diff --git a/nop-auth/nop-auth-service/src/test/java/io/nop/auth/service/TestDynamicItem.java b/nop-auth/nop-auth-service/src/test/java/io/nop/auth/service/TestDynamicItem.java new file mode 100644 index 000000000..74b1739de --- /dev/null +++ b/nop-auth/nop-auth-service/src/test/java/io/nop/auth/service/TestDynamicItem.java @@ -0,0 +1,34 @@ +package io.nop.auth.service; + +import io.nop.api.core.annotations.autotest.NopTestConfig; +import io.nop.api.core.beans.ApiRequest; +import io.nop.autotest.junit.JunitBaseTestCase; +import io.nop.core.model.selection.FieldSelectionBeanParser; +import io.nop.graphql.core.IGraphQLExecutionContext; +import io.nop.graphql.core.ast.GraphQLOperationType; +import io.nop.graphql.core.engine.IGraphQLEngine; +import jakarta.inject.Inject; +import org.junit.jupiter.api.Test; + +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +@NopTestConfig(localDb = true, initDatabaseSchema = true) +public class TestDynamicItem extends JunitBaseTestCase { + @Inject + IGraphQLEngine graphQLEngine; + + + @Test + public void testDynamicItem() { + ApiRequest> request = new ApiRequest<>(); + request.setData(Map.of("id", "123")); + request.setSelection(FieldSelectionBeanParser.fromText(null, "name, rows{nickName},rows2{userName}")); + + IGraphQLExecutionContext context = graphQLEngine.newRpcContext(GraphQLOperationType.query, + "NopAuthUser__testDynamicItem", request); + Map result = (Map) graphQLEngine.executeRpc(context).get(); + assertEquals("a", result.get("name")); + } +} diff --git a/nop-auth/nop-auth-service/src/test/java/io/nop/auth/service/biz/ItemData.java b/nop-auth/nop-auth-service/src/test/java/io/nop/auth/service/biz/ItemData.java new file mode 100644 index 000000000..6a261ca22 --- /dev/null +++ b/nop-auth/nop-auth-service/src/test/java/io/nop/auth/service/biz/ItemData.java @@ -0,0 +1,37 @@ +package io.nop.auth.service.biz; + +import io.nop.api.core.annotations.data.DataBean; +import io.nop.orm.IOrmEntity; + +import java.util.List; + +@DataBean +public class ItemData { + private String name; + private List rows; + private List rows2; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getRows() { + return rows; + } + + public void setRows(List rows) { + this.rows = rows; + } + + public List getRows2() { + return rows2; + } + + public void setRows2(List rows2) { + this.rows2 = rows2; + } +} diff --git a/nop-auth/nop-auth-service/src/test/resources/_vfs/_delta/default/nop/auth/model/NopAuthUser/ItemSchema.schema.xml b/nop-auth/nop-auth-service/src/test/resources/_vfs/_delta/default/nop/auth/model/NopAuthUser/ItemSchema.schema.xml new file mode 100644 index 000000000..b71b63943 --- /dev/null +++ b/nop-auth/nop-auth-service/src/test/resources/_vfs/_delta/default/nop/auth/model/NopAuthUser/ItemSchema.schema.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/nop-auth/nop-auth-service/src/test/resources/_vfs/_delta/default/nop/auth/model/NopAuthUser/NopAuthUser.xbiz b/nop-auth/nop-auth-service/src/test/resources/_vfs/_delta/default/nop/auth/model/NopAuthUser/NopAuthUser.xbiz index 54805c2d4..54871d318 100644 --- a/nop-auth/nop-auth-service/src/test/resources/_vfs/_delta/default/nop/auth/model/NopAuthUser/NopAuthUser.xbiz +++ b/nop-auth/nop-auth-service/src/test/resources/_vfs/_delta/default/nop/auth/model/NopAuthUser/NopAuthUser.xbiz @@ -27,5 +27,21 @@ + + + + + + + + + import io.nop.auth.service.biz.ItemData; + + const ret = new ItemData(); + ret.name = "a"; + ret.rows = []; + return ret; + + \ No newline at end of file