{"id":22207638,"url":"https://github.com/vitorsalgado/puma4j","last_synced_at":"2025-10-13T05:11:10.000Z","repository":{"id":37945925,"uuid":"404795758","full_name":"vitorsalgado/puma4j","owner":"vitorsalgado","description":"Easy and convenient way to load file resources into your tests using only annotations.","archived":false,"fork":false,"pushed_at":"2025-01-27T21:28:22.000Z","size":467,"stargazers_count":4,"open_issues_count":4,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-27T08:49:45.132Z","etag":null,"topics":["java","java-library","junit","junit5-extension","test","testing-tools"],"latest_commit_sha":null,"homepage":"https://search.maven.org/search?q=puma4j","language":"Java","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/vitorsalgado.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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,"zenodo":null},"funding":{"github":["vitorsalgado"]}},"created_at":"2021-09-09T16:35:03.000Z","updated_at":"2024-11-12T22:22:27.000Z","dependencies_parsed_at":"2024-10-19T23:48:27.678Z","dependency_job_id":"8e10fa4d-0ea9-43b8-808c-dc43dcb7d6fb","html_url":"https://github.com/vitorsalgado/puma4j","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/vitorsalgado/puma4j","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitorsalgado%2Fpuma4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitorsalgado%2Fpuma4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitorsalgado%2Fpuma4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitorsalgado%2Fpuma4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vitorsalgado","download_url":"https://codeload.github.com/vitorsalgado/puma4j/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vitorsalgado%2Fpuma4j/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279013696,"owners_count":26085390,"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","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["java","java-library","junit","junit5-extension","test","testing-tools"],"created_at":"2024-12-02T19:13:54.266Z","updated_at":"2025-10-13T05:11:09.985Z","avatar_url":"https://github.com/vitorsalgado.png","language":"Java","funding_links":["https://github.com/sponsors/vitorsalgado"],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003ePuma4j\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"docs/assets/logo.png\" alt=\"Repository Logo\" width='200px' height='200px' /\u003e\n  \u003cbr /\u003e\n  \u003ci\u003eEasy and convenient way to load file resources into your \u003cstrong\u003etests\u003c/strong\u003e using only \u003cstrong\u003eannotations\u003c/strong\u003e.\u003c/i\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/vitorsalgado/puma4j/actions/workflows/ci.yml\"\u003e\n    \u003cimg src=\"https://github.com/vitorsalgado/puma4j/actions/workflows/ci.yml/badge.svg?branch=main\" alt=\"GitHub Action Status\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/vitorsalgado/puma4j\"\u003e\n    \u003cimg src=\"https://codecov.io/gh/vitorsalgado/puma4j/branch/main/graph/badge.svg?token=EFC2SD81AV\" alt=\"Codecov Badge\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://conventionalcommits.org\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Conventional%20Commits-4.0.4-yellow.svg\" alt=\"Conventional Commits\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://sonarcloud.io/project/overview?id=vitorsalgado_puma4j\"\u003e\n    \u003cimg src=\"https://sonarcloud.io/api/project_badges/measure?project=vitorsalgado_puma4j\u0026metric=alert_status\" alt=\"Sonar Quality Gate Status\"/\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://search.maven.org/search?q=io.github.vitorsalgado.puma4j\"\u003e\n    \u003cimg alt=\"Sonatype Nexus (Releases)\" src=\"https://img.shields.io/nexus/r/io.github.vitorsalgado.puma4j/puma4j-junit5-extension?server=https%3A%2F%2Fs01.oss.sonatype.org%2F\"\u003e  \n  \u003c/a\u003e\n\u003c/p\u003e\n\n## Overview\n\nPuma4j provides a convenient and easier way to load and parse file resources in your **JUnit 5** tests using just a couple of **annotations** :)\n\n## Installation \n\n![Java 8](https://img.shields.io/badge/java-8-yellow)\n\nUsing Gradle:\n\n```gradle\ntestImplementation \"io.github.vitorsalgado.puma4j:puma4j-junit5-extension:4.0.4\"\n```\n\nor Maven:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.github.vitorsalgado.puma4j\u003c/groupId\u003e\n  \u003cartifactId\u003epuma4j-junit5-extension\u003c/artifactId\u003e\n  \u003cversion\u003e4.0.4\u003c/version\u003e\n  \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n## How It Works\n\n**Puma4j**, when enabled, detects fields or parameters annotated with `@Res` and inject resource values based on annotated element type, resource extension and\nany custom unmarshaller added.  \nYou can use `String` and `byte[]` for all types of resources.  \nPuma4j is also able to convert some resource types to object type representations:\n\n- Json: Object types based on the json structure. It uses **Jackson ObjectMapper** and **Gson**. Defaults to **Jackson ObjectMapper**\n- Yaml: Object types based on yaml structure. It uses **Jackson ObjectMapper**.\n- Properties: Converts `.properties` files to java `Properties` class.\n\nFor custom **object conversions** use a custom **unmarshaller** using the annotation `@Use`, passing the class type of your custom unmarshaller implementation.\n\n## Usage\n\nFirst, annotate your JUnit 5 test classes with `@UsePuma4j`. Now you can use the annotation `@Res`\nto inject resources on class fields and/or method parameters.  \nTake a look on the complete example below:\n\n```java\n@UsePuma4j\nclass UsageWithJUnit5 {\n\n  @Res(\"data.txt\")\n  private static String staticTextData;\n\n  @Res(\"complex.json\")\n  private List\u003cComplexModel\u003e complexModelList;\n\n  @Res(\"complex-yml.yaml\")\n  private List\u003cComplexModel\u003e complexModelListFromYaml;\n\n  @Res(\"test.properties\")\n  private Properties testProperties;\n\n  @Res(\"simple.json\")\n  @Use(JsonTreeUnmarshaller.class)\n  private JsonNode simpleJsonTree;\n\n  @Test\n  void simpleTest(final @Res(\"simple.json\") SimpleModel model) {\n    assertEquals(50, model.getAge());\n    assertEquals(\"no-one\", model.getName());\n  }\n\n  public static class JsonTreeUnmarshaller implements Unmarshaller\u003cJsonNode\u003e {\n\n    private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();\n\n    @Override\n    public JsonNode unmarshal(final Args args) throws IOException {\n      return OBJECT_MAPPER.readTree(args.getInput());\n    }\n  }\n}\n```\n\n## Features\n\n### Forcing Jackson or Gson\n\nFor **json** files, the default parser is **Jackson ObjectMapper**. If you want to use **Gson** for a specific type use: `@UseGson`. If applied in the class\nlevel, all json conversions will use Gson. You can use `@UseJackson` to keep using Object Mapper on specific resources.\n\n### Custom Unmarshaller\n\nYou can use your custom **unmarshaller** implementation.  \nFirst, create a new class implementing the interface `Unmarshaller\u003cO\u003e`.  \nThen, use the annotation `@Use(YourCustomUnmarshaller.class)` on the class, field or method level to use your new custom unmarshaller.\n\n### Kotlin Delegate\n\nYou can load resources using a Kotlin delegate also. Look the example below:\n\n```kotlin\nprivate val simpleModel: SimpleModel by res(\"simple.json\")\n```\n\nTo use the delegate `res`, add the library below to your project:\n\n```gradle\ntestImplementation \"io.github.vitorsalgado.puma4j:puma4j-kotlin:4.0.4\"\n```\n\n---\n\n## Contributing\n\nSee [CONTRIBUTING](CONTRIBUTING.md) for more details.\n\n## Contributors\n\nThanks goes to these wonderful people ✨:\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable border=\"0\"\u003e\n  \u003ctr\u003e\n    \u003ctd style='border-style: hidden;' align=\"center\"\u003e\u003ca href=\"https://github.com/smunoz2\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/61516534?v=4\" width=\"50px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eSebastián Muñoz Eyquem\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors)\nspecification. Contributions of any kind welcome!\n\n## License\n\nThis project is [MIT Licensed](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitorsalgado%2Fpuma4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvitorsalgado%2Fpuma4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvitorsalgado%2Fpuma4j/lists"}