Analog data generation method, device, equipment and computer readable storage medium

By acquiring the interface documentation, constructing a multi-branch tree, and generating simulated data, the problem of manually writing simulated data is solved, and automated generation and modification are achieved, thus improving development efficiency.

CN110221858BActive Publication Date: 2026-02-17WEBANK (CHINA)
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201910529582.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-06-17
Publication Date
2026-02-17
Estimated Expiration
2039-06-17

AI Technical Summary

Technical Problem

In existing technologies, it is time-consuming and laborious for front-end developers to manually write simulated data, resulting in low efficiency and low front-end development efficiency.

Method used

By obtaining the attribute information of data elements in the interface document, a multi-branch tree is constructed recursively, and simulated data is generated according to the node type. Custom regular expressions and modifications to simulated data are supported, enabling automated generation of simulated data.

Benefits of technology

It eliminates the need for manually writing simulation data, improving development efficiency, saving labor costs, and supporting flexible generation and modification of simulation data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110221858B_ABST
    Figure CN110221858B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of financial technology, and discloses a simulation data generation method, device and equipment and a computer readable storage medium. The simulation data generation method comprises the following steps: acquiring an interface document, wherein the interface document comprises attribute information of data elements; traversing each data element in the interface document in a recursive manner, and constructing a multi-way tree according to a serial number in the attribute information; traversing each node in the multi-way tree, and generating corresponding simulation data according to a type of a currently traversed node and a preset generation rule. The application can solve the problems that manual writing of simulation data is time-consuming and laborious and has low efficiency in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of Fintech, and in particular to a simulation data generation method and device, equipment and a computer readable storage medium. BACKGROUND

[0002] With the development of computer technology, more and more technologies (big data, distributed, Blockchain, artificial intelligence, etc.) are applied in the financial field, and the traditional financial industry is gradually changing to Fintech, but due to the security and real-time requirements of the financial industry, higher requirements are also put forward for the technology.

[0003] In the project development process, since the development of the front end and the back end is parallel, the development of the front end often needs to wait for the completion of the interface of the back end before proceeding with the related development test, thereby resulting in a low development efficiency of the front end. In order to improve the development efficiency of the front end, before development, the front-end and back-end personnel will agree on the corresponding interface document according to the project requirements, wherein the interface document agrees on the structure and type of the data, and the front-end developer can mock the back-end data according to the interface document to proceed with the development test. At present, the front-end personnel usually manually writes mock data according to the interface document, which is time-consuming and laborious and has low efficiency. SUMMARY

[0004] The main purpose of the present application is to provide a simulation data generation method, device, equipment and computer readable storage medium, which aims to solve the problem of manual writing of simulation data in the prior art, which is time-consuming and laborious and has low efficiency.

[0005] To achieve the above-mentioned purpose, the present application provides a simulation data generation method, which comprises:

[0006] Obtaining an interface document, the interface document comprising attribute information of data elements;

[0007] Traversing each data element in the interface document in a recursive manner, and constructing a multi-way tree according to the sequence number in the attribute information;

[0008] Traversing each node in the multi-way tree, and generating corresponding simulation data according to the type of the current traversed node according to a preset generation rule.

[0009] Optionally, each node in the multi-way tree contains attribute information of the corresponding data element, and the step of traversing each node in the multi-way tree and generating corresponding simulation data according to the type of the first current traversed node according to a preset generation rule comprises:

[0010] traversing each node in the multi-way tree, obtaining a response value type in attribute information corresponding to a first current traversed node, and determining a type of the first current traversed node according to the response value type;

[0011] If the type of the first current traversed node is a non-leaf node, an empty array is generated, and the empty array defines returned simulation data as simulation data of branch nodes of the first current traversed node.

[0012] If the type of the first current traversed node is a leaf node, it is detected whether the response value type is a first preset type.

[0013] If the response value type is the first preset type, a response value name in attribute information corresponding to the first current traversed node is obtained, and simulation data of a corresponding type is randomly generated according to the response value name.

[0014] If the response value type is not the first preset type, simulation data of a corresponding type is randomly generated according to the response value type.

[0015] Optionally, before the step of detecting whether the response value type is the first preset type, the method further includes:

[0016] It is detected whether a custom regular sent by a user end is received.

[0017] If the custom regular sent by the user end is not received, the step of detecting whether the response value type is the first preset type is performed.

[0018] If the custom regular sent by the user end is received, the custom regular is obtained, and the custom regular includes a custom node regular and a custom simulation data regular.

[0019] It is detected whether the first current traversed node conforms to the custom node regular according to attribute information corresponding to the first current traversed node.

[0020] If the first current traversed node conforms to the custom node regular, corresponding simulation data is generated according to the custom simulation data regular.

[0021] If the first current traversed node does not conform to the custom node regular, the step of detecting whether the response value type is the first preset type is performed.

[0022] Optionally, the step of determining the type of the first current traversed node according to the response value type includes:

[0023] It is detected whether the response value type is a second preset type.

[0024] If the response value type is a second preset type, it is determined that the type of the first current traversal node is a non-leaf node.

[0025] If the response value type is not the second preset type, it is determined that the type of the first current traversal node is a leaf node.

[0026] Optionally, the simulation data generation method further comprises:

[0027] Upon receiving a simulation data modification instruction, determining the type of the simulation data modification instruction;

[0028] Determining whether the type of the simulation data modification instruction is a simulation data modification type or an interface document modification type;

[0029] If the type of the simulation data modification instruction is the simulation data modification type, obtaining a target modification node and target modification simulation data according to the simulation data modification instruction;

[0030] Querying the target modification node in the multi-way tree and updating the simulation data of the target modification node to the target modification simulation data.

[0031] Optionally, after the step of determining whether the type of the simulation data modification instruction is the simulation data modification type or the interface document modification type, the method further comprises:

[0032] If the type of the simulation data modification instruction is the interface document modification type, obtaining a modified interface document according to the simulation data modification instruction;

[0033] Constructing a new multi-way tree based on the modified interface document and generating corresponding new simulation data;

[0034] Obtaining a previous multi-way tree and its corresponding simulation data, and merging the simulation data of the previous multi-way tree and the new simulation data of the new multi-way tree based on a preset merging rule.

[0035] Optionally, the step of merging the simulation data of the previous multi-way tree and the new simulation data of the new multi-way tree based on the preset merging rule comprises:

[0036] Traversing each node of the previous multi-way tree and detecting whether there is a node identical to a second current traversal node in the new multi-way tree;

[0037] If there is no node identical to the second current traversal node in the new multi-way tree, adding the second current traversal node and its simulation data in the new multi-way tree;

[0038] If the new multi-tree has a node identical to the second current traversal node, the node identical to the second current traversal node in the new multi-tree is recorded as a target identical node, and it is detected whether the simulation data V1 corresponding to the second current traversal node and the simulation data V2 corresponding to the target identical node are both array objects;

[0039] If the V1 and the V2 are not both array objects, the simulation data V2 corresponding to the target identical node in the new multi-tree is updated as the simulation data V1 corresponding to the second current traversal node;

[0040] If the V1 and the V2 are both array objects, the number of branch nodes of the second current traversal node is obtained, and the branch nodes of the target identical node are copied under the target identical node, so that the number of branch nodes under the copied target identical node is the same as the number of branch nodes of the second current traversal node;

[0041] It is detected whether the simulation data V3 corresponding to the branch nodes of the second current traversal node and the simulation data V4 corresponding to the branch nodes under the copied target identical node are both array objects;

[0042] If the V3 and the V4 are not both array objects, the simulation data V4 corresponding to the branch nodes under the copied target identical node in the new multi-tree is updated as the simulation data V3 corresponding to the branch nodes of the second current traversal node in a loop;

[0043] If the V3 and the V4 are both array objects, the simulation data V3 corresponding to the branch nodes of the second current traversal node and the simulation data V4 corresponding to the branch nodes under the copied target identical node are merged in a recursive manner.

[0044] In addition, to achieve the above object, the application further provides a simulation data generation device, which comprises:

[0045] A first acquisition module is configured to acquire an interface document, wherein the interface document comprises attribute information of data elements;

[0046] A first construction module is configured to traverse each data element in the interface document in a recursive manner, and construct a multi-tree according to a serial number in the attribute information;

[0047] A data generation module is configured to traverse each node in the multi-tree, and generate corresponding simulation data according to a type of a current traversal node according to a preset generation rule.

[0048] Further, in order to achieve the above object, the present application also provides a simulation data generation device, comprising a memory, a processor and a simulation data generation program stored in the memory and executable on the processor, wherein the simulation data generation program implements the steps of the simulation data generation method as described above when executed by the processor.

[0049] Further, in order to achieve the above object, the present application also provides a computer readable storage medium, wherein the computer readable storage medium stores a simulation data generation program, wherein the simulation data generation program implements the steps of the simulation data generation method as described above when executed by a processor.

[0050] The present application provides a simulation data generation method, device, equipment and computer readable storage medium, by acquiring an interface document, the interface document comprising attribute information of data elements; traversing each data element in the interface document in a recursive manner, and constructing a multi-way tree according to a serial number in the attribute information of the data elements; traversing each node in the multi-way tree, and generating corresponding simulation data according to a type of a currently traversed node and a preset generation rule. In the above manner, the present application first generates a multi-way tree according to an interface document, and then generates corresponding simulation data, thereby realizing automatic generation of simulation data according to an interface document, and improving development efficiency without manual programming of simulation data by a developer. BRIEF DESCRIPTION OF DRAWINGS

[0051] Figure 1 A device structure schematic diagram of a hardware running environment related to an embodiment of the present application;

[0052] Figure 2 A flowchart of a first embodiment of the simulation data generation method of the present application;

[0053] Figure 3 A description structure schematic diagram of an interface document related to the first embodiment of the present application for an interface;

[0054] Figure 4 A flowchart of a second embodiment of the simulation data generation method of the present application;

[0055] Figure 5 A function module schematic diagram of a first embodiment of the simulation data generation device of the present application.

[0056] The implementation, functional features and advantages of the present application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION

[0057] It should be understood that the specific embodiments described herein are merely intended to explain the present application, and are not intended to limit the present application.

[0058] Reference will now be made to the drawings, in whichFigure 1 , Figure 1 The device structure diagram of the hardware running environment involved in the embodiment of the present application.

[0059] The simulation data generation device can be a smart phone, a PC (Personal Computer), a tablet computer, a portable computer or the like.

[0060] As shown in Figure 1 , the simulation data generation device can include a processor 1001, such as a CPU, a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to realize the connection and communication between the components. The user interface 1003 can include a display screen, an input unit such as a keyboard, and can also include a standard wired interface, a wireless interface. The network interface 1004 can optionally include a standard wired interface, a wireless interface (such as a Wi-Fi interface). The memory 1005 can be a high-speed RAM memory or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 can also be a storage device independent of the aforementioned processor 1001.

[0061] Those skilled in the art can understand that Figure 1 the simulation data generation device structure shown in the above embodiment does not constitute a limitation on the simulation data generation device, and can include more or fewer components than shown, or combine certain components, or different component arrangements.

[0062] As shown in Figure 1 , the memory 1005 as a computer storage medium can include an operating system, a network communication module, a user interface module, and a simulation data generation program.

[0063] In the terminal shown in Figure 1 , the network interface 1004 is mainly used to connect to a background server and communicate data with the background server; the user interface 1003 is mainly used to connect to a client and communicate data with the client; and the processor 1001 can be used to call the simulation data generation program stored in the memory 1005 and execute each step of the following simulation data generation method.

[0064] Based on the above hardware structure, each embodiment of the simulation data generation method of the present application is proposed.

[0065] The present application provides a simulation data generation method.

[0066] Referring to Figure 2 ,Figure 2 A flowchart of a first embodiment of the simulation data generation method of the present application.

[0067] In this embodiment, the simulation data generation method comprises:

[0068] In step S10, an interface document is acquired, the interface document comprising attribute information of data elements;

[0069] The simulation data generation method of this embodiment is implemented by a simulation data generation device, which is exemplified by a server. In this embodiment, the server first acquires an interface document, the interface document comprising attribute information of data elements, wherein the attribute information comprises a sequence number, a response value name and a response value type. It should be noted that, since the interface document in the prior art is generally generated by swagger (an open source software framework) or written by a backend staff, it is difficult to construct simulation data (mock data) of a multi-level nested relationship since the interface document generated by swagger does not maintain the nested level relationship between parameters. Therefore, the interface document adopted in this embodiment is a flat hierarchical structure interface document, which is used to generate simulation data of a multi-level nested relationship. The flat hierarchical structure interface document can be written by a backend staff or automatically generated by related software. The flat hierarchical structure interface document can provide metadata of multiple interfaces, and the description structure of each interface can be simplified as shown in Figure 3 Figure 3 only the description structure of one interface is shown, as shown in Figure 3 RspFields (Response Fields) contains attribute information of multiple data elements, such as a sequence number seq, a response value name name and a response value type FieldType. The sequence number seq is used to indicate the relationship between the data elements, who is the child element of whom, so as to facilitate subsequent construction of a multi-way tree, for example Figure 3 the sequence number of data element 2 in

[0070] In step S20, each data element in the interface document is traversed in a recursive manner, and a multi-way tree is constructed according to the sequence number in the attribute information;

[0071] ​After the interface document is acquired, each data element in the interface document is traversed in a recursive manner, and a multi-way tree is constructed according to the sequence number in the attribute information of the data element. After the construction is completed, the attribute information of each data element is assigned to the data attribute of each node, and correspondingly, each node in the multi-way tree contains the attribute information of the corresponding data element. For the construction process of the multi-way tree, specifically, the root node can be initialized first, and then starting from the root node, each data element is traversed to find the ancestor node of the target node according to the sequence number of each data element in turn. If the ancestor node does not exist, the ancestor node is generated. Otherwise, the next ancestor node is continuously found. The recursion is executed until the target node, and finally the multi-way tree is generated.

[0072] It should be noted that in specific embodiments, the if-else method can also be used for traversal, but compared with if-else traversal, the recursive method for generating the multi-way tree can reduce the algorithm complexity and improve the efficiency. In addition, the recursive method has no requirement for the order of the data field and is more flexible.

[0073] Step S30, each node in the multi-way tree is traversed, and the corresponding simulation data is generated according to the type of the current traversed node according to the preset generation rule.

[0074] After the multi-way tree is constructed, each node in the multi-way tree is traversed, and the corresponding simulation data is generated according to the type of the current traversed node according to the preset generation rule. Specifically, each node in the multi-way tree contains the attribute information of the corresponding data element, and step S30 includes:

[0075] Step a1, each node in the multi-way tree is traversed, the response value type in the attribute information corresponding to the first current traversed node is acquired, and the type of the first current traversed node is determined according to the response value type;

[0076] Each node in the multi-way tree constructed above is traversed first, the response value type in the attribute information corresponding to the first current traversed node is acquired, and the type of the first current traversed node is determined according to the response value type. Wherein, the leaf node is the node without branch node in the multi-way tree, and the non-leaf node is the node with branch node in the multi-way tree, and the step of “determining the type of the first current traversed node according to the response value type” includes:

[0077] Step a11, detecting whether the response value type is a second preset type;

[0078] Step a12, if the response value type is the second preset type, determining that the type of the first current traversed node is a non-leaf node;

[0079] Step a13, if the response value type is not the second preset type, determining that the type of the first current traversal node is a leaf node.

[0080] Step a1, detecting whether the response value type is a second preset type, wherein the second preset type is List (a type used in programming to represent a list).

[0081] If the type of the first current traversal node is a non-leaf node, step a2 is performed: generating an empty array, wherein the empty array defines the returned simulation data as simulation data of branch nodes of the first current traversal node.

[0082] If the type of the first current traversal node is a non-leaf node, an empty array is generated, wherein the empty array defines the returned simulation data as simulation data of branch nodes of the first current traversal node, and the returned simulation data can be an original value or an array object.

[0083] If the type of the first current traversal node is a leaf node, step a3 is performed: detecting whether the response value type is a first preset type.

[0084] If the type of the first current traversal node is a leaf node, it is detected whether the response value type is a first preset type, wherein the first preset type is String (an identifier used in programming to define a string type variable).

[0085] Step a4, if the response value type is the first preset type, obtaining a response value name in attribute information corresponding to the first current traversal node, and randomly generating simulation data of a corresponding type according to the response value name.

[0086] If the response value type is the first preset type, i.e., not String, the response value name can be further subdivided, specifically, a response value name in attribute information corresponding to the first current traversal node is obtained, and simulation data of a corresponding type is randomly generated according to the response value name. For example, if the response value name contains email (mailbox), a random mailbox is generated as simulation data; if the response value name contains mobile (mobile phone), a random mobile phone number is generated as simulation data; if the response value name contains id (code), a random code is generated as simulation data; and if the response value name contains city name (city name), a random city name is generated as simulation data.

[0087] Step a5, if the response value type is not the first preset type, randomly generating simulation data of a corresponding type according to the response value type.

[0088] If the response value type is not the first preset type, i.e., String, then the corresponding type of simulation data is randomly generated according to the response value type. For example, if the response value type is bool (Boolean, used in programming to represent a Boolean variable), then a random Boolean value is generated as simulation data; if the response value type is date (used in programming to represent a date type), then a random date is generated as simulation data; if the response value type is Int (used in programming to represent an integer type variable), then a random integer is generated as simulation data; and if the response value type is BigDecimal (used in programming to represent a large number type), then a random floating point number is generated as simulation data.

[0089] Further, before the above step a3, the following can also be included:

[0090] Step a6, detecting whether a user terminal sent custom regular is received;

[0091] If the user terminal sent custom regular is not received, then step a3 is performed: detecting whether the response value type is the first preset type;

[0092] In this embodiment, to meet the actual needs of users and improve the flexibility of simulation data generation, in this embodiment, the user can previously customize the generation rule of simulation data, i.e., custom regular, in the configuration file through the user terminal, and then send it to the server, and the server can preferentially generate the custom regular specified by the user when generating random data. Therefore, when detecting that the type of the first current traversal node is a leaf node and corresponding simulation data needs to be generated, the user terminal sent custom regular can be detected first.

[0093] If the user terminal sent custom regular is received, then step a7 is performed: obtaining the custom regular, and the custom regular includes custom node regular and custom simulation data regular;

[0094] If it is detected that the user terminal sent custom regular is received, then the corresponding simulation data is preferentially generated using the custom regular. Specifically, the custom regular is obtained first, and the custom regular includes custom node regular and custom simulation data regular. The custom node regular and the custom simulation data regular respectively represent the regular expression for the node and the simulation data previously customized by the user. The regular expression is a logical formula for string operation, which is a "rule string" composed of some specific characters and combinations of these specific characters, and the "rule string" is used to express a filtering logic for a string.

[0095] Step a8, detecting whether the first current traversal node conforms to the self-defined node regular according to the attribute information corresponding to the first current traversal node;

[0096] If the first current traversal node conforms to the self-defined node regular, step a9 is performed: generating corresponding simulation data according to the self-defined simulation data regular;

[0097] After obtaining the self-defined node regular and the self-defined simulation data regular, first, whether the first current traversal node conforms to the self-defined node regular is detected according to the attribute information corresponding to the first current traversal node. If the first current traversal node conforms to the self-defined node regular, corresponding simulation data is generated according to the self-defined simulation data regular. It should be noted that the self-defined node regular and the self-defined simulation data regular can be one-to-one or many-to-one. When the two are one-to-one, and the self-defined node regular and the self-defined simulation data are both one, or when the two are many-to-one, the self-defined node regular is multiple, and the self-defined simulation data is one, it is explained that there is only one set of self-defined node regular and self-defined simulation data. At this time, if the first current traversal node conforms to the self-defined node regular, corresponding simulation data is generated according to the self-defined simulation data regular. When the self-defined node regular and the self-defined simulation data are both multiple, no matter whether the two are one-to-one or many-to-one, at this time, there are multiple sets of self-defined node regular and self-defined simulation data. At this time, if it is detected that the first current traversal node conforms to a self-defined node regular, at this time, corresponding simulation data is generated according to the self-defined simulation data regular corresponding to the self-defined node regular to which the first current traversal node conforms.

[0098] If the first current traversal node does not conform to the self-defined node regular, step a3 is performed: detecting whether the response value type is a first preset type.

[0099] If the first current traversal node does not conform to the self-defined node regular, at this time, the default regular needs to be used to generate simulation data. Specifically, first, whether the response value type is a first preset type is detected, and then subsequent steps are performed according to the detection. The subsequent execution process can refer to the above embodiment, which will not be described here.

[0100] In addition, it should be noted that in the above simulation data generation process, preferably, the corresponding simulation data can be generated by calling the mock.js tool. Of course, in specific embodiments, other tools or self-defined random functions can also be used to generate random simulation data. For example, the Math.random method of Javascript (a direct interpretation type script language) can be used to generate random numbers in a self-defined range as simulation data.

[0101] In the project development process of a bank or other financial institution, after an interface document is obtained, each data element in the interface document is traversed in a recursive manner, and a multi-way tree is constructed according to a serial number in attribute information of the data element; then each node in the multi-way tree is traversed, and corresponding simulation data is generated according to a type of a current traversed node according to the above process, so that the simulation data can be automatically generated according to the interface document, manual writing of the simulation data by a developer is avoided, the human cost of the bank or other financial institution can be saved, and the development efficiency of application development of the bank or other financial institution can be improved.

[0102] The embodiment of the application provides a simulation data generation method, which comprises the following steps: obtaining an interface document, the interface document comprising attribute information of a data element; traversing each data element in the interface document in a recursive manner, and constructing a multi-way tree according to a serial number in the attribute information of the data element; and traversing each node in the multi-way tree, and generating corresponding simulation data according to a type of a current traversed node according to a preset generation rule. In the embodiment of the application, the multi-way tree is intelligently generated according to the interface document, and then the corresponding simulation data is generated, so that the simulation data is automatically generated according to the interface document, manual writing of the simulation data by a developer is avoided, and the development efficiency is improved.

[0103] Further, referring to Figure 4 , Figure 4 The figure is a flowchart of the second embodiment of the simulation data generation method.

[0104] Based on the first embodiment shown in Figure 2 , the simulation data generation method further comprises the following steps after step S30:

[0105] In step S40, when the simulation data modification instruction is received, the type of the simulation data modification instruction is determined.

[0106] In the project development process, the front-end and back-end developers can debug and modify the simulation data. Generally, the front-end developer directly modifies the simulation data, and the back-end developer modifies the interface document and then updates the simulation data. Correspondingly, when the simulation data modification instruction is received, the server first determines the type of the simulation data modification instruction.

[0107] In step S50, it is determined whether the type of the simulation data modification instruction is a simulation data modification type or an interface document modification type.

[0108] After the type of the simulation data modification instruction is determined, it is determined whether the type of the simulation data modification instruction is a simulation data modification type or an interface document modification type.

[0109] If the type of the simulation data modification instruction is the simulation data modification type, step S61 is performed: obtaining a target modification node and target modification simulation data according to the simulation data modification instruction;

[0110] Step S62: querying the target modification node in the multi-way tree, and updating the simulation data of the target modification node to the target modification simulation data.

[0111] If the type of the simulation data modification instruction is the simulation data modification type, the simulation data can be directly modified. Specifically, a target modification node and target modification simulation data are obtained according to the simulation data modification instruction, and then the target modification node is queried in the multi-way tree, and the simulation data of the target modification node is updated to the target modification simulation data.

[0112] If the type of the simulation data modification instruction is the interface document modification type, step S63 is performed: obtaining modified interface documents according to the simulation data modification instruction.

[0113] Step S64: constructing a new multi-way tree based on the modified interface documents, and generating corresponding new simulation data.

[0114] If the type of the simulation data modification instruction is the interface document modification type, a new multi-way tree and corresponding simulation data need to be regenerated according to the modified interface documents. Then, to avoid covering the simulation data of the previous multi-way tree, the simulation data of the new multi-way tree needs to be merged with the simulation data of the previous multi-way tree. Specifically, the modified interface documents are obtained according to the simulation data modification instruction, and then a new multi-way tree is constructed based on the modified interface documents, and corresponding new simulation data is generated. The construction method of the new multi-way tree and the generation method of the new simulation data can refer to the first embodiment, and will not be described here.

[0115] Step S65: obtaining the previous multi-way tree and corresponding simulation data, and merging the simulation data of the previous multi-way tree and the new simulation data of the new multi-way tree based on a preset merging rule.

[0116] After the new multi-way tree is constructed and the corresponding new simulation data is generated, the previous multi-way tree and corresponding simulation data are obtained, and then the simulation data of the previous multi-way tree and the new simulation data of the new multi-way tree are merged based on a preset merging rule.

[0117] The step of "merging the simulation data of the previous multi-way tree and the new simulation data of the new multi-way tree based on a preset merging rule" includes:

[0118] Step b1, traversing each node of the previous multi-tree and detecting whether there is a same node as the second current traversing node in the new multi-tree;

[0119] In the merging process, each node of the previous multi-tree is traversed first, and it is detected whether there is a same node as the second current traversing node in the new multi-tree. It should be noted that whether there is a same node can be detected by detecting whether the response value names in the attribute information corresponding to the nodes are the same.

[0120] If there is no same node as the second current traversing node in the new multi-tree, step b2 is performed: adding the second current traversing node and its simulation data in the new multi-tree;

[0121] If there is no same node as the second current traversing node in the new multi-tree, the second current traversing node and its simulation data need to be added in the new multi-tree.

[0122] If there is a same node as the second current traversing node in the new multi-tree, step b3 is performed: the same node as the second current traversing node in the new multi-tree is recorded as a target same node, and it is detected whether the simulation data V1 corresponding to the second current traversing node and the simulation data V2 corresponding to the target same node are both array objects;

[0123] If there is a same node as the second current traversing node in the new multi-tree, for the convenience of description, the same node as the second current traversing node in the new multi-tree can be recorded as a target same node, and then it is detected whether the simulation data (recorded as V1) corresponding to the second current traversing node and the simulation data (recorded as V2) corresponding to the target same node are both array objects. It can be understood that in the specific implementation process, it is not necessary to record the same node as the second current traversing node in the new multi-tree as a target same node, and in the present embodiment, it is only for the convenience of subsequent description.

[0124] If the V1 and the V2 are not both array objects, step b4 is performed: updating the simulation data V2 corresponding to the target same node in the new multi-tree as the simulation data V1 corresponding to the second current traversing node;

[0125] If the V1 and the V2 are not both array objects, that is, at least one of the V1 and the V2 is a primitive value, at this time, the simulation data V2 corresponding to the target same node in the new multi-tree is updated as the simulation data V1 corresponding to the second current traversing node, that is, V1 covers V2.

[0126] If both V1 and V2 are array objects, step b5 is performed: the number of branch nodes of the second current traversal node is obtained, and the branch nodes under the target same node are copied under the target same node so that the number of branch nodes under the copied target same node is the same as that of the second current traversal node;

[0127] Step b6: whether the simulation data V3 corresponding to the branch nodes of the second current traversal node and the simulation data V4 corresponding to the branch nodes under the copied target same node are both array objects is detected;

[0128] If both V1 and V2 are array objects, the number of branch nodes of the second current traversal node is obtained, and the branch nodes under the target same node are copied under the target same node so that the number of branch nodes under the copied target same node is the same as that of the second current traversal node. Then, each branch node under the second current traversal node and the copied target same node is traversed to detect whether the simulation data (denoted as V3) corresponding to the branch nodes of the second current traversal node and the simulation data (denoted as V4) corresponding to the branch nodes under the copied target same node are both array objects.

[0129] If both V3 and V4 are not array objects, step b7 is performed: the simulation data V4 corresponding to the branch nodes under the copied target same node in the new multi-branch tree is updated to the simulation data V3 corresponding to the branch nodes of the second current traversal node through loop traversal;

[0130] If both V3 and V4 are array objects, step b8 is performed: the simulation data V3 corresponding to the branch nodes of the second current traversal node and the simulation data V4 corresponding to the branch nodes under the copied target same node are merged in a recursive manner.

[0131] If both V3 and V4 are not array objects, i.e., at least one of V3 and V4 is a primitive value, then the simulation data V4 corresponding to the branch nodes under the copied target same node in the new multi-branch tree is updated to the simulation data V3 corresponding to the branch nodes of the second current traversal node through loop traversal, i.e., V3 is used to cover V4. If both V3 and V4 are array objects, the simulation data V3 corresponding to the branch nodes of the second current traversal node and the simulation data V4 corresponding to the branch nodes under the copied target same node are merged in a recursive manner.

[0132] In this embodiment, different methods are used to modify the simulation data for two different modification types, so that automatic modification and update of the simulation data are realized, and developers do not need to manually search and update the simulation data, thereby further improving the development efficiency.

[0133] The application further provides a simulation data generation device.

[0134] Reference Figure 5 , Figure 5 The application further provides a simulation data generation device.

[0135] As Figure 5 shown, the simulation data generation device comprises:

[0136] The first acquisition module 10 is configured to acquire an interface document, wherein the interface document comprises attribute information of a data element;

[0137] The first construction module 20 is configured to traverse each data element in the interface document in a recursive manner, and construct a multi-way tree according to a sequence number in the attribute information;

[0138] The data generation module 30 is configured to traverse each node in the multi-way tree, and generate corresponding simulation data according to a type of a current traversed node according to a preset generation rule.

[0139] Further, each node in the multi-way tree comprises attribute information of a corresponding data element, and the data generation module 30 comprises:

[0140] The type determination unit is configured to traverse each node in the multi-way tree, acquire a response value type in the attribute information corresponding to a first current traversed node, and determine the type of the first current traversed node according to the response value type;

[0141] The first generation unit is configured to generate an empty array if the type of the first current traversed node is a non-leaf node, wherein the empty array defines that the returned simulation data is simulation data of a branch node of the first current traversed node;

[0142] The first detection unit is configured to detect whether the response value type is a first preset type if the type of the first current traversed node is a leaf node;

[0143] The second generation unit is configured to acquire a response value name in the attribute information corresponding to the first current traversed node, and generate simulation data of a corresponding type at random according to the response value name if the response value type is the first preset type;

[0144] The third generation unit is configured to generate simulation data of a corresponding type at random according to the response value type if the response value type is not the first preset type.

[0145] Further, the generating module 30 further comprises:

[0146] a second detection unit, configured to detect whether a custom regular expression sent by the user end is received;

[0147] The first detection unit is specifically configured to, if the custom regular expression sent by the user end is not received, perform the following step: detecting whether the response value type is a first preset type.

[0148] a first acquisition unit, configured to, if the custom regular expression sent by the user end is received, acquire the custom regular expression, the custom regular expression comprising a custom node regular expression and a custom simulation data regular expression;

[0149] a third detection unit, configured to detect, according to attribute information corresponding to the first current traversal node, whether the first current traversal node conforms to the custom node regular expression.

[0150] a fourth generation unit, configured to, if the first current traversal node conforms to the custom node regular expression, generate corresponding simulation data according to the custom simulation data regular expression.

[0151] The first detection unit is further specifically configured to, if the first current traversal node does not conform to the custom node regular expression, perform the following step: detecting whether the response value type is the first preset type.

[0152] Further, the type determination unit is specifically configured to:

[0153] detect whether the response value type is a second preset type;

[0154] if the response value type is the second preset type, determine that the type of the first current traversal node is a non-leaf node;

[0155] if the response value type is not the second preset type, determine that the type of the first current traversal node is a leaf node.

[0156] Further, the simulation data generation apparatus further comprises:

[0157] a type determination module, configured to, when a simulation data modification instruction is received, determine the type of the simulation data modification instruction;

[0158] a type judgment module, configured to judge whether the type of the simulation data modification instruction is a simulation data modification type or an interface document modification type;

[0159] The second obtaining module is configured to, if the type of the simulation data modification instruction is a simulation data modification type, obtain a target modification node and target modification simulation data according to the simulation data modification instruction.

[0160] The data updating module is configured to query the target modification node in the multiway tree, and update simulation data of the target modification node to the target modification simulation data.

[0161] Further, the simulation data generation apparatus further comprises:

[0162] The third obtaining module is configured to, if the type of the simulation data modification instruction is an interface document modification type, obtain a modified interface document according to the simulation data modification instruction.

[0163] The second constructing module is configured to construct a new multiway tree based on the modified interface document, and generate corresponding new simulation data.

[0164] The data merging module is configured to obtain a previous multiway tree and corresponding simulation data thereof, and merge simulation data of the previous multiway tree and new simulation data of the new multiway tree based on a preset merging rule.

[0165] Further, the data merging module comprises:

[0166] The fourth detecting unit is configured to traverse each node of the previous multiway tree, and detect whether there is a same node as a second current traversed node in the new multiway tree.

[0167] The node adding unit is configured to, if there is no same node as the second current traversed node in the new multiway tree, add the second current traversed node and simulation data thereof in the new multiway tree.

[0168] The fifth detecting unit is configured to, if there is a same node as the second current traversed node in the new multiway tree, mark the same node as the second current traversed node in the new multiway tree as a target same node, and detect whether simulation data V1 corresponding to the second current traversed node and simulation data V2 corresponding to the target same node are both array objects.

[0169] The first updating unit is configured to, if the V1 and the V2 are not both array objects, update the simulation data V2 corresponding to the target same node in the new multiway tree to the simulation data V1 corresponding to the second current traversed node.

[0170] a node copying unit, configured to: if the V1 and the V2 are both array objects, acquire a number of branch nodes of the second current traversal node, and copy the branch nodes of the target same node under the target same node, so that the number of the branch nodes under the copied target same node is the same as the number of the branch nodes of the second current traversal node;

[0171] a sixth detection unit, configured to detect whether the simulation data V3 corresponding to the branch nodes of the second current traversal node and the simulation data V4 corresponding to the branch nodes under the copied target same node are both array objects;

[0172] a second updating unit, configured to: if the V3 and the V4 are not both array objects, perform loop traversal, and update the simulation data V4 corresponding to the branch nodes under the copied target same node in the new multi-ary tree to the simulation data V3 corresponding to the branch nodes of the second current traversal node;

[0173] a data merging unit, configured to: if the V3 and the V4 are both array objects, merge the simulation data V3 corresponding to the branch nodes of the second current traversal node and the simulation data V4 corresponding to the branch nodes under the copied target same node in a recursive manner.

[0174] Correspondingly, the function implementation of each module in the simulation data generation apparatus corresponds to each step in the simulation data generation method embodiment, and the function and implementation process will not be described here.

[0175] The application further provides a computer readable storage medium, which stores a simulation data generation program, and the simulation data generation program, when executed by a processor, implements the steps of the simulation data generation method according to any one of the above embodiments.

[0176] The specific embodiments of the computer readable storage medium of the application are basically the same as those of the simulation data generation method embodiments, and will not be described here.

[0177] It should be noted that, in this document, the terms “comprising”, “including”, or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or system including a series of elements not only includes those elements, but also includes other elements not explicitly listed, or further includes elements inherent to such a process, method, article, or system. Without more limitations, the element defined by the statement “including a…” does not exclude the presence of another identical element in the process, method, article, or system including the element.

[0178] The above-mentioned embodiment numbers of the application are only for description, and do not represent the advantages and disadvantages of the embodiments.

[0179] Those skilled in the art can clearly understand the above-mentioned embodiment method can be realized by means of software and necessary general hardware platform, of course, also can be realized by hardware, but in many cases the former is a better embodiment. Based on such understanding, the technical solutions of the present application essentially or say the part of contribution to the prior art can be embodied in the form of software product, the computer software product is stored in a storage medium (such as ROM / RAM, magnetic disc, optical disc) as described above, including a number of instructions to make a terminal device (may be a mobile phone, computer, server, air conditioner, or network equipment, etc.) executes the method described in various embodiments of the present application.

[0180] The above is only the preferred embodiment of the present application, not therefore limit the patent scope of the present application, any equivalent structure or equivalent flow transformation made by using the content of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.

Claims

1. A method of analog data generation, characterized by, The simulation data generation method comprises: obtaining an interface document, the interface document comprising attribute information of data elements, the structure of the interface document being a flat hierarchical structure; traversing each data element in the interface document in a recursive manner, and constructing a multi-way tree according to a sequence number in the attribute information, the sequence number being used to represent the relationship between the data elements; traversing each node in the multi-way tree, and generating corresponding simulation data according to the type of the current traversed node according to a preset generation rule; when a simulation data modification instruction is received, determining the type of the simulation data modification instruction; determining whether the type of the simulation data modification instruction is a simulation data modification type or an interface document modification type; if the type of the simulation data modification instruction is an interface document modification type, obtaining a modified interface document according to the simulation data modification instruction; constructing a new multi-way tree based on the modified interface document, and generating corresponding new simulation data; obtaining a previous multi-way tree and its corresponding simulation data, traversing each node of the previous multi-way tree, and detecting whether there is a node identical to a second current traversed node in the new multi-way tree by detecting whether the response value names in the attribute information of the nodes in the new multi-way tree are identical; if there is no node identical to the second current traversed node in the new multi-way tree, adding the second current traversed node and its simulation data to the new multi-way tree; if there is a node identical to the second current traversed node in the new multi-way tree, marking the node identical to the second current traversed node in the new multi-way tree as a target identical node, and detecting whether the simulation data V1 corresponding to the second current traversed node and the simulation data V2 corresponding to the target identical node are both array objects; if the V1 and the V2 are not both array objects, updating the simulation data V2 corresponding to the target identical node in the new multi-way tree to the simulation data V1 corresponding to the second current traversed node; if the V1 and the V2 are both array objects, obtaining the number of branch nodes of the second current traversed node, and copying the branch nodes of the target identical node under the target identical node so that the number of branch nodes under the copied target identical node is identical to the number of branch nodes of the second current traversed node; detecting whether the simulation data V3 corresponding to the branch nodes of the second current traversed node and the simulation data V4 corresponding to the branch nodes under the copied target identical node are both array objects; if the V3 and the V4 are not both array objects, performing loop traversal to update the simulation data V4 corresponding to the branch nodes under the copied target identical node in the new multi-way tree to the simulation data V3 corresponding to the branch nodes of the second current traversed node; if the V3 and the V4 are both array objects, merging the simulation data V3 corresponding to the branch nodes of the second current traversed node and the simulation data V4 corresponding to the branch nodes under the copied target identical node in a recursive manner.

2. The analog data generation method of claim 1, wherein, The attribute information of the corresponding data element is contained in each node in the multi-ary tree, and the step of traversing each node in the multi-ary tree and generating corresponding simulation data according to the type of the first current traversed node according to a preset generation rule comprises: traversing each node in the multi-ary tree, obtaining the response value type in the attribute information corresponding to the first current traversed node, and determining the type of the first current traversed node according to the response value type; if the type of the first current traversed node is a non-leaf node, an empty array is generated, and the empty array defines the returned simulation data as the simulation data of the branch node of the first current traversed node; if the type of the first current traversed node is a leaf node, it is detected whether the response value type is a first preset type; if the response value type is the first preset type, the response value name in the attribute information corresponding to the first current traversed node is obtained, and simulation data of a corresponding type is randomly generated according to the response value name; if the response value type is not the first preset type, simulation data of a corresponding type is randomly generated according to the response value type.

3. The analog data generation method of claim 2, wherein, Before the step of detecting whether the response value type is the first preset type, the method further comprises: detecting whether a custom regular sent by a user end is received; if the custom regular sent by the user end is not received, the step of detecting whether the response value type is the first preset type is performed; if the custom regular sent by the user end is received, the custom regular is obtained, and the custom regular comprises a custom node regular and a custom simulation data regular; it is detected whether the first current traversed node conforms to the custom node regular according to the attribute information corresponding to the first current traversed node; if the first current traversed node conforms to the custom node regular, corresponding simulation data is generated according to the custom simulation data regular; if the first current traversed node does not conform to the custom node regular, the step of detecting whether the response value type is the first preset type is performed.

4. The analog data generation method of claim 2, wherein, The step of determining the type of the first current traversed node according to the response value type comprises: detecting whether the response value type is a second preset type; if the response value type is the second preset type, it is determined that the type of the first current traversed node is a non-leaf node; if the response value type is not the second preset type, it is determined that the type of the first current traversed node is a leaf node.

5. The analog data generation method of claim 1, wherein, After judging whether the type of the simulation data modification instruction is a simulation data modification type or an interface document modification type, the method further comprises: if the type of the simulation data modification instruction is a simulation data modification type, a target modification node and a target modification simulation data are obtained according to the simulation data modification instruction; the target modification node is queried in the multi-ary tree, and the simulation data of the target modification node is updated to the target modification simulation data.

6. A simulation data generating apparatus characterized by comprising: The simulation data generation device comprises: a first obtaining module configured to obtain an interface document, wherein the interface document comprises attribute information of a data element, and a structure of the interface document is a flat hierarchical structure; The first construction module is configured to traverse each data element in the interface document in a recursive manner, and construct a multi-way tree according to a serial number in the attribute information, the serial number being used to represent a relationship between the data elements; The data generation module is configured to traverse each node in the multi-way tree, and generate corresponding simulation data according to a preset generation rule according to a type of a current traversed node; The type determination module is configured to determine a type of the simulation data modification instruction when the simulation data modification instruction is received. The type judgment module is configured to judge whether the type of the simulation data modification instruction is a simulation data modification type or an interface document modification type. The third acquisition module is configured to acquire a modified interface document according to the simulation data modification instruction if the type of the simulation data modification instruction is the interface document modification type. The second construction module is configured to construct a new multi-way tree based on the modified interface document, and generate corresponding new simulation data. The data merging module is configured to obtain a previous multi-ary tree and corresponding simulation data thereof, traverse each node of the previous multi-ary tree, and detect whether a node identical to a second current traversed node exists in a new multi-ary tree by detecting whether the response value names in the attribute information of the nodes in the new multi-ary tree are identical; if the node identical to the second current traversed node does not exist in the new multi-ary tree, the second current traversed node and the simulation data thereof are added to the new multi-ary tree; if the node identical to the second current traversed node exists in the new multi-ary tree, the node identical to the second current traversed node in the new multi-ary tree is recorded as a target identical node, and it is detected whether the simulation data V1 corresponding to the second current traversed node and the simulation data V2 corresponding to the target identical node are both array objects; if the V1 and the V2 are not both array objects, the simulation data V2 corresponding to the target identical node in the new multi-ary tree is updated to the simulation data V1 corresponding to the second current traversed node; if the V1 and the V2 are both array objects, the number of branch nodes of the second current traversed node is obtained, and the branch nodes of the target identical node are copied under the target identical node so that the number of branch nodes under the copied target identical node is identical to the number of branch nodes of the second current traversed node; it is detected whether the simulation data V3 corresponding to the branch nodes of the second current traversed node and the simulation data V4 corresponding to the branch nodes under the copied target identical node are both array objects; if the V3 and the V4 are not both array objects, the simulation data V4 corresponding to the branch nodes under the copied target identical node in the new multi-ary tree is updated to the simulation data V3 corresponding to the branch nodes of the second current traversed node through a loop; and if the V3 and the V4 are both array objects, the simulation data V3 corresponding to the branch nodes of the second current traversed node and the simulation data V4 corresponding to the branch nodes under the copied target identical node are merged in a recursive manner.

7. A simulation data generating apparatus characterized by comprising: The simulation data generation device comprises a memory, a processor, and a simulation data generation program stored on the memory and executable on the processor, and the simulation data generation program, when executed by the processor, implements the steps of the simulation data generation method according to any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, The simulation data generation program is stored on the computer readable storage medium and, when executed by the processor, implements the steps of the simulation data generation method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Json data analysis method and device and computer readable storage medium

    CN109558128A