-
Notifications
You must be signed in to change notification settings - Fork 74
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
fc6e40a
commit ea27a9f
Showing
25 changed files
with
237 additions
and
12 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
Empty file.
Binary file added
BIN
+11.6 KB
...ule/service/entity/TestNopRuleDefinitionBizModel/testImport/input/decision-tree.rule.xlsx
Binary file not shown.
12 changes: 12 additions & 0 deletions
12
...s/io/nop/rule/service/entity/TestNopRuleDefinitionBizModel/testImport/input/request.json5
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,12 @@ | ||
{ | ||
data: { | ||
data: { | ||
ruleName: "test", | ||
ruleGroup: "default", | ||
ruleVersion: 1, | ||
displayName: "Test Tree", | ||
status: 1, | ||
importFile: "@var:downloadPath" | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
.../service/entity/TestNopRuleDefinitionBizModel/testImport/input/tables/nop_file_record.csv
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 @@ | ||
FILE_ID,FILE_NAME,FILE_PATH,FILE_EXT,MIME_TYPE,FILE_LENGTH,FILE_LAST_MODIFIED,BIZ_OBJ_NAME,BIZ_OBJ_ID,FIELD_NAME,FILE_HASH,DEL_FLAG,CREATED_BY,CREATE_TIME,REMARK |
1 change: 1 addition & 0 deletions
1
...vice/entity/TestNopRuleDefinitionBizModel/testImport/input/tables/nop_rule_definition.csv
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 @@ | ||
RULE_ID,RULE_NAME,RULE_VERSION,DISPLAY_NAME,RULE_GROUP,RULE_TYPE,DESCRIPTION,MODEL_TEXT,STATUS,VERSION,CREATED_BY,CREATE_TIME,UPDATED_BY,UPDATE_TIME,REMARK |
1 change: 1 addition & 0 deletions
1
...service/entity/TestNopRuleDefinitionBizModel/testImport/input/tables/nop_sys_sequence.csv
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 @@ | ||
SEQ_NAME,SEQ_TYPE,IS_UUID,NEXT_VALUE,STEP_SIZE,CACHE_SIZE,MAX_VALUE,RESET_TYPE,DEL_FLAG,VERSION,CREATED_BY,CREATE_TIME,UPDATED_BY,UPDATE_TIME,REMARK |
56 changes: 56 additions & 0 deletions
56
...io/nop/rule/service/entity/TestNopRuleDefinitionBizModel/testImport/output/response.json5
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,56 @@ | ||
{ | ||
"data": { | ||
"ruleId": "@var:NopRuleDefinition@ruleId", | ||
"ruleName": "test", | ||
"ruleVersion": 1, | ||
"displayName": "Test Tree", | ||
"ruleGroup": "default", | ||
"ruleType": "TREE", | ||
"ruleType_label": "TREE-决策树", | ||
"modelText": "<rule displayName=\"测试规则\" x:schema=\"/nop/schema/rule.xdef\" xmlns:x=\"/nop/schema/xdsl.xdef\">\n <inputs>\n <input displayName=\"季度\" mandatory=\"true\" name=\"season\" type=\"java.lang.String\">\n <schema/>\n </input>\n <input displayName=\"客人数\" mandatory=\"true\" name=\"guestCount\" type=\"java.lang.Integer\">\n <schema/>\n </input>\n </inputs>\n <outputs>\n <output displayName=\"食物\" name=\"dish\" type=\"java.lang.String\">\n <schema/>\n </output>\n </outputs>\n</rule>", | ||
"status": 1, | ||
"status_label": "1-启用", | ||
"version": 0, | ||
"createdBy": "autotest-ref", | ||
"createTime": "@var:NopRuleDefinition@updateTime", | ||
"updatedBy": "autotest-ref", | ||
"updateTime": "@var:NopRuleDefinition@updateTime", | ||
"ruleInputs": [ | ||
{ | ||
"name": "season", | ||
"displayName": "季度", | ||
"type": "java.lang.String", | ||
"mandatory": true, | ||
"computed": false, | ||
"defaultExpr": null, | ||
"description": null, | ||
"schema": {} | ||
}, | ||
{ | ||
"name": "guestCount", | ||
"displayName": "客人数", | ||
"type": "java.lang.Integer", | ||
"mandatory": true, | ||
"computed": false, | ||
"defaultExpr": null, | ||
"description": null, | ||
"schema": {} | ||
} | ||
], | ||
"ruleOutputs": [ | ||
{ | ||
"name": "dish", | ||
"displayName": "食物", | ||
"type": "java.lang.String", | ||
"aggregate": null, | ||
"description": null, | ||
"schema": {} | ||
} | ||
], | ||
"beforeExecute": null, | ||
"id": "@var:NopRuleDefinition@ruleId", | ||
"description": null, | ||
"remark": null | ||
}, | ||
"status": 0 | ||
} |
2 changes: 2 additions & 0 deletions
2
...service/entity/TestNopRuleDefinitionBizModel/testImport/output/tables/nop_file_record.csv
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,2 @@ | ||
_chgType,FILE_ID,FILE_NAME,FILE_PATH,FILE_EXT,MIME_TYPE,FILE_LENGTH,FILE_LAST_MODIFIED,BIZ_OBJ_NAME,BIZ_OBJ_ID,FIELD_NAME,FILE_HASH,DEL_FLAG,CREATED_BY,CREATE_TIME,REMARK | ||
A,@var:NopFileRecord@fileId,decision-tree.rule.xlsx,@var:NopFileRecord@filePath,xlsx,binary,1000,,NopRuleDefinition,__TEMP__,importFile,,1,autotest-ref,*, |
16 changes: 16 additions & 0 deletions
16
...ice/entity/TestNopRuleDefinitionBizModel/testImport/output/tables/nop_rule_definition.csv
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,16 @@ | ||
_chgType,RULE_ID,RULE_NAME,RULE_VERSION,DISPLAY_NAME,RULE_GROUP,RULE_TYPE,DESCRIPTION,MODEL_TEXT,STATUS,VERSION,CREATED_BY,CREATE_TIME,UPDATED_BY,UPDATE_TIME,REMARK | ||
A,@var:NopRuleDefinition@ruleId,test,1,Test Tree,default,TREE,,"<rule displayName=""测试规则"" x:schema=""/nop/schema/rule.xdef"" xmlns:x=""/nop/schema/xdsl.xdef""> | ||
<inputs> | ||
<input displayName=""季度"" mandatory=""true"" name=""season"" type=""java.lang.String""> | ||
<schema/> | ||
</input> | ||
<input displayName=""客人数"" mandatory=""true"" name=""guestCount"" type=""java.lang.Integer""> | ||
<schema/> | ||
</input> | ||
</inputs> | ||
<outputs> | ||
<output displayName=""食物"" name=""dish"" type=""java.lang.String""> | ||
<schema/> | ||
</output> | ||
</outputs> | ||
</rule>",1,0,autotest-ref,*,autotest-ref,*, |
24 changes: 24 additions & 0 deletions
24
...e/service/entity/TestNopRuleDefinitionBizModel/testImport/output/tables/nop_rule_node.csv
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,24 @@ | ||
_chgType,SID,RULE_ID,LABEL,SORT_NO,PREDICATE,OUTPUTS,PARENT_ID,IS_LEAF,VERSION,CREATED_BY,CREATE_TIME,UPDATED_BY,UPDATE_TIME,REMARK | ||
A,@var:NopRuleNode@sid_8,@var:NopRuleDefinition@ruleId,,1,"{""$type"":""gt"",""name"":""guestCount"",""value"":8}","{ | ||
""dish"": ""\""Stew\"""" | ||
}",@var:NopRuleNode@sid_7,true,0,autotest-ref,*,autotest-ref,*, | ||
A,@var:NopRuleNode@sid_9,@var:NopRuleDefinition@ruleId,,5,"{""$type"":""eq"",""name"":""season"",""value"":""Summer""}",,,true,0,autotest-ref,*,autotest-ref,*, | ||
A,@var:NopRuleNode@sid_10,@var:NopRuleDefinition@ruleId,,1,"{""$type"":""alwaysTrue""}","{ | ||
""dish"": ""\""Light Salad and nice Steak\"""" | ||
}",@var:NopRuleNode@sid_9,true,0,autotest-ref,*,autotest-ref,*, | ||
A,@var:NopRuleNode@sid,@var:NopRuleDefinition@ruleId,,1,"{""$type"":""eq"",""name"":""season"",""value"":""Fall""}",,,true,0,autotest-ref,*,autotest-ref,*, | ||
A,@var:NopRuleNode@sid_1,@var:NopRuleDefinition@ruleId,,1,"{""$type"":""le"",""name"":""guestCount"",""value"":8}","{ | ||
""dish"": ""\""Spareribs\"""" | ||
}",@var:NopRuleNode@sid,true,0,autotest-ref,*,autotest-ref,*, | ||
A,@var:NopRuleNode@sid_2,@var:NopRuleDefinition@ruleId,,2,"{""$type"":""eq"",""name"":""season"",""value"":""Winter""}",,,true,0,autotest-ref,*,autotest-ref,*, | ||
A,@var:NopRuleNode@sid_3,@var:NopRuleDefinition@ruleId,,1,"{""$type"":""le"",""name"":""guestCount"",""value"":8}","{ | ||
""dish"": ""\""Roastbeef\"""" | ||
}",@var:NopRuleNode@sid_2,true,0,autotest-ref,*,autotest-ref,*, | ||
A,@var:NopRuleNode@sid_4,@var:NopRuleDefinition@ruleId,,3,"{""$type"":""eq"",""name"":""season"",""value"":""Spring""}",,,true,0,autotest-ref,*,autotest-ref,*, | ||
A,@var:NopRuleNode@sid_5,@var:NopRuleDefinition@ruleId,,1,"{""$type"":""le"",""name"":""guestCount"",""value"":4}","{ | ||
""dish"": ""\""Dry Aged Gourmet Steak\"""" | ||
}",@var:NopRuleNode@sid_4,true,0,autotest-ref,*,autotest-ref,*, | ||
A,@var:NopRuleNode@sid_6,@var:NopRuleDefinition@ruleId,,2,"{""$type"":""and"",""$body"":[{""$type"":""le"",""name"":""guestCount"",""value"":8},{""$type"":""ge"",""name"":""guestCount"",""value"":5}]}","{ | ||
""dish"": ""\""Steak\"""" | ||
}",@var:NopRuleNode@sid_4,true,0,autotest-ref,*,autotest-ref,*, | ||
A,@var:NopRuleNode@sid_7,@var:NopRuleDefinition@ruleId,,4,"{""$type"":""in"",""name"":""season"",""value"":[""Fall"",""Winter"",""Spring""]}",,,true,0,autotest-ref,*,autotest-ref,*, |
2 changes: 2 additions & 0 deletions
2
...ervice/entity/TestNopRuleDefinitionBizModel/testImport/output/tables/nop_sys_sequence.csv
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,2 @@ | ||
_chgType,SEQ_NAME,SEQ_TYPE,IS_UUID,NEXT_VALUE,STEP_SIZE,CACHE_SIZE,MAX_VALUE,RESET_TYPE,DEL_FLAG,VERSION,CREATED_BY,CREATE_TIME,UPDATED_BY,UPDATE_TIME,REMARK | ||
A,default,seq,0,101,1,100,,,0,1,autotest-ref,*,autotest-ref,*, |
8 changes: 8 additions & 0 deletions
8
...p/rule/service/entity/TestNopRuleDefinitionBizModel/testImport/output/upload-result.json5
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,8 @@ | ||
{ | ||
"data": { | ||
"filename": "decision-tree.rule.xlsx", | ||
"url": null, | ||
"value": "@var:downloadPath" | ||
}, | ||
"status": 0 | ||
} |
60 changes: 60 additions & 0 deletions
60
...-rule-service/src/test/java/io/nop/rule/service/entity/TestNopRuleDefinitionBizModel.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,60 @@ | ||
package io.nop.rule.service.entity; | ||
|
||
import io.nop.api.core.annotations.autotest.EnableSnapshot; | ||
import io.nop.api.core.annotations.autotest.NopTestConfig; | ||
import io.nop.api.core.beans.ApiRequest; | ||
import io.nop.api.core.beans.ApiResponse; | ||
import io.nop.autotest.junit.JunitAutoTestCase; | ||
import io.nop.commons.util.IoHelper; | ||
import io.nop.core.reflect.bean.BeanTool; | ||
import io.nop.core.resource.IResource; | ||
import io.nop.file.core.UploadRequestBean; | ||
import io.nop.graphql.core.IGraphQLExecutionContext; | ||
import io.nop.graphql.core.ast.GraphQLOperationType; | ||
import io.nop.graphql.core.engine.IGraphQLEngine; | ||
import io.nop.rule.dao.entity.NopRuleDefinition; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import javax.inject.Inject; | ||
import java.io.InputStream; | ||
import java.util.Map; | ||
|
||
@NopTestConfig(localDb = true, initDatabaseSchema = true) | ||
public class TestNopRuleDefinitionBizModel extends JunitAutoTestCase { | ||
|
||
@Inject | ||
IGraphQLEngine graphQLEngine; | ||
|
||
@EnableSnapshot | ||
@Test | ||
public void testImport() { | ||
IResource resource = inputResource("decision-tree.rule.xlsx"); | ||
InputStream is = resource.getInputStream(); | ||
|
||
try { | ||
UploadRequestBean request = new UploadRequestBean(); | ||
request.setFileName("decision-tree.rule.xlsx"); | ||
request.setBizObjName(NopRuleDefinition.class.getSimpleName()); | ||
request.setFieldName("importFile"); | ||
request.setLength(1000); | ||
request.setMimeType("binary"); | ||
request.setLastModified(1000); | ||
request.setInputStream(is); | ||
|
||
IGraphQLExecutionContext ctx = graphQLEngine.newRpcContext(GraphQLOperationType.mutation, | ||
"NopFileStore__upload", ApiRequest.build(request)); | ||
ApiResponse<?> response = graphQLEngine.executeRpc(ctx); | ||
// 每次生成的下载路径都是一个随机值,所以需要注册为变量 | ||
setVar("downloadPath", BeanTool.getComplexProperty(response, "data.value")); | ||
output("upload-result.json5", response); | ||
} finally { | ||
IoHelper.safeCloseObject(is); | ||
} | ||
|
||
ApiRequest<?> request = request("request.json5", Map.class); | ||
IGraphQLExecutionContext ctx = graphQLEngine.newRpcContext(GraphQLOperationType.mutation, | ||
"NopRuleDefinition__save", request); | ||
ApiResponse<?> response = graphQLEngine.executeRpc(ctx); | ||
output("response.json5", response); | ||
} | ||
} |
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
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
Oops, something went wrong.