{"id":15134424,"url":"https://github.com/mrtimeey/java-live-templates","last_synced_at":"2025-10-23T11:30:27.688Z","repository":{"id":56165734,"uuid":"290514455","full_name":"MrTimeey/java-live-templates","owner":"MrTimeey","description":"A set of java live templates for use with JetBrains IDEs.","archived":false,"fork":false,"pushed_at":"2021-02-25T14:28:54.000Z","size":726,"stargazers_count":19,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-30T17:38:43.500Z","etag":null,"topics":["intellij","intellij-idea","java","jetbrains","live-templates"],"latest_commit_sha":null,"homepage":"","language":null,"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/MrTimeey.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":"2020-08-26T14:10:25.000Z","updated_at":"2024-09-18T09:39:48.000Z","dependencies_parsed_at":"2022-08-15T14:00:19.952Z","dependency_job_id":null,"html_url":"https://github.com/MrTimeey/java-live-templates","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrTimeey%2Fjava-live-templates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrTimeey%2Fjava-live-templates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrTimeey%2Fjava-live-templates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrTimeey%2Fjava-live-templates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrTimeey","download_url":"https://codeload.github.com/MrTimeey/java-live-templates/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237811515,"owners_count":19370144,"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":["intellij","intellij-idea","java","jetbrains","live-templates"],"created_at":"2024-09-26T05:20:36.841Z","updated_at":"2025-10-23T11:30:22.357Z","avatar_url":"https://github.com/MrTimeey.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Custom Live Templates for Java\n\nThese are my custom [IntelliJ IDEA Live Templates](https://www.jetbrains.com/help/idea/using-live-templates.html) for Java that i'm currently using.\n\nI thought some of them might be helpful for others so i shared them. If you got other cool custom Java live templates which you want to share, feel free to contribute!\n\n## Export and Import\nAll these custom live templates are placed in a custom group. According to [sharing live templates](https://www.jetbrains.com/help/idea/sharing-live-templates.html) I've selected only the live templates and created an export. You can import these settings if you want to get all these templates. \nFurthermore I've added the templates config file from the IDEA settings. Copy this file to your IDEA settings directory and you are ready to go.\n\nIf you just want to add a single live template you can also create it manually.\n\n## Java\nThe live templates are all applicable in Java classes.\n\n### JUnit Test Method\nSimple test method generation with imported `assertThat` from AssertJ.\n\n![Generate simple test method](test_method/example.gif)\n\nAbbreviation: __test__\nTemplate text:\n```\n@org.junit.jupiter.api.Test\nvoid test$Function$() throws java.io.IOException {\n    org.assertj.core.api.Assertions.assertThat(\"\").isEqualTo(\"false\");\n}\n```\nOptions:\n- [x] Reformat according to style\n- [x] Use static import if possible\n- [x] Shorten FQ names\n\n### JUnit Test Method with MockMvc\nTest method generation with imported `MockMvc` from Spring.\n\n![Generate mockmvc test method](test_mvc_method/example.gif)\n\nAbbreviation: __testmvc__\nTemplate text:\n```\n@org.springframework.beans.factory.annotation.Autowired\nprivate org.springframework.test.web.servlet.MockMvc mockMvc;\n\n@org.junit.jupiter.api.Test\nvoid test$Function$() throws java.lang.Exception {\n    org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder request = org.springframework.test.web.servlet.request.MockMvcRequestBuilders\n            .get(\"\")\n            .contentType(org.springframework.http.MediaType.APPLICATION_JSON);\n\n    mockMvc.perform(request)\n            .andExpect(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status().isOk())\n            .andExpect(org.springframework.test.web.servlet.result.MockMvcResultMatchers.content().contentType(org.springframework.http.MediaType.APPLICATION_JSON))\n            .andExpect(org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath(\"\", org.hamcrest.Matchers.is(\"\")));\n}\n```\nOptions:\n- [x] Reformat according to style\n- [ ] Use static import if possible\n- [x] Shorten FQ names\n\n### Create SLF4J-Logger\nCreates SLF4J logger and adds the static imports.\n\n![Generate simple test method](slf4j_logger/example.gif)\n\nAbbreviation: __log__\n\nTemplate text:\n```java\nprivate static final org.slf4j.Logger LOGGER = org.slf4j.LoggerFactory.getLogger($CLASS$.class);\n```\nOptions:\n- [x] Reformat according to style\n- [ ] Use static import if possible\n- [x] Shorten FQ names\n\n### Load file from resources directory (for test)\nLoad a file from resources directory. Often used in tests to load expected data or other files.\nDo not use in production code because it will result into an ``IllegalArgumentException``.\n\n![Load resource file](test_resource_file/example.gif)\n\nAbbreviation: __testfile__\n\nTemplate text:\n```\njava.net.URL resource = getClass().getResource(\"$Function$\");\njava.nio.file.Path filePath = java.nio.file.Paths.get(resource.toURI());\n```\nOptions:\n- [x] Reformat according to style\n- [ ] Use static import if possible\n- [x] Shorten FQ names\n\n### Load byte[] from resources directory \nLoads byte[] from resources directory. \n\n![Load bytes from resource file](load_bytes/example.gif)\n\nAbbreviation: __bytesfile__\n\nTemplate text:\n```\ntry (java.io.InputStream is = getClass().getClassLoader().getResourceAsStream(\"$Function$\")) {\n    byte[] bytes = is.readAllBytes();\n}\n```\nOptions:\n- [x] Reformat according to style\n- [ ] Use static import if possible\n- [x] Shorten FQ names\n\n\n### Create UUID for Spring Data Entity\nCreates ID field for entity class which will be auto generated as UUID.\n\n![Generate UUID id field for entity](entity_uuid/example.gif)\n\nAbbreviation: __id__\n\nTemplate text:\n```\n@javax.persistence.Id\n@javax.persistence.GeneratedValue(generator = \"system-uuid\")\n@org.hibernate.annotations.GenericGenerator(name = \"system-uuid\", strategy = \"uuid\")\nprivate String id;\n\n\n```\nOptions:\n- [x] Reformat according to style\n- [ ] Use static import if possible\n- [x] Shorten FQ names\n\nApplicable: Java - declartion\n\n## Contributing\nWant to add some more live templates? Send a pull request or open a ticket!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrtimeey%2Fjava-live-templates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrtimeey%2Fjava-live-templates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrtimeey%2Fjava-live-templates/lists"}