1#!/usr/bin/perl 2 3use strict; 4use warnings; 5 6use Test::Deep; 7use Test::Exception; 8use Test::More; 9use XML::TreePP; 10 11use FusionInventory::Agent::XML::Query; 12 13plan tests => 7; 14 15my $message; 16throws_ok { 17 $message = FusionInventory::Agent::XML::Query->new( 18 deviceid => 'foo', 19 ); 20} qr/^no query/, 'no query type'; 21 22lives_ok { 23 $message = FusionInventory::Agent::XML::Query->new( 24 deviceid => 'foo', 25 query => 'TEST', 26 foo => 'foo', 27 ); 28} 'everything OK'; 29 30isa_ok($message, 'FusionInventory::Agent::XML::Query'); 31 32my $tpp = XML::TreePP->new(); 33 34cmp_deeply( 35 scalar $tpp->parse($message->getContent()), 36 { 37 REQUEST => { 38 DEVICEID => 'foo', 39 FOO => 'foo', 40 QUERY => 'TEST' 41 } 42 }, 43 'expected content' 44); 45 46lives_ok { 47 $message = FusionInventory::Agent::XML::Query->new( 48 deviceid => 'foo', 49 query => 'TEST', 50 foo => 'foo', 51 castor => [ 52 { 53 FOO => 'fu', 54 FFF => 'GG', 55 GF => [ { FFFF => 'GG' } ] 56 }, 57 { 58 FddF => [ { GG => 'O' } ] 59 } 60 ] 61 ); 62} 'everything OK'; 63 64isa_ok($message, 'FusionInventory::Agent::XML::Query'); 65 66cmp_deeply( 67 scalar $tpp->parse($message->getContent()), 68 { 69 REQUEST => { 70 CASTOR => [ 71 { 72 FFF => 'GG', 73 FOO => 'fu', 74 GF => { FFFF => 'GG' } 75 }, 76 { 77 FddF => { GG => 'O' } 78 } 79 ], 80 DEVICEID => 'foo', 81 FOO => 'foo', 82 QUERY => 'TEST' 83 } 84 }, 85 'expected content' 86); 87