6 use SGN::Test::WWW::WebDriver;
10 my $d = SGN::Test::WWW::WebDriver->new();
11 my $j = JSON::Any->new();
15 $d->get_ok('/brapi/v1/token?grant_type=wrongtype&username=johndoe&password=secretpw');
16 ok($d->driver->get_page_source()=~/Grant Type Not Supported/, "authentication call bad grant type");
18 $d->get_ok('/brapi/v1/token?grant_type=password&username=johndoe&password=wrong');
19 ok($d->driver->get_page_source()=~/Incorrect Password/, "authentication call bad password");
21 $d->get_ok('/brapi/v1/token?grant_type=password&username=janedoe&password=secretpw');
22 my $json_response = $d->find_element_ok('body', 'tag_name', "find body")->get_text();
23 my $auth = $j->jsonToObj($json_response);
24 my $session_token = $auth->{session_token};
29 #Germplasm Search by Name
31 $d->get_ok('/brapi/v1/germplasm?name=test*&matchMethod=wildcard&session_token='.$session_token);
32 $json_response = $d->find_element_ok('body', 'tag_name', "find body")->get_text();
33 my $germplasm = $j->jsonToObj($json_response);
34 #print STDERR Dumper $germplasm;
35 is_deeply($germplasm, {
49 'germplasmName' => 'test_accession1',
50 'defaultDisplayName' => 'test_accession1',
53 'germplasmDbId' => 38840,
54 'accessionNumber' => '',
55 'germplasmPUI' => 'test_accession1'
59 'germplasmName' => 'test_accession2',
60 'defaultDisplayName' => 'test_accession2',
63 'germplasmDbId' => 38841,
64 'accessionNumber' => '',
65 'germplasmPUI' => 'test_accession2'
69 'germplasmName' => 'test_accession3',
70 'defaultDisplayName' => 'test_accession3',
73 'germplasmDbId' => 38842,
74 'accessionNumber' => '',
75 'germplasmPUI' => 'test_accession3'
79 'germplasmName' => 'test_accession4',
80 'defaultDisplayName' => 'test_accession4',
83 'germplasmDbId' => 38843,
84 'accessionNumber' => '',
85 'germplasmPUI' => 'test_accession4'
89 'germplasmName' => 'test_accession5',
90 'defaultDisplayName' => 'test_accession5',
93 'germplasmDbId' => 38844,
94 'accessionNumber' => '',
95 'germplasmPUI' => 'test_accession5'
98 'pedigree' => 'test_accession4/test_accession5',
99 'germplasmName' => 'test5P001',
100 'defaultDisplayName' => 'test5P001',
103 'germplasmDbId' => 38873,
104 'accessionNumber' => '',
105 'germplasmPUI' => 'test5P001'
108 'pedigree' => 'test_accession4/test_accession5',
109 'germplasmName' => 'test5P002',
110 'defaultDisplayName' => 'test5P002',
113 'germplasmDbId' => 38874,
114 'accessionNumber' => '',
115 'germplasmPUI' => 'test5P002'
118 'pedigree' => 'test_accession4/test_accession5',
119 'germplasmName' => 'test5P003',
120 'defaultDisplayName' => 'test5P003',
123 'germplasmDbId' => 38875,
124 'accessionNumber' => '',
125 'germplasmPUI' => 'test5P003'
128 'pedigree' => 'test_accession4/test_accession5',
129 'germplasmName' => 'test5P004',
130 'defaultDisplayName' => 'test5P004',
133 'germplasmDbId' => 38876,
134 'accessionNumber' => '',
135 'germplasmPUI' => 'test5P004'
138 'pedigree' => 'test_accession4/test_accession5',
139 'germplasmName' => 'test5P005',
140 'defaultDisplayName' => 'test5P005',
143 'germplasmDbId' => 38877,
144 'accessionNumber' => '',
145 'germplasmPUI' => 'test5P005'
149 }, 'germplasm test');
151 #Germplasm Details by germplasmId
153 $d->get_ok('/brapi/v1/germplasm/38843?session_token='.$session_token);
154 $json_response = $d->find_element_ok('body', 'tag_name', "find body")->get_text();
155 my $germplasm_detail = $j->jsonToObj($json_response);
156 #print STDERR Dumper $germplasm_detail;
158 is_deeply($germplasm_detail, {
170 'germplasmName' => 'test_accession4',
171 'defaultDisplayName' => 'test_accession4',
174 'germplasmDbId' => '38843',
175 'accessionNumber' => 'test_accession4',
176 'germplasmPUI' => 'test_accession4'
178 }, 'germplasm detail test');
185 #$d->get_ok('/brapi/v1/germplasm/38843/MCPD');
186 #ok($d->driver->get_page_source()=~/test_accession4/, "germplasm MCPD detail call");
188 #Germplasm Details List by StudyId
190 $d->get_ok('/brapi/v1/studies/139/germplasm?session_token='.$session_token);
191 $json_response = $d->find_element_ok('body', 'tag_name', "find body")->get_text();
192 my $studies_germplasm = $j->jsonToObj($json_response);
193 #print STDERR Dumper $studies_germplasm;
195 is_deeply($studies_germplasm, {
206 'studyName' => 'Kasese solgs trial',
210 'studyEntryNumberId' => '',
211 'germplasmName' => 'UG120001',
213 'defaultDisplayName' => 'UG120001',
215 'germplasmDbId' => 38878,
216 'accessionNumber' => 'UG120001',
217 'germplasmPUI' => 'UG120001'
221 'studyEntryNumberId' => '',
222 'germplasmName' => 'UG120002',
224 'defaultDisplayName' => 'UG120002',
226 'germplasmDbId' => 38879,
227 'accessionNumber' => 'UG120002',
228 'germplasmPUI' => 'UG120002'
232 'studyEntryNumberId' => '',
233 'germplasmName' => 'UG120003',
235 'defaultDisplayName' => 'UG120003',
237 'germplasmDbId' => 38880,
238 'accessionNumber' => 'UG120003',
239 'germplasmPUI' => 'UG120003'
243 'studyEntryNumberId' => '',
244 'germplasmName' => 'UG120004',
246 'defaultDisplayName' => 'UG120004',
248 'germplasmDbId' => 38881,
249 'accessionNumber' => 'UG120004',
250 'germplasmPUI' => 'UG120004'
254 'studyEntryNumberId' => '',
255 'germplasmName' => 'UG120005',
257 'defaultDisplayName' => 'UG120005',
259 'germplasmDbId' => 38882,
260 'accessionNumber' => 'UG120005',
261 'germplasmPUI' => 'UG120005'
265 'studyEntryNumberId' => '',
266 'germplasmName' => 'UG120006',
268 'defaultDisplayName' => 'UG120006',
270 'germplasmDbId' => 38883,
271 'accessionNumber' => 'UG120006',
272 'germplasmPUI' => 'UG120006'
276 'studyEntryNumberId' => '',
277 'germplasmName' => 'UG120007',
279 'defaultDisplayName' => 'UG120007',
281 'germplasmDbId' => 38884,
282 'accessionNumber' => 'UG120007',
283 'germplasmPUI' => 'UG120007'
287 'studyEntryNumberId' => '',
288 'germplasmName' => 'UG120008',
290 'defaultDisplayName' => 'UG120008',
292 'germplasmDbId' => 38885,
293 'accessionNumber' => 'UG120008',
294 'germplasmPUI' => 'UG120008'
298 'studyEntryNumberId' => '',
299 'germplasmName' => 'UG120009',
301 'defaultDisplayName' => 'UG120009',
303 'germplasmDbId' => 38886,
304 'accessionNumber' => 'UG120009',
305 'germplasmPUI' => 'UG120009'
309 'studyEntryNumberId' => '',
310 'germplasmName' => 'UG120010',
312 'defaultDisplayName' => 'UG120010',
314 'germplasmDbId' => 38887,
315 'accessionNumber' => 'UG120010',
316 'germplasmPUI' => 'UG120010'
320 'studyEntryNumberId' => '',
321 'germplasmName' => 'UG120011',
323 'defaultDisplayName' => 'UG120011',
325 'germplasmDbId' => 38888,
326 'accessionNumber' => 'UG120011',
327 'germplasmPUI' => 'UG120011'
331 'studyEntryNumberId' => '',
332 'germplasmName' => 'UG120012',
334 'defaultDisplayName' => 'UG120012',
336 'germplasmDbId' => 38889,
337 'accessionNumber' => 'UG120012',
338 'germplasmPUI' => 'UG120012'
342 'studyEntryNumberId' => '',
343 'germplasmName' => 'UG120013',
345 'defaultDisplayName' => 'UG120013',
347 'germplasmDbId' => 38890,
348 'accessionNumber' => 'UG120013',
349 'germplasmPUI' => 'UG120013'
353 'studyEntryNumberId' => '',
354 'germplasmName' => 'UG120014',
356 'defaultDisplayName' => 'UG120014',
358 'germplasmDbId' => 38891,
359 'accessionNumber' => 'UG120014',
360 'germplasmPUI' => 'UG120014'
364 'studyEntryNumberId' => '',
365 'germplasmName' => 'UG120015',
367 'defaultDisplayName' => 'UG120015',
369 'germplasmDbId' => 38892,
370 'accessionNumber' => 'UG120015',
371 'germplasmPUI' => 'UG120015'
375 'studyEntryNumberId' => '',
376 'germplasmName' => 'UG120016',
378 'defaultDisplayName' => 'UG120016',
380 'germplasmDbId' => 38893,
381 'accessionNumber' => 'UG120016',
382 'germplasmPUI' => 'UG120016'
386 'studyEntryNumberId' => '',
387 'germplasmName' => 'UG120017',
389 'defaultDisplayName' => 'UG120017',
391 'germplasmDbId' => 38894,
392 'accessionNumber' => 'UG120017',
393 'germplasmPUI' => 'UG120017'
397 'studyEntryNumberId' => '',
398 'germplasmName' => 'UG120018',
400 'defaultDisplayName' => 'UG120018',
402 'germplasmDbId' => 38895,
403 'accessionNumber' => 'UG120018',
404 'germplasmPUI' => 'UG120018'
408 'studyEntryNumberId' => '',
409 'germplasmName' => 'UG120019',
411 'defaultDisplayName' => 'UG120019',
413 'germplasmDbId' => 38896,
414 'accessionNumber' => 'UG120019',
415 'germplasmPUI' => 'UG120019'
419 'studyEntryNumberId' => '',
420 'germplasmName' => 'UG120020',
422 'defaultDisplayName' => 'UG120020',
424 'germplasmDbId' => 38897,
425 'accessionNumber' => 'UG120020',
426 'germplasmPUI' => 'UG120020'
431 }, 'study germplasm test');
435 $d->get_ok('/brapi/v1/germplasm/38846/pedigree?session_token='.$session_token);
436 $json_response = $d->find_element_ok('body', 'tag_name', "find body")->get_text();
437 my $germplasm_pedigree = $j->jsonToObj($json_response);
438 #print STDERR Dumper $germplasm_pedigree;
440 is_deeply($germplasm_pedigree, {
451 'pedigree' => 'test_accession4/test_accession5',
452 'parent2Id' => 38844,
453 'germplasmDbId' => '38846',
456 }, 'germplasm pedigree test');
458 #Germplasm Markerprofiles
460 #$d->get_ok('/brapi/v1/germplasm/39024/markerprofiles?session_token='.$session_token);
461 #my $json_response = $d->find_element_ok('body', 'tag_name', "find body")->get_text();
462 #my $germplasm_markerprofiles = $j->jsonToObj($json_response);
463 #print STDERR Dumper $germplasm_markerprofiles;
466 #Germplasm Attributes
474 #Markerprofile search
476 $d->get_ok('/brapi/v1/markerprofiles?session_token='.$session_token);
477 $json_response = $d->find_element_ok('body', 'tag_name', "find body")->get_text();
478 my $markerprofiles = $j->jsonToObj($json_response);
479 #print STDERR Dumper $markerprofiles;
481 is_deeply($markerprofiles, {
494 'resultCount' => 500,
495 'markerProfileDbId' => 1622,
496 'germplasmDbId' => 38937,
498 'analysisMethod' => 'GBS ApeKI genotyping v4'
501 'resultCount' => 500,
502 'markerProfileDbId' => 1623,
503 'germplasmDbId' => 38994,
505 'analysisMethod' => 'GBS ApeKI genotyping v4'
508 'resultCount' => 500,
509 'markerProfileDbId' => 1624,
510 'germplasmDbId' => 39006,
512 'analysisMethod' => 'GBS ApeKI genotyping v4'
515 'resultCount' => 500,
516 'markerProfileDbId' => 1625,
517 'germplasmDbId' => 39045,
519 'analysisMethod' => 'GBS ApeKI genotyping v4'
522 'resultCount' => 500,
523 'markerProfileDbId' => 1626,
524 'germplasmDbId' => 38881,
526 'analysisMethod' => 'GBS ApeKI genotyping v4'
529 'resultCount' => 500,
530 'markerProfileDbId' => 1627,
531 'germplasmDbId' => 39007,
533 'analysisMethod' => 'GBS ApeKI genotyping v4'
536 'resultCount' => 500,
537 'markerProfileDbId' => 1628,
538 'germplasmDbId' => 39027,
540 'analysisMethod' => 'GBS ApeKI genotyping v4'
543 'resultCount' => 500,
544 'markerProfileDbId' => 1629,
545 'germplasmDbId' => 39028,
547 'analysisMethod' => 'GBS ApeKI genotyping v4'
550 'resultCount' => 500,
551 'markerProfileDbId' => 1630,
552 'germplasmDbId' => 39033,
554 'analysisMethod' => 'GBS ApeKI genotyping v4'
557 'resultCount' => 500,
558 'markerProfileDbId' => 1631,
559 'germplasmDbId' => 38917,
561 'analysisMethod' => 'GBS ApeKI genotyping v4'
564 'resultCount' => 500,
565 'markerProfileDbId' => 1632,
566 'germplasmDbId' => 39044,
568 'analysisMethod' => 'GBS ApeKI genotyping v4'
571 'resultCount' => 500,
572 'markerProfileDbId' => 1633,
573 'germplasmDbId' => 39050,
575 'analysisMethod' => 'GBS ApeKI genotyping v4'
578 'resultCount' => 500,
579 'markerProfileDbId' => 1634,
580 'germplasmDbId' => 39070,
582 'analysisMethod' => 'GBS ApeKI genotyping v4'
585 'resultCount' => 500,
586 'markerProfileDbId' => 1635,
587 'germplasmDbId' => 38884,
589 'analysisMethod' => 'GBS ApeKI genotyping v4'
592 'resultCount' => 500,
593 'markerProfileDbId' => 1636,
594 'germplasmDbId' => 38981,
596 'analysisMethod' => 'GBS ApeKI genotyping v4'
599 'resultCount' => 500,
600 'markerProfileDbId' => 1637,
601 'germplasmDbId' => 38998,
603 'analysisMethod' => 'GBS ApeKI genotyping v4'
606 'resultCount' => 500,
607 'markerProfileDbId' => 1638,
608 'germplasmDbId' => 39078,
610 'analysisMethod' => 'GBS ApeKI genotyping v4'
613 'resultCount' => 500,
614 'markerProfileDbId' => 1639,
615 'germplasmDbId' => 39052,
617 'analysisMethod' => 'GBS ApeKI genotyping v4'
620 'resultCount' => 500,
621 'markerProfileDbId' => 1640,
622 'germplasmDbId' => 38946,
624 'analysisMethod' => 'GBS ApeKI genotyping v4'
627 'resultCount' => 500,
628 'markerProfileDbId' => 1641,
629 'germplasmDbId' => 39024,
631 'analysisMethod' => 'GBS ApeKI genotyping v4'
635 }, 'markerprofiles test');
639 $d->get_ok('/brapi/v1/markerprofiles/1622?session_token='.$session_token);
640 $json_response = $d->find_element_ok('body', 'tag_name', "find body")->get_text();
641 my $markerprofiles_detail = $j->jsonToObj($json_response);
642 #print STDERR Dumper $markerprofiles_detail;
644 is_deeply($markerprofiles_detail, {
655 'markerprofileDbId' => '1622',
679 'S224_309814' => 'BB'
682 'S248_174244' => 'BB'
685 'S318_245078' => 'AA'
688 'S325_476494' => 'AB'
691 'S341_311907' => 'BB'
694 'S341_745165' => 'BB'
697 'S341_927602' => 'BB'
700 'S435_153155' => 'BB'
703 'S620_130205' => 'BB'
709 'S821_289681' => 'AA'
712 'S823_109683' => 'AA'
715 'S823_119622' => 'BB'
718 'germplasmDbId' => 38937,
720 'analysisMethod' => 'GBS ApeKI genotyping v4',
721 'encoding' => 'AA,BB,AB'
723 }, 'markerprofiles detail test');
727 $d->get_ok('/brapi/v1/maps?session_token='.$session_token);
728 $json_response = $d->find_element_ok('body', 'tag_name', "find body")->get_text();
729 my $maps = $j->jsonToObj($json_response);
730 #print STDERR Dumper $maps;
745 'name' => 'GBS ApeKI genotyping v4',
746 'publishedDate' => undef,
747 'species' => 'Cassava SNP genotypes for stock 520 20 24 25 29 30 44 46 108 109 112 114 520name = UG120066, id = 38937)',
750 'markerCount' => 500,
752 'linkageGroupCount' => 268,
757 }, 'maps data test');
759 $d->get_ok('/brapi/v1/maps/1?session_token='.$session_token);
760 $json_response = $d->find_element_ok('body', 'tag_name', "find body")->get_text();
761 my $maps_detail = $j->jsonToObj($json_response);
762 #print STDERR Dumper $maps_detail;
764 is_deeply($maps_detail, {
776 'name' => 'GBS ApeKI genotyping v4',
779 'numberMarkers' => 1,
780 'maxPosition' => '185859',
781 'linkageGroupId' => 'S10114'
784 'numberMarkers' => 2,
785 'maxPosition' => '899514',
786 'linkageGroupId' => 'S10173'
789 'numberMarkers' => 1,
790 'maxPosition' => '146006',
791 'linkageGroupId' => 'S10241'
794 'numberMarkers' => 1,
795 'maxPosition' => '465354',
796 'linkageGroupId' => 'S1027'
799 'numberMarkers' => 1,
800 'maxPosition' => '21679',
801 'linkageGroupId' => 'S10367'
804 'numberMarkers' => 1,
805 'maxPosition' => '216535',
806 'linkageGroupId' => 'S1046'
809 'numberMarkers' => 3,
810 'maxPosition' => '529025',
811 'linkageGroupId' => 'S10493'
814 'numberMarkers' => 3,
815 'maxPosition' => '96591',
816 'linkageGroupId' => 'S10551'
819 'numberMarkers' => 5,
820 'maxPosition' => '996687',
821 'linkageGroupId' => 'S10563'
824 'numberMarkers' => 2,
825 'maxPosition' => '585587',
826 'linkageGroupId' => 'S10689'
829 'numberMarkers' => 1,
830 'maxPosition' => '25444',
831 'linkageGroupId' => 'S10780'
834 'numberMarkers' => 2,
835 'maxPosition' => '244349',
836 'linkageGroupId' => 'S10797'
839 'numberMarkers' => 1,
840 'maxPosition' => '781226',
841 'linkageGroupId' => 'S10963'
844 'numberMarkers' => 1,
845 'maxPosition' => '78443',
846 'linkageGroupId' => 'S11106'
849 'numberMarkers' => 2,
850 'maxPosition' => '231468',
851 'linkageGroupId' => 'S11179'
854 'numberMarkers' => 1,
855 'maxPosition' => '108022',
856 'linkageGroupId' => 'S11267'
859 'numberMarkers' => 1,
860 'maxPosition' => '16826',
861 'linkageGroupId' => 'S1127'
864 'numberMarkers' => 1,
865 'maxPosition' => '135336',
866 'linkageGroupId' => 'S11279'
869 'numberMarkers' => 4,
870 'maxPosition' => '591849',
871 'linkageGroupId' => 'S11297'
874 'numberMarkers' => 2,
875 'maxPosition' => '582872',
876 'linkageGroupId' => 'S11341'
879 'type' => 'physical',
882 }, 'map details test');
884 $d->get_ok('/brapi/v1/maps/1/positions?session_token='.$session_token);
885 $json_response = $d->find_element_ok('body', 'tag_name', "find body")->get_text();
886 my $maps_position = $j->jsonToObj($json_response);
887 #print STDERR Dumper $maps_position;
889 is_deeply($maps_position, {
902 'markerName' => 'S5_36739',
903 'linkageGroup' => 'S5',
904 'markerId' => 'S5_36739',
905 'location' => '36739'
908 'markerName' => 'S13_92567',
909 'linkageGroup' => 'S13',
910 'markerId' => 'S13_92567',
911 'location' => '92567'
914 'markerName' => 'S69_57277',
915 'linkageGroup' => 'S69',
916 'markerId' => 'S69_57277',
917 'location' => '57277'
920 'markerName' => 'S80_224901',
921 'linkageGroup' => 'S80',
922 'markerId' => 'S80_224901',
923 'location' => '224901'
926 'markerName' => 'S80_232173',
927 'linkageGroup' => 'S80',
928 'markerId' => 'S80_232173',
929 'location' => '232173'
932 'markerName' => 'S80_265728',
933 'linkageGroup' => 'S80',
934 'markerId' => 'S80_265728',
935 'location' => '265728'
938 'markerName' => 'S97_219243',
939 'linkageGroup' => 'S97',
940 'markerId' => 'S97_219243',
941 'location' => '219243'
944 'markerName' => 'S224_309814',
945 'linkageGroup' => 'S224',
946 'markerId' => 'S224_309814',
947 'location' => '309814'
950 'markerName' => 'S248_174244',
951 'linkageGroup' => 'S248',
952 'markerId' => 'S248_174244',
953 'location' => '174244'
956 'markerName' => 'S318_245078',
957 'linkageGroup' => 'S318',
958 'markerId' => 'S318_245078',
959 'location' => '245078'
962 'markerName' => 'S325_476494',
963 'linkageGroup' => 'S325',
964 'markerId' => 'S325_476494',
965 'location' => '476494'
968 'markerName' => 'S341_311907',
969 'linkageGroup' => 'S341',
970 'markerId' => 'S341_311907',
971 'location' => '311907'
974 'markerName' => 'S341_745165',
975 'linkageGroup' => 'S341',
976 'markerId' => 'S341_745165',
977 'location' => '745165'
980 'markerName' => 'S341_927602',
981 'linkageGroup' => 'S341',
982 'markerId' => 'S341_927602',
983 'location' => '927602'
986 'markerName' => 'S435_153155',
987 'linkageGroup' => 'S435',
988 'markerId' => 'S435_153155',
989 'location' => '153155'
992 'markerName' => 'S620_130205',
993 'linkageGroup' => 'S620',
994 'markerId' => 'S620_130205',
995 'location' => '130205'
998 'markerName' => 'S784_76866',
999 'linkageGroup' => 'S784',
1000 'markerId' => 'S784_76866',
1001 'location' => '76866'
1004 'markerName' => 'S821_289681',
1005 'linkageGroup' => 'S821',
1006 'markerId' => 'S821_289681',
1007 'location' => '289681'
1010 'markerName' => 'S823_109683',
1011 'linkageGroup' => 'S823',
1012 'markerId' => 'S823_109683',
1013 'location' => '109683'
1016 'markerName' => 'S823_119622',
1017 'linkageGroup' => 'S823',
1018 'markerId' => 'S823_119622',
1019 'location' => '119622'
1023 }, 'maps positions test');