Entitymock DSL

From OS.bee documentation
Revision as of 12:39, 30 March 2017 by Yang (Talk | contribs) (Created page with "== Copyright Notice == {{Copyright Notice}} == Documentation == [http://download.osbee.org/downloads/samples/documentation/EntitymockDSL.pdf EntityMockDSL.pdf] ===Introducti...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Copyright Notice

All rights are reserved by Compex Systemhaus GmbH. In particular, duplications, translations, microfilming, saving and processing in electronic systems are protected by copyright. Use of this manual is only authorized with the permission of Compex Systemhaus GmbH. Infringements of the law shall be punished in accordance with civil and penal laws. We have taken utmost care in putting together texts and images. Nevertheless, the possibility of errors cannot be completely ruled out. The Figures and information in this manual are only given as approximations unless expressly indicated as binding. Amendments to the manual due to amendments to the standard software remain reserved. Please note that the latest amendments to the manual can be accessed through our helpdesk at any time. The contractually agreed regulations of the licensing and maintenance of the standard software shall apply with regard to liability for any errors in the documentation. Guarantees, particularly guarantees of quality or durability can only be assumed for the manual insofar as its quality or durability are expressly stipulated as guaranteed. If you would like to make a suggestion, the Compex Team would be very pleased to hear from you.

(c) 2016-2024 Compex Systemhaus GmbH

Documentation

EntityMockDSL.pdf

Introduction

Mock object

In object-oriented programming, mock objects are simulated objects that mimic the behavior of real objects in controlled ways. In a unit test, mock objects can simulate the behavior of complex, real objects and are therefore useful when a real object is impractical or impossible to incorporate into a unit test. Mock objects have the same interface as the real objects they mimic, allowing a client object to remain unaware of whether it is using a real object or a mock object. Many available mock object frameworks allow the programmer to specify which, and in what order, methods will be invoked on a mock object and what parameters will be passed to them, as well as what values will be returned. Thus, the behavior of a complex object such as a network socket can be mimicked by a mock object, allowing the programmer to discover whether the object being tested responds appropriately to the wide variety of states such mock objects may be in.

EntitymockDSL

In our implementation, we use a complex database, which would have to be initialized. If you do hand-entering data one by one, you will waste so much time to build up the volume and variety of data that we need. So we design to generate all mock objects for our database by initialization using entitymockDSL.

The main semantic elements of the EntitymockDSL are:

  • “mock entitymodel” - the root element that contains all the other elements. A model can contain multiple mock entitymodels.
  • “import” declarations - used to import external models or even Java classes.
  • “datainterchanges” - define the imported datainterchange model to fill the mock data.
  • “resources” - define all availabilities of a resource definition. Resources will be used as enum in objects or directly in the definition of mock entities.
  • “objects” - contains consistent information for some kind of object definition. Objects are used as template for mock entities.
  • “mock entities” - define the mocking rules of entities.

Syntax

Mock entitymodel