lib/commands/resource.rb in spring-gen-0.2.2 vs lib/commands/resource.rb in spring-gen-0.2.3
- old
+ new
@@ -58,17 +58,20 @@
'templates/src/test/java/TestUtil.java.erb',
"#{content_root}/src/test/java/util/TestUtil.java") unless File.exist?("#{content_root}/src/test/java/util/TestUtil.java")
case config.repository_technique
when 'jpa'
+ @id_type = "Long"
#TODO unify sample data. This check should not need to exist.
template "templates/src/test/java/integration/#{config.repository_technique}/sampleData.xml.erb",
"#{content_root}/src/test/resources/sampledata/#{@model_name.downcase}SampleData.xml"
when "mongodb"
+ @id_type = "String"
template "templates/src/test/java/integration/#{config.repository_technique}/SampleData.java.erb",
"#{content_root}/src/test/java/#{fs_path}/integration/#{@model_name.downcase}/#{@model_name}SampleData.java"
when "neo4j"
+ @id_type = "Long"
template "templates/src/test/java/integration/#{config.repository_technique}/SampleData.java.erb",
"#{content_root}/src/test/java/#{fs_path}/integration/#{@model_name.downcase}/#{@model_name}SampleData.java"
else
raise ("not a suitable repository-technique.")
end
@@ -108,7 +111,18 @@
template(
'templates/src/main/java/resource/Resource.java.erb',
"#{content_root}/src/main/java/#{fs_path}/resource/#{@model_name}Resource.java")
end
end
+
+ no_tasks do
+ def augment_test_id(id)
+ case @id_type
+ when "String" then "String.valueOf(#{id})"
+ when "Long" then "Long.valueOf(#{id})"
+ else id
+ end
+ end
+ end
+
end
\ No newline at end of file