RLiferayTool 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/bin/r_liferay_tool +8 -0
- data/lib/r_liferay_tool.rb +81 -0
- data/test/liferay-plugin-package.properties +9 -0
- data/test/pom.xml +52 -0
- data/test/portlet.xml +33 -0
- data/test/r_liferay_lib/buildup_mixin.rb +14 -0
- data/test/r_liferay_lib/cleanup_mixin.rb +15 -0
- data/test/r_liferay_lib/test_prepare_portlet.rb +109 -0
- data/test/r_liferay_lib/test_r_liferay_tool.rb +28 -0
- data/test/r_liferay_lib/test_read_pom.rb +23 -0
- data/test/r_liferay_lib/test_read_service.rb +31 -0
- data/test/r_liferay_lib/test_template_utility.rb +63 -0
- data/test/r_liferay_lib/test_xml_utility.rb +37 -0
- data/test/service.xml +233 -0
- data/test/temp/src/main/webapp/WEB-INF/portlet.xml +33 -0
- data/test/test_helper.rb +32 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ODFiMWVkNzBiM2JkNmUyOWJiNWYyMWRjYzFjNjQ1YTk5ZGFkZmZjMQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YzE1NTgzZDkyZWY3ZjU0OGJhNGFjYzBmMTViMTEwMzMzYWUzMjQwZg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZWY5NzVhMTJmNGFhNzZiZDhhMzBlNmFiMWE0MTJhZDdjZmVmMWE3NTk5NDgz
|
10
|
+
YWFkYjhhZDU4YjM2ZGJmMTY3OWJmNDU3ODY4ZDYwZGQ4MjJiNjc4NDA1ZGEy
|
11
|
+
NmFmY2RlMGM2YmY5MTE3MzViMjNkNDY0ZmE0NDkyZTNhZmYwM2Y=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NzRjMDUwMWM5NTA5NjY4NGIyZjYyMWY3OWY1YTVlMjFjODc5YjUzNmE0ZWU4
|
14
|
+
YWZjMDIwNmNmYTQxMGVlNTUyYzU5ZjZjMDM3M2JiZTNlYjM3YTU2ZWM2Mjcx
|
15
|
+
OWU3Y2EzYTFhZjg2ODMxOGExYjdkODJlMmMwNjI2NDUzMjcwOWQ=
|
data/bin/r_liferay_tool
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
require_relative 'r_liferay_lib/prepare_portlet_service'
|
5
|
+
require_relative 'r_liferay_lib/read_service'
|
6
|
+
require_relative 'r_liferay_lib/read_pom'
|
7
|
+
|
8
|
+
class RLiferayTool < Thor
|
9
|
+
|
10
|
+
desc "update_portlet_service", "Generate code files from a Liferay Service xml file."
|
11
|
+
#method_option :project_name, :type => :string, :required => true, :desc => "You must enter a name for the project"
|
12
|
+
#method_option :project_version, :type => :string, :required => true, :desc => "You must enter a project version"
|
13
|
+
#method_option :service_xml_file, :type => :string, :required => true, :desc => "Specify the location of the service.xml file in your project"
|
14
|
+
#method_option :platform, :aliases => "-p", :type => :string, :required => true, :default => 'rails', :desc => "Choose which platform you are targeting for code generation."
|
15
|
+
default_task :update_portlet_service
|
16
|
+
|
17
|
+
def update_portlet_service()
|
18
|
+
|
19
|
+
has_error=false
|
20
|
+
|
21
|
+
base_directory = f = File.expand_path File.dirname(__FILE__)
|
22
|
+
|
23
|
+
project_name = File.basename(Dir.pwd)
|
24
|
+
|
25
|
+
target_directory = project_name + '-portlet'
|
26
|
+
|
27
|
+
pom_file = './pom.xml'
|
28
|
+
|
29
|
+
if !Dir.exist? target_directory
|
30
|
+
has_error = true
|
31
|
+
say "You are not in a Liferay portlet service directory.", :red
|
32
|
+
end
|
33
|
+
|
34
|
+
if !File.exist? pom_file
|
35
|
+
has_error = true
|
36
|
+
say "You are not in a valid maven project directory.", :red
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
template_directory = base_directory + '/r_liferay_lib/portlet_service_templates'
|
41
|
+
|
42
|
+
service_xml = target_directory + "/src/main/webapp/WEB-INF/service.xml"
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
if has_error
|
47
|
+
return
|
48
|
+
else
|
49
|
+
read_service = RLiferayLib::ReadService.new(service_xml)
|
50
|
+
read_pom = RLiferayLib::ReadPOM.new(pom_file)
|
51
|
+
|
52
|
+
|
53
|
+
template_variables = read_service.entities[read_service.entities.keys[0]]
|
54
|
+
template_variables['project_name'] = project_name
|
55
|
+
template_variables['project_version'] = read_pom.version
|
56
|
+
prepare_portlet_service = RLiferayLib::PreparePortletService.new(template_directory, target_directory, template_variables)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
def say_error(error)
|
71
|
+
say 'Internal RLiferayTool Error', :red
|
72
|
+
say '-------------------------', :red
|
73
|
+
say error.message, :red
|
74
|
+
unless error.backtrace.nil?
|
75
|
+
error.backtrace.each do | line |
|
76
|
+
say line, :red
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
data/test/pom.xml
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
3
|
+
<modelVersion>4.0.0</modelVersion>
|
4
|
+
<parent>
|
5
|
+
<artifactId>ikrome-portlet-hook-parent</artifactId>
|
6
|
+
<groupId>mil.army.hrc.ikrome</groupId>
|
7
|
+
<version>3.00.000</version>
|
8
|
+
</parent>
|
9
|
+
<groupId>mil.army.hrc.ikrome.test</groupId>
|
10
|
+
<artifactId>bob-list</artifactId>
|
11
|
+
<packaging>pom</packaging>
|
12
|
+
<name>bob-list</name>
|
13
|
+
<version>3.00.000</version>
|
14
|
+
<build>
|
15
|
+
<plugins>
|
16
|
+
<plugin>
|
17
|
+
<groupId>com.liferay.maven.plugins</groupId>
|
18
|
+
<artifactId>liferay-maven-plugin</artifactId>
|
19
|
+
<version>${liferay.maven.plugin.version}</version>
|
20
|
+
<configuration>
|
21
|
+
<autoDeployDir>${liferay.auto.deploy.dir}</autoDeployDir>
|
22
|
+
<appServerDeployDir>${liferay.app.server.deploy.dir}</appServerDeployDir>
|
23
|
+
<appServerLibGlobalDir>${liferay.app.server.lib.global.dir}</appServerLibGlobalDir>
|
24
|
+
<appServerPortalDir>${liferay.app.server.portal.dir}</appServerPortalDir>
|
25
|
+
<liferayVersion>${liferay.version}</liferayVersion>
|
26
|
+
<pluginName>bob-list-portlet</pluginName>
|
27
|
+
<pluginType>portlet</pluginType>
|
28
|
+
</configuration>
|
29
|
+
</plugin>
|
30
|
+
<plugin>
|
31
|
+
<artifactId>maven-compiler-plugin</artifactId>
|
32
|
+
<version>2.5</version>
|
33
|
+
<configuration>
|
34
|
+
<encoding>UTF-8</encoding>
|
35
|
+
<source>1.6</source>
|
36
|
+
<target>1.6</target>
|
37
|
+
</configuration>
|
38
|
+
</plugin>
|
39
|
+
<plugin>
|
40
|
+
<artifactId>maven-resources-plugin</artifactId>
|
41
|
+
<version>2.5</version>
|
42
|
+
<configuration>
|
43
|
+
<encoding>UTF-8</encoding>
|
44
|
+
</configuration>
|
45
|
+
</plugin>
|
46
|
+
</plugins>
|
47
|
+
</build>
|
48
|
+
<modules>
|
49
|
+
<module>bob-list-portlet</module>
|
50
|
+
<module>bob-list-portlet-service</module>
|
51
|
+
</modules>
|
52
|
+
</project>
|
data/test/portlet.xml
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<portlet-app schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0">
|
3
|
+
<portlet>
|
4
|
+
<portlet-name>bob-list</portlet-name>
|
5
|
+
<display-name>bob-list</display-name>
|
6
|
+
<portlet-class>com.liferay.util.bridges.mvc.MVCPortlet</portlet-class>
|
7
|
+
<init-param>
|
8
|
+
<name>view-template</name>
|
9
|
+
<value>/view.jsp</value>
|
10
|
+
</init-param>
|
11
|
+
<expiration-cache>0</expiration-cache>
|
12
|
+
<supports>
|
13
|
+
<mime-type>text/html</mime-type>
|
14
|
+
</supports>
|
15
|
+
<portlet-info>
|
16
|
+
<title>bob-list</title>
|
17
|
+
<short-title>bob-list</short-title>
|
18
|
+
<keywords>bob-list</keywords>
|
19
|
+
</portlet-info>
|
20
|
+
<security-role-ref>
|
21
|
+
<role-name>administrator</role-name>
|
22
|
+
</security-role-ref>
|
23
|
+
<security-role-ref>
|
24
|
+
<role-name>guest</role-name>
|
25
|
+
</security-role-ref>
|
26
|
+
<security-role-ref>
|
27
|
+
<role-name>power-user</role-name>
|
28
|
+
</security-role-ref>
|
29
|
+
<security-role-ref>
|
30
|
+
<role-name>user</role-name>
|
31
|
+
</security-role-ref>
|
32
|
+
</portlet>
|
33
|
+
</portlet-app>
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require_relative '../test_helper'
|
3
|
+
require_relative 'cleanup_mixin'
|
4
|
+
require_relative 'buildup_mixin'
|
5
|
+
require_relative '../../lib/r_liferay_lib/prepare_portlet_service'
|
6
|
+
require_relative '../../lib/r_liferay_lib/read_service'
|
7
|
+
|
8
|
+
module RLiferayLib
|
9
|
+
class TestPreparePortletService < Minitest::Test
|
10
|
+
include RLiferayLib::CleanupMixin
|
11
|
+
include RLiferayLib::BuildupMixin
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
def setup
|
16
|
+
clean_up
|
17
|
+
build_up
|
18
|
+
end
|
19
|
+
|
20
|
+
def teardown
|
21
|
+
# clean_up
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_generate_portlet_xml_content
|
25
|
+
assert_equal(true,File.exist?(TestFiles::TEMP_PORTLET_XML),"Portlet.xml file is missing.")
|
26
|
+
portlet_xml_content = File.read(TestFiles::TEMP_PORTLET_XML)
|
27
|
+
assert_equal(true,portlet_xml_content.include?("mil.army.hrc.ikrome.#{@template_variables['project_name']}"),"Portlet xml file content was not updated.")
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_generate_plugin_package_properties
|
31
|
+
assert_equal(true,File.exist?(TestFiles::TEMP_PLUGIN_PACKAGE_FILE),"Plugin properites file is missing.")
|
32
|
+
properties_content = File.read(TestFiles::TEMP_PLUGIN_PACKAGE_FILE)
|
33
|
+
assert_equal(true,properties_content.include?("name=#{@template_variables['project_name']}"),"Plugin properties file content was not updated.")
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_generate_view_jsp
|
37
|
+
assert_equal(true,File.exist?(TestFiles::TEMP_VIEW_JSP),"View.jsp file is missing.")
|
38
|
+
properties_content = File.read(TestFiles::TEMP_VIEW_JSP)
|
39
|
+
check_value = "keyProperty=\"responseId\""
|
40
|
+
assert_equal(true,properties_content.include?(check_value),"View.jsp file content was not updated. #{check_value}")
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_generate_init_jsp
|
44
|
+
assert_equal(true,File.exist?(TestFiles::TEMP_INIT_JSP),"Init.jsp file is missing.")
|
45
|
+
properties_content = File.read(TestFiles::TEMP_INIT_JSP)
|
46
|
+
check_value = "mil.army.hrc.ikrome.test.service.ChatResponseLocalServiceUtil"
|
47
|
+
assert_equal(true,properties_content.include?(check_value),"Init.jsp file content was not updated. #{check_value}")
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_generate_edit_jsp
|
51
|
+
assert_equal(true,File.exist?(TestFiles::TEMP_EDIT_JSP),"Edit.jsp file is missing.")
|
52
|
+
properties_content = File.read(TestFiles::TEMP_EDIT_JSP)
|
53
|
+
check_value = 'aui:input type="number" name="createdByUserId" label="createdByUserId" value="${param.createdByUserId}"'
|
54
|
+
assert_equal(true,properties_content.include?(check_value),"Edit.jsp file content was not updated. #{check_value}")
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_generate_add_jsp
|
58
|
+
assert_equal(true,File.exist?(TestFiles::TEMP_ADD_JSP),"Add.jsp file is missing.")
|
59
|
+
properties_content = File.read(TestFiles::TEMP_ADD_JSP)
|
60
|
+
check_value = 'aui:input type="text" name="firstContent" label="firstContent"'
|
61
|
+
assert_equal(true,properties_content.include?(check_value),"Add.jsp file content was not updated. #{check_value}")
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_generate_controller
|
65
|
+
file_name = @java_portlet_path + '/' + RLiferayLib::PreparePortletService::CONTROLLER_NAME
|
66
|
+
assert_equal(true,File.exist?(file_name),"Controller class file is missing.")
|
67
|
+
properties_content = File.read(file_name)
|
68
|
+
check_value = 'List<ChatResponse> allItems = ChatResponseLocalServiceUtil.getChatResponses(QueryUtil.ALL_POS, QueryUtil.ALL_POS);'
|
69
|
+
assert_equal(true,properties_content.include?(check_value),"Controller class file content was not updated. #{check_value}")
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_generate_local_impl
|
73
|
+
file_name = "#{@java_service_path}/#{@template_variables['name']}#{RLiferayLib::PreparePortletService::LOCAL_IMPL_NAME}"
|
74
|
+
assert_equal(true,File.exist?(file_name),"Local impl class file is missing.")
|
75
|
+
properties_content = File.read(file_name)
|
76
|
+
check_value = "add#{@template_variables['name']}"
|
77
|
+
assert_equal(true,properties_content.include?(check_value),"Local impl class file content was not updated. #{check_value}")
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_generate_remote_impl
|
81
|
+
file_name = "#{@java_service_path}/#{@template_variables['name']}#{RLiferayLib::PreparePortletService::REMOTE_IMPL_NAME}"
|
82
|
+
assert_equal(true,File.exist?(file_name),"Remote impl class file is missing.")
|
83
|
+
properties_content = File.read(file_name)
|
84
|
+
check_value = "add#{@template_variables['name']}"
|
85
|
+
assert_equal(true,properties_content.include?(check_value),"Remote impl class file content was not updated. #{check_value}")
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
def build_up
|
90
|
+
_build_up
|
91
|
+
read_service = ReadService.new(TestFiles::SERVICE_XML)
|
92
|
+
@template_variables = read_service.entities[read_service.entities.keys[0]]
|
93
|
+
@template_variables['name'] = read_service.entities.keys[0]
|
94
|
+
@template_variables['project_name'] = 'test'
|
95
|
+
@template_variables['project_version'] = '1.00.000'
|
96
|
+
|
97
|
+
@java_portlet_path=TestFiles::JAVA_DIR + '/' + @template_variables['project_name'].downcase + '/portlet'
|
98
|
+
@java_service_path=TestFiles::JAVA_DIR + '/' + @template_variables['project_name'].downcase + '/service/impl'
|
99
|
+
|
100
|
+
FileUtils.mkpath(@java_portlet_path)
|
101
|
+
FileUtils.mkpath(@java_service_path)
|
102
|
+
|
103
|
+
|
104
|
+
@test_object = PreparePortletService.new(TestFiles::TEMPLATE_DIR, TestFiles::TEMP_DIR , @template_variables)
|
105
|
+
@test_class_constant = PreparePortletService
|
106
|
+
end
|
107
|
+
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require_relative '../test_helper'
|
3
|
+
require_relative 'buildup_mixin'
|
4
|
+
require_relative 'cleanup_mixin'
|
5
|
+
require_relative '../../lib/r_liferay_tool'
|
6
|
+
|
7
|
+
module RLiferayLib
|
8
|
+
class TestPreparePortletService < Minitest::Test
|
9
|
+
include RLiferayLib::BuildupMixin
|
10
|
+
include RLiferayLib::CleanupMixin
|
11
|
+
|
12
|
+
def setup
|
13
|
+
clean_up
|
14
|
+
build_up
|
15
|
+
end
|
16
|
+
|
17
|
+
def teardown
|
18
|
+
clean_up
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_command_line
|
22
|
+
RLiferayTool.start
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require_relative '../test_helper'
|
3
|
+
require_relative '../../lib/r_liferay_lib/read_pom'
|
4
|
+
|
5
|
+
module RLiferayLib
|
6
|
+
class TestReadPOM < Minitest::Test
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@test_object = ReadPOM.new(TestFiles::POM_XML)
|
10
|
+
@test_class_constant = ReadPOM
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_version
|
17
|
+
version = '3.00.000'
|
18
|
+
|
19
|
+
assert_equal(true,@test_object.version.include?(version),"Did not vind the version")
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require_relative '../test_helper'
|
3
|
+
require_relative '../../lib/r_liferay_lib/read_service'
|
4
|
+
|
5
|
+
module RLiferayLib
|
6
|
+
class TestReadService < Minitest::Test
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@test_object = ReadService.new(TestFiles::SERVICE_XML)
|
10
|
+
@test_class_constant = ReadService
|
11
|
+
end
|
12
|
+
|
13
|
+
def teardown
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_entities
|
17
|
+
entity_name = 'ChatResponse'
|
18
|
+
|
19
|
+
assert_equal(true,@test_object.entities.include?(entity_name),"Did not find Foo entity")
|
20
|
+
assert_equal('responseId',@test_object.entities[entity_name]['primary_key'],"Did not find primary key responseId")
|
21
|
+
column_name='title'
|
22
|
+
assert_equal(true,@test_object.entities[entity_name]['columns'].include?(column_name),"Did not find column #{column_name}")
|
23
|
+
assert_equal('String',@test_object.entities[entity_name]['columns'][column_name].column_type,"Did not find column #{column_name}'s type which is String")
|
24
|
+
|
25
|
+
column_name='companyId'
|
26
|
+
assert_equal(false,@test_object.entities[entity_name]['columns'].include?(column_name),"Did not find column #{column_name}")
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require_relative '../test_helper'
|
3
|
+
require_relative 'buildup_mixin'
|
4
|
+
require_relative 'cleanup_mixin'
|
5
|
+
require_relative '../../lib/r_liferay_lib/read_service'
|
6
|
+
require_relative '../../lib/r_liferay_lib/template_utility'
|
7
|
+
|
8
|
+
module RLiferayLib
|
9
|
+
class TestTemplateUtility < Minitest::Test
|
10
|
+
include RLiferayLib::CleanupMixin
|
11
|
+
include RLiferayLib::BuildupMixin
|
12
|
+
|
13
|
+
|
14
|
+
def setup
|
15
|
+
clean_up
|
16
|
+
build_up
|
17
|
+
end
|
18
|
+
|
19
|
+
def teardown
|
20
|
+
#clean_up
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_erb_results
|
24
|
+
assert_equal(true,File.exist?(@target_file_name),"File #{@target_file_name} was not created.")
|
25
|
+
begin
|
26
|
+
f = File.open(@target_file_name)
|
27
|
+
contents = f.read
|
28
|
+
|
29
|
+
string_contained = "mil.army.hrc.ikrome.#{@template_variables['project_name']}.model.ChatResponse"
|
30
|
+
assert_equal(true,contents.include?(string_contained),"File did not contain #{string_contained}")
|
31
|
+
|
32
|
+
string_contained = 'keyProperty="responseId"'
|
33
|
+
assert_equal(true,contents.include?(string_contained),"File did not contain #{string_contained}")
|
34
|
+
|
35
|
+
string_contained = 'value="${item.responseId}"'
|
36
|
+
assert_equal(true,contents.include?(string_contained),"File did not contain #{string_contained}")
|
37
|
+
ensure
|
38
|
+
f.close()
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_file_backup
|
43
|
+
assert_equal(true,File.exist?(@target_file_name),"File #{@target_file_name} was not created.")
|
44
|
+
build_up
|
45
|
+
assert_equal(true,Dir[@target_file_name + '\.[0-9]*'].length > 0, 'Did not find any backed up files.')
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def build_up
|
52
|
+
_build_up
|
53
|
+
@target_name = 'test_view.jsp'
|
54
|
+
@target_file_name = TestFiles::TEMP_DIR + '/' + @target_name
|
55
|
+
read_service = ReadService.new(TestFiles::SERVICE_XML)
|
56
|
+
@template_variables = read_service.entities[read_service.entities.keys[0]]
|
57
|
+
@template_variables['project_name'] = 'test'
|
58
|
+
@test_object = TemplateUtility.new(TestFiles::VIEW_JSP, TestFiles::TEMP_DIR, @target_name , @template_variables)
|
59
|
+
@test_class_constant = TemplateUtility
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require_relative '../test_helper'
|
3
|
+
require_relative 'buildup_mixin'
|
4
|
+
require_relative 'cleanup_mixin'
|
5
|
+
require_relative '../../lib/r_liferay_lib/xml_utility'
|
6
|
+
|
7
|
+
module RLiferayLib
|
8
|
+
class TestXMLUtility < Minitest::Test
|
9
|
+
include RLiferayLib::CleanupMixin
|
10
|
+
include RLiferayLib::BuildupMixin
|
11
|
+
|
12
|
+
def setup
|
13
|
+
clean_up
|
14
|
+
build_up
|
15
|
+
FileUtils.copy_file(TestFiles::PORTLET_XML,TestFiles::TEMP_PORTLET_XML)
|
16
|
+
@test_object = XMLUtility.new(TestFiles::TEMP_PORTLET_XML)
|
17
|
+
@test_class_constant = XMLUtility
|
18
|
+
end
|
19
|
+
|
20
|
+
def teardown
|
21
|
+
#clean_up
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_read_file_returns_content
|
25
|
+
refute_nil @test_object.xml_content
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_write_file
|
29
|
+
FileUtils.remove(TestFiles::TEMP_PORTLET_XML)
|
30
|
+
assert_equal(false,File.exist?(TestFiles::TEMP_PORTLET_XML),"XML content file was not deleted.")
|
31
|
+
@test_object.write_xml_content
|
32
|
+
assert_equal(true,File.exist?(TestFiles::TEMP_PORTLET_XML),"XMLUtility did not write file")
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
data/test/service.xml
ADDED
@@ -0,0 +1,233 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.1.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_1_0.dtd">
|
3
|
+
<service-builder
|
4
|
+
package-path="mil.army.hrc.ikrome.cybertools.dataaccess">
|
5
|
+
<author>rowebs</author>
|
6
|
+
<namespace>cybertools</namespace>
|
7
|
+
|
8
|
+
<entity name="ChatResponse" local-service="true" remote-service="true">
|
9
|
+
|
10
|
+
<!-- PK fields -->
|
11
|
+
|
12
|
+
<column name="responseId" type="long" primary="true" />
|
13
|
+
|
14
|
+
<!-- Audit fields -->
|
15
|
+
|
16
|
+
<column name="companyId" type="long" />
|
17
|
+
<column name="createdByUserId" type="long" />
|
18
|
+
<column name="createdByUserName" type="String" />
|
19
|
+
<column name="createDate" type="Date" />
|
20
|
+
<column name="modifiedDate" type="Date" />
|
21
|
+
<column name="modifiedByUserId" type="long" />
|
22
|
+
<column name="modifiedByUserName" type="String" />
|
23
|
+
|
24
|
+
<!-- Other fields -->
|
25
|
+
|
26
|
+
<column name="title" type="String" />
|
27
|
+
<column name="firstContent" type="String" />
|
28
|
+
<column name="secondContent" type="String" />
|
29
|
+
<column name="viewCount" type="long" />
|
30
|
+
<column name="viewedDate" type="Date" />
|
31
|
+
|
32
|
+
<!-- Order -->
|
33
|
+
|
34
|
+
<order by="asc">
|
35
|
+
<order-column name="title" />
|
36
|
+
</order>
|
37
|
+
|
38
|
+
<!-- Finder methods -->
|
39
|
+
|
40
|
+
<finder name="modifiedDateLessThan" return-type="Collection">
|
41
|
+
<finder-column name="modifiedDate" comparator="<=" />
|
42
|
+
</finder>
|
43
|
+
<finder name="LastViewDateOlderThan" return-type="Collection">
|
44
|
+
<finder-column name="viewedDate" comparator="<=" />
|
45
|
+
</finder>
|
46
|
+
|
47
|
+
<finder name="contentLike" return-type="Collection">
|
48
|
+
<finder-column name="firstContent" comparator="LIKE" />
|
49
|
+
<finder-column name="secondContent" comparator="LIKE" />
|
50
|
+
</finder>
|
51
|
+
</entity>
|
52
|
+
<entity name="CyberToolsProperty" local-service="true" remote-service="true">
|
53
|
+
|
54
|
+
<!-- PK fields -->
|
55
|
+
|
56
|
+
<column name="propertyName" type="String" primary="true" />
|
57
|
+
|
58
|
+
<!-- Audit fields -->
|
59
|
+
|
60
|
+
<column name="companyId" type="long" />
|
61
|
+
<column name="createDate" type="Date" />
|
62
|
+
<column name="modifiedDate" type="Date" />
|
63
|
+
<column name="modifiedByUserId" type="long" />
|
64
|
+
|
65
|
+
|
66
|
+
<!-- Other fields -->
|
67
|
+
|
68
|
+
<column name="propertyValue" type="String" />
|
69
|
+
|
70
|
+
<!-- Order -->
|
71
|
+
|
72
|
+
<order by="asc">
|
73
|
+
<order-column name="propertyName" />
|
74
|
+
</order>
|
75
|
+
|
76
|
+
<!-- Finder methods -->
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
</entity>
|
81
|
+
<entity name="MOSKeyword" local-service="true" remote-service="true">
|
82
|
+
<column name="keyword" type="String" primary ="true" />
|
83
|
+
|
84
|
+
<!-- Audit fields -->
|
85
|
+
|
86
|
+
<order by="asc">
|
87
|
+
<order-column name="keyword" />
|
88
|
+
</order>
|
89
|
+
</entity>
|
90
|
+
|
91
|
+
<entity name="MOSData" local-service="true" remote-service="true">
|
92
|
+
|
93
|
+
<!-- PK fields -->
|
94
|
+
<column name="mosDataId" type="long" primary="true" />
|
95
|
+
<column name="mosId" type="String" />
|
96
|
+
|
97
|
+
<!-- Audit fields -->
|
98
|
+
|
99
|
+
<column name="keywords" type="String" />
|
100
|
+
<column name="createDate" type="Date" />
|
101
|
+
<column name="modifiedDate" type="Date" />
|
102
|
+
<column name="modifiedByUserId" type="long" />
|
103
|
+
<column name="companyId" type="long" />
|
104
|
+
|
105
|
+
|
106
|
+
<!-- Other fields -->
|
107
|
+
|
108
|
+
<column name="title" type="String" />
|
109
|
+
<column name="notes" type="String" />
|
110
|
+
<column name="term" type="int" />
|
111
|
+
<column name="clearance" type="String" />
|
112
|
+
<column name="citizenship" type="String" />
|
113
|
+
<column name="vision" type="String" />
|
114
|
+
<column name="driversLicense" type="String" />
|
115
|
+
<column name="gender" type="String" />
|
116
|
+
<column name="ait" type="String" />
|
117
|
+
<column name="length" type="String" />
|
118
|
+
<column name="linkData" type="String" />
|
119
|
+
|
120
|
+
<!-- Test Scores -->
|
121
|
+
<column name="gt" type="int" />
|
122
|
+
<column name="gm" type="int" />
|
123
|
+
<column name="el" type="int" />
|
124
|
+
<column name="cl" type="int" />
|
125
|
+
<column name="mm" type="int" />
|
126
|
+
<column name="sc" type="int" />
|
127
|
+
<column name="co" type="int" />
|
128
|
+
<column name="fa" type="int" />
|
129
|
+
<column name="ofscore" type="int" />
|
130
|
+
<column name="st" type="int" />
|
131
|
+
|
132
|
+
|
133
|
+
<!-- Order -->
|
134
|
+
|
135
|
+
<order by="asc">
|
136
|
+
<order-column name="mosId" />
|
137
|
+
</order>
|
138
|
+
|
139
|
+
<!-- Finder methods -->
|
140
|
+
<finder name="Category" return-type="Collection">
|
141
|
+
<finder-column name="keywords" />
|
142
|
+
</finder>
|
143
|
+
<finder name="name" return-type="MOSData">
|
144
|
+
<finder-column name="mosId" />
|
145
|
+
</finder>
|
146
|
+
|
147
|
+
|
148
|
+
</entity>
|
149
|
+
|
150
|
+
<entity name="ReferenceArea" local-service="true" remote-service="true">
|
151
|
+
<column name="referenceAreaId" primary="true" type="long"></column>
|
152
|
+
<column name="name" type="String"></column>
|
153
|
+
<order>
|
154
|
+
<order-column name="name" order-by="asc"></order-column>
|
155
|
+
</order>
|
156
|
+
<finder name="RefName" return-type="Collection">
|
157
|
+
<finder-column name="name" />
|
158
|
+
</finder>
|
159
|
+
</entity>
|
160
|
+
<entity name="ReferenceInfo" local-service="true" remote-service="true">
|
161
|
+
<column name="referenceInfoId" type="long" primary="true"></column>
|
162
|
+
<column name="referenceAreaId" type="long"></column>
|
163
|
+
<column name="title" type="String"></column>
|
164
|
+
<column name="createdDate" type="Date"></column>
|
165
|
+
<column name="createdBy" type="String"></column>
|
166
|
+
<column name="lastModifiedDate" type="Date"></column>
|
167
|
+
<column name="lastModifiedBy" type="String"></column>
|
168
|
+
<column name="documentId" type="String"></column>
|
169
|
+
<column name="data" type="String"></column>
|
170
|
+
<column name="viewCount" type="long"></column>
|
171
|
+
<column name="lastViewDate" type="Date"></column>
|
172
|
+
<order by="asc">
|
173
|
+
<order-column name="title"></order-column>
|
174
|
+
<order-column name="referenceAreaId"></order-column>
|
175
|
+
</order>
|
176
|
+
<finder name="AreaId" return-type="Collection">
|
177
|
+
<finder-column name="referenceAreaId"/>
|
178
|
+
</finder>
|
179
|
+
<finder name="LastViewDateOlderThan" return-type="Collection">
|
180
|
+
<finder-column name="lastViewDate" comparator="<=" />
|
181
|
+
</finder>
|
182
|
+
</entity>
|
183
|
+
|
184
|
+
<entity name="GirthEntry" table="HEIGHT_WEIGHT_VIEW" local-service="true" remote-service="true"
|
185
|
+
data-source="lemaDataSource" session-factory="lemaSessionFactory"
|
186
|
+
tx-manager="lemaTransactionManager">
|
187
|
+
|
188
|
+
<!-- PK fields -->
|
189
|
+
|
190
|
+
<column name="Height" type="int" primary="true" />
|
191
|
+
|
192
|
+
<column name="MaxWeight" type="int" />
|
193
|
+
<column name="NPSMaxWeight" type="int" />
|
194
|
+
<column name="Sex" type="String" primary="true"/>
|
195
|
+
<column name="FromAge" type="int" primary="true" />
|
196
|
+
<column name="ToAge" type="int" />
|
197
|
+
<column name="MinWeight" type="int" />
|
198
|
+
<column name="NPSMinWeight" type="int" />
|
199
|
+
<column name="BFM_PERCENT" type="int" />
|
200
|
+
<column name="NPS_BFM_PERCENT" type="int" />
|
201
|
+
|
202
|
+
<order by="asc">
|
203
|
+
<order-column name="Height" />
|
204
|
+
</order>
|
205
|
+
|
206
|
+
<!-- Finder methods -->
|
207
|
+
<finder name="ageheightg" return-type="Collection">
|
208
|
+
<finder-column name="Height" />
|
209
|
+
<finder-column name="FromAge" comparator="<="/>
|
210
|
+
<finder-column name="ToAge" comparator=">="/>
|
211
|
+
<finder-column name="Sex" />
|
212
|
+
</finder>
|
213
|
+
</entity>
|
214
|
+
|
215
|
+
<!-- We only use local service here, as we only ever read. -->
|
216
|
+
<entity name="BasePayEntry" local-service="true" remote-service="false" data-source="lemaDataSource" session-factory="lemaSessionFactory" tx-manager="lemaTransactionManager" table="BASE_PAY_VIEW">
|
217
|
+
<column name="rank" type="String" primary="true"/>
|
218
|
+
<column name="armyType" type="String" primary="true" />
|
219
|
+
<column name="trainingType" type="String" primary="true" />
|
220
|
+
<column name="compensation" type="double" />
|
221
|
+
<column name="yearsActive" type="int" primary="true" />
|
222
|
+
|
223
|
+
<order by="asc">
|
224
|
+
<order-column name="armyType" order-by="asc" />
|
225
|
+
<order-column name="trainingType" order-by="desc" />
|
226
|
+
</order>
|
227
|
+
|
228
|
+
<finder name="RankAndYis" return-type="Collection">
|
229
|
+
<finder-column name="rank" />
|
230
|
+
<finder-column name="yearsActive" />
|
231
|
+
</finder>
|
232
|
+
</entity>
|
233
|
+
</service-builder>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<portlet-app schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" version="2.0">
|
3
|
+
<portlet>
|
4
|
+
<portlet-name>bob-list</portlet-name>
|
5
|
+
<display-name>bob-list</display-name>
|
6
|
+
<portlet-class>com.liferay.util.bridges.mvc.MVCPortlet</portlet-class>
|
7
|
+
<init-param>
|
8
|
+
<name>view-template</name>
|
9
|
+
<value>/view.jsp</value>
|
10
|
+
</init-param>
|
11
|
+
<expiration-cache>0</expiration-cache>
|
12
|
+
<supports>
|
13
|
+
<mime-type>text/html</mime-type>
|
14
|
+
</supports>
|
15
|
+
<portlet-info>
|
16
|
+
<title>bob-list</title>
|
17
|
+
<short-title>bob-list</short-title>
|
18
|
+
<keywords>bob-list</keywords>
|
19
|
+
</portlet-info>
|
20
|
+
<security-role-ref>
|
21
|
+
<role-name>administrator</role-name>
|
22
|
+
</security-role-ref>
|
23
|
+
<security-role-ref>
|
24
|
+
<role-name>guest</role-name>
|
25
|
+
</security-role-ref>
|
26
|
+
<security-role-ref>
|
27
|
+
<role-name>power-user</role-name>
|
28
|
+
</security-role-ref>
|
29
|
+
<security-role-ref>
|
30
|
+
<role-name>user</role-name>
|
31
|
+
</security-role-ref>
|
32
|
+
</portlet>
|
33
|
+
</portlet-app>
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative '../lib/r_liferay_lib/prepare_portlet_service'
|
2
|
+
|
3
|
+
class TestFiles
|
4
|
+
|
5
|
+
TEMP_DIR = './test/temp'
|
6
|
+
|
7
|
+
TEMPLATE_DIR = './lib/r_liferay_lib/portlet_service_templates/'
|
8
|
+
|
9
|
+
WEB_INF_DIR = TEMP_DIR + '/' + RLiferayLib::PreparePortletService::WEB_INF_DIR
|
10
|
+
JSP_DIR = TEMP_DIR + '/' + RLiferayLib::PreparePortletService::JSP_DIR
|
11
|
+
JAVA_DIR = TEMP_DIR + '/' + RLiferayLib::PreparePortletService::JAVA_DIR
|
12
|
+
|
13
|
+
PORTLET_XML = './test/portlet.xml'
|
14
|
+
TEMP_PORTLET_XML = "#{WEB_INF_DIR}/portlet.xml"
|
15
|
+
|
16
|
+
TEMP_PLUGIN_PACKAGE_FILE = "#{WEB_INF_DIR}/liferay-plugin-package.properties"
|
17
|
+
|
18
|
+
TEMP_VIEW_JSP = "#{JSP_DIR}/view.jsp"
|
19
|
+
TEMP_INIT_JSP = "#{JSP_DIR}/init.jsp"
|
20
|
+
TEMP_EDIT_JSP = "#{JSP_DIR}/edit.jsp"
|
21
|
+
TEMP_ADD_JSP = "#{JSP_DIR}/add.jsp"
|
22
|
+
|
23
|
+
SERVICE_XML = './test/service.xml'
|
24
|
+
|
25
|
+
POM_XML = './test/pom.xml'
|
26
|
+
|
27
|
+
VIEW_JSP = './lib/r_liferay_lib/portlet_service_templates/view.jsp.erb'
|
28
|
+
INIT_JSP = './lib/r_liferay_lib/portlet_service_templates/init.jsp.erb'
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: RLiferayTool
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Lynch, Mike Zanchi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.2'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.2'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: thor
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.17'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.17'
|
69
|
+
description: A tool to generate opinionated code for a Liferay maven portlet-service
|
70
|
+
project. You must be in the root folder of the Liferay Maven Portlet-Service project.
|
71
|
+
email: chrislynch42@yahoo.com
|
72
|
+
executables:
|
73
|
+
- r_liferay_tool
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- lib/r_liferay_tool.rb
|
78
|
+
- test/liferay-plugin-package.properties
|
79
|
+
- test/pom.xml
|
80
|
+
- test/portlet.xml
|
81
|
+
- test/r_liferay_lib/buildup_mixin.rb
|
82
|
+
- test/r_liferay_lib/cleanup_mixin.rb
|
83
|
+
- test/r_liferay_lib/test_prepare_portlet.rb
|
84
|
+
- test/r_liferay_lib/test_r_liferay_tool.rb
|
85
|
+
- test/r_liferay_lib/test_read_pom.rb
|
86
|
+
- test/r_liferay_lib/test_read_service.rb
|
87
|
+
- test/r_liferay_lib/test_template_utility.rb
|
88
|
+
- test/r_liferay_lib/test_xml_utility.rb
|
89
|
+
- test/service.xml
|
90
|
+
- test/temp/src/main/webapp/WEB-INF/portlet.xml
|
91
|
+
- test/test_helper.rb
|
92
|
+
- bin/r_liferay_tool
|
93
|
+
homepage: https://github.com/ChrisLynch42/RLiferayTool
|
94
|
+
licenses:
|
95
|
+
- GPL v3
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ! '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.1.10
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: A tool to generate opinionated code for a Liferay maven portlet-service project.
|
117
|
+
test_files:
|
118
|
+
- test/liferay-plugin-package.properties
|
119
|
+
- test/pom.xml
|
120
|
+
- test/portlet.xml
|
121
|
+
- test/r_liferay_lib/buildup_mixin.rb
|
122
|
+
- test/r_liferay_lib/cleanup_mixin.rb
|
123
|
+
- test/r_liferay_lib/test_prepare_portlet.rb
|
124
|
+
- test/r_liferay_lib/test_r_liferay_tool.rb
|
125
|
+
- test/r_liferay_lib/test_read_pom.rb
|
126
|
+
- test/r_liferay_lib/test_read_service.rb
|
127
|
+
- test/r_liferay_lib/test_template_utility.rb
|
128
|
+
- test/r_liferay_lib/test_xml_utility.rb
|
129
|
+
- test/service.xml
|
130
|
+
- test/temp/src/main/webapp/WEB-INF/portlet.xml
|
131
|
+
- test/test_helper.rb
|