{"id":15596201,"url":"https://github.com/cdimascio/couchinator-java-wrapper","last_synced_at":"2025-03-29T11:28:42.434Z","repository":{"id":57732731,"uuid":"157115592","full_name":"cdimascio/couchinator-java-wrapper","owner":"cdimascio","description":" Fixtures for CouchDB and IBM Cloudant.","archived":false,"fork":false,"pushed_at":"2018-12-06T23:41:01.000Z","size":506,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-04T10:57:33.552Z","etag":null,"topics":["cloudant","couchdb","fixtures","test-fixtures","testing"],"latest_commit_sha":null,"homepage":"","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/cdimascio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-11T19:56:06.000Z","updated_at":"2021-02-23T23:32:42.000Z","dependencies_parsed_at":"2022-09-26T22:11:08.485Z","dependency_job_id":null,"html_url":"https://github.com/cdimascio/couchinator-java-wrapper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdimascio%2Fcouchinator-java-wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdimascio%2Fcouchinator-java-wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdimascio%2Fcouchinator-java-wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdimascio%2Fcouchinator-java-wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cdimascio","download_url":"https://codeload.github.com/cdimascio/couchinator-java-wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246177372,"owners_count":20735957,"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":["cloudant","couchdb","fixtures","test-fixtures","testing"],"created_at":"2024-10-03T01:02:12.119Z","updated_at":"2025-03-29T11:28:42.415Z","avatar_url":"https://github.com/cdimascio.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# couchinator-java-wrapper\n\n![](https://travis-ci.org/cdimascio/couchinator-java-wrapper.svg?branch=master)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/67edd40fa18644d3b86b36d7f44ea258)](https://www.codacy.com/app/cdimascio/couchinator-java-wrapper?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=cdimascio/couchinator-java-wrapper\u0026amp;utm_campaign=Badge_Grade)\n![](https://img.shields.io/badge/license-MIT-blue.svg)\n\nFixtures for [CouchDB](http://couchdb.apache.org/) and [IBM Cloudant](https://www.ibm.com/cloud/cloudant).\n\n_Setup_ and _teardown_ cloudant databases with ease. Couchinator is a great tool for unit testing and more. Couchinator is both a library and a [command line utility](https://github.com/cdimascio/couchinator).\n\n\u003cp align=\"center\"\u003e\n\t\u003cimage src=\"https://raw.githubusercontent.com/cdimascio/couchinator-java-wrapper/master/assets/couchinator-java-wrapper.png\" width=\"600\" /\u003e\n\u003c/p\u003e\n\nThe project is a Java wrapper around [couchinator](https://github.com/cdimascio/couchinator), thus it requires Node.js.\n\n## Install\n\n### Prequisites\n\n- [Node.js](https://nodejs.org/) 8.x or greater\n\n### Maven\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.github.cdimascio\u003c/groupId\u003e\n    \u003cartifactId\u003ecouchinator-java-wrapper\u003c/artifactId\u003e\n    \u003cversion\u003e2.0.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Gradle\n\n```groovy\ncompile 'io.github.cdimascio:couchinator-java-wrapper:2.0.1'\n```\n\n### Import\n\n```java\nimport io.github.cdimascio.couchinatorw.Couchinator;\n```\n\n## Usage\n\n```java\nCouchinator couchinator = Couchinator.build()\n// or \nCouchinator couchinator = Couchinator\n\t.configure\n\t.url(\"\u003cYOUR_COUCHDB_URL\u003e\")\n\t.resources(\"./my-fixtures\")\n\t.affectDesignDocsOnly(true)\n\t.build()\n\n// Setup the databases and fixtures defined in your data layout\ncouchinator.create();\n\n// Teardown, then setup the databases and fixtures defined in your data layout\ncouchinator.reCreate();\n\n// Teardown the database defined in your data layout\ncouchinator.destroy();\n```\n\n**Note:** Couchinator will only setup and destroy databases defined in your data layout.\n\n### Junit Example\n\n```java\n@TestInstance(TestInstance.Lifecycle.PER_CLASS)\nclass ExampleUnitTest {\n    private Couchinator couchinator = Couchinator\n\t\t.configure()\n\t\t.url(\"http://localhost:5984\")     // couchdb or cloudant url (include usename/password)\n\t\t.resources(\"./src/test/resources/fixtures\")  // fixtures resource location\n\t\t.build();\n\n    @BeforeAll\n    void beforeAll() throws CouchinatorException{\n    \t// setup the dbs defined in your data layout\n        couchinator.create();\n    }\n\n    @Test\n    public void doStuff() {\n        assertNotNull(\"test stuff\");\n    }\n\n    @AfterAll\n    void afterAll() throws CouchinatorException{\n        // teardown the dbs defined in your data layout\n        couchinator.destroy();\n    }\n}\n```\n\n## Data Layout\n\nThe following sections describe how to create a data layout.\n\nTo skip directly to a working example, go [here](https://github.com/cdimascio/couchinator/blob/master/examples/db-resources)\n\n### Getting Started\n\nCouchinator enables you to represent CouchDB and Cloudant database(s) using a simple filesystem structure that mimics the actual database structure.\n\nA couchinator filesystem data layout might look as such:\n\n\n```shell\nusers\n    _design\n        students.json\n\t teachers.json\n    students-docs.json\n    teachers-docs.json\nclassrooms\n    _design\n        classrooms.json\n        classrooms-docs.json\n```\n\n### Create a data layout representing 2 databases\n\nLet's create a data layout to describe two databases **users** and **classrooms**\n\n1. **Create two folders, one for `users` and another for `classrooms`.**\n\n\t```shell\n\tusers/\n\tclassrooms/\n\t```\n\t**Note:** Couchinator will use the folder name as the database name\n\n2. **Within each folder _optionally_ create a `_design` folder to store any design documents**\n\n\t```shell\n\tusers/\n\t    _design/\n\tclassrooms/\n\t    _design/\n\t```\n\n3. **Create design document(s) and store them in the appropriate `_design` folder**\n\n   In the example below, we create two design documents in the `schools` database and one in the `users` database.\n\n\t```shell\n\tusers/\n\t    _design/\n\t        students.json\n\t        teachers.json\n\tclassrooms/\n\t    _design/\n\t        classrooms.json\n\t```\n\n\tThe contents of each design document `.json` must be a valid CouchDB [design document]([design document](http://docs.couchdb.org/en/2.0.0/json-structure.html#design-document)).\n\t\n\tFor example, `students.json`:\n\t\n   ```json\n   {\n     \"_id\": \"_design/students\",\n     \"views\": {\n       \"byId\": {\n          \"map\": \"function (doc) {  \n\t      if (doc.type === 'student') {\n\t          emit(doc._id, doc);\n\t      }\n          }\"\n       }\n     },\n     \"language\": \"javascript\"\n   }\n   ```\n\n4. **Create the data to store in each database**\n\n\t- Data must be stored using CouchDB's [bulk document](http://docs.couchdb.org/en/2.0.0/json-structure.html#bulk-documents) format\n\t- The data may be stored in a _single_ JSON file or spread across _multiple_ JSON files (useful for organizing data)\n\n\t```shell\n\tusers/\n\t    _design/\n\t        students.json\n\t        teachers.json\n\t    students-docs.json   # contains student data\n\t    teachers-docs.json   # contains teacher data\n\t\n\tclassrooms/\n\t    _design/\n\t        classrooms.json\n\t    users-docs.json\n\t```\n\t\n\n   For example, `student-docs.json` contains students\n\n   ```json\n   {\n     \"docs\": [\n       {\n         \"_id\": \"sam895454857\",\n         \"name\": \"Sam C.\",\n         \"type\": \"student\"\n       },\n       {\n         \"_id\": \"josie895454856\",\n         \"name\": \"Josie D.\",\n         \"type\": \"student\"\n       }\n     ]\n   }\n   ```\n\n5. **Run couchinator to create each database**\n\nSee [Junit example](#junit-example)\n\n## Integrating with Travis\n\ncouchinator-java-wrapper wraps [couchinator](https://github.com/cdimascio/couchinator), a Node.js based tool, hence to Node.js must be installed in the running environment.\n\n```yaml\nlanguage: java\njdk:\n- oraclejdk8\n \nbefore_install:\n- nvm install 10 # install node.js\n\nscript:\n# do stuff\n# ...\n```\t\n\n## License\n\n[Apache 2.0](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdimascio%2Fcouchinator-java-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcdimascio%2Fcouchinator-java-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdimascio%2Fcouchinator-java-wrapper/lists"}