49
49
from wlsdeploy .aliases .alias_constants import WLST_SUBFOLDERS_PATH
50
50
from wlsdeploy .aliases .alias_constants import WLST_TYPE
51
51
52
+ from wlsdeploy .exception .expection_types import ExceptionType
53
+ from wlsdeploy .tool .util .attribute_setter import AttributeSetter
52
54
53
55
class ListTestCase (unittest .TestCase ):
54
56
_resources_dir = '../../test-classes/'
@@ -496,18 +498,33 @@ def _verify_attribute_set_method_attribute_value(self, folder_name, attribute_na
496
498
SET_METHOD , alias_attribute_value )
497
499
result .append (message )
498
500
else :
499
- offline_value = self .alias_entries ._resolve_curly_braces (alias_attribute_value )
500
- if len (offline_value ) > 0 and not offline_value .startswith ('MBEAN' ):
501
- message = self ._get_invalid_alias_attribute_value_message (folder_name , attribute_name , SET_METHOD ,
502
- 'offline' , offline_value ,
503
- 'it does not start with MBEAN' )
504
- result .append (message )
505
- online_value = self .alias_entries ._resolve_curly_braces (alias_attribute_value )
506
- if offline_value != online_value and len (online_value ) > 0 and not online_value .startswith ('MBEAN' ):
501
+ result .extend (self ._verify_attribute_set_method (folder_name , attribute_name , WlstModes .OFFLINE ,
502
+ alias_attribute_value , self .alias_entries ))
503
+ result .extend (self ._verify_attribute_set_method (folder_name , attribute_name , WlstModes .ONLINE ,
504
+ alias_attribute_value , self .online_alias_entries ))
505
+ return result
506
+
507
+ def _verify_attribute_set_method (self , folder_name , attribute_name , wlst_mode , attribute_value , aliases ):
508
+ result = []
509
+ resolved_attribute = aliases ._resolve_curly_braces (attribute_value )
510
+ if resolved_attribute :
511
+ if not resolved_attribute .startswith ('MBEAN' ):
507
512
message = self ._get_invalid_alias_attribute_value_message (folder_name , attribute_name , SET_METHOD ,
508
- 'online' , online_value ,
513
+ WlstModes .from_value (wlst_mode ),
514
+ resolved_attribute ,
509
515
'it does not start with MBEAN' )
510
516
result .append (message )
517
+ else :
518
+ set_method_value_components = resolved_attribute .split ('.' )
519
+ if len (set_method_value_components ) == 2 :
520
+ invoker = set_method_value_components [1 ]
521
+
522
+ instance = AttributeSetter (aliases , None , ExceptionType .ALIAS , wlst_mode )
523
+ try :
524
+ getattr (instance , invoker )
525
+ except AttributeError :
526
+ result .append (self .set_method_not_found_message (folder_name , attribute_name ,
527
+ WlstModes .from_value (wlst_mode ), invoker ))
511
528
return result
512
529
513
530
def _verify_attribute_uses_path_tokens_attribute_value (self , folder_name , attribute_name , alias_attribute_value ):
@@ -750,3 +767,8 @@ def _get_invalid_alias_attribute_value_message(self, folder_name, attribute_name
750
767
text = 'Folder at path %s has a defined attribute %s with alias attribute %s whose ' \
751
768
'%s value %s was not valid because %s'
752
769
return text % (folder_name , attribute_name , alias_attribute_name , wlst_mode , alias_attribute_value , cause )
770
+
771
+ def set_method_not_found_message (self , folder_name , attribute_name , wlst_mode , alias_attribute_value ):
772
+ text = 'Folder at path %s has a %s defined attribute %s whose set_method %s was not found in the' \
773
+ ' attribute setter class'
774
+ return text % (folder_name , attribute_name , wlst_mode , alias_attribute_value )
0 commit comments