summaryrefslogtreecommitdiff
path: root/test/toxbank-investigation-types.rb
blob: a5fa45d1f1d54914fa2393414fcadf15faab9ee4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
require_relative "toxbank-setup.rb"
require File.join(File.expand_path(File.dirname(__FILE__)),".." ,".." ,"toxbank-investigation", "util.rb")

begin
  puts "Service URI is: #{$investigation[:uri]}"
rescue
  puts "Configuration Error: $investigation[:uri] is not defined in: " + File.join(ENV["HOME"],".opentox","config","test.rb")
  exit
end

class TBInvestigationNoISADataInvalidPOST < MiniTest::Test
  
  # no file no params
  # @note expect OpenTox::BadRequestError
  def test_nofile_nodata
    puts "\nno data no params"
    response = OpenTox::RestClientWrapper.post $investigation[:uri], {}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task_uri
    assert_equal "Error", task.hasStatus, "Task should be not completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    assert_match "No file uploaded or parameters given.", task.error_report[RDF::OT.message], "wrong error: #{task.error_report[RDF::OT.message]}."

  end

  ## test types
  # attached file but missing type
  # @note expect OpenTox::BadRequestError
  def test_attached_file_missing_type  
    puts "\nattached file but missing type"
    file = File.join File.dirname(__FILE__), "data/toxbank-investigation/valid", "unformated.zip"
    response = OpenTox::RestClientWrapper.post $investigation[:uri], {:file => File.open(file), :title => "New Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :owningPro => "#{$user_service}/project/G81, #{$user_service[:uri]}/project/G79", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727" }, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task_uri
    assert_equal "Error", task.hasStatus, "Task should be not completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    assert_match "Could not parse isatab file in 'unformated.zip'.", task.error_report[RDF::OT.message], "wrong error: #{task.error_report[RDF::OT.message]}."
  end
  
  # type noData but ftp file in params
  # @note expect OpenTox::BadRequestError
  def test_noData
    puts "\ntype noData but ftp file in params"
    response = OpenTox::RestClientWrapper.post $investigation[:uri], {:type => "noData", :title => "New Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :owningPro => "#{$user_service}/project/G81", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727", :ftpFile => "JIC37_Ethanol_0.07_Internal_1_3.txt"}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task_uri
    assert_equal "Error", task.hasStatus, "Task should be not completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    assert_equal "Parameter 'ftpData' not expected for type 'noData'.", task.error_report[RDF::OT.message], "wrong error: #{task.error_report[RDF::OT.message]}."
  end
  
  # attached file but type is noData
  # @note expect OpenTox::BadRequestError
  def test_wrong_type_noData
    puts "\nattached file but type is noData"
    file = File.join File.dirname(__FILE__), "data/toxbank-investigation/valid", "unformated.zip"
    response = OpenTox::RestClientWrapper.post $investigation[:uri], {:file => File.open(file), :type => "noData", :title => "New Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :owningPro => "#{$user_service}/project/G81", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727"}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task_uri
    assert_equal "Error", task.hasStatus, "Task should be not completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    assert_equal "No file expected for type 'noData'.", task.error_report[RDF::OT.message], "wrong error: #{task.error_report[RDF::OT.message]}."
  end
  
  # attached file but type is ftpData
  # @note expect OpenTox::BadRequestError
  def test_wrong_type_ftpData
    puts "\nattached file but type is ftpData"
    file = File.join File.dirname(__FILE__), "data/toxbank-investigation/valid", "unformated.zip"
    response = OpenTox::RestClientWrapper.post $investigation[:uri], {:file => File.open(file), :type => "ftpData", :title => "New Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :owningPro => "#{$user_service}/project/G81", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727"}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task_uri
    assert_equal "Error", task.hasStatus, "Task should be not completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    assert_equal "No file expected for type 'ftpData'.", task.error_report[RDF::OT.message], "wrong error: #{task.error_report[RDF::OT.message]}."
  end
  
  # unknown inv type
  # @note expect OpenTox::BadRequestError
  def test_unknown_inv_type
    puts "\nunknown inv type"
    response = OpenTox::RestClientWrapper.post $investigation[:uri], { :type => "Data", :title => "New Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :owningPro => "#{$user_service}/project/G81", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727"}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task_uri
    assert_equal "Error", task.hasStatus, "Task should be not completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    assert_equal "Investigation type 'Data' not supported.", task.error_report[RDF::OT.message], "wrong error: #{task.error_report[RDF::OT.message]}."
  end
  
  # attached file unknown inv type
  # @note expect OpenTox::BadRequestError
  def test_file_unknown_inv_type
    puts "\nattached file unknown inv type"
    file = File.join File.dirname(__FILE__), "data/toxbank-investigation/valid", "unformated.zip"
    response = OpenTox::RestClientWrapper.post $investigation[:uri], { :file => File.open(file), :type => "Data", :title => "New Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :owningPro => "#{$user_service}/project/G81", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727"}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task_uri
    assert_equal "Error", task.hasStatus, "Task should be not completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    assert_equal "Investigation type 'Data' not supported.", task.error_report[RDF::OT.message], "wrong error: #{task.error_report[RDF::OT.message]}."
  end
  ## test parameters
  # missing title
  # @note expect OpenTox::BadRequestError
  def test_attached_file_missing_title  
    puts "\nattached file missing title"
    file = File.join File.dirname(__FILE__), "data/toxbank-investigation/valid", "unformated.zip"
    response = OpenTox::RestClientWrapper.post $investigation[:uri], {:file => File.open(file), :type => "unformattedData", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :owningPro => "#{$user_service}/project/G81", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727" }, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task_uri
    assert_equal "Error", task.hasStatus, "Task should be not completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    assert_match "Parameter 'title' is required.", task.error_report[RDF::OT.message], "wrong error: #{task.error_report[RDF::OT.message]}."
  end
  
  # missing abstract
  # @note expect OpenTox::BadRequestError
  def test_attached_file_missing_abstract  
    puts "\nattached file missing abstract"
    file = File.join File.dirname(__FILE__), "data/toxbank-investigation/valid", "unformated.zip"
    response = OpenTox::RestClientWrapper.post $investigation[:uri], {:file => File.open(file), :type => "unformattedData", :title => "New Title", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :owningPro => "#{$user_service}/project/G81", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727" }, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task_uri
    assert_equal "Error", task.hasStatus, "Task should be not completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    assert_match "Parameter 'abstract' is required.", task.error_report[RDF::OT.message], "wrong error: #{task.error_report[RDF::OT.message]}."
  end

  # missing owningOrg
  # @note expect OpenTox::BadRequestError
  def test_attached_file_missing_owningOrg
    puts "\nattached file missing owningOrg"
    file = File.join File.dirname(__FILE__), "data/toxbank-investigation/valid", "unformated.zip"
    response = OpenTox::RestClientWrapper.post $investigation[:uri], {:file => File.open(file), :type => "unformattedData", :title => "New Title", :abstract => "This is a short description", :owningPro => "#{$user_service}/project/G81", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727" }, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task_uri
    assert_equal "Error", task.hasStatus, "Task should be not completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    assert_equal "Parameter 'owningOrg' is required.", task.error_report[RDF::OT.message], "wrong error: #{task.error_report[RDF::OT.message]}."
  end
  
  # missing owningPro
  # @note expect OpenTox::BadRequestError
  def test_attached_file_missing_owningPro
    puts "\nattached file missing owningPro"
    file = File.join File.dirname(__FILE__), "data/toxbank-investigation/valid", "unformated.zip"
    response = OpenTox::RestClientWrapper.post $investigation[:uri], {:file => File.open(file), :type => "unformattedData", :title => "New Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727" }, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task_uri
    assert_equal "Error", task.hasStatus, "Task should be not completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    assert_equal "Parameter 'owningPro' is required.", task.error_report[RDF::OT.message], "wrong error: #{task.error_report[RDF::OT.message]}."
  end
  
  # missing authors
  # @note expect OpenTox::BadRequestError
  def test_attached_file_missing_authors
    puts "\nattached file missing authors"
    file = File.join File.dirname(__FILE__), "data/toxbank-investigation/valid", "unformated.zip"
    response = OpenTox::RestClientWrapper.post $investigation[:uri], {:file => File.open(file), :type => "unformattedData", :title => "New Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :owningPro => "#{$user_service}/project/G81", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727" }, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task_uri
    assert_equal "Error", task.hasStatus, "Task should be not completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    assert_equal "Parameter 'authors' is required.", task.error_report[RDF::OT.message], "wrong error: #{task.error_report[RDF::OT.message]}."
  end
  
  # missing keywords
  # @note expect OpenTox::BadRequestError
  def test_attached_file_missing_keywords
    puts "\nattached file missing keywords"
    file = File.join File.dirname(__FILE__), "data/toxbank-investigation/valid", "unformated.zip"
    response = OpenTox::RestClientWrapper.post $investigation[:uri], {:file => File.open(file), :type => "unformattedData", :title => "New Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :owningPro => "#{$user_service}/project/G81", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479" }, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task_uri
    assert_equal "Error", task.hasStatus, "Task should be not completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    assert_equal "Parameter 'keywords' is required.", task.error_report[RDF::OT.message], "wrong error: #{task.error_report[RDF::OT.message]}."
  end


  ## test mime type
  # attached file wrong mime type
  # @note expect OpenTox::BadRequestError
  def test_wrong_mime
    puts "\nattached file wrong mime"
    file = File.join File.dirname(__FILE__), "data/toxbank-investigation/invalid", "empty.zup"
    response = OpenTox::RestClientWrapper.post $investigation[:uri], {:file => File.open(file), :type => "noData", :title => "New Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :owningPro => "#{$user_service}/project/G81", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727"}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task_uri
    assert_equal "Error", task.hasStatus, "Task should be not completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    assert_equal "Mime type text/plain not supported. Please submit data as zip archive (application/zip).", task.error_report[RDF::OT.message], "wrong error: #{task.error_report[RDF::OT.message]}."
  end

  # test file size

  # unformated data larger 10MB
  # @note expect OpenTox::BadRequestError
  def test_file_larger_10mb
    puts "\nunformated data larger 10MB"
    file = File.join File.dirname(__FILE__), "data/toxbank-investigation/invalid", "unformated10mb.zip"
    response = OpenTox::RestClientWrapper.post $investigation[:uri], {:file => File.open(file), :type => "unformattedData", :title => "New Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :owningPro => "#{$user_service}/project/G81", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727"}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task_uri
    assert_equal "Error", task.hasStatus, "Task should be not completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    assert_equal "File 'unformated10mb.zip' is to large. Please choose FTP investigation type and upload to your FTP directory first.", task.error_report[RDF::OT.message], "wrong error: #{task.error_report[RDF::OT.message]}."
  end
  
  # invalid param URI
  # @note expect OpenTox::BadRequestError
  def test_invalid_param_uri
    puts "\ninvalid param URI"
    file = File.join File.dirname(__FILE__), "data/toxbank-investigation/valid", "unformated.zip"
    response = OpenTox::RestClientWrapper.post $investigation[:uri], {:file => File.open(file), :type => "unformattedData", :title => "New Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :owningPro => "#{$user_service[:uri]}/project/G81", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/oxbank.owl/K727"}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task_uri
    assert_equal "Error", task.hasStatus, "Task should be not completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    assert_equal "'http://www.owl-ontologies.com/oxbank.owl/K727' is not a valid URI.", task.error_report[RDF::OT.message], "wrong error: #{task.error_report[RDF::OT.message]}."
  end

end

class TBInvestigationNoISADataValidPOST < MiniTest::Test

  def test_01_post_type_nodata
    puts "\nvalid noData"
    response =  OpenTox::RestClientWrapper.post $investigation[:uri], {:type => "noData", :title => "New Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :owningPro => "#{$user_service[:uri]}/project/G81", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727"}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task.uri
    uri = task.resultURI
    assert_equal "Completed", task.hasStatus, "Task should be completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    
    # GET metadata
    response = OpenTox::RestClientWrapper.get uri.to_s+"/metadata", {}, {:accept => "application/rdf+xml", :subjectid => $pi[:subjectid] }
    @g = RDF::Graph.new
    RDF::Reader.for(:rdfxml).new(response.to_s){|r| r.each{|s| @g << s}}
    #@g.each{|g| puts g.object}
    @g.query(:predicate => RDF::TB.hasInvType){|r| assert_match /noData/, r[2].to_s}
    @g.query(:predicate => RDF::DC.modified){|r| assert_equal uri.to_s, r[0].to_s}
    expected_owner = ["#{$user_service[:uri]}/user/U271"]
    owner = @g.query(:predicate => RDF::TB.hasOwner).collect{|r| r[2].to_s}
    assert_equal owner, expected_owner
    expected_authors = ["#{$user_service[:uri]}/user/U271", "#{$user_service[:uri]}/user/U479"]
    authors = @g.query(:predicate => RDF::TB.hasAuthor).collect{|r| r[2].to_s}
    assert_equal authors, expected_authors
    expected_keywords = ["http://www.owl-ontologies.com/toxbank.owl/K124", "http://www.owl-ontologies.com/toxbank.owl/K727"]
    keywords = @g.query(:predicate => RDF::TB.hasKeyword).collect{|r| r[2].to_s}
    assert_equal keywords, expected_keywords
    orgs = ["#{$user_service[:uri]}/organisation/G16"]
    expected_orgs = @g.query(:predicate => RDF::TB.hasOrganisation).collect{|r| r[2].to_s}
    assert_equal orgs, expected_orgs
    @g.query(:predicate => RDF::TB.hasProject){|r| assert_match "#{$user_service[:uri]}/project/G81", r[2].to_s}
    @g.query(:predicate => RDF::DC.title){|r| assert_match /New Title/, r[2].to_s}
    @g.query(:predicate => RDF::DC.abstract){|r| assert_match /This is a short description/, r[2].to_s}
    @g.query(:predicate => RDF::TB.isSummarySearchable){|r| assert_match /false/, r[2].to_s}
    @g.query(:predicate => RDF::TB.isPublished){|r| assert_match /false/, r[2].to_s}
    
    # PUT
    response =  OpenTox::RestClientWrapper.put uri, {:type => "noData", :title => "Second Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :owningPro => "#{$user_service[:uri]}/project/G81", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727"}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task.uri
    uri = task.resultURI
    assert_equal "Completed", task.hasStatus, "Task should be completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    
    # GET metadata
    response = OpenTox::RestClientWrapper.get uri.to_s+"/metadata", {}, {:accept => "application/rdf+xml", :subjectid => $pi[:subjectid] }
    assert_equal "200", response.code.to_s
    @g = RDF::Graph.new
    RDF::Reader.for(:rdfxml).new(response.to_s){|r| r.each{|s| @g << s}}
    #@g.each{|g| puts g.object}
    @g.query(:predicate => RDF::TB.hasInvType){|r| assert_match /noData/, r[2].to_s}
    @g.query(:predicate => RDF::DC.modified){|r| assert_equal uri.to_s, r[0].to_s}
    expected_owner = ["#{$user_service[:uri]}/user/U271"]
    owner = @g.query(:predicate => RDF::TB.hasOwner).collect{|r| r[2].to_s}
    assert_equal owner, expected_owner
    expected_authors = ["#{$user_service[:uri]}/user/U271", "#{$user_service[:uri]}/user/U479"]
    authors = @g.query(:predicate => RDF::TB.hasAuthor).collect{|r| r[2].to_s}
    assert_equal authors, expected_authors
    expected_keywords = ["http://www.owl-ontologies.com/toxbank.owl/K124", "http://www.owl-ontologies.com/toxbank.owl/K727"]
    keywords = @g.query(:predicate => RDF::TB.hasKeyword).collect{|r| r[2].to_s}
    assert_equal keywords, expected_keywords
    orgs = ["#{$user_service[:uri]}/organisation/G16"]
    expected_orgs = @g.query(:predicate => RDF::TB.hasOrganisation).collect{|r| r[2].to_s}
    assert_equal orgs, expected_orgs
    @g.query(:predicate => RDF::DC.title){|r| assert_match /Second Title/, r[2].to_s}
    @g.query(:predicate => RDF::DC.abstract){|r| assert_match /This is a short description/, r[2].to_s}
    @g.query(:predicate => RDF::TB.isSummarySearchable){|r| assert_match /false/, r[2].to_s}
    @g.query(:predicate => RDF::TB.isPublished){|r| assert_match /false/, r[2].to_s}
    
    # DELETE
    response =  OpenTox::RestClientWrapper.delete uri.to_s, {}, { :subjectid => $pi[:subjectid] }
    assert_equal "200", response.code.to_s
  end

  def test_02_post_type_ftpdata
    puts "\nvalid ftpData"
    response = OpenTox::RestClientWrapper.post $investigation[:uri], {:type => "ftpData", :title => "New Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :owningPro => "#{$user_service[:uri]}/project/G81", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727", :ftpFile => "JIC37_Ethanol_0.07_Internal_1_3.txt"}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task.uri
    uri = task.resultURI
    assert_equal "Completed", task.hasStatus, "Task should be completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    
    # GET metadata
    response = OpenTox::RestClientWrapper.get uri.to_s+"/metadata", {}, {:accept => "application/rdf+xml", :subjectid => $pi[:subjectid] }
    assert_equal "200", response.code.to_s
    @g = RDF::Graph.new
    RDF::Reader.for(:rdfxml).new(response.to_s){|r| r.each{|s| @g << s}}
    #@g.each{|g| puts g.object}
    @g.query(:predicate => RDF::TB.hasInvType){|r| assert_match /ftpData/, r[2].to_s}
    @g.query(:predicate => RDF::DC.modified){|r| assert_equal uri.to_s, r[0].to_s}
    expected_owner = ["#{$user_service[:uri]}/user/U271"]
    owner = @g.query(:predicate => RDF::TB.hasOwner).collect{|r| r[2].to_s}
    assert_equal owner, expected_owner
    expected_authors = ["#{$user_service[:uri]}/user/U271", "#{$user_service[:uri]}/user/U479"]
    authors = @g.query(:predicate => RDF::TB.hasAuthor).collect{|r| r[2].to_s}
    assert_equal authors, expected_authors
    expected_keywords = ["http://www.owl-ontologies.com/toxbank.owl/K124", "http://www.owl-ontologies.com/toxbank.owl/K727"]
    keywords = @g.query(:predicate => RDF::TB.hasKeyword).collect{|r| r[2].to_s}
    assert_equal keywords, expected_keywords
    orgs = ["#{$user_service[:uri]}/organisation/G16"]
    expected_orgs = @g.query(:predicate => RDF::TB.hasOrganisation).collect{|r| r[2].to_s}
    assert_equal orgs, expected_orgs
    @g.query(:predicate => RDF::DC.title){|r| assert_match /New Title/, r[2].to_s}
    @g.query(:predicate => RDF::DC.abstract){|r| assert_match /This is a short description/, r[2].to_s}
    @g.query(:predicate => RDF::TB.isSummarySearchable){|r| assert_match /false/, r[2].to_s}
    @g.query(:predicate => RDF::TB.isPublished){|r| assert_match /false/, r[2].to_s}
    
    # GET file in uri-list
    response = OpenTox::RestClientWrapper.get uri.to_s, {}, {:accept => "text/uri-list", :subjectid => $pi[:subjectid] }
    assert_match /JIC37_Ethanol_0.07_Internal_1_3.txt/, response.to_s
    
    # GET file
    response = OpenTox::RestClientWrapper.get uri.to_s+"/files/JIC37_Ethanol_0.07_Internal_1_3.txt", {}, { :subjectid => $pi[:subjectid] }
    assert_equal "200", response.code.to_s
    assert_match /isttest/, response.to_s
    
    # PUT
    response =  OpenTox::RestClientWrapper.put uri, {:type => "ftpData", :title => "Second Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :owningPro => "#{$user_service[:uri]}/project/G81", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727", :ftpFile => "JIC37_Ethanol_0.07_Internal_1_3.txt"}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task.uri
    uri = task.resultURI
    assert_equal "Completed", task.hasStatus, "Task should be completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."

    # GET metadata
    response = OpenTox::RestClientWrapper.get uri.to_s+"/metadata", {}, {:accept => "application/rdf+xml", :subjectid => $pi[:subjectid] }
    assert_equal "200", response.code.to_s
    @g = RDF::Graph.new
    RDF::Reader.for(:rdfxml).new(response.to_s){|r| r.each{|s| @g << s}}
    #@g.each{|g| puts g.object}
    @g.query(:predicate => RDF::TB.hasInvType){|r| assert_match /ftpData/, r[2].to_s}
    @g.query(:predicate => RDF::DC.modified){|r| assert_equal uri.to_s, r[0].to_s}
    expected_owner = ["#{$user_service[:uri]}/user/U271"]
    owner = @g.query(:predicate => RDF::TB.hasOwner).collect{|r| r[2].to_s}
    assert_equal owner, expected_owner
    expected_authors = ["#{$user_service[:uri]}/user/U271", "#{$user_service[:uri]}/user/U479"]
    authors = @g.query(:predicate => RDF::TB.hasAuthor).collect{|r| r[2].to_s}
    assert_equal authors, expected_authors
    expected_keywords = ["http://www.owl-ontologies.com/toxbank.owl/K124", "http://www.owl-ontologies.com/toxbank.owl/K727"]
    keywords = @g.query(:predicate => RDF::TB.hasKeyword).collect{|r| r[2].to_s}
    assert_equal keywords, expected_keywords
    orgs = ["#{$user_service[:uri]}/organisation/G16"]
    expected_orgs = @g.query(:predicate => RDF::TB.hasOrganisation).collect{|r| r[2].to_s}
    assert_equal orgs, expected_orgs
    @g.query(:predicate => RDF::DC.title){|r| assert_match /Second Title/, r[2].to_s}
    @g.query(:predicate => RDF::DC.abstract){|r| assert_match /This is a short description/, r[2].to_s}
    @g.query(:predicate => RDF::TB.isSummarySearchable){|r| assert_match /false/, r[2].to_s}
    @g.query(:predicate => RDF::TB.isPublished){|r| assert_match /false/, r[2].to_s}

    # DELETE
    response =  OpenTox::RestClientWrapper.delete uri.to_s, {}, { :subjectid => $pi[:subjectid] }
    assert_equal "200", response.code.to_s
  end

  def test_03_post_type_unformattedData
    puts "\nvalid unformattedData"
    file = File.join File.dirname(__FILE__), "data/toxbank-investigation/valid", "unformated.zip"
    response = OpenTox::RestClientWrapper.post $investigation[:uri], {:file => File.open(file), :type => "unformattedData", :title => "New Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :owningPro => "#{$user_service[:uri]}/project/G81", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727"}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task.uri
    uri = task.resultURI
    assert_equal "Completed", task.hasStatus, "Task should be completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    
    # GET metadata
    response = OpenTox::RestClientWrapper.get uri.to_s+"/metadata", {}, {:accept => "application/rdf+xml", :subjectid => $pi[:subjectid] }
    assert_equal "200", response.code.to_s
    @g = RDF::Graph.new
    RDF::Reader.for(:rdfxml).new(response.to_s){|r| r.each{|s| @g << s}}
    #@g.each{|g| puts g.object}
    @g.query(:predicate => RDF::TB.hasInvType){|r| assert_match /unformattedData/, r[2].to_s}
    @g.query(:predicate => RDF::DC.modified){|r| assert_equal uri.to_s, r[0].to_s}
    expected_owner = ["#{$user_service[:uri]}/user/U271"]
    owner = @g.query(:predicate => RDF::TB.hasOwner).collect{|r| r[2].to_s}
    assert_equal owner, expected_owner
    expected_authors = ["#{$user_service[:uri]}/user/U271", "#{$user_service[:uri]}/user/U479"]
    authors = @g.query(:predicate => RDF::TB.hasAuthor).collect{|r| r[2].to_s}
    assert_equal authors, expected_authors
    expected_keywords = ["http://www.owl-ontologies.com/toxbank.owl/K124", "http://www.owl-ontologies.com/toxbank.owl/K727"]
    keywords = @g.query(:predicate => RDF::TB.hasKeyword).collect{|r| r[2].to_s}
    assert_equal keywords, expected_keywords
    orgs = ["#{$user_service[:uri]}/organisation/G16"]
    expected_orgs = @g.query(:predicate => RDF::TB.hasOrganisation).collect{|r| r[2].to_s}
    assert_equal orgs, expected_orgs
    @g.query(:predicate => RDF::DC.title){|r| assert_match /New Title/, r[2].to_s}
    @g.query(:predicate => RDF::DC.abstract){|r| assert_match /This is a short description/, r[2].to_s}
    @g.query(:predicate => RDF::TB.isSummarySearchable){|r| assert_match /false/, r[2].to_s}
    @g.query(:predicate => RDF::TB.isPublished){|r| assert_match /false/, r[2].to_s}
    
    # GET file by uri-list
    response = OpenTox::RestClientWrapper.get uri.to_s, {}, {:accept => "text/uri-list", :subjectid => $pi[:subjectid] }
    assert_match /files\/unformated\.zip/, response.to_s
    
    # PUT
    response =  OpenTox::RestClientWrapper.put uri, {:file => File.open(file), :type => "unformattedData", :title => "Second Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :owningPro => "#{$user_service[:uri]}/project/G81", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727"}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task.uri
    uri = task.resultURI
    assert_equal "Completed", task.hasStatus, "Task should be completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."

    # GET metadata
    response = OpenTox::RestClientWrapper.get uri.to_s+"/metadata", {}, {:accept => "application/rdf+xml", :subjectid => $pi[:subjectid] }
    assert_equal "200", response.code.to_s
    @g = RDF::Graph.new
    RDF::Reader.for(:rdfxml).new(response.to_s){|r| r.each{|s| @g << s}}
    #@g.each{|g| puts g.object}
    @g.query(:predicate => RDF::TB.hasInvType){|r| assert_match /unformattedData/, r[2].to_s}
    @g.query(:predicate => RDF::DC.modified){|r| assert_equal uri.to_s, r[0].to_s}
    expected_owner = ["#{$user_service[:uri]}/user/U271"]
    owner = @g.query(:predicate => RDF::TB.hasOwner).collect{|r| r[2].to_s}
    assert_equal owner, expected_owner
    expected_authors = ["#{$user_service[:uri]}/user/U271", "#{$user_service[:uri]}/user/U479"]
    authors = @g.query(:predicate => RDF::TB.hasAuthor).collect{|r| r[2].to_s}
    assert_equal authors, expected_authors
    expected_keywords = ["http://www.owl-ontologies.com/toxbank.owl/K124", "http://www.owl-ontologies.com/toxbank.owl/K727"]
    keywords = @g.query(:predicate => RDF::TB.hasKeyword).collect{|r| r[2].to_s}
    assert_equal keywords, expected_keywords
    orgs = ["#{$user_service[:uri]}/organisation/G16"]
    expected_orgs = @g.query(:predicate => RDF::TB.hasOrganisation).collect{|r| r[2].to_s}
    assert_equal orgs, expected_orgs
    @g.query(:predicate => RDF::DC.title){|r| assert_match /Second Title/, r[2].to_s}
    @g.query(:predicate => RDF::DC.abstract){|r| assert_match /This is a short description/, r[2].to_s}
    @g.query(:predicate => RDF::TB.isSummarySearchable){|r| assert_match /false/, r[2].to_s}
    @g.query(:predicate => RDF::TB.isPublished){|r| assert_match /false/, r[2].to_s}
    
    # DELETE
    #response =  OpenTox::RestClientWrapper.delete uri.to_s, {}, { :subjectid => $pi[:subjectid] }
    #assert_equal "200", response.code.to_s
  end
  
  def test_post_type_nodata_put_error
    puts "\nvalid noData"
    response =  OpenTox::RestClientWrapper.post $investigation[:uri], {:type => "noData", :title => "New Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :owningPro => "#{$user_service[:uri]}/project/G81", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727"}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task.uri
    uri = task.resultURI
    @uri = uri
    assert_equal "Completed", task.hasStatus, "Task should be completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    
    # PUT missing type
    puts "\nPUT missing type expect error"
    response =  OpenTox::RestClientWrapper.put @uri.to_s, { :title => "Second Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :owningPro => "#{$user_service[:uri]}/project/G81", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727"}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task.uri
    assert_equal "Error", task.hasStatus, "Task should be not completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    assert_match "No file uploaded or any valid parameter given.", task.error_report[RDF::OT.message], "wrong error: #{task.error_report[RDF::OT.message]}."
    # PUT missing title
    response =  OpenTox::RestClientWrapper.put @uri.to_s, { :type => "noData", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :owningPro => "#{$user_service[:uri]}/project/G81", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727"}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task.uri
    assert_equal "Error", task.hasStatus, "Task should be not completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    assert_match "Parameter 'title' is required.", task.error_report[RDF::OT.message], "wrong error: #{task.error_report[RDF::OT.message]}."


    # DELETE
    #response =  OpenTox::RestClientWrapper.delete uri.to_s, {}, { :subjectid => $pi[:subjectid] }
    #assert_equal "200", response.code.to_s
  end

end

class TBInvestigationNoISADataValidPOSTchangeType < MiniTest::Test
  
  def test_change_type
    puts "\ntype noData"
    file = File.join File.dirname(__FILE__), "data/toxbank-investigation/valid", "unformated.zip"
    response = OpenTox::RestClientWrapper.post $investigation[:uri], {:type => "noData", :title => "New Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :owningPro => "#{$user_service[:uri]}/project/G81", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727"}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task.uri
    uri = task.resultURI
    assert_equal "Completed", task.hasStatus, "Task should be completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    # check files
    response = OpenTox::RestClientWrapper.get(uri, {}, { :accept=>"text/uri-list", :subjectid => $pi[:subjectid] }).chomp
    assert_equal uri+"/files/"+uri.split("/").last+".nt", response, "uri-list should be equal to #{uri.split("/").last} but is #{response}"
    
    puts "\ntype ftpData"
    response = OpenTox::RestClientWrapper.put uri, {:type => "ftpData", :title => "New Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :owningPro => "#{$user_service[:uri]}/project/G81", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727", :ftpFile => "JIC37_Ethanol_0.07_Internal_1_3.txt, JIC37_Ethanol_0.07_Internal_1_4.txt"}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task.uri
    uri = task.resultURI
    assert_equal "Completed", task.hasStatus, "Task should be completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    response = OpenTox::RestClientWrapper.get($investigation[:uri], {}, { :accept=>"text/uri-list", :subjectid => $pi[:subjectid] }).split("\n").size
    # check files#TODO check Backend output
    response = OpenTox::RestClientWrapper.get(uri, {}, { :accept=>"text/uri-list", :subjectid => $pi[:subjectid] }).chomp
    assert_match uri+"/files/"+uri.split("/").last+".nt", response, "uri-list should match #{uri+"/files/"+uri.split("/").last+".nt"} but is #{response}"
    assert_match uri+"/files/"+"JIC37_Ethanol_0.07_Internal_1_3.txt", response, "uri-list should match #{uri+"/files/"+"JIC37_Ethanol_0.07_Internal_1_3.txt"} but is #{response}"
    assert_match uri+"/files/"+"JIC37_Ethanol_0.07_Internal_1_4.txt", response, "uri-list should match #{uri+"/files/"+"JIC37_Ethanol_0.07_Internal_1_4.txt"} but is #{response}"
    
    puts "\ntype unformattedData"
    response = OpenTox::RestClientWrapper.put uri, {:file => File.open(file), :type => "unformattedData", :title => "New Title", :abstract => "This is a short description", :owningOrg => "#{$user_service[:uri]}/organisation/G16", :authors => "#{$user_service[:uri]}/user/U271, #{$user_service[:uri]}/user/U479", :owningPro => "#{$user_service[:uri]}/project/G81", :keywords => "http://www.owl-ontologies.com/toxbank.owl/K124, http://www.owl-ontologies.com/toxbank.owl/K727"}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task.uri
    uri = task.resultURI
    assert_equal "Completed", task.hasStatus, "Task should be completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    # check files
    response = OpenTox::RestClientWrapper.get(uri, {}, { :accept=>"text/uri-list", :subjectid => $pi[:subjectid] }).chomp
    assert_match uri+"/files/"+uri.split("/").last+".nt", response, "uri-list should match #{uri+"/files/"+uri.split("/").last+".nt"} but is #{response}"
    assert_match uri+"/files/"+"unformated.zip", response, "uri-list should match #{uri+"/files/"+"unformated.zip"} but is #{response}"
    refute_match uri+"/files/"+"JIC37_Ethanol_0.07_Internal_1_3.txt", response, "uri-list should not match #{uri+"/files/"+"JIC37_Ethanol_0.07_Internal_1_3.txt"} but is #{response}"
    refute_match uri+"/files/"+"JIC37_Ethanol_0.07_Internal_1_4.txt", response, "uri-list should not match #{uri+"/files/"+"JIC37_Ethanol_0.07_Internal_1_4.txt"} but is #{response}"
    
    puts "\ntype isatab"
    file = File.join File.dirname(__FILE__), "data/toxbank-investigation/valid", "BII-I-1-tb2.zip"
    response = OpenTox::RestClientWrapper.put uri, {:file => File.open(file)}, { :subjectid => $pi[:subjectid] }
    task_uri = response.chomp
    task = OpenTox::Task.new task_uri
    task.wait
    #puts task.uri
    #uri = task.resultURI
    assert_equal "Error", task.hasStatus, "Task should be not completed but is: #{task.hasStatus}. Task URI is #{task_uri} ."
    assert_match "Unable to edit unformated investigation with ISA-TAB data.", task.error_report[RDF::OT.message], "wrong error: #{task.error_report[RDF::OT.message]}."
    # DELETE
    response =  OpenTox::RestClientWrapper.delete uri, {}, { :subjectid => $pi[:subjectid] }
    assert_equal "200", response.code.to_s
  end

end