{"id":25776312,"url":"https://github.com/LMAX-Exchange/Simple-DSL","last_synced_at":"2025-02-27T06:06:00.488Z","repository":{"id":8056714,"uuid":"9468248","full_name":"LMAX-Exchange/Simple-DSL","owner":"LMAX-Exchange","description":"Utilities to write a simple DSL in Java","archived":false,"fork":false,"pushed_at":"2023-07-21T12:55:01.000Z","size":497,"stargazers_count":71,"open_issues_count":5,"forks_count":28,"subscribers_count":34,"default_branch":"master","last_synced_at":"2025-02-19T20:51:45.161Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LMAX-Exchange.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-04-16T08:46:00.000Z","updated_at":"2025-02-11T09:20:33.000Z","dependencies_parsed_at":"2024-11-19T21:46:58.763Z","dependency_job_id":null,"html_url":"https://github.com/LMAX-Exchange/Simple-DSL","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LMAX-Exchange%2FSimple-DSL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LMAX-Exchange%2FSimple-DSL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LMAX-Exchange%2FSimple-DSL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LMAX-Exchange%2FSimple-DSL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LMAX-Exchange","download_url":"https://codeload.github.com/LMAX-Exchange/Simple-DSL/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240987435,"owners_count":19889333,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-27T06:01:21.360Z","updated_at":"2025-02-27T06:06:00.482Z","avatar_url":"https://github.com/LMAX-Exchange.png","language":"Java","funding_links":[],"categories":["测试"],"sub_categories":[],"readme":"Simple-DSL\n==========\n\n[![Java CI with Gradle](https://github.com/LMAX-Exchange/Simple-DSL/workflows/Java%20CI%20with%20Gradle/badge.svg)](https://github.com/LMAX-Exchange/Simple-DSL/actions?query=workflow%3A%22Java+CI+with+Gradle%22)\n[![CodeQL](https://github.com/LMAX-Exchange/Simple-DSL/workflows/CodeQL/badge.svg?branch=master)](https://github.com/LMAX-Exchange/Simple-DSL/actions?query=workflow%3ACodeQL)\n[![License](https://img.shields.io/github/license/LMAX-Exchange/Simple-DSL)](https://github.com/LMAX-Exchange/Simple-DSL/blob/master/LICENCE.txt)\n\n\nSimple-DSL is a style for writing acceptance tests used at LMAX Exchange that aims to balance human and machine readability. The intention is that developers and non-developers alike can easily read\nand understand an acceptance test, and developer IDEs can understand enough of an acceptance test to support useful, but not necessarily comprehensive searching, refactoring and name completion.\n\nThe Simple-DSL library provides one component of the DSL for writing acceptance tests - focusing on parsing arguments to methods. The rest of the DSL is heavily\ndependent on the system under test but the [wiki](https://github.com/LMAX-Exchange/Simple-DSL/wiki) provides a number of patterns that have proven successful in\nbuilding DSLs that stand the test of time.\n\n\n### Example\n\nA simple test case for placing an order on an exchange might look like:\n\n```java\npackage com.lmax.exchange.acceptance.test.api;\n\nimport com.lmax.exchange.acceptance.dsl.DslTestCase;\nimport org.junit.Before;\nimport org.junit.Test;\n\npublic class PlaceOrderAcceptanceTest extends DslTestCase\n{\n    @Before\n    public void setup()\n    {\n        adminAPI.createInstrument(\"name: FTSE100\");\n        registrationAPI.createUser(\"Bob\");\n\n        publicAPI.login(\"Bob\");\n    }\n\n    @Test\n    public void shouldReceiveCancellationMessageAfterCancellingAnOrder()\n    {\n        publicAPI.placeOrder(\"FTSE100\", \"side: buy\", \"quantity: 10\", \"price: 5000\", \"expectedStatus: UNMATCHED\");\n    }\n}\n```\n\nThe top level variables \u003ccode\u003eadminAPI\u003c/code\u003e, \u003ccode\u003eregistrationAPI\u003c/code\u003e and \u003ccode\u003epublicAPI\u003c/code\u003e are provided by the \u003ccode\u003eDslTestCase\u003c/code\u003e class and represent three key gateways different\ntypes of users use to access the system. This is the type of test that results from applying the various patterns described on the [wiki](https://github.com/LMAX-Exchange/Simple-DSL/wiki). However,\nthe Simple-DSL library is focused on verifying and parsing the string arguments that are passed to each method. The implementation of publicAPI.placeOrder would look something like:\n\n```java\npublic void placeOrder(String... args) {\n    DslParams params = new DslParams(args,\n                                     new RequiredParam(\"instrument\"),\n                                     new RequiredParam(\"side\").setAllowedValues(\"buy\", \"sell\"),\n                                     new RequiredParam(\"quantity\"),\n                                     new OptionalParam(\"price\"),\n                                     new OptionalParam(\"expectedStatus\").setAllowedValues(\"REJECTED\", \"UNMATCHED\", \"MATCHED\").setDefault(\"MATCHED\"));\n\n    long instrumentId = testContext.getInstrumentId(params.value(\"instrument\"));\n    BigDecimal quantity = params.valueAsBigDecimal(\"quantity\");\n    boolean buy = params.value(\"side\").equals(buy);\n    PublicApiDriver driver = getDriver();\n    String orderId = driver.placeOrder(instrumentId, quantity, buy);\n    driver.waitForOrderStatus(orderId, params.value(\"expectedStatus\"));\n}\n```\n\nCreating the \u003ccode\u003eDslParams\u003c/code\u003e object defines which parameters are accepted by the method, which are required, what values are allowed and any default values. The \u003ccode\u003eparams\u003c/code\u003e object\ncan then be used to retrieve the values in a variety of forms and uses the driver layer to interact with the system under test to actually place the order. If the steps required to place an order\nchange in the future, the driver or the way this method uses it can be adapted without needing to change every test that places an order.\n\n### Other Resources\n\n * The [wiki](https://github.com/LMAX-Exchange/Simple-DSL/wiki) provides further examples and patterns to build out a DSL using Simple-DSL.\n * The [Testing@LMAX series](https://www.symphonious.net/testing-at-lmax/) provides further detail on the approach we take to testing.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLMAX-Exchange%2FSimple-DSL","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FLMAX-Exchange%2FSimple-DSL","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FLMAX-Exchange%2FSimple-DSL/lists"}