[ 
https://issues.apache.org/jira/browse/DTACLOUD-499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13587039#comment-13587039
 ] 

Michal Fojtik commented on DTACLOUD-499:
----------------------------------------

Attached a sample test case:

 ~/code/core/server › ruby tests/cimi/model/schema_spec.rb 
Run options: --seed 42038

# Running tests:

.....F............

Finished tests in 0.006219s, 2894.4607 tests/s, 14472.3036 assertions/s.

  1) Failure:
test_0005_should convert ref in array(Schema::arrays) 
[tests/cimi/model/schema_spec.rb:246]:
Expected #<struct 
volume_template=#<CIMI::Model::VolumeTemplateRef:0x00000003260220 
@select_attrs=[], @base_id=nil, @attribute_values={:property=>{}, 
:volume_config=>#<CIMI::Model::VolumeConfigurationRef:0x0000000325e358 
@select_attrs=[], @base_id=nil, @attribute_values={:id=>nil, :name=>nil, 
:description=>nil, :created=>nil, :updated=>nil, :property=>{}, :type=>#<struct 
href=nil>, :format=>nil, :capacity=>nil, :operations=>[], :href=>nil}, 
@entity=nil>, :volume_image=>#<CIMI::Model::VolumeImageRef:0x0000000325d318 
@select_attrs=[], @base_id=nil, @attribute_values={:id=>nil, :name=>nil, 
:description=>nil, :created=>nil, :updated=>nil, :property=>{}, 
:image_location=>#<struct href=nil>, :image_data=>nil, :bootable=>nil, 
:operations=>[], :href=>nil}, @entity=nil>, :meter_templates=>[], 
:event_log_template=>#<struct href=nil>, :operations=>[]}, @entity=nil>> 
(#<Class:0x00000003258548>) to respond to #volume_config.

18 tests, 90 assertions, 1 failures, 0 errors, 0 skips
                
> The 'ref' attributes are not (de)serialized properly when used in array
> -----------------------------------------------------------------------
>
>                 Key: DTACLOUD-499
>                 URL: https://issues.apache.org/jira/browse/DTACLOUD-499
>             Project: DeltaCloud
>          Issue Type: Bug
>          Components: CIMI/Frontend
>            Reporter: Michal Fojtik
>            Assignee: David Lutterkort
>         Attachments: 0001-Sample-test.patch
>
>
> If you have this definition in CIMI model (MachineTemplate in this case):
> array :volume_templates do
>   ref :volume_template
> end
> and you use this JSON in .from_json method to create an instance of the 
> MachineTemplate:
> <snip>
> 'volume_templates' : [
>   { 'volumeConfig' : { 'capacity' : '12345' } }
> ]
> </snip>
> The resulting 
> 'machine_template.volume_templates.first.volume_config.capacity' will be 
> 'nil'.
> I tried to play a bit with the input JSON and I found that if you use this:
> <snip>
> 'volume_templates' : [
>   'volume_template' : {
>     { 'volumeConfig' : { 'capacity' : '12345' } }
>   }
> ]
> </snip>
> The resulting 
> 'machine_template.volume_templates.first.volume_template.capacity' is set 
> properly to '12345' :-)
> The XML output then looks like:
> <snip>
>         <volumeTemplate>
>           <volumeTemplate>
>             <volumeConfig>
>               <capacity>10240</capacity>
>             </volumeConfig>
>           </volumeTemplate>
>         </volumeTemplate>
> </snip>
> I think we need to do something smart in the 'array' to remove the upper 
> 'volumeTemplate' or introduce something like 'ref_arr :volume_templates'.
> Anyway, I'm leaving this one to you David, as you might have better schema 
> knowledge than me ;-)
> CC'ing Dies, as he reported this issue original in his email.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to