Skip to content

Commit

Permalink
单元测试阶段teimstamp输出到graphql数据中时保留毫秒数据
Browse files Browse the repository at this point in the history
  • Loading branch information
entropy-cloud committed Jul 28, 2024
1 parent 0229fc6 commit c3dd961
Show file tree
Hide file tree
Showing 101 changed files with 209 additions and 184 deletions.
6 changes: 3 additions & 3 deletions nop-api-core/src/main/java/io/nop/api/core/ApiConfigs.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public interface ApiConfigs {
varRef(s_loc, "nop.auth.enable-data-auth", Boolean.class, false);


@Description("时间戳类型是否返回毫秒信息")
IConfigReference<Boolean> CFG_CONVERT_IGNORE_MILLIS_IN_TIMESTAMP =
varRef(s_loc, "nop.convert.ignore-millis-in-timestamp", Boolean.class, true);
// @Description("时间戳类型是否返回毫秒信息")
// IConfigReference<Boolean> CFG_CONVERT_IGNORE_MILLIS_IN_TIMESTAMP =
// varRef(s_loc, "nop.convert.ignore-millis-in-timestamp", Boolean.class, true);

}
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
_chgType,ROLE_ID,ROLE_NAME,CHILD_ROLE_IDS,IS_PRIMARY,DEL_FLAG,VERSION,CREATED_BY,CREATE_TIME,UPDATED_BY,UPDATE_TIME,REMARK

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
_chgType,SESSION_ID,USER_ID,USER_NAME,TENANT_ID,LOGIN_ADDR,LOGIN_DEVICE,LOGIN_APP,LOGIN_OS,LOGIN_TIME,LOGIN_TYPE,LOGOUT_TIME,LOGOUT_TYPE,LOGOUT_BY,LAST_ACCESS_TIME,ACCESS_TOKEN,REFRESH_TOKEN,CACHE_DATA,CREATED_BY,CREATE_TIME,REMARK
A,@var:NopAuthSession@sessionId,@var:NopAuthUser@userId,auto_test1,0,,,,,@var:NopAuthSession@loginTime,1,@var:NopAuthSession@logoutTime,4,autotest-ref,,,,,autotest-ref,*,
A,@var:NopAuthSession@sessionId_1,@var:NopAuthUser@userId,auto_test1,0,,,,,@var:NopAuthSession@loginTime,1,,0,,,,,,autotest-ref,*,
A,@var:NopAuthSession@sessionId_1,@var:NopAuthUser@userId,auto_test1,0,,,,,@var:NopAuthSession@loginTime_1,1,,0,,,,,,autotest-ref,*,
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"delFlag": 0,
"version": 0,
"createdBy": "autotest-ref",
"createTime": "@var:NopAuthUserRole@updateTime",
"createTime": "@var:NopAuthRole@updateTime",
"updatedBy": "autotest-ref",
"updateTime": "@var:NopAuthUserRole@updateTime",
"updateTime": "@var:NopAuthRole@updateTime",
"remark": null
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"delFlag": 0,
"version": 0,
"createdBy": "autotest-ref",
"createTime": "@var:NopAuthUserRole@updateTime",
"createTime": "@var:NopAuthRole@updateTime",
"updatedBy": "autotest-ref",
"updateTime": "@var:NopAuthUserRole@updateTime",
"updateTime": "@var:NopAuthRole@updateTime",
"remark": null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ public interface AutoTestConstants {
String VARIANT_DEFAULT = "_default";

char PATTERN_PREFIX = '@';

String CFG_GRAPHQL_IGNORE_MILLIS_IN_TIMESTAMP = "nop.graphql.ignore-millis-in-timestamp";
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,17 @@
*/
package io.nop.autotest.core.data;

import io.nop.commons.util.DateHelper;
import io.nop.commons.util.StringHelper;
import io.nop.core.lang.json.JsonTool;
import io.nop.core.lang.json.utils.JsonTransformHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.TreeMap;

import static io.nop.api.core.ApiConfigs.CFG_CONVERT_IGNORE_MILLIS_IN_TIMESTAMP;
import static io.nop.autotest.core.AutoTestConstants.PATTERN_PREFIX;
import static io.nop.autotest.core.AutoTestConstants.V_VAR_PREFIX;
import static io.nop.commons.util.StringHelper.leftPad;
Expand Down Expand Up @@ -133,11 +130,6 @@ private static Object normalizeValue(Object value) {
return null;
if (value instanceof String)
return value;
if (value instanceof Timestamp) {
if (CFG_CONVERT_IGNORE_MILLIS_IN_TIMESTAMP.get()) {
return DateHelper.formatTimestampNoMillis((Timestamp) value);
}
}
return JsonTool.serializeToJson(value, false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import io.nop.api.core.annotations.autotest.NopTestProperties;
import io.nop.api.core.annotations.autotest.NopTestProperty;
import io.nop.api.core.config.AppConfig;
import io.nop.api.core.config.SimpleConfigProvider;
import io.nop.api.core.ioc.BeanContainerStartMode;
import io.nop.api.core.time.CoreMetrics;
import io.nop.core.initialize.CoreInitialization;
Expand All @@ -20,6 +19,7 @@
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

import static io.nop.autotest.core.AutoTestConstants.CFG_GRAPHQL_IGNORE_MILLIS_IN_TIMESTAMP;
import static io.nop.core.unittest.BaseTestCase.setTestConfig;
import static io.nop.ioc.IocConfigs.CFG_IOC_APP_BEANS_CONTAINER_START_MODE;

Expand All @@ -39,6 +39,9 @@ void processTestConfig(ExtensionContext context) {
// 单元测试总是采用lazy模式启动程序
setTestConfig(CFG_IOC_APP_BEANS_CONTAINER_START_MODE, BeanContainerStartMode.ALL_LAZY.name());

// 为了更精确的匹配JSON数据,这里保留Timestamp的毫秒部分
setTestConfig(CFG_GRAPHQL_IGNORE_MILLIS_IN_TIMESTAMP, false);

NopTestConfig config = context.getRequiredTestClass().getAnnotation(NopTestConfig.class);
if (config != null) {
new NopTestConfigProcessor().process(config);
Expand All @@ -49,10 +52,10 @@ void processTestConfig(ExtensionContext context) {
for (NopTestProperty prop : props.value()) {
setTestConfig(prop.name(), prop.value());
}
}else{
} else {
NopTestProperty prop = context.getRequiredTestClass().getAnnotation(NopTestProperty.class);
if(prop != null){
setTestConfig(prop.name(),prop.value());
if (prop != null) {
setTestConfig(prop.name(), prop.value());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3835,6 +3835,12 @@
"java.lang.String"
]
},
{
"name": "parseTime",
"parameterTypes": [
"java.lang.String"
]
},
{
"name": "registerFormatter",
"parameterTypes": [
Expand Down Expand Up @@ -5213,6 +5219,13 @@
"java.lang.String"
]
},
{
"name": "mergeTagSet",
"parameterTypes": [
"java.lang.String",
"java.lang.String"
]
},
{
"name": "methodAdd",
"parameterTypes": [
Expand Down Expand Up @@ -13750,6 +13763,12 @@
"java.lang.String"
]
},
{
"name": "getDialectNameForQuerySpace",
"parameterTypes": [
"java.lang.String"
]
},
{
"name": "getMainTxnGroup",
"parameterTypes": [
Expand All @@ -13760,6 +13779,10 @@
"name": "getNamedQuerySpaces",
"parameterTypes": []
},
{
"name": "getQuerySpaceToDialectMap",
"parameterTypes": []
},
{
"name": "getRegisteredTransaction",
"parameterTypes": [
Expand Down
1 change: 1 addition & 0 deletions nop-cli-core/src/main/resources/nop-vfs-index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
/nop/core/xlib/file.xlib
/nop/core/xlib/filter.xlib
/nop/core/xlib/meta-gen.xlib
/nop/core/xlib/meta-prop.xlib
/nop/dao/beans/dao-defaults.beans.xml
/nop/dao/dialect/db2.dialect.xml
/nop/dao/dialect/default.dialect.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public DefaultConfigProvider(IConfigSource configSource, IConfigValueEnhancer co
super(refs, staticValues);
this.configSource = configSource;
this.configValueEnhancer = configValueEnhancer;
this.configRefs = (Map) refs;
this.configRefs = refs;
this.configValues = configSource.getConfigValues();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public void testApiRequest() {
public void testTimestamp() {
String str = JsonTool.stringify(new Timestamp(System.currentTimeMillis()));
System.out.println(str);
assertTrue(str.length() > 19);

assertEquals(3, JsonTool.serializeToJson(3));
}
Expand Down
Binary file modified nop-file/model/nop-file.orm.xlsx
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@
<column code="BIZ_OBJ_NAME" displayName="对象名" name="bizObjName" precision="200" propId="8"
stdDataType="string" stdSqlType="VARCHAR" i18n-en:displayName="BizObjName"/>
<column code="BIZ_OBJ_ID" displayName="对象ID" name="bizObjId" precision="200" propId="9"
stdDataType="string" stdSqlType="VARCHAR" i18n-en:displayName="BizObjId"/>
stdDataType="string" stdSqlType="VARCHAR" tagSet="var" i18n-en:displayName="BizObjId"/>
<column code="FIELD_NAME" displayName="字段名" name="fieldName" precision="100" propId="10"
stdDataType="string" stdSqlType="VARCHAR" i18n-en:displayName="Field Name"/>
<column code="FILE_HASH" displayName="文件摘要" name="fileHash" precision="200" propId="11"
stdDataType="string" stdSqlType="VARCHAR" i18n-en:displayName="File Hash"/>
<column code="ORIGIN_FILE_ID" comment="原始文件ID,用于跟踪哪些文件是从同一个文件复制而来" displayName="原始文件ID" mandatory="true"
name="originFileId" precision="50" propId="12" stdDataType="string" stdSqlType="VARCHAR"
i18n-en:displayName="Original File ID"/>
tagSet="var" i18n-en:displayName="Original File ID"/>
<column code="IS_PUBLIC" displayName="是否允许公开访问" mandatory="true" name="isPublic" propId="13"
stdDataType="boolean" stdSqlType="BOOLEAN" i18n-en:displayName="Is Public"/>
<column code="DEL_FLAG" displayName="删除标识" domain="delFlag" mandatory="true" name="delFlag" propId="14"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +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
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,ORIGIN_FILE_ID,IS_PUBLIC,DEL_FLAG,CREATED_BY,CREATE_TIME,REMARK
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"data": {
"id": "@var:NopRuleDefinition@ruleId",
"ruleId": "@var:NopRuleDefinition@ruleId",
"ruleName": "testMatrix",
"ruleVersion": 1,
Expand Down Expand Up @@ -57,8 +58,9 @@
"internal": false,
"deprecated": false,
"lazy": false,
"insertable": true,
"updatable": true,
"sortable": false,
"insertable": false,
"updatable": false,
"queryable": false,
"virtual": false,
"published": true,
Expand All @@ -75,8 +77,9 @@
"internal": false,
"deprecated": false,
"lazy": false,
"insertable": true,
"updatable": true,
"sortable": false,
"insertable": false,
"updatable": false,
"queryable": false,
"virtual": false,
"published": true,
Expand Down Expand Up @@ -120,7 +123,6 @@
],
"beforeExecute": null,
"decisionMatrix": "<_>\n <cells>\n <cell pos=\"A1\">\n <outputs>\n <output name=\"result\">\n <valueExpr>1</valueExpr>\n </output>\n </outputs>\n </cell>\n <cell pos=\"B1\">\n <outputs>\n <output name=\"result\">\n <valueExpr>2</valueExpr>\n </output>\n </outputs>\n </cell>\n <cell pos=\"C1\">\n <outputs>\n <output name=\"result\">\n <valueExpr>3</valueExpr>\n </output>\n </outputs>\n </cell>\n <cell pos=\"D1\">\n <outputs>\n <output name=\"result\">\n <valueExpr>4</valueExpr>\n </output>\n </outputs>\n </cell>\n <cell pos=\"A2\">\n <outputs>\n <output name=\"result\">\n <valueExpr>5</valueExpr>\n </output>\n </outputs>\n </cell>\n <cell pos=\"B2\">\n <outputs>\n <output name=\"result\">\n <valueExpr>6</valueExpr>\n </output>\n </outputs>\n </cell>\n <cell pos=\"C2\">\n <outputs>\n <output name=\"result\">\n <valueExpr>7</valueExpr>\n </output>\n </outputs>\n </cell>\n <cell pos=\"D2\">\n <outputs>\n <output name=\"result\">\n <valueExpr>8</valueExpr>\n </output>\n </outputs>\n </cell>\n <cell pos=\"A3\">\n <outputs>\n <output name=\"result\">\n <valueExpr>9</valueExpr>\n </output>\n </outputs>\n </cell>\n <cell pos=\"B3\">\n <outputs>\n <output name=\"result\">\n <valueExpr>10</valueExpr>\n </output>\n </outputs>\n </cell>\n <cell pos=\"C3\">\n <outputs>\n <output name=\"result\">\n <valueExpr>11</valueExpr>\n </output>\n </outputs>\n </cell>\n <cell pos=\"D3\">\n <outputs>\n <output name=\"result\">\n <valueExpr>12</valueExpr>\n </output>\n </outputs>\n </cell>\n <cell pos=\"A4\">\n <outputs>\n <output name=\"result\">\n <valueExpr>13</valueExpr>\n </output>\n </outputs>\n </cell>\n <cell pos=\"B4\">\n <outputs>\n <output name=\"result\">\n <valueExpr>14</valueExpr>\n </output>\n <output name=\"type\">\n <valueExpr> 'A'</valueExpr>\n </output>\n </outputs>\n </cell>\n <cell pos=\"C4\">\n <outputs>\n <output name=\"result\">\n <valueExpr>15</valueExpr>\n </output>\n </outputs>\n </cell>\n <cell pos=\"D4\">\n <outputs>\n <output name=\"result\">\n <valueExpr>16</valueExpr>\n </output>\n </outputs>\n </cell>\n </cells>\n <colDecider>\n <children>\n <child id=\"C1\" label=\"有房\">\n <children>\n <child id=\"C2\" label=\"已婚\">\n <predicate>\n <eq name=\"是否已婚\" value=\"已婚\"/>\n </predicate>\n </child>\n <child id=\"D2\" label=\"未婚\" leafIndex=\"1\">\n <predicate>\n <eq name=\"是否已婚\" value=\"未婚\"/>\n </predicate>\n </child>\n </children>\n <predicate>\n <eq name=\"是否有房\" value=\"@:true\"/>\n </predicate>\n </child>\n <child id=\"F1\" label=\"无房\">\n <children>\n <child id=\"F2\" label=\"已婚\" leafIndex=\"2\">\n <predicate>\n <eq name=\"是否已婚\" value=\"已婚\"/>\n </predicate>\n </child>\n <child id=\"G2\" label=\"未婚\" leafIndex=\"3\">\n <predicate>\n <eq name=\"是否已婚\" value=\"未婚\"/>\n </predicate>\n </child>\n </children>\n <predicate>\n <eq name=\"是否有房\" value=\"@:false\"/>\n </predicate>\n </child>\n </children>\n </colDecider>\n <rowDecider>\n <children>\n <child id=\"A3\" label=\"&lt;20\">\n <children>\n <child id=\"B3\" label=\"男\">\n <predicate>\n <eq name=\"gender\" value=\"@:1\"/>\n </predicate>\n </child>\n <child id=\"B4\" label=\"女\" leafIndex=\"1\">\n <predicate>\n <eq name=\"gender\" value=\"@:2\"/>\n </predicate>\n </child>\n </children>\n <predicate>\n <lt name=\"baseInfo.age\" value=\"@:20\"/>\n </predicate>\n </child>\n <child id=\"A5\" label=\"&lt;30\">\n <children>\n <child id=\"B5\" label=\"男\" leafIndex=\"2\">\n <predicate>\n <eq name=\"gender\" value=\"@:1\"/>\n </predicate>\n </child>\n </children>\n <predicate>\n <lt name=\"baseInfo.age\" value=\"@:30\"/>\n </predicate>\n </child>\n <child id=\"A6\" label=\"&gt;=30\">\n <children>\n <child id=\"B6\" label=\"-\" leafIndex=\"3\">\n <predicate>\n <alwaysTrue/>\n </predicate>\n </child>\n </children>\n <predicate>\n <ge name=\"baseInfo.age\" value=\"@:30\"/>\n </predicate>\n </child>\n </children>\n </rowDecider>\n</_>",
"id": "@var:NopRuleDefinition@ruleId",
"description": null,
"remark": null
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +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-matrix.rule.xlsx,@var:NopFileRecord@filePath,xlsx,binary,15067,,NopRuleDefinition,__TEMP__,importFile,,1,autotest-ref,*,
_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,ORIGIN_FILE_ID,IS_PUBLIC,DEL_FLAG,CREATED_BY,CREATE_TIME,REMARK
A,@var:NopFileRecord@fileId,decision-matrix.rule.xlsx,@var:NopFileRecord@filePath,xlsx,binary,15067,,NopRuleDefinition,@var:NopFileRecord@bizObjId,importFile,,@var:NopFileRecord@originFileId,false,1,autotest-ref,*,
Original file line number Diff line number Diff line change
@@ -1 +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
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,ORIGIN_FILE_ID,IS_PUBLIC,DEL_FLAG,CREATED_BY,CREATE_TIME,REMARK
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"data": {
"id": "@var:NopRuleDefinition@ruleId",
"ruleId": "@var:NopRuleDefinition@ruleId",
"ruleName": "test",
"ruleVersion": 1,
Expand Down Expand Up @@ -49,7 +50,6 @@
],
"beforeExecute": null,
"decisionMatrix": null,
"id": "@var:NopRuleDefinition@ruleId",
"description": null,
"remark": null
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +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,11856,,NopRuleDefinition,__TEMP__,importFile,,1,autotest-ref,*,
_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,ORIGIN_FILE_ID,IS_PUBLIC,DEL_FLAG,CREATED_BY,CREATE_TIME,REMARK
A,@var:NopFileRecord@fileId,decision-tree.rule.xlsx,@var:NopFileRecord@filePath,xlsx,binary,11856,,NopRuleDefinition,@var:NopFileRecord@bizObjId,importFile,,@var:NopFileRecord@originFileId,false,1,autotest-ref,*,
Loading

0 comments on commit c3dd961

Please sign in to comment.