Added project name to custom test template
This commit is contained in:
parent
eef391e90c
commit
09d95118c6
2 changed files with 4 additions and 10 deletions
|
@ -71,13 +71,14 @@ class GeneratedVersionTest {
|
||||||
gv.setTemplate(new File(gv.getProject().srcTestResourcesDirectory().getAbsolutePath(),
|
gv.setTemplate(new File(gv.getProject().srcTestResourcesDirectory().getAbsolutePath(),
|
||||||
"version_test.txt"));
|
"version_test.txt"));
|
||||||
gv.setPackageName("com.example.my");
|
gv.setPackageName("com.example.my");
|
||||||
|
gv.setProjectName("My App");
|
||||||
gv.setClassName("MyVersion");
|
gv.setClassName("MyVersion");
|
||||||
|
|
||||||
var t = GeneratedVersionOperation.buildTemplate(gv);
|
var t = GeneratedVersionOperation.buildTemplate(gv);
|
||||||
|
|
||||||
assertThat(t.getContent()).contains("package com.example.my;").contains("class MyVersion")
|
assertThat(t.getContent()).contains("package com.example.my;").contains("class MyVersion")
|
||||||
.contains("MAJOR = 2").contains("MINOR = 1").contains("REVISION = 3").contains("QUALIFIER = \"\"")
|
.contains("MAJOR = 2").contains("MINOR = 1").contains("REVISION = 3").contains("QUALIFIER = \"\"")
|
||||||
.contains("private MyVersion");
|
.contains("private MyVersion").contains("PROJECT = \"My App\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,20 +1,13 @@
|
||||||
package {{v packageName/}};
|
package {{v packageName/}};
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides project version information.
|
|
||||||
*/
|
|
||||||
public final class {{v className/}} {
|
public final class {{v className/}} {
|
||||||
|
public static final int PROJECT = "{{v project/}}";
|
||||||
public static final int MAJOR = {{v major/}};
|
public static final int MAJOR = {{v major/}};
|
||||||
public static final int MINOR = {{v minor/}};
|
public static final int MINOR = {{v minor/}};
|
||||||
public static final int REVISION = {{v revision/}};
|
public static final int REVISION = {{v revision/}};
|
||||||
public static final String QUALIFIER = "{{v qualifier/}}";
|
public static final String QUALIFIER = "{{v qualifier/}}";
|
||||||
|
|
||||||
/**
|
|
||||||
* Disables the default constructor.
|
|
||||||
*/
|
|
||||||
private {{v className/}}() {
|
private {{v className/}}() {
|
||||||
throw new UnsupportedOperationException("Illegal constructor call.");
|
// no-op
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue