{"id":26796661,"url":"https://github.com/disc99/hogan","last_synced_at":"2025-04-22T20:18:47.903Z","repository":{"id":36176228,"uuid":"40480349","full_name":"disc99/hogan","owner":"disc99","description":"Hogan is the utility library which allows you to access DB intuitively.","archived":false,"fork":false,"pushed_at":"2017-02-17T15:56:47.000Z","size":135,"stargazers_count":5,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-22T20:18:44.039Z","etag":null,"topics":["dsl","groovy","java","sql","testing"],"latest_commit_sha":null,"homepage":"","language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/disc99.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-10T12:04:53.000Z","updated_at":"2023-04-25T08:44:23.000Z","dependencies_parsed_at":"2022-08-18T14:21:35.942Z","dependency_job_id":null,"html_url":"https://github.com/disc99/hogan","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/disc99%2Fhogan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/disc99%2Fhogan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/disc99%2Fhogan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/disc99%2Fhogan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/disc99","download_url":"https://codeload.github.com/disc99/hogan/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250316071,"owners_count":21410477,"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":["dsl","groovy","java","sql","testing"],"created_at":"2025-03-29T18:28:45.580Z","updated_at":"2025-04-22T20:18:47.867Z","avatar_url":"https://github.com/disc99.png","language":"Groovy","readme":"# Hogan\n\n![Hogan Image](https://raw.githubusercontent.com/wiki/disc99/hogan/images/hogan.png)\n\n[![MIT license](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)\n[![Download](https://api.bintray.com/packages/disc99/maven/hogan/images/download.svg) ](https://bintray.com/disc99/maven/hogan/_latestVersion)\n[![Build Status](https://travis-ci.org/disc99/hogan.svg?branch=master)](https://travis-ci.org/disc99/hogan)\n[![Coverage Status](https://coveralls.io/repos/github/disc99/hogan/badge.svg?branch=master)](https://coveralls.io/github/disc99/hogan?branch=master)\n\nHogan is the utility library which allows you to access DB intuitively.\n\n\n## Description\nAs you know, DB processing needs boilerplate code.\u003cbr\u003e\nHogan expresses data structure with Spock like DSL (known as \"data table DSL\").\u003cbr\u003e\nThat's why you can access DB intuitively.\n\n## Features\n- Insert multiple tables\n- Assert multiple tables (@Beta)\n\n\n## Usage\n### Add dependency\nAt first, please add following dependency and repository.\n\n```groovy\ndependencies {\n  testCompile \"io.disc99:hogan:0.9.2\"\n}\nrepositories {\n  jcenter()\n}\n```\n### Enable Hogan DSL\nThere are two ways to enable Hogan DSL.\u003cbr\u003e\nOne way is to create subclass of `Specification`.\u003cbr\u003e\nThe other way is to add `@EnableHogan` annotation to the target class.\n\n### Create `Database` instance\nCreate `Database` class which processes DB access.\u003cbr\u003e\nConstractor of `Database` is a deregater to create `groovy.sql.Sql`(new Sql or Sql.newInstance).\u003cbr\u003e\nIf you need more information, check the following link.\u003cbr\u003e\n[`groovy.sql.Sql`](http://docs.groovy-lang.org/docs/latest/html/gapi/groovy/sql/Sql.html)\n\n```groovy\nDatabase db = new Database(\"jdbc:h2:mem:\", \"org.h2.Driver\")\n```\n\n### Feature: insert\nDescribe table name whith label, and execute SQL each of it.\u003cbr\u003e\nExecute 'Insert' according to the table definition.\u003cbr\u003e\nAnd of cource you can deal with the number of labels.\n\n```groovy\nclass HoganSpec extends Specification {\n  def test() {\n    setup:\n    db.insert {\n      item_master:\n      id | name     | price\n      1  | 'Apple'  | 500\n      2  | 'Orange' | 250\n\n      sales:\n      id | day          | item_id | num\n      1  | '2015-04-01' | 1       | 3\n      2  | '2015-04-02' | 2       | 1\n      3  | '2015-04-02' | 1       | 2\n    }\n\n    expect:\n    // ...\n  }\n}\n```\n\nFollowings are acutual executed SQL.\n\n```sql\nINSERT INTO ITEM_MASTER (ID, NAME, PRICE) VALUES (1, 'Apple', 500)\nINSERT INTO ITEM_MASTER (ID, NAME, PRICE) VALUES (2, 'Orange', 250)\nINSERT INTO SALES (ID, DAY, ITEM_ID, NUM) VALUES (1, '2015-04-01', 1, 3)\nINSERT INTO SALES (ID, DAY, ITEM_ID, NUM) VALUES (2, '2015-04-02', 2, 1)\nINSERT INTO SALES (ID, DAY, ITEM_ID, NUM) VALUES (3, '2015-04-02', 1, 2)\n```\n\n### Feature: assert (@Beta)\nAssert to the table according to the definition.\u003cbr\u003e\nAnd undefined columns will be ignored.\n\n```groovy\nclass HoganSpec extends Specification {\n  def test() {\n    when:\n    // ...\n\n    then:\n    db.assert {\n      item_master:\n      id  | name\n      100 | 'Banana'\n      101 | 'Pine'\n    }\n  }\n}\n```\n\nYou will get following message when there's any discard.\n\n```\nassert actual == expected\n       |      |  |\n       |      |  [[ID:100, NAME:Banana], [ID:101, NAME:Pine]]\n       |      false\n       [[ID:100, NAME:Banana], [ID:101, NAME:Pineapple]]\n```\n\n## License\n[MIT License](https://github.com/disc99/hogan/blob/master/LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdisc99%2Fhogan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdisc99%2Fhogan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdisc99%2Fhogan/lists"}