Skip to content

Commit

Permalink
Added template for resource file
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTimeey committed Oct 1, 2020
1 parent 4a13db8 commit be5f2d2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Simple test method generation with imported `assertThat` from AssertJ.

Abbreviation: __test__
Template text:
```java
```
@org.junit.jupiter.api.Test
public void test$Function$() {
org.assertj.core.api.Assertions.assertThat("").isEqualTo("false");
Expand All @@ -38,7 +38,7 @@ Test method generation with imported `MockMvc` from Spring.

Abbreviation: __testmvc__
Template text:
```java
```
@org.springframework.beans.factory.annotation.Autowired
private org.springframework.test.web.servlet.MockMvc mockMvc;
Expand Down Expand Up @@ -75,6 +75,24 @@ Options:
- [ ] Use static import if possible
- [x] Shorten FQ names

### Load file from resources directory
Load a file from resources directory. Often used in tests to load expected data or other files.

![Load resource file](resource_file/example.gif)

Abbreviation: __resfile__

Template text:
```
java.net.URL resource = getClass().getResource("$Function$");
java.nio.file.Path filePath = java.nio.file.Paths.get(resource.toURI());
```
Options:
- [x] Reformat according to style
- [ ] Use static import if possible
- [x] Shorten FQ names


### Create UUID for Spring Data Entity
Creates ID field for entity class which will be auto generated as UUID.

Expand All @@ -83,7 +101,7 @@ Creates ID field for entity class which will be auto generated as UUID.
Abbreviation: __id__

Template text:
```java
```
@javax.persistence.Id
@javax.persistence.GeneratedValue(generator = "system-uuid")
@org.hibernate.annotations.GenericGenerator(name = "system-uuid", strategy = "uuid")
Expand Down
6 changes: 6 additions & 0 deletions custom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,10 @@
<option name="JAVA_CODE" value="true" />
</context>
</template>
<template name="resfile" value="java.net.URL resource = getClass().getResource(&quot;$Function$&quot;);&#10;java.nio.file.Path filePath = java.nio.file.Paths.get(resource.toURI());" description="Get file from resources" toReformat="true" toShortenFQNames="true">
<variable name="Function" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_CODE" value="true" />
</context>
</template>
</templateSet>
Binary file added resource_file/example.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified settings.zip
Binary file not shown.

0 comments on commit be5f2d2

Please sign in to comment.