@@ -23,6 +23,7 @@ use utf8;
2323# CPAN modules
2424use HTTP::Request::Common qw( GET) ;
2525use Test2::V0;
26+ use Try::Tiny;
2627
2728# OTOBO modules
2829use Kernel::System::UnitTest::RegisterOM; # Set up $Kernel::OM
@@ -143,11 +144,7 @@ my @Tests = (
143144 UserID => 1,
144145 },
145146 Request => " Action=someaction;Subaction=somesubaction;ArticleID=-1" ,
146- Success => 1,
147- ExectedResult => {
148- ObjectID => -1,
149- Data => {},
150- },
147+ Throws => 1,
151148 },
152149 {
153150 Name => ' Wrong ArticleID and TicketID in the request' ,
@@ -156,11 +153,7 @@ my @Tests = (
156153 UserID => 1,
157154 },
158155 Request => " Action=someaction;Subaction=somesubaction;ArticleID=-1;TicketID=-1" ,
159- Success => 1,
160- ExectedResult => {
161- ObjectID => -1,
162- Data => {},
163- },
156+ Throws => 1,
164157 },
165158 {
166159 Name => ' Correct Article with wrong TicketID in the request' ,
@@ -169,11 +162,7 @@ my @Tests = (
169162 UserID => 1,
170163 },
171164 Request => " Action=someaction;Subaction=somesubaction;ArticleID=$ArticleID ;TicketID=-1" ,
172- Success => 1,
173- ExectedResult => {
174- ObjectID => $ArticleID ,
175- Data => {},
176- },
165+ Throws => 1,
177166 },
178167 {
179168 Name => ' Correct Article without TicketID in the request' ,
@@ -208,6 +197,7 @@ my $ObjectHandlerObject = $Kernel::OM->Get('Kernel::System::DynamicField::Object
208197TEST:
209198for my $Test (@Tests ) {
210199
200+ print STDERR " TEST: $Test ->{Name} \n " ;
211201 # force the ParamObject to use the new request params
212202 my $QueryString = $Test -> {Request } // ' ' ;
213203 $Kernel::OM -> ObjectParamAdd(
@@ -217,7 +207,18 @@ for my $Test (@Tests) {
217207 );
218208
219209 # implicitly call Kernel::System::Web::Request->new();
220- my %ObjectData = $ObjectHandlerObject -> ObjectDataGet( %{ $Test -> {Config } } );
210+ my %ObjectData ;
211+ try {
212+ %ObjectData = $ObjectHandlerObject -> ObjectDataGet( %{ $Test -> {Config } } );
213+ }
214+ catch {
215+
216+ if ( !$Test -> {Throws } ) {
217+
218+ ok(0," $Test ->{Name} - not expected to throw" );
219+ }
220+ next TEST;
221+ };
221222
222223 if ( !$Test -> {Success } ) {
223224 is(
0 commit comments