-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a7df8e
commit c8730d0
Showing
4 changed files
with
102 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
nop-auth/nop-auth-service/src/test/java/io/nop/auth/service/TestDynamicItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Map<String, Object>> 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<String, Object> result = (Map<String, Object>) graphQLEngine.executeRpc(context).get(); | ||
assertEquals("a", result.get("name")); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
nop-auth/nop-auth-service/src/test/java/io/nop/auth/service/biz/ItemData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<IOrmEntity> rows; | ||
private List<IOrmEntity> rows2; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public List<IOrmEntity> getRows() { | ||
return rows; | ||
} | ||
|
||
public void setRows(List<IOrmEntity> rows) { | ||
this.rows = rows; | ||
} | ||
|
||
public List<IOrmEntity> getRows2() { | ||
return rows2; | ||
} | ||
|
||
public void setRows2(List<IOrmEntity> rows2) { | ||
this.rows2 = rows2; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
...e/src/test/resources/_vfs/_delta/default/nop/auth/model/NopAuthUser/ItemSchema.schema.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<schema x:schema="/nop/schema/schema/schema.xdef" xmlns:x="/nop/schema/xdsl.xdef"> | ||
<props> | ||
<prop name="name"> | ||
<schema type="String"/> | ||
</prop> | ||
|
||
<prop name="rows" graphql:type="[NopAuthUser]" /> | ||
|
||
<prop name="rows2"> | ||
<schema> | ||
<item bizObjName="NopAuthUser" /> | ||
</schema> | ||
</prop> | ||
</props> | ||
</schema> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters