@@ -616,20 +616,24 @@ void fetchGet() {
616616 "https://support.oneskyapp.com/hc/en-us/article_attachments/202761627/example_1.json" );
617617 result .json ();
618618 result .jsonMap ();
619- // assertEquals("{\"gameId\":483159,\"knight\":{\"name\":"
620- // + "\"Sir. Russell Jones of
621- // Alberta\",\"attack\":2,\"armor\":7,\"agility\":3,\"endurance\":8}}",
622- // result.text());
623- // assertEquals("Sir. Russell Jones of Alberta",
624- // (String) Underscore.get((Map<String, Object>) result.json(), "knight.name"));
619+ assertEquals ("{\n "
620+ + " \" fruit\" : \" Apple\" ,\n "
621+ + " \" size\" : \" Large\" ,\n "
622+ + " \" color\" : \" Red\" \n "
623+ + "}" ,
624+ result .text ());
625+ assertEquals ("Apple" ,
626+ U .get ((Map <String , Object >) result .json (), "fruit" ));
625627 U .Chain <?> resultChain =
626628 U .chain (
627629 "https://support.oneskyapp.com/hc/en-us/article_attachments/202761627/example_1.json" )
628630 .fetch ();
629- // assertEquals("{\"gameId\":483159,\"knight\":{\"name\":"
630- // + "\"Sir. Russell Jones of
631- // Alberta\",\"attack\":2,\"armor\":7,\"agility\":3,\"endurance\":8}}",
632- // resultChain.item());
631+ assertEquals ("{\n "
632+ + " \" fruit\" : \" Apple\" ,\n "
633+ + " \" size\" : \" Large\" ,\n "
634+ + " \" color\" : \" Red\" \n "
635+ + "}" ,
636+ resultChain .item ());
633637 U .chain (
634638 "https://support.oneskyapp.com/hc/en-us/article_attachments/202761627/example_1.json" )
635639 .fetch ();
@@ -662,10 +666,12 @@ void fetchGetWithTimeouts() {
662666 "https://support.oneskyapp.com/hc/en-us/article_attachments/202761627/example_1.json" ,
663667 30000 ,
664668 30000 );
665- // assertEquals("{\"gameId\":483159,\"knight\":{\"name\":"
666- // + "\"Sir. Russell Jones of
667- // Alberta\",\"attack\":2,\"armor\":7,\"agility\":3,\"endurance\":8}}",
668- // result.text());
669+ assertEquals ("{\n "
670+ + " \" fruit\" : \" Apple\" ,\n "
671+ + " \" size\" : \" Large\" ,\n "
672+ + " \" color\" : \" Red\" \n "
673+ + "}" ,
674+ result .text ());
669675 }
670676
671677 @ Test
@@ -725,9 +731,7 @@ void fetchPut() {
725731 + " \" fireBreath\" : 10"
726732 + " }"
727733 + "}" );
728- // assertEquals("{\"status\":\"Victory\",\"message\":\"Dragon was successful in a
729- // glorious battle\"}",
730- // result.text());
734+ assertEquals (403 , result .getStatus ());
731735 U .FetchResponse result2 =
732736 U .fetch (
733737 "https://support.oneskyapp.com/hc/en-us/article_attachments/202761627/example_1.json" ,
@@ -743,10 +747,8 @@ void fetchPut() {
743747 null ,
744748 null ,
745749 null );
746- // assertEquals("{\"status\":\"Defeat\",\"message\":"
747- // + "\"No dragon showed up, knight dealt his deeds as he pleased.\"}",
748- // result2.text());
749- U .Chain resultChain =
750+ assertEquals (403 , result2 .getStatus ());
751+ U .Chain <String > resultChain =
750752 U .chain (
751753 "http://support.oneskyapp.com/hc/en-us/article_attachments/202761627/example_1.json" )
752754 .fetch (
@@ -759,9 +761,13 @@ void fetchPut() {
759761 + " \" fireBreath\" : 10"
760762 + " }"
761763 + "}" );
762- // assertEquals("{\"status\":\"Victory\",\"message\":\"Dragon was successful in a
763- // glorious battle\"}",
764- // resultChain.item());
764+ assertEquals ("<html>\n "
765+ + "<head><title>301 Moved Permanently</title></head>\n "
766+ + "<body>\n "
767+ + "<center><h1>301 Moved Permanently</h1></center>\n "
768+ + "<hr><center>cloudflare</center>\n "
769+ + "</body>\n "
770+ + "</html>\n " , resultChain .item ().replace ("\r \n " , "\n " ));
765771 }
766772
767773 @ Test
@@ -1022,6 +1028,31 @@ void xmpToJson4() {
10221028 + "</z:catalog>" ));
10231029 }
10241030
1031+ @ Test
1032+ void xmlToJsonMinimum () {
1033+ assertEquals (
1034+ "{\n "
1035+ + " \" root\" : {\n "
1036+ + " \" element\" : [\n "
1037+ + " \" 1\" ,\n "
1038+ + " \" 2\" \n "
1039+ + " ],\n "
1040+ + " \" a\" : \" \" \n "
1041+ + " }\n "
1042+ + "}" ,
1043+ U .xmlToJsonMinimum ("<root><element>1</element><element>2</element><a/></root>" ));
1044+ assertEquals (
1045+ "[\n "
1046+ + " \" a\" ,\n "
1047+ + " \" b\" \n "
1048+ + "]" ,
1049+ U .xmlToJsonMinimum ("<?xml version=\" 1.0\" encoding=\" UTF-8\" ?>\n "
1050+ + "<root>\n "
1051+ + " <element>a</element>\n "
1052+ + " <element>b</element>\n "
1053+ + "</root>" ));
1054+ }
1055+
10251056 @ Test
10261057 void xmlOrJsonToJson () {
10271058 assertEquals (
0 commit comments