Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public void testTutorial() throws Exception {
"create table PERSON (ID int not null, NAME varchar(20), primary key (ID))",
"insert into PERSON values (1, 'foo')"
});
setHibernateToolsExtensionSection(
"hibernateTools { \n" +
" generateAnnotations=false \n" +
"}"
);
createProject();
executeGradleCommand("generateJava");
verifyProject();
Expand All @@ -45,17 +50,4 @@ private void verifyProject() throws Exception {
assertTrue(generatedPersonJavaFileContents.contains("public class Person "));
}

protected void addHibernateToolsExtension(StringBuffer gradleBuildFileContents) {
int pos = gradleBuildFileContents.indexOf("dependencies {");
pos = gradleBuildFileContents.indexOf("}", pos);
StringBuffer hibernateToolsExtension = new StringBuffer();
hibernateToolsExtension
.append("\n")
.append("\n")
.append("hibernateTools { \n")
.append(" generateAnnotations=false \n")
.append("}");
gradleBuildFileContents.insert(pos + 1, hibernateToolsExtension.toString());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public void testTutorial() throws Exception {
"create table ITEM (ID int not null, NAME varchar(20), OWNER_ID int not null, " +
" primary key (ID), foreign key (OWNER_ID) references PERSON(ID))"
});
setHibernateToolsExtensionSection(
"hibernateTools { \n" +
" useGenerics=false \n" +
"}"
);
createProject();
executeGradleCommand("generateJava");
verifyProject();
Expand All @@ -51,17 +56,4 @@ private void verifyProject() throws Exception {
assertTrue(generatedItemJavaFileContents.contains("public class Item "));
}

protected void addHibernateToolsExtension(StringBuffer gradleBuildFileContents) {
int pos = gradleBuildFileContents.indexOf("dependencies {");
pos = gradleBuildFileContents.indexOf("}", pos);
StringBuffer hibernateToolsExtension = new StringBuffer();
hibernateToolsExtension
.append("\n")
.append("\n")
.append("hibernateTools { \n")
.append(" useGenerics=false \n")
.append("}");
gradleBuildFileContents.insert(pos + 1, hibernateToolsExtension.toString());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class TestTemplate {
private File databaseFile;

private String[] databaseCreationScript;
private String hibernateToolsExtensionSection;

protected File getProjectDir() { return projectDir; }
protected File getGradlePropertiesFile() { return gradlePropertiesFile; }
Expand All @@ -38,6 +39,8 @@ public class TestTemplate {
protected void setDatabaseFile(File f) { databaseFile = f; }
protected String[] getDatabaseCreationScript() { return databaseCreationScript; }
protected void setDatabaseCreationScript(String[] script) { databaseCreationScript = script; }
protected String getHibernateToolsExtensionSection() { return hibernateToolsExtensionSection; }
protected void setHibernateToolsExtensionSection(String s) { hibernateToolsExtensionSection = s; }

protected void executeGradleCommand(String ... gradleCommandLine) {
GradleRunner runner = GradleRunner.create();
Expand Down Expand Up @@ -143,6 +146,14 @@ protected void addHibernateToolsPluginLine(StringBuffer gradleBuildFileContents)
gradleBuildFileContents.insert(pos, constructHibernateToolsPluginLine() + "\n");
}

protected void addHibernateToolsExtension(StringBuffer gradleBuildFileContents) {}

protected void addHibernateToolsExtension(StringBuffer gradleBuildFileContents) {
String extension = getHibernateToolsExtensionSection();
if (extension != null) {
int pos = gradleBuildFileContents.indexOf("dependencies {");
pos = gradleBuildFileContents.indexOf("}", pos);
gradleBuildFileContents.insert(pos + 1, "\n\n" + extension);
}
}
}