Skip to content

Commit 618b195

Browse files
authored
Merge pull request #103 from oracle/Issue#102-Aliases-method-missing-from-alias_helper.py
Added missing alias_helper methods and some unit tests
2 parents 40e1182 + 66b3930 commit 618b195

File tree

2 files changed

+132
-1
lines changed

2 files changed

+132
-1
lines changed

core/src/main/python/wlsdeploy/tool/util/alias_helper.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,20 @@ def get_model_topology_top_level_folder_names(self):
522522
"""
523523
return self.__aliases.get_model_topology_top_level_folder_names()
524524

525+
def get_model_resources_top_level_folder_names(self):
526+
"""
527+
Get the model resources top-level folder names.
528+
:return: the list of top-level resources folders
529+
"""
530+
return self.__aliases.get_model_resources_top_level_folder_names()
531+
532+
def get_model_app_deployments_top_level_folder_names(self):
533+
"""
534+
Get the model app_deployments top-level folder names.
535+
:return: the list of top-level app_deployments folders
536+
"""
537+
return self.__aliases.get_model_app_deployments_top_level_folder_names()
538+
525539
def get_model_attribute_names(self, location):
526540
"""
527541
Get the model attribute names.

core/src/test/python/validation_test.py

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
from wlsdeploy.util.model_translator import FileToPython
1111
from wlsdeploy.util.model_context import ModelContext
1212

13+
import validate
1314
from wlsdeploy.tool.validate.validator import Validator
1415
from wlsdeploy.tool.validate import validation_utils
1516
from wlsdeploy.aliases.wlst_modes import WlstModes
1617
from wlsdeploy.aliases import alias_constants
18+
from wlsdeploy.util.cla_utils import CommandLineArgUtil
1719

1820
import oracle.weblogic.deploy.util.TranslateException as TranslateException
19-
21+
from oracle.weblogic.deploy.validate import ValidateException
2022

2123
class ValidationTestCase(unittest.TestCase):
2224
_program_name = 'validation_test'
@@ -65,6 +67,121 @@ def testModelValidation(self):
6567

6668
self.assertNotEqual(return_code, Validator.ReturnCode.STOP)
6769

70+
def testPrintUsageFoldersOnly(self):
71+
_method_name = 'testPrintUsageFoldersOnly'
72+
73+
_FOLDERS_ONLY = '-folders_only'
74+
75+
args = {
76+
'-oracle_home': os.environ['MW_HOME']
77+
}
78+
79+
model_paths = [
80+
'topology:/Server'
81+
]
82+
83+
try:
84+
# Loop through valid list of model sections
85+
for model_path in model_paths:
86+
# Set print usage context
87+
args['-print_usage'] = '%s %s' % (model_path, _FOLDERS_ONLY)
88+
self._logger.info('args={0}', str(args), class_name=self._class_name, method_name=_method_name)
89+
model_context = ModelContext(self._program_name, args)
90+
model_validator = Validator(model_context, wlst_mode=WlstModes.ONLINE)
91+
model_validator.print_usage(model_path)
92+
self.assertEquals(True, True)
93+
except ValidateException, ve:
94+
self.fail(ve.getLocalizedMessage())
95+
96+
return
97+
98+
def testPrintUsageAttributesOnly(self):
99+
_method_name = 'testPrintUsageAttributesOnly'
100+
101+
_ATTRIBUTES_ONLY = '-attributes_only'
102+
103+
args = {
104+
'-oracle_home': os.environ['MW_HOME']
105+
}
106+
107+
model_paths = [
108+
'domainInfo'
109+
]
110+
111+
try:
112+
# Loop through valid list of model sections
113+
for model_path in model_paths:
114+
# Set print usage context
115+
args['-print_usage'] = '%s %s' % (model_path, _ATTRIBUTES_ONLY)
116+
self._logger.info('args={0}', str(args), class_name=self._class_name, method_name=_method_name)
117+
model_context = ModelContext(self._program_name, args)
118+
model_validator = Validator(model_context, wlst_mode=WlstModes.ONLINE)
119+
model_validator.print_usage(model_path)
120+
self.assertEquals(True, True)
121+
except ValidateException, ve:
122+
self.fail(ve.getLocalizedMessage())
123+
124+
return
125+
126+
def testPrintUsageRecursive(self):
127+
_method_name = 'testPrintUsageRecursive'
128+
129+
_RECURSIVE = '-recursive'
130+
131+
args = {
132+
'-oracle_home': os.environ['MW_HOME']
133+
}
134+
135+
model_paths = [
136+
'appDeployments:/Application'
137+
]
138+
139+
try:
140+
# Loop through valid list of model sections
141+
for model_path in model_paths:
142+
# Set print usage context
143+
args['-print_usage'] = '%s %s' % (model_path, _RECURSIVE)
144+
self._logger.info('args={0}', str(args), class_name=self._class_name, method_name=_method_name)
145+
model_context = ModelContext(self._program_name, args)
146+
model_validator = Validator(model_context, wlst_mode=WlstModes.ONLINE)
147+
model_validator.print_usage(model_path)
148+
self.assertEquals(True, True)
149+
except ValidateException, ve:
150+
self.fail(ve.getLocalizedMessage())
151+
152+
return
153+
154+
def testPrintUsageCLAEnforcement(self):
155+
_method_name = 'testPrintUsageCLAEnforcement'
156+
157+
_FOLDERS_ONLY = '-folders_only'
158+
_RECURSIVE = '-recursive'
159+
160+
args = list()
161+
args.append(self._program_name)
162+
args.append('-oracle_home')
163+
args.append(os.environ['MW_HOME'])
164+
args.append('-print_usage')
165+
args.append('topology:/Server')
166+
args.append(_FOLDERS_ONLY)
167+
args.append('')
168+
args.append(_RECURSIVE)
169+
170+
self._logger.info('args={0}', str(args), class_name=self._class_name, method_name=_method_name)
171+
172+
try:
173+
# Should raise an exception because control options
174+
# are mutually exclusive, and we passed _FOLDERS_ONLY
175+
# and _RECURSIVE
176+
validate.main(args)
177+
except ValidateException, ve:
178+
self.fail(ve.getLocalizedMessage())
179+
except SystemExit, se:
180+
exit_code = str(se)
181+
self.assertEqual(exit_code, str(CommandLineArgUtil.USAGE_ERROR_EXIT_CODE))
182+
183+
return
184+
68185
def testIsCompatibleDataType(self):
69186
_method_name = 'testIsCompatibleDataType'
70187

0 commit comments

Comments
 (0)