11. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 10/3/2017 11:15:12 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

11.1 Files compared

# Location File Last Modified
1 ehmp.zip\ehmp\ehmp\product\production\jds\src\vpr VPRJTGDS.m Mon Jul 10 17:46:22 2017 UTC
2 ehmp.zip\ehmp\ehmp\product\production\jds\src\vpr VPRJTGDS.m Mon Oct 2 19:46:21 2017 UTC

11.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 4466
Changed 1 2
Inserted 0 0
Removed 0 0

11.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

11.4 Active regular expressions

No regular expressions were active.

11.5 Comparison detail

  1   VPRJTGDS ; KRM/CJE --  Unit Test s for CRUD  operation s for Gene ric Data S tores
  2    ;
  3    ; Endpoin ts tested
  4    ; GET <st ore>/{uid}  GET^VPRJG DS
  5    ; PUT <st ore/{uid}  SET^VPRJGD S
  6    ; DELETE  <store>/{u id} DEL^VP RJGDS
  7    ; GET <st ore> INFO^ VPRJGDS
  8    ; POST <s tore> SET^ VPRJGDS
  9    ; POST <s tore>/inde x CINDEX^V PRJGDS
  10    ; GET <st ore>/index /{indexNam e} INDEX^V PRJGDS
  11    ; POST <s tore>/temp late CTEMP LATE^VPRJG DS
  12    ; GET <st ore>/index /{indexNam e}/{templa te} INDEX^ VPRJGDS
  13    ; GET <st ore>/lock
  14    ; PUT <st ore>/lock/ {uid}
  15    ; DELETE  <store>/lo ck/{uid}
  16    ; DELETE  <store> CL R^VPRJGDS
  17    Q
  18   STARTUP  ;  Run once  before all  tests
  19    ; ensure  that we ha ve a store  for the u nit tests
  20    N HTTPREQ ,HTTPERR
  21    D ADDSTOR E^VPRJCONF IG("ut")
  22    K ^||TMP( "HTTPERR", $J)
  23    Q
  24   SHUTDOWN ;  Run once  after all  tests
  25    ; DELETE  database t est will r emove the  store from  the datab ase and ro ute map
  26    K HTTPREQ
  27    K ^VPRMET A("collect ion","ut") ,^VPRMETA( "index","g dsutest"), ^VPRMETA(" index","gd sutest2"), ^VPRMETA(" index","gd sutest3")
  28    Q
  29   TEARDOWN ;  Run after  each test
  30    K ^||TMP( $J)
  31    K ^||TMP( "HTTPERR", $J)
  32    Q
  33   ASSERT(EXP ECT,ACTUAL ,MSG) ; fo r convenie nce
  34    D EQ^VPRJ T(EXPECT,A CTUAL,$G(M SG))
  35    Q
  36    ;
  37   SAMPLEDATA (ROLES,UID ) ; Setup  Session Da ta JSON fo r set
  38    ; special  case to r emove uid  attribute  from JSON
  39    Q:$G(UID) ="null" "{ ""createDa te"": {""d ate"": ""2 0000101120 000000""}, ""lastLogi n"": {""da te"": ""20 1305260500 00000""}," "roles"":  ["_ROLES_" ]}"
  40    Q "{""cre ateDate"":  {""date"" : ""200001 0112000000 0""},""las tLogin"":  {""date"":  ""2013052 6050000000 ""},""role s"": ["_RO LES_"],""u id"": """_ UID_"""}"
  41    ;
  42   SAMPLEINDE X(NAME,FIE LDS,SORT,T YPE) ; Set up Index d ata JSON f or Create  Index
  43    Q:$G(NAME )="null" " {""fields" ": """_FIE LDS_""","" sort"": "" "_SORT_""" ,""type"":  """_TYPE_ """}"
  44    Q:$G(FIEL DS)="null"  "{""index Name"": "" "_NAME_""" ,""sort"":  """_SORT_ """,""type "": """_TY PE_"""}"
  45    Q:$G(SORT )="null" " {""indexNa me"": """_ NAME_"""," "fields"":  """_FIELD S_""",""ty pe"": """_ TYPE_"""}"
  46    Q:$G(TYPE )="null" " {""indexNa me"": """_ NAME_"""," "fields"":  """_FIELD S_""",""so rt"": """_ SORT_"""}"
  47    Q "{""ind exName"":  """_NAME_" "",""field s"": """_F IELDS_""", ""sort"":  """_SORT_" "",""type" ": """_TYP E_"""}"
  48    ;
  49    ; Setup T emplate da ta JSON fo r Create T emplate
  50   SAMPLETEMP LATE(NAME, DIRECTIVES ,FIELDS)
  51    Q:$G(NAME )="null" " {""fields" ": """_FIE LDS_""","" directives "": """_DI RECTIVES_" ""}"
  52    Q:$G(FIEL DS)="null"  "{""name" ": """_NAM E_""",""di rectives"" : """_DIRE CTIVES_""" }"
  53    Q:$G(DIRE CTIVES)="n ull" "{""n ame"": """ _NAME_""", ""fields"" : """_FIEL DS_"""}"
  54    Q "{""nam e"": """_N AME_""","" fields"":  """_FIELDS _""",""dir ectives"":  """_DIREC TIVES_"""} "
  55    ;
  56    ; Parse r eturn type =3 respons es (paged  responses)
  57    ; @param  {array} RA W - (passe d by refer ence) RAW  response
  58    ; @param  {array} PA RSED - (pa ssed by re ference) M  array rep resentatio n of JSON
  59    ; @param  {string} P ARSE - boo lean to co ntrol pars ing of dat a
  60   PARSE(RAW, PARSED,PAR SE)
  61    ; Assumes  HTTPREQ i s newed by  caller
  62    ;
  63    ; QUIT ea rly if the re is noth ing to do
  64    I '$D(RAW ) QUIT
  65    ;
  66    N START,L IMIT,SIZE, PREAMBLE,R SP,DATA,I, J,RETCNTS
  67    S PARSE=$ G(PARSE,1)
  68    ; Setup p aging info  for PAGE^ VPRJRUT
  69    S HTTPREQ ("paging") =$G(ARGS(" start"),0) _":"_$G(AR GS("limit" ),999999)
  70    S START=$ P(HTTPREQ( "paging"), ":"),LIMIT =$P(HTTPRE Q("paging" ),":",2),S TARTID=$G( RAW("start id"))
  71    S RETCNTS =$S($G(RAW ("returnco unts"))="t rue":1,1:0 )
  72    I STARTID '="" F I=1 :1:$G(@RAW @("total") ) I $D(@RA W@("data", I,STARTID) ) S START= START+I Q
  73    D PAGE^VP RJRUT(.RAW ,START,LIM IT,.SIZE,. PREAMBLE,R ETCNTS)
  74    ; Emulate  RESPOND^V PRJRSP to  get a real  JSON resp onse
  75    S DATA(0) =PREAMBLE
  76    F I=START :1:(START+ LIMIT-1) Q :'$D(@RAW@ ($J,I))  D
  77    . I I>STA RT S DATA( I)="," ; s eparate it ems with a  comma
  78    . S J=""  F  S J=$O( @RAW@($J,I ,J)) Q:'J   S DATA(I) =$G(DATA(I ))_@RAW@($ J,I,J)
  79    S DATA(I) =$G(DATA(I ))_"]}"
  80    D:$D(DATA )&PARSE DE CODE^VPRJS ON("DATA", "PARSED"," ERR")
  81    D:PARSE A SSERT(0,$D (ERR),"ERR OR Decodin g JSON (IN  PARSE^VPR JTGDS)")
  82    M:'PARSE  PARSED=DAT A
  83    QUIT
  84    ;
  85    ; Begin T est Suite
  86    ;
  87   SETNOSTORE  ;; @TEST  Error code  is set if  no store  in HTTPREQ
  88    N RETURN, BODY,ARG,H TTPERR
  89    ; Create  sample JSO N
  90    S BODY(1) =$$SAMPLED ATA("""ehm p-proxy""" ,"urn:va:u ser:9E7A:1 0000000265 ")
  91    ; Send it  to the UR L
  92    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  93    D ASSERT( 0,$D(^VPRJ UT("urn:va :user:9E7A :100000002 65")),"Dat a stored w hen it sho uldn't be" )
  94    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  95    D ASSERT( 253,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 253 rea son code s hould have  occurred" )
  96    ; Cleanup  HTTPERR
  97    K ^||TMP( "HTTPERR", $J)
  98    Q
  99    ;
  100   SETNOGLOBA L ;; @TEST  Error cod e is set i f no globa l is in VP RCONFIG
  101    N RETURN, BODY,ARG,H TTPERR,GLO BALSAVE
  102    ; Create  sample JSO N
  103    S BODY(1) =$$SAMPLED ATA("""ehm p-proxy""" ,"urn:va:u ser:9E7A:1 0000000265 ")
  104    ; Kill of f the glob al area fo r the test
  105    S GLOBALS AVE=^VPRCO NFIG("stor e","ut","g lobal")
  106    K ^VPRCON FIG("store ","ut","gl obal")
  107    ; Send it  to the UR L
  108    S HTTPREQ ("store")= "ut"
  109    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  110    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," global")), "VPRCONFIG  global st orage area  exists an d it shoul dn't")
  111    D ASSERT( 0,$D(^VPRJ UT("urn:va :user:9E7A :100000002 65")),"Dat a stored w hen it sho uldn't be" )
  112    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  113    D ASSERT( 253,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 253 rea son code s hould have  occurred" )
  114    ; Cleanup  HTTPERR
  115    K ^||TMP( "HTTPERR", $J)
  116    ; Restore  the globa l area for  the rest  of the tes ts
  117    S ^VPRCON FIG("store ","ut","gl obal")=GLO BALSAVE
  118    Q
  119    ;
  120   SETNOJSON  ;; @TEST E rror code  is set if  no JSON in  body
  121    N RETURN, BODY,ARG,H TTPERR,GLO BALSAVE
  122    ; Send it  to the UR L
  123    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  124    D ASSERT( 0,$D(^VPRJ UT),"Data  stored whe n it shoul dn't be")
  125    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  126    D ASSERT( 255,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 255 rea son code s hould have  occurred" )
  127    ; Cleanup  HTTPERR
  128    K ^||TMP( "HTTPERR", $J)
  129    Q
  130    ;
  131   SETJSONERR  ;; @TEST  Error code  is set if  JSON is m angled in  PUT/POST
  132    N RETURN, BODY,ARG,H TTPERR
  133    ; Create  bad JSON
  134    S BODY(1) =$$SAMPLED ATA("""ehm p-proxy""" ,"urn:va:u ser:9E7A:1 0000000265 ")
  135    S BODY(1) =BODY(1)_" :"
  136    ; Send it  to the UR L
  137    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  138    D ASSERT( 0,$D(^VPRJ UT("urn:va :user:9E7A :100000002 65")),"Dat a stored w hen it sho uldn't be" )
  139    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  140    D ASSERT( 202,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 202 rea son code s hould have  occurred" )
  141    ; Cleanup  HTTPERR
  142    K ^||TMP( "HTTPERR", $J)
  143    Q
  144    ;
  145   SETNOUID ; ; @TEST PO ST with no  UID
  146    N RETURN, BODY,ARG,H TTPERR
  147    ; Try wit h an empty  string fo r the uid  field
  148    S BODY(1) =$$SAMPLED ATA("""ehm p-proxy""" ,"")
  149    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  150    D ASSERT( 10,$D(^VPR JUT("urn:v a:ut:"_$G( ^VPRJUT(0) ))),"Data  NOT stored  when it s hould be")
  151    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  152    D ASSERT( "urn:va:ut :"_$G(^VPR JUT(0)),$G (^VPRJUT(" urn:va:ut: "_$G(^VPRJ UT(0)),"ui d")),"The  uid field  was not st ored corre ctly")
  153    D ASSERT( "201305260 50000000", $G(^VPRJUT ("urn:va:u t:"_$G(^VP RJUT(0))," lastLogin" ,"date")), "The lastL ogin.date  attribute  was not st ored corre ctly")
  154    D ASSERT( $G(RETURN) ,"/ut/"_"u rn:va:ut:" _$G(^VPRJU T(0)),"The  UID wasn' t returned ")
  155    ; Cleanup  HTTPERR
  156    K ^||TMP( "HTTPERR", $J)
  157    ; Cleanup  Vars
  158    K BODY,RE TURN,ARG
  159    ; Try wit h a non ex istent uid  field
  160    ; "null"  is a magic  string to  the SAMPL EDATA gene rator to p revent the  uid field  from even  being pas sed
  161    S BODY(1) =$$SAMPLED ATA("""ehm p-proxy""" ,"null")
  162    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  163    D ASSERT( 10,$D(^VPR JUT("urn:v a:ut:"_$G( ^VPRJUT(0) ))),"Data  NOT stored  when it s hould be")
  164    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  165    D ASSERT( "urn:va:ut :"_$G(^VPR JUT(0)),$G (^VPRJUT(" urn:va:ut: "_$G(^VPRJ UT(0)),"ui d")),"The  uid field  was not st ored corre ctly")
  166    D ASSERT( "201305260 50000000", $G(^VPRJUT ("urn:va:u t:"_$G(^VP RJUT(0))," lastLogin" ,"date")), "The lastL ogin.date  attribute  was not st ored corre ctly")
  167    D ASSERT( $G(RETURN) ,"/ut/"_"u rn:va:ut:" _$G(^VPRJU T(0)),"The  UID wasn' t returned ")
  168    ; Cleanup  HTTPERR
  169    K ^||TMP( "HTTPERR", $J)
  170    Q
  171    ;
  172   SET1 ;; @T EST PUT wi th UID
  173    N RETURN, BODY,ARG,H TTPERR
  174    S BODY(1) =$$SAMPLED ATA("""ehm p-proxy""" ,"urn:va:u t:23")
  175    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  176    D ASSERT( 10,$D(^VPR JUT("urn:v a:ut:23")) ,"Data NOT  stored wh en it shou ld be")
  177    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  178    D ASSERT( "urn:va:ut :23",$G(^V PRJUT("urn :va:ut:23" ,"uid"))," The uid fi eld was no t stored c orrectly")
  179    D ASSERT( "201305260 50000000", $G(^VPRJUT ("urn:va:u t:23","las tLogin","d ate")),"Th e lastLogi n.date att ribute was  not store d correctl y")
  180    D ASSERT( $G(RETURN) ,"/ut/"_"u rn:va:ut:2 3","The UI D wasn't r eturned")
  181    ; Cleanup  HTTPERR
  182    K ^||TMP( "HTTPERR", $J)
  183    Q
  184    ;
  185   SET2 ;; @T EST PUTing  2 items w ith UID
  186    N RETURN, BODY,ARG,H TTPERR
  187    S BODY(1) =$$SAMPLED ATA("""ehm p-proxy""" ,"urn:va:u t:23")
  188    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  189    D ASSERT( 10,$D(^VPR JUT("urn:v a:ut:23")) ,"Data NOT  stored wh en it shou ld be")
  190    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  191    D ASSERT( "urn:va:ut :23",$G(^V PRJUT("urn :va:ut:23" ,"uid"))," The uid fi eld was no t stored c orrectly")
  192    D ASSERT( "201305260 50000000", $G(^VPRJUT ("urn:va:u t:23","las tLogin","d ate")),"Th e lastLogi n.date att ribute was  not store d correctl y")
  193    D ASSERT( "ehmp-prox y",$G(^VPR JUT("urn:v a:ut:23"," roles",1)) ,"The role s array (1 ) was not  stored cor rectly")
  194    D ASSERT( $G(RETURN) ,"/ut/"_"u rn:va:ut:2 3","The UI D wasn't r eturned")
  195    ; Cleanup  HTTPERR
  196    K ^||TMP( "HTTPERR", $J)
  197    ; Cleanup  Vars
  198    K RETURN, BODY,ARG
  199    ; Update  the record
  200    S BODY(1) =$$SAMPLED ATA("""ehm p-proxy"", ""ehmp-tes t""","urn: va:ut:23")
  201    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  202    D ASSERT( 10,$D(^VPR JUT("urn:v a:ut:23")) ,"Data NOT  stored wh en it shou ld be")
  203    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  204    D ASSERT( "urn:va:ut :23",$G(^V PRJUT("urn :va:ut:23" ,"uid"))," The uid fi eld was no t stored c orrectly")
  205    D ASSERT( "201305260 50000000", $G(^VPRJUT ("urn:va:u t:23","las tLogin","d ate")),"Th e lastLogi n.date att ribute was  not store d correctl y")
  206    D ASSERT( "ehmp-prox y",$G(^VPR JUT("urn:v a:ut:23"," roles",1)) ,"The role s array (1 ) was not  stored cor rectly")
  207    D ASSERT( "ehmp-test ",$G(^VPRJ UT("urn:va :ut:23","r oles",2)), "The roles  array (2)  was not s tored corr ectly")
  208    D ASSERT( $G(RETURN) ,"/ut/"_"u rn:va:ut:2 3","The UI D wasn't r eturned")
  209    ; Cleanup  HTTPERR
  210    K ^||TMP( "HTTPERR", $J)
  211    ; Cleanup  Vars
  212    K RETURN, BODY,ARG
  213    ; Add a s econd one
  214    S BODY(1) =$$SAMPLED ATA("""ehm p-proxy"", ""ehmp-tes t""","urn: va:ut:5")
  215    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  216    D ASSERT( 10,$D(^VPR JUT("urn:v a:ut:5")), "Data NOT  stored whe n it shoul d be")
  217    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  218    D ASSERT( "urn:va:ut :5",$G(^VP RJUT("urn: va:ut:5"," uid")),"Th e uid fiel d was not  stored cor rectly")
  219    D ASSERT( "201305260 50000000", $G(^VPRJUT ("urn:va:u t:5","last Login","da te")),"The  lastLogin .date attr ibute was  not stored  correctly ")
  220    D ASSERT( "ehmp-prox y",$G(^VPR JUT("urn:v a:ut:5","r oles",1)), "The roles  array (1)  was not s tored corr ectly")
  221    D ASSERT( "ehmp-test ",$G(^VPRJ UT("urn:va :ut:5","ro les",2))," The roles  array (2)  was not st ored corre ctly")
  222    D ASSERT( $G(RETURN) ,"/ut/"_"u rn:va:ut:5 ","The UID  wasn't re turned")
  223    ; Cleanup  HTTPERR
  224    K ^||TMP( "HTTPERR", $J)
  225    Q
  226   SETCOLLISI ON ;; caus e a collis ion and en sure every thing work s as inten ded
  227    Q
  228    ;
  229    ;
  230   DELNOSTORE  ;; @TEST  Error code  is set if  no store  in HTTPREQ
  231    N DATA,OB JECT,ERR,A RGS,HTTPER R
  232    ; Send it  to the UR L
  233    K HTTPREQ ("store")
  234    D DEL^VPR JGDS(.DATA ,.ARGS)
  235    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  236    D ASSERT( 253,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 253 rea son code s hould have  occurred" )
  237    ; Cleanup  HTTPERR
  238    K ^||TMP( "HTTPERR", $J)
  239    Q
  240    ;
  241   DELNOGLOBA L ;; @TEST  Error cod e is set i f no globa l is in VP RCONFIG
  242    N DATA,OB JECT,ERR,A RGS,HTTPER R,GLOBALSA VE
  243    ; Kill of f the glob al area fo r the test
  244    S GLOBALS AVE=^VPRCO NFIG("stor e","ut","g lobal")
  245    K ^VPRCON FIG("store ","ut","gl obal")
  246    ; Send it  to the UR L
  247    S HTTPREQ ("store")= "ut"
  248    D DEL^VPR JGDS(.DATA ,.ARGS)
  249    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," global")), "VPRCONFIG  global st orage area  exists an d it shoul dn't")
  250    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  251    D ASSERT( 253,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 253 rea son code s hould have  occurred" )
  252    ; Cleanup  HTTPERR
  253    K ^||TMP( "HTTPERR", $J)
  254    ; Restore  the globa l area for  the rest  of the tes ts
  255    S ^VPRCON FIG("store ","ut","gl obal")=GLO BALSAVE
  256    Q
  257    ;
  258   DELIDERR ; ; @TEST Er ror code i s set if n o uid
  259    N DATA,OB JECT,ERR,A RGS,HTTPER R
  260    ; Try wit h a non ex istent uid
  261    D DEL^VPR JGDS(.DATA ,.ARGS)
  262    D ASSERT( 0,$D(DATA) ,"No DATA  should be  returned")
  263    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  264    D ASSERT( 111,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 111 rea son code s hould have  occurred" )
  265    ; Cleanup  HTTPERR
  266    K ^||TMP( "HTTPERR", $J)
  267    ; Cleanup  vars
  268    K DATA,OB JECT,ERR,A RGS
  269    ; Try wit h a blank  uid
  270    S ARGS("u id")=""
  271    D DEL^VPR JGDS(.DATA ,.ARGS)
  272    D ASSERT( 0,$D(DATA) ,"No DATA  should be  returned")
  273    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  274    D ASSERT( 111,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 111 rea son code s hould have  occurred" )
  275    ; Cleanup  HTTPERR
  276    K ^||TMP( "HTTPERR", $J)
  277    Q
  278    ;
  279   DEL ;; @TE ST Delete  Data
  280    N RETURN, BODY,ARG,D ATA,ARGS,O BJECT,ERR, HTTPERR
  281    ; delete  it
  282    S ARGS("u id")="urn: va:ut:23"
  283    D DEL^VPR JGDS(.DATA ,.ARGS)
  284    D DECODE^ VPRJSON("D ATA","OBJE CT","ERR")
  285    D ASSERT( 0,$D(^VPRJ UT("urn:va :ut:23")), "Data exis ts and it  should not ")
  286    D ASSERT( 0,$D(^VPRJ UTJ("JSON" ,"urn:va:u t:23")),"D ata exists  and it sh ould not")
  287    D ASSERT( 0,$D(^VPRJ UTJ("TEMPL ATE","urn: va:ut:23") ),"Data ex ists and i t should n ot")
  288    D ASSERT( "{""ok"":  true}",$G( DATA),"DAT A returned  from a DE LETE call  (should no t happen)" )
  289    ; Cleanup  HTTPERR
  290    K ^||TMP( "HTTPERR", $J)
  291    Q
  292    ;
  293    ;
  294   INFONOSTOR E ;; @TEST  Error cod e is set i f no store  in HTTPRE Q
  295    N DATA,OB JECT,ERR,A RGS,HTTPER R
  296    ; Send it  to the UR L
  297    K HTTPREQ ("store")
  298    D INFO^VP RJGDS(.DAT A,.ARGS)
  299    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  300    D ASSERT( 253,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 253 rea son code s hould have  occurred" )
  301    ; Cleanup  HTTPERR
  302    K ^||TMP( "HTTPERR", $J)
  303    Q
  304    ;
  305   INFONOGLOB AL ;; @TES T Error co de is set  if no glob al is in V PRCONFIG
  306    N DATA,OB JECT,ERR,A RGS,HTTPER R,GLOBALSA VE
  307    ; Kill of f the glob al area fo r the test
  308    S GLOBALS AVE=^VPRCO NFIG("stor e","ut","g lobal")
  309    K ^VPRCON FIG("store ","ut","gl obal")
  310    ; Send it  to the UR L
  311    S HTTPREQ ("store")= "ut"
  312    D INFO^VP RJGDS(.DAT A,.ARGS)
  313    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," global")), "VPRCONFIG  global st orage area  exists an d it shoul dn't")
  314    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  315    D ASSERT( 253,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 253 rea son code s hould have  occurred" )
  316    ; Cleanup  HTTPERR
  317    K ^||TMP( "HTTPERR", $J)
  318    ; Restore  the globa l area for  the rest  of the tes ts
  319    S ^VPRCON FIG("store ","ut","gl obal")=GLO BALSAVE
  320    Q
  321    ;
  322   INFO ;; @T EST Get da tabase inf ormation
  323    N RETURN, BODY,ARG,D ATA,ARGS,O BJECT,ERR, HTTPERR,CO UNT
  324    ; GET the  database  info
  325    D INFO^VP RJGDS(.DAT A,.ARGS)
  326    D DECODE^ VPRJSON("D ATA","OBJE CT","ERR")
  327    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J)),"An  HTTP Erro r Occured" )
  328    D ASSERT( 0,$D(ERR), "A JSON De code Error  Occured")
  329    ; only te st the inf o that is  supported
  330    D ASSERT( "ut",$G(OB JECT("db_n ame")),"Th e db_name  doesn't ma tch")
  331    D ASSERT( 1,$G(OBJEC T("disk_fo rmat_versi on")),"The  disk_form at_version  doesn't m atch")
  332    D ASSERT( 1,$D(OBJEC T("doc_cou nt")),"The  doc_count  doesn't m atch")
  333    ; save of f the coun t so we ca n prove it  works
  334    S COUNT=$ G(OBJECT(" doc_count" ))
  335    ; Cleanup  HTTPERR
  336    K ^||TMP( "HTTPERR", $J)
  337    ; Cleanup  Vars
  338    K OBJECT, DATA,ERR,A RGS
  339    ; Create  more data  to test co unt
  340    S BODY(1) =$$SAMPLED ATA("""ehm p-proxy""" ,"")
  341    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  342    D ASSERT( 10,$D(^VPR JUT("urn:v a:ut:"_$G( ^VPRJUT(0) ))),"Data  NOT stored  when it s hould be")
  343    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  344    D ASSERT( "urn:va:ut :"_$G(^VPR JUT(0)),$G (^VPRJUT(" urn:va:ut: "_$G(^VPRJ UT(0)),"ui d")),"The  uid field  was not st ored corre ctly")
  345    D ASSERT( "201305260 50000000", $G(^VPRJUT ("urn:va:u t:"_$G(^VP RJUT(0))," lastLogin" ,"date")), "The lastL ogin.date  attribute  was not st ored corre ctly")
  346    D ASSERT( $G(RETURN) ,"/ut/"_"u rn:va:ut:" _$G(^VPRJU T(0)),"The  UID wasn' t returned ")
  347    ; Cleanup  HTTPERR
  348    K ^||TMP( "HTTPERR", $J)
  349    ; Cleanup  Vars
  350    K BODY,RE TURN,ARG
  351    ; Now get  the datab ase info,  we only ha ve to test  count
  352    D INFO^VP RJGDS(.DAT A,.ARGS)
  353    D DECODE^ VPRJSON("D ATA","OBJE CT","ERR")
  354    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J)),"An  HTTP Erro r Occured" )
  355    D ASSERT( 0,$D(ERR), "A JSON De code Error  Occured")
  356    ; ensure  the count  is one mor e than las t time
  357    D ASSERT( COUNT+1,$G (OBJECT("d oc_count") ),"The doc _count doe sn't match ")
  358    ; Cleanup  HTTPERR
  359    K ^||TMP( "HTTPERR", $J)
  360    Q
  361    ;
  362    ;
  363   GETNOSTORE  ;; @TEST  Error code  is set if  no store  in HTTPREQ
  364    N DATA,OB JECT,ERR,A RGS,HTTPER R
  365    ; Send it  to the UR L
  366    K HTTPREQ ("store")
  367    D GET^VPR JGDS(.DATA ,.ARGS)
  368    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  369    D ASSERT( 253,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 253 rea son code s hould have  occurred" )
  370    ; Cleanup  HTTPERR
  371    K ^||TMP( "HTTPERR", $J)
  372    Q
  373    ;
  374   GETNOGLOBA L ;; @TEST  Error cod e is set i f no globa l is in VP RCONFIG
  375    N DATA,OB JECT,ERR,A RGS,HTTPER R,GLOBALSA VE
  376    ; Kill of f the glob al area fo r the test
  377    S GLOBALS AVE=^VPRCO NFIG("stor e","ut","g lobal")
  378    K ^VPRCON FIG("store ","ut","gl obal")
  379    ; Send it  to the UR L
  380    S HTTPREQ ("store")= "ut"
  381    D GET^VPR JGDS(.DATA ,.ARGS)
  382    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," global")), "VPRCONFIG  global st orage area  exists an d it shoul dn't")
  383    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  384    D ASSERT( 253,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 253 rea son code s hould have  occurred" )
  385    ; Cleanup  HTTPERR
  386    K ^||TMP( "HTTPERR", $J)
  387    ; Restore  the globa l area for  the rest  of the tes ts
  388    S ^VPRCON FIG("store ","ut","gl obal")=GLO BALSAVE
  389    Q
  390    ;
  391   GETNOID ;;  @TEST Dat a is retur ned if no  uid passed
  392    N DATA,AR GS,OBJECT, HTTPERR
  393    ; Try wit h a non ex istent uid  attribute
  394    D GET^VPR JGDS(.DATA ,.ARGS)
  395    ;
  396    ; Parse t he paged r esponse
  397    D PARSE(. DATA,.OBJE CT)
  398    ;
  399    D ASSERT( 11,$D(DATA ),"DATA sh ould be re turned")
  400    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  401    D ASSERT( "urn:va:ut :7",$G(OBJ ECT("items ",4,"uid") ),"The uid  field was  not retur ned correc tly")
  402    D ASSERT( 0,$D(OBJEC T("totalIt ems")),"to talItems a ttribute r eturned, a nd it shou ld not be" )
  403    D ASSERT( 0,$D(OBJEC T("current ItemCount" )),"curren tItemCount  attribute  returned,  and it sh ould not b e")
  404    ; Cleanup  HTTPERR
  405    K ^||TMP( "HTTPERR", $J)
  406    ; Cleanup  Vars
  407    K DATA,OB JECT,ARGS, ERR
  408    ; Try wit h a null u id
  409    S ARGS("u id")=""
  410    D GET^VPR JGDS(.DATA ,.ARGS)
  411    ;
  412    ; Parse t he paged r esponse
  413    D PARSE(. DATA,.OBJE CT)
  414    ;
  415    D ASSERT( 11,$D(DATA ),"DATA sh ould be re turned")
  416    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  417    D ASSERT( "urn:va:ut :7",$G(OBJ ECT("items ",4,"uid") ),"The uid  field was  not retur ned correc tly")
  418    ; Cleanup  HTTPERR
  419    K ^||TMP( "HTTPERR", $J)
  420    ;
  421    ; Cleanup  HTTPERR
  422    K ^||TMP( "HTTPERR", $J)
  423    ; Cleanup  Vars
  424    K DATA,OB JECT,ARGS, ERR
  425    ;
  426    D GET^VPR JGDS(.DATA ,.ARGS)
  427    ;
  428    ; Need to  pass this  in to DAT A directly , because  RESPOND^VP RJRSP is n ot run her e
  429    ; Try wit h counts r eturned
  430    S DATA("r eturncount s")="true"
  431    ;
  432    ; Parse t he paged r esponse
  433    D PARSE(. DATA,.OBJE CT)
  434    ;
  435    D ASSERT( 11,$D(DATA ),"DATA sh ould be re turned")
  436    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  437    D ASSERT( "urn:va:ut :7",$G(OBJ ECT("items ",4,"uid") ),"The uid  field was  not retur ned correc tly")
  438    D ASSERT( 1,$D(OBJEC T("totalIt ems")),"to talItems a ttribute n ot returne d")
  439    D ASSERT( $O(OBJECT( "items","" ),-1),$G(O BJECT("tot alItems")) ,"totalIte ms attribu te did not  match tot al items r eturned")
  440    D ASSERT( 1,$D(OBJEC T("current ItemCount" )),"curren tItemCount  attribute  not retur ned")
  441    ; Cleanup  HTTPERR
  442    K ^||TMP( "HTTPERR", $J)
  443    QUIT
  444    ;
  445   GETUIDUNK  ;; @TEST E rror code  if uid doe sn't exist
  446    N DATA,AR GS,OBJECT, HTTPERR
  447    ; Try wit h a non ex istent uid  attribute
  448    S ARGS("u id")="urn: va:ut:1337 "
  449    D GET^VPR JGDS(.DATA ,.ARGS)
  450    D ASSERT( 0,$D(DATA) ,"No DATA  should be  returned")
  451    D ASSERT( 404,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 404 e rror shoul d have occ ured")
  452    D ASSERT( 229,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 229 rea son code s hould have  occurred" )
  453    ; Cleanup  HTTPERR
  454    K ^||TMP( "HTTPERR", $J)
  455    Q
  456    ;
  457   GET ;; @TE ST Get Sin gle object
  458    N RETURN, ARG,BODY,D ATA,ARGS,O BJECT,ERR, HTTPERR
  459    ; Get the  data we'v e stored s o far
  460    S ARGS("u id")="urn: va:ut:7"
  461    D GET^VPR JGDS(.DATA ,.ARGS)
  462    D:$D(DATA ) DECODE^V PRJSON("DA TA","OBJEC T","ERR")
  463    D ASSERT( 10,$D(^VPR JUT("urn:v a:ut:7")), "Data does  not exist  and it sh ould")
  464    D ASSERT( 0,$D(ERR), "A JSON De code Error  Occured")
  465    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  466    D ASSERT( "urn:va:ut :7",$G(OBJ ECT("uid") ),"The uid  field was  not retur ned correc tly")
  467    D ASSERT( "201305260 50000000", $G(OBJECT( "lastLogin ","date")) ,"The last Login.date  attribute  was not r eturned co rrectly")
  468    ; Cleanup  HTTPERR
  469    K ^||TMP( "HTTPERR", $J)
  470    ; Cleanup  Vars
  471    K DATA,AR GS,OBJECT, ERR
  472    ; Get ano ther objec t
  473    S ARGS("u id")="urn: va:ut:5"
  474    D GET^VPR JGDS(.DATA ,.ARGS)
  475    D:$D(DATA ) DECODE^V PRJSON("DA TA","OBJEC T","ERR")
  476    D ASSERT( 10,$D(^VPR JUT("urn:v a:ut:5")), "Data does  not exist  and it sh ould")
  477    D ASSERT( 0,$D(ERR), "A JSON De code Error  Occured")
  478    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  479    D ASSERT( "urn:va:ut :5",$G(OBJ ECT("uid") ),"The uid  field was  not retur ned correc tly")
  480    D ASSERT( "201305260 50000000", $G(OBJECT( "lastLogin ","date")) ,"The last Login.date  attribute  was not r eturned co rrectly")
  481    D ASSERT( "ehmp-prox y",$G(OBJE CT("roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  482    D ASSERT( "ehmp-test ",$G(OBJEC T("roles", 2)),"The r oles array  (2) was n ot returne d correctl y")
  483    ; Cleanup  HTTPERR
  484    K ^||TMP( "HTTPERR", $J)
  485    QUIT
  486    ;
  487   GETSTARTID  ;; @TEST  Get object s beginnin g with a s elected id
  488    N RETURN, ARGS,BODY, DATA,ARGS, OBJECT,ERR ,HTTPERR
  489    S ARGS("s tartid")=" urn:va:ut: 2"
  490    D GET^VPR JGDS(.DATA ,.ARGS)
  491    D PARSE(. DATA,.OBJE CT)
  492    D ASSERT( 11,$D(DATA ),"DATA sh ould be re turned")
  493    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  494    D ASSERT( "urn:va:ut :2",$G(OBJ ECT("items ",1,"uid") ),"Returne d list sho uld have s tarted wit h urn:va:u t:2")
  495    D ASSERT( "urn:va:ut :7",$G(OBJ ECT("items ",3,"uid") ),"urn:va: ut:7 shoul d have bee n third it em in list ")
  496    K ^||TMP( "HTTPERR", $J),@DATA
  497    QUIT
  498    ;
  499   GETSTART ; ; @TEST Ge t objects  beginning  at an offs et
  500    N RETURN, ARGS,BODY, DATA,ARGS, OBJECT,ERR ,HTTPERR
  501    S ARGS("s tart")="2"
  502    D GET^VPR JGDS(.DATA ,.ARGS)
  503    D PARSE(. DATA,.OBJE CT)
  504    D ASSERT( 11,$D(DATA ),"DATA sh ould be re turned")
  505    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  506    D ASSERT( "urn:va:ut :5",$G(OBJ ECT("items ",1,"uid") ),"Returne d list sho uld have s tarted wit h urn:va:u t:2")
  507    D ASSERT( "",$G(OBJE CT("items" ,3,"uid")) ,"There sh ould not h ave been a  third ite m in the l ist")
  508    K ^||TMP( "HTTPERR", $J),@DATA
  509    Q
  510    ;
  511   GETLIMIT ; ; @TEST Ge t objects  up to a li mit
  512    N RETURN, ARGS,BODY, DATA,ARGS, OBJECT,ERR ,HTTPERR
  513    S ARGS("l imit")="3"
  514    D GET^VPR JGDS(.DATA ,.ARGS)
  515    D PARSE(. DATA,.OBJE CT)
  516    D ASSERT( 11,$D(DATA ),"DATA sh ould be re turned")
  517    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  518    D ASSERT( "urn:va:ut :1",$G(OBJ ECT("items ",1,"uid") ),"Returne d list sho uld have s tarted wit h urn:va:u t:1")
  519    D ASSERT( "urn:va:ut :5",$G(OBJ ECT("items ",3,"uid") ),"urn:va: ut:5 shoul d have bee n third it em in list ")
  520    D ASSERT( 0,$D(OBJEC T("items", 4)),"There  should no t be a fou th item re turned")
  521    K ^||TMP( "HTTPERR", $J),@DATA
  522    Q
  523    ;
  524   UPDATE ;;  @TEST Upda te a recor d
  525    N RETURN, BODY,ARG,H TTPERR
  526    ; Store a  record wi th more da ta first
  527    S BODY(1) =$$SAMPLED ATA("""ehm p-proxy"", ""ehmp-tes t""","urn: va:ut:99")
  528    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  529    D ASSERT( 10,$D(^VPR JUT("urn:v a:ut:99")) ,"Data NOT  stored wh en it shou ld be")
  530    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  531    D ASSERT( "urn:va:ut :99",$G(^V PRJUT("urn :va:ut:99" ,"uid"))," The uid fi eld was no t stored c orrectly")
  532    D ASSERT( "ehmp-prox y",$G(^VPR JUT("urn:v a:ut:99"," roles","1" )),"The fi rst role a ttribute i n the arra y was not  stored cor rectly")
  533    D ASSERT( "ehmp-test ",$G(^VPRJ UT("urn:va :ut:99","r oles","2") ),"The sec ond role a ttribute i n the arra y was not  stored cor rectly")
  534    D ASSERT( $G(RETURN) ,"/ut/"_"u rn:va:ut:9 9","The UI D wasn't r eturned")
  535    ; Cleanup  HTTPERR
  536    K ^||TMP( "HTTPERR", $J)
  537    K RETURN, BODY,ARG,H TTPERR
  538    ; Store a  record wi th less da ta
  539    S BODY(1) =$$SAMPLED ATA("""ehm p-test""", "urn:va:ut :99")
  540    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  541    D ASSERT( 10,$D(^VPR JUT("urn:v a:ut:99")) ,"Data NOT  stored wh en it shou ld be")
  542    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  543    D ASSERT( "urn:va:ut :99",$G(^V PRJUT("urn :va:ut:99" ,"uid"))," The uid fi eld was no t stored c orrectly")
  544    D ASSERT( "ehmp-test ",$G(^VPRJ UT("urn:va :ut:99","r oles","1") ),"The fir st role at tribute in  the array  was not s tored corr ectly")
  545    D ASSERT( "",$G(^VPR JUT("urn:v a:ut:99"," roles","2" )),"The se cond role  attribute  in the arr ay was not  stored co rrectly")
  546    D ASSERT( $G(RETURN) ,"/ut/"_"u rn:va:ut:9 9","The UI D wasn't r eturned")
  547    ; Cleanup  HTTPERR
  548    K ^||TMP( "HTTPERR", $J)
  549    Q
  550    ;
  551   GETFILTER  ;; @TEST G et object  with filte r
  552    N RETURN, ARG,BODY,D ATA,ARGS,O BJECT,ERR, HTTPERR
  553    ; Get wit h eq filte r an exact  match
  554    S ARGS("f ilter")="e q(""uid"", ""urn:va:u t:7"")"
  555    D GET^VPR JGDS(.DATA ,.ARGS)
  556    ;
  557    ; Parse t he paged r esponse
  558    D PARSE(. DATA,.OBJE CT)
  559    ;
  560    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  561    D ASSERT( "urn:va:ut :7",$G(OBJ ECT("items ",1,"uid") ),"The uid  field was  not retur ned correc tly")
  562    D ASSERT( "201305260 50000000", $G(OBJECT( "items",1, "lastLogin ","date")) ,"The last Login.date  attribute  was not r eturned co rrectly")
  563    ; Cleanup  HTTPERR
  564    K ^||TMP( "HTTPERR", $J)
  565    ; Cleanup  Vars
  566    K @DATA,A RGS,OBJECT ,ERR
  567    ; Get wit h eq filte r a value  in an arra y
  568    S ARGS("f ilter")="e q(""roles[ ]"",""ehmp -proxy"")"
  569    D GET^VPR JGDS(.DATA ,.ARGS)
  570    ;
  571    ; Parse t he paged r esponse
  572    D PARSE(. DATA,.OBJE CT)
  573    ;
  574    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  575    D ASSERT( "urn:va:ut :1",$G(OBJ ECT("items ",1,"uid") ),"The uid  field was  not retur ned correc tly")
  576    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,1,"roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  577    D ASSERT( "urn:va:ut :2",$G(OBJ ECT("items ",2,"uid") ),"The uid  field was  not retur ned correc tly")
  578    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,2,"roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  579    D ASSERT( "urn:va:ut :5",$G(OBJ ECT("items ",3,"uid") ),"The uid  field was  not retur ned correc tly")
  580    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,3,"roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  581    D ASSERT( "ehmp-test ",$G(OBJEC T("items", 3,"roles", 2)),"The r oles array  (2) was n ot returne d correctl y")
  582    D ASSERT( "urn:va:ut :7",$G(OBJ ECT("items ",4,"uid") ),"The uid  field was  not retur ned correc tly")
  583    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,4,"roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  584    ; Cleanup  HTTPERR
  585    K ^||TMP( "HTTPERR", $J)
  586    ; Cleanup  Vars
  587    K @DATA,A RGS,OBJECT ,ERR
  588    ; Get wit h eq filte r a value  in an arra y (two mat ches)
  589    S ARGS("f ilter")="e q(""roles[ ]"",""ehmp -test"")"
  590    D GET^VPR JGDS(.DATA ,.ARGS)
  591    ;
  592    ; Parse t he paged r esponse
  593    D PARSE(. DATA,.OBJE CT)
  594    ;
  595    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  596    D ASSERT( "urn:va:ut :5",$G(OBJ ECT("items ",1,"uid") ),"The uid  field was  not retur ned correc tly")
  597    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,1,"roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  598    D ASSERT( "ehmp-test ",$G(OBJEC T("items", 1,"roles", 2)),"The r oles array  (2) was n ot returne d correctl y")
  599    D ASSERT( "urn:va:ut :99",$G(OB JECT("item s",2,"uid" )),"The ui d field wa s not retu rned corre ctly")
  600    D ASSERT( "ehmp-test ",$G(OBJEC T("items", 2,"roles", 1)),"The r oles array  (2) was n ot returne d correctl y")
  601    ; Cleanup  HTTPERR
  602    K ^||TMP( "HTTPERR", $J)
  603    ; Cleanup  Vars
  604    K @DATA,A RGS,OBJECT ,ERR
  605    ; Get wit h complex  filter (on ly one mat ch)
  606    ; This is  an implic it and
  607    S ARGS("f ilter")="e q(""roles[ ]"",""ehmp -test""),e q(""uid"", ""urn:va:u t:99"")"
  608    D GET^VPR JGDS(.DATA ,.ARGS)
  609    ;
  610    ; Parse t he paged r esponse
  611    D PARSE(. DATA,.OBJE CT)
  612    ;
  613    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  614    D ASSERT( "urn:va:ut :99",$G(OB JECT("item s",1,"uid" )),"The ui d field wa s not retu rned corre ctly")
  615    D ASSERT( "ehmp-test ",$G(OBJEC T("items", 1,"roles", 1)),"The r oles array  (2) was n ot returne d correctl y")
  616    ; Cleanup  HTTPERR
  617    K ^||TMP( "HTTPERR", $J)
  618    ; Cleanup  Vars
  619    K @DATA,A RGS,OBJECT ,ERR
  620    ; Get wit h complex  filter (mu ltiple mat ches)
  621    ; This is  an implic it and
  622    S ARGS("f ilter")="o r(eq(""rol es[]"",""e hmp-proxy" "),eq(""ui d"",""urn: va:ut:99"" ))"
  623    D GET^VPR JGDS(.DATA ,.ARGS)
  624    ;
  625    ; Parse t he paged r esponse
  626    D PARSE(. DATA,.OBJE CT)
  627    ;
  628    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  629    D ASSERT( "urn:va:ut :1",$G(OBJ ECT("items ",1,"uid") ),"The uid  field was  not retur ned correc tly")
  630    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,1,"roles" ,1)),"The  roles arra y (2) was  not return ed correct ly")
  631    D ASSERT( "urn:va:ut :2",$G(OBJ ECT("items ",2,"uid") ),"The uid  field was  not retur ned correc tly")
  632    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,2,"roles" ,1)),"The  roles arra y (2) was  not return ed correct ly")
  633    D ASSERT( "urn:va:ut :5",$G(OBJ ECT("items ",3,"uid") ),"The uid  field was  not retur ned correc tly")
  634    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,3,"roles" ,1)),"The  roles arra y (2) was  not return ed correct ly")
  635    D ASSERT( "urn:va:ut :7",$G(OBJ ECT("items ",4,"uid") ),"The uid  field was  not retur ned correc tly")
  636    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,4,"roles" ,1)),"The  roles arra y (2) was  not return ed correct ly")
  637    D ASSERT( "urn:va:ut :99",$G(OB JECT("item s",5,"uid" )),"The ui d field wa s not retu rned corre ctly")
  638    D ASSERT( "ehmp-test ",$G(OBJEC T("items", 5,"roles", 1)),"The r oles array  (2) was n ot returne d correctl y")
  639    ; Cleanup  HTTPERR
  640    K ^||TMP( "HTTPERR", $J)
  641    QUIT
  642    ;
  643    ;
  644   CINDEXNOST ORE ;; @TE ST Create  Index - Er ror code i s set if n o store in  HTTPREQ
  645    N RETURN, BODY,ARG,H TTPERR
  646    K HTTPREQ
  647    ; Create  sample JSO N
  648    S BODY(1) =$$SAMPLEI NDEX("gdsu test","rol es[]","rol es asc","a ttr")
  649    ; Send it  to the UR L
  650    S RETURN= $$CINDEX^V PRJGDS(.AR G,.BODY)
  651    D ASSERT( 0,$D(^VPRJ UTX("attr" ,"gdsutest ")),"Index  created w hen it sho uldn't be" )
  652    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  653    D ASSERT( 253,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 253 rea son code s hould have  occurred" )
  654    ; Cleanup  HTTPERR
  655    K ^||TMP( "HTTPERR", $J)
  656    S HTTPREQ ("store")= "ut"
  657    Q
  658    ;
  659   CINDEXNOGL OBAL ;; @T EST Error  code is se t if no gl obal is in  VPRCONFIG
  660    N RETURN, BODY,ARG,H TTPERR,GLO BALSAVE
  661    ; Create  sample JSO N
  662    S BODY(1) =$$SAMPLEI NDEX("gdsu test","rol es[]","rol es asc","a ttr")
  663    ; Kill of f the glob al area fo r the test
  664    S GLOBALS AVE=^VPRCO NFIG("stor e","ut","g lobal")
  665    K ^VPRCON FIG("store ","ut","gl obal")
  666    ; Send it  to the UR L
  667    S HTTPREQ ("store")= "ut"
  668    S RETURN= $$CINDEX^V PRJGDS(.AR G,.BODY)
  669    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," global")), "VPRCONFIG  global st orage area  exists an d it shoul dn't")
  670    D ASSERT( 0,$D(^VPRJ UTX("attr" ,"gdsutest ")),"Index  created w hen it sho uldn't be" )
  671    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  672    D ASSERT( 253,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 253 rea son code s hould have  occurred" )
  673    ; Cleanup  HTTPERR
  674    K ^||TMP( "HTTPERR", $J)
  675    ; Restore  the globa l area for  the rest  of the tes ts
  676    S ^VPRCON FIG("store ","ut","gl obal")=GLO BALSAVE
  677    Q
  678    ;
  679   CINDEXNOJS ON ;; @TES T Error co de is set  if no JSON  in body
  680    N RETURN, BODY,ARG,H TTPERR,GLO BALSAVE
  681    ; Send it  to the UR L
  682    S RETURN= $$CINDEX^V PRJGDS(.AR G,.BODY)
  683    D ASSERT( 0,$D(^VPRJ UTX("attr" ,"gdsutest ")),"Index  created w hen it sho uldn't be" )
  684    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  685    D ASSERT( 255,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 255 rea son code s hould have  occurred" )
  686    ; Cleanup  HTTPERR
  687    K ^||TMP( "HTTPERR", $J)
  688    Q
  689    ;
  690   CINDEXJSON ERR ;; @TE ST Error c ode is set  if JSON i s mangled  in PUT/POS T
  691    N RETURN, BODY,ARG,H TTPERR
  692    ; Create  bad JSON
  693    S BODY(1) =$$SAMPLEI NDEX("gdsu test","rol es[]","rol es asc","a ttr")
  694    S BODY(1) =BODY(1)_" :"
  695    ; Send it  to the UR L
  696    S RETURN= $$CINDEX^V PRJGDS(.AR G,.BODY)
  697    D ASSERT( 0,$D(^VPRJ UTX("attr" ,"gdsutest ")),"Index  created w hen it sho uldn't be" )
  698    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  699    D ASSERT( 202,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 202 rea son code s hould have  occurred" )
  700    ; Cleanup  HTTPERR
  701    K ^||TMP( "HTTPERR", $J)
  702    Q
  703    ;
  704   CINDEXMFIE LDS ;; @TE ST POST wi thout requ ired field s
  705    N RETURN, BODY,ARG,H TTPERR
  706    ; Try wit h an empty  string fo r the name
  707    S BODY(1) =$$SAMPLEI NDEX("","r oles[]","r oles asc", "attr")
  708    S RETURN= $$CINDEX^V PRJGDS(.AR G,.BODY)
  709    D ASSERT( 0,$D(^VPRJ UTX("attr" ,"gdsutest ")),"Index  created w hen it sho uldn't be" )
  710    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP error  should ha ve occured ")
  711    D ASSERT( 273,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 273 rea son code s hould have  occurred" )
  712    ; Cleanup  HTTPERR
  713    K ^||TMP( "HTTPERR", $J)
  714    ; Cleanup  Vars
  715    K BODY,RE TURN,ARG
  716    ;
  717    ; Try wit h an empty  string fo r the fiel ds
  718    S BODY(1) =$$SAMPLEI NDEX("gdsu test",""," roles asc" ,"attr")
  719    S RETURN= $$CINDEX^V PRJGDS(.AR G,.BODY)
  720    D ASSERT( 0,$D(^VPRJ UTX("attr" ,"gdsutest ")),"Index  created w hen it sho uldn't be" )
  721    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP error  should ha ve occured ")
  722    D ASSERT( 273,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 273 rea son code s hould have  occurred" )
  723    ; Cleanup  HTTPERR
  724    K ^||TMP( "HTTPERR", $J)
  725    ; Cleanup  Vars
  726    K BODY,RE TURN,ARG
  727    ;
  728    ; Try wit h an empty  string fo r the sort
  729    S BODY(1) =$$SAMPLEI NDEX("gdsu test","rol es[]",""," attr")
  730    S RETURN= $$CINDEX^V PRJGDS(.AR G,.BODY)
  731    D ASSERT( 0,$D(^VPRJ UTX("attr" ,"gdsutest ")),"Index  created w hen it sho uldn't be" )
  732    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP error  should ha ve occured ")
  733    D ASSERT( 273,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 273 rea son code s hould have  occurred" )
  734    ; Cleanup  HTTPERR
  735    K ^||TMP( "HTTPERR", $J)
  736    ; Cleanup  Vars
  737    K BODY,RE TURN,ARG
  738     ;
  739    ; Try wit h an empty  string fo r the type
  740    S BODY(1) =$$SAMPLEI NDEX("gdsu test","rol es[]","rol es asc","" )
  741    S RETURN= $$CINDEX^V PRJGDS(.AR G,.BODY)
  742    D ASSERT( 0,$D(^VPRJ UTX("attr" ,"gdsutest ")),"Index  created w hen it sho uldn't be" )
  743    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP error  should ha ve occured ")
  744    D ASSERT( 273,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 273 rea son code s hould have  occurred" )
  745    ; Cleanup  HTTPERR
  746    K ^||TMP( "HTTPERR", $J)
  747    ; Cleanup  Vars
  748    K BODY,RE TURN,ARG
  749    ;
  750    ; Try wit h an empty  string fo r all
  751    S BODY(1) =$$SAMPLEI NDEX("","" ,"","")
  752    S RETURN= $$CINDEX^V PRJGDS(.AR G,.BODY)
  753    D ASSERT( 0,$D(^VPRJ UTX("attr" ,"gdsutest ")),"Index  created w hen it sho uldn't be" )
  754    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP error  should ha ve occured ")
  755    D ASSERT( 273,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 273 rea son code s hould have  occurred" )
  756    ; Cleanup  HTTPERR
  757    K ^||TMP( "HTTPERR", $J)
  758    ; Cleanup  Vars
  759    K BODY,RE TURN,ARG
  760    ;
  761    ; Try wit h a non ex istent nam e
  762    ; "null"  is a magic  string to  the SAMPL EINDEX gen erator to  prevent th e field fr om even be ing passed
  763    S BODY(1) =$$SAMPLEI NDEX("null ","roles[] ","roles a sc","attr" )
  764    S RETURN= $$CINDEX^V PRJGDS(.AR G,.BODY)
  765    D ASSERT( 0,$D(^VPRJ UTX("attr" ,"gdsutest ")),"Index  created w hen it sho uldn't be" )
  766    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP error  should ha ve occured ")
  767    D ASSERT( 273,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 273 rea son code s hould have  occurred" )
  768    ; Cleanup  HTTPERR
  769    K ^||TMP( "HTTPERR", $J)
  770    ;
  771    ; Try wit h a non ex istent fie lds
  772    ; "null"  is a magic  string to  the SAMPL EINDEX gen erator to  prevent th e field fr om even be ing passed
  773    S BODY(1) =$$SAMPLEI NDEX("gdsu test","nul l","roles  asc","attr ")
  774    S RETURN= $$CINDEX^V PRJGDS(.AR G,.BODY)
  775    D ASSERT( 0,$D(^VPRJ UTX("attr" ,"gdsutest ")),"Index  created w hen it sho uldn't be" )
  776    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP error  should ha ve occured ")
  777    D ASSERT( 273,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 273 rea son code s hould have  occurred" )
  778    ; Cleanup  HTTPERR
  779    K ^||TMP( "HTTPERR", $J)
  780    ;
  781    ; Try wit h a non ex istent sor t
  782    ; "null"  is a magic  string to  the SAMPL EINDEX gen erator to  prevent th e field fr om even be ing passed
  783    S BODY(1) =$$SAMPLEI NDEX("gdsu test","rol es[]","nul l","attr")
  784    S RETURN= $$CINDEX^V PRJGDS(.AR G,.BODY)
  785    D ASSERT( 0,$D(^VPRJ UTX("attr" ,"gdsutest ")),"Index  created w hen it sho uldn't be" )
  786    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP error  should ha ve occured ")
  787    D ASSERT( 273,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 273 rea son code s hould have  occurred" )
  788    ; Cleanup  HTTPERR
  789    K ^||TMP( "HTTPERR", $J)
  790    ;
  791    ; Try wit h a non ex istent typ e
  792    ; "null"  is a magic  string to  the SAMPL EINDEX gen erator to  prevent th e field fr om even be ing passed
  793    S BODY(1) =$$SAMPLEI NDEX("gdsu test","rol es[]","rol es asc","n ull")
  794    S RETURN= $$CINDEX^V PRJGDS(.AR G,.BODY)
  795    D ASSERT( 0,$D(^VPRJ UTX("attr" ,"gdsutest ")),"Index  created w hen it sho uldn't be" )
  796    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP error  should ha ve occured ")
  797    D ASSERT( 273,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 273 rea son code s hould have  occurred" )
  798    ; Cleanup  HTTPERR
  799    K ^||TMP( "HTTPERR", $J)
  800    Q
  801    ;
  802   CINDEX1 ;;  @TEST Cre ate 1 inde x (happy p ath)
  803    N RETURN, BODY,ARG,H TTPERR
  804    S BODY(1) =$$SAMPLEI NDEX("gdsu test","rol es[]","rol es asc","a ttr")
  805    S RETURN= $$CINDEX^V PRJGDS(.AR G,.BODY)
  806    D ASSERT( 11,$D(^VPR JUTX("attr ","gdsutes t")),"Inde x NOT crea ted when i t should b e")
  807    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  808    D ASSERT( 1,$D(^VPRJ UTX("attr" ,"gdsutest ","ehmp-pr oxy ","urn :va:ut:1", "roles#1") ),"The fir st role ty pe is not  as expecte d")
  809    D ASSERT( 1,$D(^VPRJ UTX("attr" ,"gdsutest ","ehmp-te st ","urn: va:ut:5"," roles#2")) ,"The seco nd role ty pe is not  as expecte d")
  810    D ASSERT( 10,$D(^VPR CONFIG("st ore","ut", "index","g dsutest")) ,"Index No t stored i n VPRJCONF IG")
  811    ; Cleanup  HTTPERR
  812    K ^||TMP( "HTTPERR", $J)
  813    Q
  814    ;
  815   CINDEX2 ;;  @TEST Cre ating 2 (a dditional)  indexes
  816    N RETURN, BODY,ARG,H TTPERR
  817    S BODY(1) =$$SAMPLEI NDEX("gdsu test2","la stLogin.da te","date  asc","attr ")
  818    S RETURN= $$CINDEX^V PRJGDS(.AR G,.BODY)
  819    D ASSERT( 11,$D(^VPR JUTX("attr ","gdsutes t2")),"Ind ex NOT cre ated when  it should  be")
  820    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  821    D ASSERT( 1,$D(^VPRJ UTX("attr" ,"gdsutest 2","201305 2605000000 0 ","urn:v a:ut:1",1) ),"The fir st lastLog in.date in dex is not  as expect ed")
  822    D ASSERT( 1,$D(^VPRJ UTX("attr" ,"gdsutest 2","201305 2605000000 0 ","urn:v a:ut:2",1) ),"The sec ond lastLo gin.date i ndex is no t as expec ted")
  823    D ASSERT( 10,$D(^VPR CONFIG("st ore","ut", "index","g dsutest2") ),"Index N ot stored  in VPRJCON FIG")
  824    ; Cleanup  HTTPERR
  825    K ^||TMP( "HTTPERR", $J)
  826    ; Cleanup  Vars
  827    K RETURN, BODY,ARG
  828    ; Update  the record
  829    S BODY(1) =$$SAMPLEI NDEX("gdsu test3","cr eateDate.d ate","date  asc","att r")
  830    S RETURN= $$CINDEX^V PRJGDS(.AR G,.BODY)
  831    D ASSERT( 11,$D(^VPR JUTX("attr ","gdsutes t3")),"Ind ex NOT cre ated when  it should  be")
  832    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  833    D ASSERT( 1,$D(^VPRJ UTX("attr" ,"gdsutest 3","200001 0112000000 0 ","urn:v a:ut:1",1) ),"The fir st createD ate.date i ndex is no t as expec ted")
  834    D ASSERT( 1,$D(^VPRJ UTX("attr" ,"gdsutest 3","200001 0112000000 0 ","urn:v a:ut:2",1) ),"The sec ond create Date.date  index is n ot as expe cted")
  835    D ASSERT( 10,$D(^VPR CONFIG("st ore","ut", "index","g dsutest3") ),"Index N ot stored  in VPRJCON FIG")
  836    ; Cleanup  HTTPERR
  837    K ^||TMP( "HTTPERR", $J)
  838    Q
  839    ;
  840    ;
  841   INDEXNOSTO RE ;; @TES T Error co de is set  if no stor e in HTTPR EQ
  842    N DATA,OB JECT,ERR,A RGS,HTTPER R
  843    ; Send it  to the UR L
  844    K HTTPREQ ("store")
  845    D INDEX^V PRJGDS(.DA TA,.ARGS)
  846    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  847    D ASSERT( 253,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 253 rea son code s hould have  occurred" )
  848    ; Cleanup  HTTPERR
  849    K ^||TMP( "HTTPERR", $J)
  850    Q
  851    ;
  852   INDEXNOGLO BAL ;; @TE ST Error c ode is set  if no glo bal is in  VPRCONFIG
  853    N DATA,OB JECT,ERR,A RGS,HTTPER R,GLOBALSA VE
  854    ; Kill of f the glob al area fo r the test
  855    S GLOBALS AVE=^VPRCO NFIG("stor e","ut","g lobal")
  856    K ^VPRCON FIG("store ","ut","gl obal")
  857    ; Send it  to the UR L
  858    S HTTPREQ ("store")= "ut"
  859    D INDEX^V PRJGDS(.DA TA,.ARGS)
  860    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," global")), "VPRCONFIG  global st orage area  exists an d it shoul dn't")
  861    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  862    D ASSERT( 253,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 253 rea son code s hould have  occurred" )
  863    ; Cleanup  HTTPERR
  864    K ^||TMP( "HTTPERR", $J)
  865    ; Restore  the globa l area for  the rest  of the tes ts
  866    S ^VPRCON FIG("store ","ut","gl obal")=GLO BALSAVE
  867    Q
  868    ;
  869   INDEXNOIND EX ;; @TES T Error co de is set  if no inde x specifie d
  870    N DATA,OB JECT,ERR,A RGS,HTTPER R,GLOBALSA VE
  871    ; Try wit h non-exis tent index Name
  872    ; Send it  to the UR L
  873    D INDEX^V PRJGDS(.DA TA,.ARGS)
  874    D ASSERT( 0,$D(DATA) ,"DATA ret urned and  there shou ldn't be a ny")
  875    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  876    D ASSERT( 102,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 102 rea son code s hould have  occurred" )
  877    ; Cleanup  HTTPERR
  878    K ^||TMP( "HTTPERR", $J)
  879    ; Try wit h null ind exName
  880    ; Send it  to the UR L
  881    S ARGS("i ndexName") =""
  882    D INDEX^V PRJGDS(.DA TA,.ARGS)
  883    D ASSERT( 0,$D(DATA) ,"DATA ret urned and  there shou ldn't be a ny")
  884    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  885    D ASSERT( 102,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 102 rea son code s hould have  occurred" )
  886    ; Cleanup  HTTPERR
  887    K ^||TMP( "HTTPERR", $J)
  888    Q
  889    ;
  890   INDEX ;; @ TEST Get v ia Index
  891    N RETURN, ARG,BODY,D ATA,ARGS,O BJECT,ERR, HTTPERR
  892    ;
  893    ; Get the  data we'v e stored s o far
  894    S ARGS("i ndexName") ="gdsutest "
  895    D INDEX^V PRJGDS(.RS P,.ARGS)
  896    ;
  897    ; Parse t he paged r esponse
  898    D PARSE(. RSP,.OBJEC T)
  899    ;
  900    D ASSERT( 10,$D(OBJE CT("items" )),"Data d oes not ex ist and it  should")
  901    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  902    D ASSERT( "urn:va:ut :1",$G(OBJ ECT("items ",1,"uid") ),"The uid  field was  not retur ned correc tly")
  903    D ASSERT( "urn:va:ut :2",$G(OBJ ECT("items ",2,"uid") ),"The uid  field was  not retur ned correc tly")
  904    D ASSERT( "urn:va:ut :99",$G(OB JECT("item s",5,"uid" )),"The ui d field wa s not retu rned corre ctly")
  905    ; Cleanup  HTTPERR
  906    K ^||TMP( "HTTPERR", $J)
  907    K ^||TMP( $J)
  908    ; Cleanup  Vars
  909    K DATA,AR GS,OBJECT, ERR,RSP
  910    ; Get ano ther objec t
  911    S ARGS("i ndexName") ="gdsutest 2"
  912    D INDEX^V PRJGDS(.RS P,.ARGS)
  913    ;
  914    ; Parse t he paged r esponse
  915    D PARSE(. RSP,.OBJEC T)
  916    ;
  917    D ASSERT( 10,$D(OBJE CT("items" )),"Data d oes not ex ist and it  should")
  918    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  919    D ASSERT( "urn:va:ut :1",$G(OBJ ECT("items ",1,"uid") ),"The uid  field was  not retur ned correc tly")
  920    D ASSERT( "urn:va:ut :2",$G(OBJ ECT("items ",2,"uid") ),"The uid  field was  not retur ned correc tly")
  921    D ASSERT( "urn:va:ut :99",$G(OB JECT("item s",5,"uid" )),"The ui d field wa s not retu rned corre ctly")
  922    ; Cleanup  HTTPERR
  923    K ^||TMP( "HTTPERR", $J)
  924    ; Cleanup  Vars
  925    K DATA,AR GS,OBJECT, ERR,RSP
  926    ;
  927    ; make su re that re turncounts  is a reco gnized que ry paramet er and it  returns th e data as  expected
  928    S (ARGS(" returncoun ts"),RSP(" returncoun ts"))="tru e"
  929    S ARGS("i ndexName") ="gdsutest 2"
  930    D INDEX^V PRJGDS(.RS P,.ARGS)
  931    ;
  932    ; Parse t he paged r esponse
  933    D PARSE(. RSP,.OBJEC T)
  934    ;
  935    D ASSERT( 11,$D(RSP) ,"RSP shou ld be retu rned")
  936    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  937    D ASSERT( "urn:va:ut :7",$G(OBJ ECT("items ",4,"uid") ),"The uid  field was  not retur ned correc tly")
  938    D ASSERT( 1,$D(OBJEC T("totalIt ems")),"to talItems a ttribute n ot returne d")
  939    D ASSERT( $O(OBJECT( "items","" ),-1),$G(O BJECT("tot alItems")) ,"totalIte ms attribu te did not  match tot al items r eturned")
  940    D ASSERT( 1,$D(OBJEC T("current ItemCount" )),"curren tItemCount  attribute  not retur ned")
  941    ;
  942    ; Cleanup  HTTPERR
  943    K ^||TMP( "HTTPERR", $J)
  944    Q
  945    ;
  946   INDEXLOCK  ;; @TEST G et via Ind ex and a l ocked reco rd
  947    N RETURN, BODY,DATA, ARGS,OBJEC T,ERR,HTTP ERR,TIMEOU T,RSP
  948    ;
  949    ; Get the  data we'v e stored s o far
  950    ; lock ui d: urn:va: ut:2
  951    S ARGS("u id")="urn: va:ut:2"
  952    S RETURN= $$SETLOCK^ VPRJGDS(.A RGS,.BODY)
  953    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  954    D ASSERT( "/ut/lock/ urn:va:ut: 2",$G(RETU RN),"The r eturned lo cation hea der isn't  as expecte d")
  955    K ARGS,BO DY,RETURN
  956    ;
  957    S ARGS("i ndexName") ="gdsutest "
  958    S ARGS("s kiplocked" )="true"
  959    D INDEX^V PRJGDS(.RS P,.ARGS)
  960    ;
  961    ; Parse t he paged r esponse
  962    D PARSE(. RSP,.OBJEC T)
  963    ;
  964    D ASSERT( 10,$D(OBJE CT("items" )),"Data d oes not ex ist and it  should")
  965    D ASSERT( 0,$D(ERR), "A JSON De code Error  Occured")
  966    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  967    D ASSERT( "urn:va:ut :1",$G(OBJ ECT("items ",1,"uid") ),"The uid  field was  not retur ned correc tly")
  968    D ASSERT( "urn:va:ut :5",$G(OBJ ECT("items ",2,"uid") ),"The uid  field was  not retur ned correc tly")
  969    D ASSERT( "urn:va:ut :99",$G(OB JECT("item s",4,"uid" )),"The ui d field wa s not retu rned corre ctly")
  970    D ASSERT( 0,$D(OBJEC T("items", 5)),"Too m any items  were retur ned")
  971    ; Cleanup  HTTPERR
  972    K ^||TMP( "HTTPERR", $J)
  973    ; Cleanup  Vars
  974    K DATA,AR GS,OBJECT, ERR,RSP
  975    K ^||TMP( $J)
  976    ;
  977    ; expire  the lock
  978    ; Set the  timeout v alue to so mething sm aller so t he tests d on't take  forever
  979    S TIMEOUT =$G(^VPRCO NFIG("stor e","ut","l ockTimeout "))
  980    S ^VPRCON FIG("store ","ut","lo ckTimeout" )=1
  981    H 2
  982    S ARGS("i ndexName") ="gdsutest "
  983    S ARGS("s kiplocked" )="true"
  984    D INDEX^V PRJGDS(.RS P,.ARGS)
  985    ;
  986    ; Parse t he paged r esponse
  987    D PARSE(. RSP,.OBJEC T)
  988    ;
  989    D ASSERT( 10,$D(OBJE CT("items" )),"Data d oes not ex ist and it  should")
  990    D ASSERT( 0,$D(ERR), "A JSON De code Error  Occured")
  991    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  992    D ASSERT( "urn:va:ut :1",$G(OBJ ECT("items ",1,"uid") ),"The uid  field was  not retur ned correc tly")
  993    D ASSERT( "urn:va:ut :2",$G(OBJ ECT("items ",2,"uid") ),"The uid  field was  not retur ned correc tly")
  994    D ASSERT( "urn:va:ut :99",$G(OB JECT("item s",5,"uid" )),"The ui d field wa s not retu rned corre ctly")
  995    D ASSERT( 0,$D(OBJEC T("items", 6)),"Too m any items  were retur ned")
  996    ; Cleanup  HTTPERR
  997    K ^||TMP( "HTTPERR", $J)
  998    ; Remove  the lock
  999    K ^VPRJUT L("urn:va: ut:2")
  1000    ; Restore  the timeo ut value
  1001    S ^VPRCON FIG("store ","ut","lo ckTimeout" )=TIMEOUT
  1002    QUIT
  1003    ;
  1004   DELETEITEM INDEX ;; @ TEST delet ed item is n't in Ind ex
  1005    N RETURN, ARG,BODY,D ATA,ARGS,O BJECT,ERR, HTTPERR
  1006    ;
  1007    ; delete  an object
  1008    S ARGS("u id")="urn: va:ut:99"
  1009    D DEL^VPR JGDS(.DATA ,.ARGS)
  1010    K ARGS
  1011    ; Get the  data we'v e stored s o far
  1012    S ARGS("i ndexName") ="gdsutest "
  1013    D INDEX^V PRJGDS(.RS P,.ARGS)
  1014    ;
  1015    ; Parse t he paged r esponse
  1016    D PARSE(. RSP,.OBJEC T)
  1017    ;
  1018    D ASSERT( 10,$D(OBJE CT("items" )),"Data d oes not ex ist and it  should")
  1019    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1020    D ASSERT( "urn:va:ut :1",$G(OBJ ECT("items ",1,"uid") ),"The uid  field was  not retur ned correc tly")
  1021    D ASSERT( "urn:va:ut :2",$G(OBJ ECT("items ",2,"uid") ),"The uid  field was  not retur ned correc tly")
  1022    D ASSERT( "",$G(OBJE CT("items" ,5,"uid")) ,"Object 9 9 exists a nd shouldn 't")
  1023    ; Cleanup  HTTPERR
  1024    K ^||TMP( "HTTPERR", $J)
  1025    K BODY,RE TURN,ARG
  1026    ; RE-add  uid urn:va :ut:99
  1027    S BODY(1) =$$SAMPLED ATA("""ehm p-test""", "urn:va:ut :99")
  1028    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  1029    Q
  1030    ;
  1031   INDEXFILTE R ;; @TEST  Get index  with filt er
  1032    N RETURN, ARG,BODY,D ATA,ARGS,O BJECT,ERR, HTTPERR,I, J
  1033    ;
  1034    ; Get Ind ex with eq  filter fo r an exact  match
  1035    S ARGS("i ndexName") ="gdsutest "
  1036    S ARGS("f ilter")="e q(""uid"", ""urn:va:u t:7"")"
  1037    D INDEX^V PRJGDS(.RS P,.ARGS)
  1038    ;
  1039    ; Parse t he paged r esponse
  1040    D PARSE(. RSP,.OBJEC T)
  1041    ;
  1042    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1043    D ASSERT( "urn:va:ut :7",$G(OBJ ECT("items ",1,"uid") ),"The uid  field was  not retur ned correc tly")
  1044    D ASSERT( "201305260 50000000", $G(OBJECT( "items",1, "lastLogin ","date")) ,"The last Login.date  attribute  was not r eturned co rrectly")
  1045    ; Cleanup  HTTPERR
  1046    K ^||TMP( "HTTPERR", $J)
  1047    K ^||TMP( $J)
  1048    ; Cleanup  Vars
  1049    K ARGS,OB JECT,RSP
  1050    ; Get Ind ex with eq  filter a  value in a n array
  1051    S ARGS("i ndexName") ="gdsutest "
  1052    S ARGS("f ilter")="e q(""roles[ ]"",""ehmp -proxy"")"
  1053    D INDEX^V PRJGDS(.RS P,.ARGS)
  1054    ;
  1055    ; Parse t he paged r esponse
  1056    D PARSE(. RSP,.OBJEC T)
  1057    ;
  1058    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1059    D ASSERT( "urn:va:ut :1",$G(OBJ ECT("items ",1,"uid") ),"The uid  field was  not retur ned correc tly")
  1060    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,1,"roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  1061    D ASSERT( "urn:va:ut :2",$G(OBJ ECT("items ",2,"uid") ),"The uid  field was  not retur ned correc tly")
  1062    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,2,"roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  1063    D ASSERT( "urn:va:ut :5",$G(OBJ ECT("items ",3,"uid") ),"The uid  field was  not retur ned correc tly")
  1064    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,3,"roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  1065    D ASSERT( "ehmp-test ",$G(OBJEC T("items", 3,"roles", 2)),"The r oles array  (2) was n ot returne d correctl y")
  1066    D ASSERT( "urn:va:ut :7",$G(OBJ ECT("items ",4,"uid") ),"The uid  field was  not retur ned correc tly")
  1067    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,4,"roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  1068    ; Cleanup  HTTPERR
  1069    K ^||TMP( "HTTPERR", $J)
  1070    K ^||TMP( $J)
  1071    ; Cleanup  Vars
  1072    K ARGS,OB JECT,RSP
  1073    ; Get wit h eq filte r a value  in an arra y (two mat ches)
  1074    S ARGS("i ndexName") ="gdsutest "
  1075    S ARGS("f ilter")="e q(""roles[ ]"",""ehmp -test"")"
  1076    D INDEX^V PRJGDS(.RS P,.ARGS)
  1077    ;
  1078    ; Parse t he paged r esponse
  1079    D PARSE(. RSP,.OBJEC T)
  1080    ;
  1081    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1082    D ASSERT( "urn:va:ut :5",$G(OBJ ECT("items ",1,"uid") ),"The uid  field was  not retur ned correc tly")
  1083    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,1,"roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  1084    D ASSERT( "ehmp-test ",$G(OBJEC T("items", 1,"roles", 2)),"The r oles array  (2) was n ot returne d correctl y")
  1085    D ASSERT( "urn:va:ut :99",$G(OB JECT("item s",2,"uid" )),"The ui d field wa s not retu rned corre ctly")
  1086    D ASSERT( "ehmp-test ",$G(OBJEC T("items", 2,"roles", 1)),"The r oles array  (2) was n ot returne d correctl y")
  1087    ; Cleanup  HTTPERR
  1088    K ^||TMP( "HTTPERR", $J)
  1089    K ^||TMP( $J)
  1090    ; Cleanup  Vars
  1091    K ARGS,OB JECT,RSP
  1092    ; Get wit h complex  filter (on ly one mat ch)
  1093    ; This is  an implic it and
  1094    S ARGS("i ndexName") ="gdsutest "
  1095    S ARGS("f ilter")="e q(""roles[ ]"",""ehmp -test""),e q(""uid"", ""urn:va:u t:99"")"
  1096    D INDEX^V PRJGDS(.RS P,.ARGS)
  1097    ;
  1098    ; Parse t he paged r esponse
  1099    D PARSE(. RSP,.OBJEC T)
  1100    ;
  1101    D ASSERT( 0,$D(ERR), "A JSON De code Error  Occured")
  1102    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1103    D ASSERT( "urn:va:ut :99",$G(OB JECT("item s",1,"uid" )),"The ui d field wa s not retu rned corre ctly")
  1104    D ASSERT( "ehmp-test ",$G(OBJEC T("items", 1,"roles", 1)),"The r oles array  (2) was n ot returne d correctl y")
  1105    ; Cleanup  HTTPERR
  1106    K ^||TMP( "HTTPERR", $J)
  1107    K ^||TMP( $J)
  1108    ; Cleanup  Vars
  1109    K ARGS,OB JECT,RSP
  1110    ; Get wit h complex  filter (mu ltiple mat ches)
  1111    ; This is  an implic it and
  1112    S ARGS("i ndexName") ="gdsutest "
  1113    S ARGS("f ilter")="o r(eq(""rol es[]"",""e hmp-proxy" "),eq(""ui d"",""urn: va:ut:99"" ))"
  1114    D INDEX^V PRJGDS(.RS P,.ARGS)
  1115    ;
  1116    ; Parse t he paged r esponse
  1117    D PARSE(. RSP,.OBJEC T)
  1118    ;
  1119    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1120    D ASSERT( "urn:va:ut :1",$G(OBJ ECT("items ",1,"uid") ),"The uid  field was  not retur ned correc tly")
  1121    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,1,"roles" ,1)),"The  roles arra y (2) was  not return ed correct ly")
  1122    D ASSERT( "urn:va:ut :2",$G(OBJ ECT("items ",2,"uid") ),"The uid  field was  not retur ned correc tly")
  1123    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,2,"roles" ,1)),"The  roles arra y (2) was  not return ed correct ly")
  1124    D ASSERT( "urn:va:ut :5",$G(OBJ ECT("items ",3,"uid") ),"The uid  field was  not retur ned correc tly")
  1125    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,3,"roles" ,1)),"The  roles arra y (2) was  not return ed correct ly")
  1126    D ASSERT( "urn:va:ut :7",$G(OBJ ECT("items ",4,"uid") ),"The uid  field was  not retur ned correc tly")
  1127    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,4,"roles" ,1)),"The  roles arra y (2) was  not return ed correct ly")
  1128    D ASSERT( "urn:va:ut :99",$G(OB JECT("item s",5,"uid" )),"The ui d field wa s not retu rned corre ctly")
  1129    D ASSERT( "ehmp-test ",$G(OBJEC T("items", 5,"roles", 1)),"The r oles array  (2) was n ot returne d correctl y")
  1130    ; Cleanup  HTTPERR
  1131    K ^||TMP( "HTTPERR", $J)
  1132    K ^||TMP( $J)
  1133    QUIT
  1134    ;
  1135   INDEXFILTE RLOCK ;; @ TEST Get i ndex with  filter and  a lock on  the objec t
  1136    N RETURN, ARG,BODY,D ATA,ARGS,O BJECT,ERR, HTTPERR,I, J
  1137    N START,L IMIT,SIZE, PREAMBLE,R SP
  1138    ; Setup p aging info  for PAGE^ VPRJRUT
  1139    S HTTPREQ ("paging") =$G(HTTPAR GS("start" ),0)_":"_$ G(HTTPARGS ("limit"), 999999)
  1140    S START=$ P(HTTPREQ( "paging"), ":"),LIMIT =$P(HTTPRE Q("paging" ),":",2)
  1141    K ^||TMP( $J)
  1142    ;
  1143    ; Get Ind ex with eq  filter fo r an exact  match
  1144    ; lock ui d: urn:va: ut:7
  1145    S ARGS("u id")="urn: va:ut:7"
  1146    S ARGS("s kiplocked" )="true"
  1147    S RETURN= $$SETLOCK^ VPRJGDS(.A RGS,.BODY)
  1148    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  1149    D ASSERT( "/ut/lock/ urn:va:ut: 7",$G(RETU RN),"The r eturned lo cation hea der isn't  as expecte d")
  1150    K ARGS,BO DY,RETURN
  1151    ;
  1152    S ARGS("i ndexName") ="gdsutest "
  1153    S ARGS("f ilter")="e q(""uid"", ""urn:va:u t:7"")"
  1154    S ARGS("s kiplocked" )="true"
  1155    D INDEX^V PRJGDS(.RS P,.ARGS)
  1156    ; Parse t he paged r esponse
  1157    D PARSE(. DATA,.OBJE CT)
  1158    ;
  1159    D ASSERT( 0,$D(DATA) ,"DATA sho uld be ret urned")
  1160    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1161    D ASSERT( 0,$D(OBJEC T("items") ),"items w ere return ed that sh ouldn't be ")
  1162    ; Cleanup  HTTPERR
  1163    K ^||TMP( "HTTPERR", $J)
  1164    K ^||TMP( $J)
  1165    ; Remove  the lock
  1166    K ^VPRJUT L("urn:va: ut:7")
  1167    QUIT
  1168    ;
  1169   INDEXRANGE FILTER ;;  @TEST Get  index with  range and  filter
  1170    N RETURN, ARG,BODY,D ATA,ARGS,O BJECT,ERR, HTTPERR,I, J
  1171    ;
  1172    ; Get the  data we'v e stored s o far by r ange
  1173    S ARGS("i ndexName") ="gdsutest "
  1174    S ARGS("r ange")="eh mp-test"
  1175    D INDEX^V PRJGDS(.RS P,.ARGS)
  1176    ;
  1177    ; Parse t he paged r esponse
  1178    D PARSE(. RSP,.OBJEC T)
  1179    ;
  1180    D ASSERT( 10,$D(OBJE CT("items" )),"Data d oes not ex ist and it  should")
  1181    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1182    D ASSERT( "urn:va:ut :5",$G(OBJ ECT("items ",1,"uid") ),"The uid  field was  not retur ned correc tly")
  1183    D ASSERT( "urn:va:ut :99",$G(OB JECT("item s",2,"uid" )),"The ui d field wa s not retu rned corre ctly")
  1184    ; Cleanup  HTTPERR
  1185    K ^||TMP( "HTTPERR", $J)
  1186    K ^||TMP( $J)
  1187    ; Cleanup  Vars
  1188    K ARGS,OB JECT,RSP
  1189    ;
  1190    ; Get the  data we'v e stored s o far by r ange - no  results
  1191    S ARGS("i ndexName") ="gdsutest "
  1192    S ARGS("r ange")="z"
  1193    D INDEX^V PRJGDS(.RS P,.ARGS)
  1194    ;
  1195    ; Parse t he paged r esponse
  1196    D PARSE(. RSP,.OBJEC T,0)
  1197    ;
  1198    D ASSERT( 0,$D(@RSP@ ("data")), "Data does  not exist  and it sh ould")
  1199    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1200    ; Cleanup  HTTPERR
  1201    K ^||TMP( "HTTPERR", $J)
  1202    K ^||TMP( $J)
  1203    ; Cleanup  Vars
  1204    K ARGS,OB JECT,RSP
  1205    ;
  1206    ; Get wit h complex  filter (mu ltiple mat ches)
  1207    ; This is  an implic it and
  1208    S ARGS("i ndexName") ="gdsutest "
  1209    S ARGS("f ilter")="o r(eq(""rol es[]"",""e hmp-proxy" "),eq(""ui d"",""urn: va:ut:99"" ))"
  1210    S ARGS("r ange")="eh mp-proxy"
  1211    D INDEX^V PRJGDS(.RS P,.ARGS)
  1212    ;
  1213    ; Parse t he paged r esponse
  1214    D PARSE(. RSP,.OBJEC T)
  1215    ;
  1216    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1217    D ASSERT( "urn:va:ut :1",$G(OBJ ECT("items ",1,"uid") ),"The uid  field was  not retur ned correc tly")
  1218    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,1,"roles" ,1)),"The  roles arra y (2) was  not return ed correct ly")
  1219    D ASSERT( "urn:va:ut :2",$G(OBJ ECT("items ",2,"uid") ),"The uid  field was  not retur ned correc tly")
  1220    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,2,"roles" ,1)),"The  roles arra y (2) was  not return ed correct ly")
  1221    D ASSERT( "urn:va:ut :5",$G(OBJ ECT("items ",3,"uid") ),"The uid  field was  not retur ned correc tly")
  1222    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,3,"roles" ,1)),"The  roles arra y (2) was  not return ed correct ly")
  1223    D ASSERT( "urn:va:ut :7",$G(OBJ ECT("items ",4,"uid") ),"The uid  field was  not retur ned correc tly")
  1224    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,4,"roles" ,1)),"The  roles arra y (2) was  not return ed correct ly")
  1225    D ASSERT( 0,$D(OBJEC T("items", 5)),"More  results re turned tha n expected ")
  1226    ; Cleanup  HTTPERR
  1227    K ^||TMP( "HTTPERR", $J)
  1228    K ^||TMP( $J)
  1229    QUIT
  1230    ;
  1231   INDEXSTART ID ;; @TES T Get obje cts beginn ing with a  selected  id
  1232    N RETURN, ARGS,BODY, DATA,ARGS, OBJECT,ERR ,HTTPERR
  1233    S ARGS("s tartid")=" urn:va:ut: 2"
  1234    S ARGS("i ndexName") ="gdsutest "
  1235    D INDEX^V PRJGDS(.DA TA,.ARGS)
  1236    D PARSE(. DATA,.OBJE CT)
  1237    D ASSERT( 11,$D(DATA ),"DATA sh ould be re turned")
  1238    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1239    D ASSERT( "urn:va:ut :2",$G(OBJ ECT("items ",1,"uid") ),"Returne d list sho uld have s tarted wit h urn:va:u t:2")
  1240    D ASSERT( "urn:va:ut :7",$G(OBJ ECT("items ",3,"uid") ),"urn:va: ut:7 shoul d have bee n third it em in list ")
  1241    K ^||TMP( "HTTPERR", $J),@DATA
  1242    QUIT
  1243    ;
  1244   INDEXRANGE FILTERLOCK  ;; @TEST  Get index  with range  and filte r and lock ed object
  1245    N RETURN, ARG,BODY,D ATA,ARGS,O BJECT,ERR, HTTPERR,I, J
  1246    N START,L IMIT,SIZE, PREAMBLE,R SP
  1247    ; Setup p aging info  for PAGE^ VPRJRUT
  1248    S HTTPREQ ("paging") =$G(HTTPAR GS("start" ),0)_":"_$ G(HTTPARGS ("limit"), 999999)
  1249    S START=$ P(HTTPREQ( "paging"), ":"),LIMIT =$P(HTTPRE Q("paging" ),":",2)
  1250    K ^||TMP( $J)
  1251    ;
  1252    ; Get the  data we'v e stored s o far by r ange
  1253    ; lock ui d: urn:va: ut:5
  1254    S ARGS("u id")="urn: va:ut:5"
  1255    S ARGS("s kiplocked" )="true"
  1256    S RETURN= $$SETLOCK^ VPRJGDS(.A RGS,.BODY)
  1257    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  1258    D ASSERT( "/ut/lock/ urn:va:ut: 5",$G(RETU RN),"The r eturned lo cation hea der isn't  as expecte d")
  1259    K ARGS,BO DY,RETURN
  1260    ;
  1261    S ARGS("i ndexName") ="gdsutest "
  1262    S ARGS("r ange")="eh mp-test"
  1263    S ARGS("s kiplocked" )="true"
  1264    D INDEX^V PRJGDS(.RS P,.ARGS)
  1265    D PAGE^VP RJRUT(.RSP ,START,LIM IT,.SIZE,. PREAMBLE)
  1266    ; Emulate  RESPOND^V PRJRSP to  get a real  JSON resp onse
  1267    S DATA(0) =PREAMBLE
  1268    F I=START :1:(START+ LIMIT-1) Q :'$D(@RSP@ ($J,I))  D
  1269    . I I>STA RT S DATA( I)="," ; s eparate it ems with a  comma
  1270    . S J=""  F  S J=$O( @RSP@($J,I ,J)) Q:'J   S DATA(I) =$G(DATA(I ))_@RSP@($ J,I,J)
  1271    S DATA(I) ="]}"
  1272    D:$D(DATA )'="" DECO DE^VPRJSON ("DATA","O BJECT","ER R")
  1273    D ASSERT( 10,$D(OBJE CT("items" )),"Data d oes not ex ist and it  should")
  1274    D ASSERT( 0,$D(ERR), "A JSON De code Error  Occured")
  1275    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1276    D ASSERT( "urn:va:ut :99",$G(OB JECT("item s",1,"uid" )),"The ui d field wa s not retu rned corre ctly")
  1277    D ASSERT( 0,$D(OBJEC T("items", 2)),"Too m any items  were retur ned")
  1278    ; Cleanup  HTTPERR
  1279    K ^||TMP( "HTTPERR", $J)
  1280    K ^||TMP( $J)
  1281    ; Remove  the lock
  1282    K ^VPRJUT L("urn:va: ut:5")
  1283    QUIT
  1284    ;
  1285   PATCH1 ;;  @TEST PATC H existing  document
  1286    N RETURN, BODY,ARG,H TTPERR
  1287    S BODY(1) ="{""lastL ogin"": {" "date"":"" 2016061512 0000000""} }"
  1288    S ARG("ui d")="urn:v a:ut:23"
  1289    S HTTPREQ ("method") ="PATCH"
  1290    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  1291    D ASSERT( 10,$D(^VPR JUT("urn:v a:ut:23")) ,"Data NOT  stored wh en it shou ld be")
  1292    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  1293    D ASSERT( "urn:va:ut :23",$G(^V PRJUT("urn :va:ut:23" ,"uid"))," The uid fi eld was no t stored c orrectly")
  1294    D ASSERT( "201606151 20000000", $G(^VPRJUT ("urn:va:u t:23","las tLogin","d ate")),"Th e lastLogi n.date att ribute was  not store d correctl y")
  1295    D ASSERT( $G(RETURN) ,"/ut/"_"u rn:va:ut:2 3","The UI D wasn't r eturned")
  1296    ; Cleanup  HTTPERR
  1297    K ^||TMP( "HTTPERR", $J)
  1298    K HTTPREQ ("method")
  1299    K BODY,RE TURN,ARG
  1300    ; Reset d ata back t o what it  was
  1301    S BODY(1) ="{""lastL ogin"": {" "date"":"" 2013052605 0000000""} }"
  1302    S ARG("ui d")="urn:v a:ut:23"
  1303    S HTTPREQ ("method") ="PATCH"
  1304    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  1305    ; Cleanup  HTTPERR
  1306    K ^||TMP( "HTTPERR", $J)
  1307    K HTTPREQ ("method")
  1308    Q
  1309    ;
  1310   PATCH2 ;;  @TEST PATC H new docu ment
  1311    N RETURN, BODY,ARG,H TTPERR,UID
  1312    S BODY(1) ="{""lastL ogin"": {" "date"":"" 2016061512 0000000""} }"
  1313    S HTTPREQ ("method") ="PATCH"
  1314    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  1315    S UID="ur n:va:ut:"_ $G(^VPRJUT (0))
  1316    D ASSERT( 10,$D(^VPR JUT(UID)), "Data NOT  stored whe n it shoul d be")
  1317    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  1318    D ASSERT( UID,$G(^VP RJUT(UID," uid")),"Th e uid fiel d was not  stored cor rectly")
  1319    D ASSERT( "201606151 20000000", $G(^VPRJUT (UID,"last Login","da te")),"The  lastLogin .date attr ibute was  not stored  correctly ")
  1320    D ASSERT( $G(RETURN) ,"/ut/"_UI D,"The UID  wasn't re turned")
  1321    ; Cleanup  HTTPERR
  1322    K ^||TMP( "HTTPERR", $J)
  1323    K HTTPREQ ("method")
  1324    Q
  1325    ;
  1326   PATCH3 ;;  @TEST PATC H new docu ment
  1327    N RETURN, BODY,ARG,H TTPERR
  1328    S BODY(1) ="{""lastL ogin"": {" "date"":"" 2016061512 0000000""} ,""uid"":9 9999}"
  1329    S HTTPREQ ("method") ="PATCH"
  1330    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  1331    D ASSERT( 10,$D(^VPR JUT(99999) ),"Data NO T stored w hen it sho uld be")
  1332    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  1333    D ASSERT( 99999,$G(^ VPRJUT(999 99,"uid")) ,"The uid  field was  not stored  correctly ")
  1334    D ASSERT( "201606151 20000000", $G(^VPRJUT (99999,"la stLogin"," date")),"T he lastLog in.date at tribute wa s not stor ed correct ly")
  1335    D ASSERT( $G(RETURN) ,"/ut/"_99 999,"The U ID wasn't  returned")
  1336    ; Cleanup  HTTPERR
  1337    K ^||TMP( "HTTPERR", $J)
  1338    K HTTPREQ ("method")
  1339    Q
  1340    ;
  1341   CTEMPLATEN OSTORE ;;  @TEST Crea te TEMPLAT E - Error  code is se t if no st ore in HTT PREQ
  1342    N RETURN, BODY,ARG,H TTPERR
  1343    K HTTPREQ
  1344    ; Create  sample JSO N
  1345    S BODY(1) =$$SAMPLET EMPLATE("g dsutest"," include, a pplyOnSave ","roles")
  1346    ; Send it  to the UR L
  1347    S RETURN= $$CTEMPLAT E^VPRJGDS( .ARG,.BODY )
  1348    D ASSERT( 0,$D(^VPRM ETA("templ ate","gdsu test")),"T emplate No t stored i n VPRMETA" )
  1349    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," template", "gdsutest" )),"Templa te Not sto red in VPR JCONFIG")
  1350    D ASSERT( 0,$D(^VPRJ UTJ("TEMPL ATE")),"Te mplates ap plied to e xisting da ta")
  1351    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  1352    D ASSERT( 253,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 253 rea son code s hould have  occurred" )
  1353    ; Cleanup  HTTPERR
  1354    K ^||TMP( "HTTPERR", $J)
  1355    S HTTPREQ ("store")= "ut"
  1356    Q
  1357    ;
  1358   CTEMPLATEN OGLOBAL ;;  @TEST Err or code is  set if no  global is  in VPRCON FIG
  1359    N RETURN, BODY,ARG,H TTPERR,GLO BALSAVE
  1360    ; Create  sample JSO N
  1361    S BODY(1) =$$SAMPLET EMPLATE("g dsutest"," include, a pplyOnSave ","roles")
  1362    ; Kill of f the glob al area fo r the test
  1363    S GLOBALS AVE=^VPRCO NFIG("stor e","ut","g lobal")
  1364    K ^VPRCON FIG("store ","ut","gl obal")
  1365    ; Send it  to the UR L
  1366    S HTTPREQ ("store")= "ut"
  1367    S RETURN= $$CTEMPLAT E^VPRJGDS( .ARG,.BODY )
  1368    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," global")), "VPRCONFIG  global st orage area  exists an d it shoul dn't")
  1369    D ASSERT( 0,$D(^VPRM ETA("templ ate","gdsu test")),"T emplate No t stored i n VPRMETA" )
  1370    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," template", "gdsutest" )),"Templa te Not sto red in VPR JCONFIG")
  1371    D ASSERT( 0,$D(^VPRJ UTJ("TEMPL ATE")),"Te mplates ap plied to e xisting da ta")
  1372    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  1373    D ASSERT( 253,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 253 rea son code s hould have  occurred" )
  1374    ; Cleanup  HTTPERR
  1375    K ^||TMP( "HTTPERR", $J)
  1376    ; Restore  the globa l area for  the rest  of the tes ts
  1377    S ^VPRCON FIG("store ","ut","gl obal")=GLO BALSAVE
  1378    Q
  1379    ;
  1380   CTEMPLATEN OJSON ;; @ TEST Error  code is s et if no J SON in bod y
  1381    N RETURN, BODY,ARG,H TTPERR,GLO BALSAVE
  1382    ; Send it  to the UR L
  1383    S RETURN= $$CTEMPLAT E^VPRJGDS( .ARG,.BODY )
  1384    D ASSERT( 0,$D(^VPRM ETA("templ ate","gdsu test")),"T emplate No t stored i n VPRMETA" )
  1385    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," template", "gdsutest" )),"Templa te Not sto red in VPR JCONFIG")
  1386    D ASSERT( 0,$D(^VPRJ UTJ("TEMPL ATE")),"Te mplates ap plied to e xisting da ta")
  1387    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  1388    D ASSERT( 255,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 255 rea son code s hould have  occurred" )
  1389    ; Cleanup  HTTPERR
  1390    K ^||TMP( "HTTPERR", $J)
  1391    Q
  1392    ;
  1393   CTEMPLATEJ SONERR ;;  @TEST Erro r code is  set if JSO N is mangl ed in PUT/ POST
  1394    N RETURN, BODY,ARG,H TTPERR
  1395    ; Create  bad JSON
  1396    S BODY(1) =$$SAMPLET EMPLATE("g dsutest"," include, a pplyOnSave ","roles")
  1397    S BODY(1) =BODY(1)_" :"
  1398    ; Send it  to the UR L
  1399    S RETURN= $$CTEMPLAT E^VPRJGDS( .ARG,.BODY )
  1400    D ASSERT( 0,$D(^VPRM ETA("templ ate","gdsu test")),"T emplate No t stored i n VPRMETA" )
  1401    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," template", "gdsutest" )),"Templa te Not sto red in VPR JCONFIG")
  1402    D ASSERT( 0,$D(^VPRJ UTJ("TEMPL ATE")),"Te mplates ap plied to e xisting da ta")
  1403    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  1404    D ASSERT( 202,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 202 rea son code s hould have  occurred" )
  1405    ; Cleanup  HTTPERR
  1406    K ^||TMP( "HTTPERR", $J)
  1407    Q
  1408    ;
  1409   CTEMPLATEM FIELDS ;;  @TEST POST  without r equired fi elds
  1410    N RETURN, BODY,ARG,H TTPERR
  1411    ; Try wit h an empty  string fo r the name
  1412    S BODY(1) =$$SAMPLET EMPLATE("" ,"include,  applyOnSa ve","roles ")
  1413    S RETURN= $$CTEMPLAT E^VPRJGDS( .ARG,.BODY )
  1414    D ASSERT( 0,$D(^VPRM ETA("templ ate","gdsu test")),"T emplate No t stored i n VPRMETA" )
  1415    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," template", "gdsutest" )),"Templa te Not sto red in VPR JCONFIG")
  1416    D ASSERT( 0,$D(^VPRJ UTJ("TEMPL ATE")),"Te mplates ap plied to e xisting da ta")
  1417    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP error  should ha ve occured ")
  1418    D ASSERT( 273,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 273 rea son code s hould have  occurred" )
  1419    ; Cleanup  HTTPERR
  1420    K ^||TMP( "HTTPERR", $J)
  1421    ; Cleanup  Vars
  1422    K BODY,RE TURN,ARG
  1423    ;
  1424    ; Try wit h an empty  string fo r the dire ctives
  1425    S BODY(1) =$$SAMPLET EMPLATE("g dsutest"," ","roles")
  1426    S RETURN= $$CTEMPLAT E^VPRJGDS( .ARG,.BODY )
  1427    D ASSERT( 0,$D(^VPRM ETA("templ ate","gdsu test")),"T emplate No t stored i n VPRMETA" )
  1428    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," template", "gdsutest" )),"Templa te Not sto red in VPR JCONFIG")
  1429    D ASSERT( 0,$D(^VPRJ UTJ("TEMPL ATE")),"Te mplates ap plied to e xisting da ta")
  1430    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP error  should ha ve occured ")
  1431    D ASSERT( 273,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 273 rea son code s hould have  occurred" )
  1432    ; Cleanup  HTTPERR
  1433    K ^||TMP( "HTTPERR", $J)
  1434    ; Cleanup  Vars
  1435    K BODY,RE TURN,ARG
  1436    ;
  1437    ; Try wit h an empty  string fo r the fiel ds
  1438    S BODY(1) =$$SAMPLET EMPLATE("g dsutest"," include, a pplyOnSave ","")
  1439    S RETURN= $$CTEMPLAT E^VPRJGDS( .ARG,.BODY )
  1440    D ASSERT( 0,$D(^VPRM ETA("templ ate","gdsu test")),"T emplate No t stored i n VPRMETA" )
  1441    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," template", "gdsutest" )),"Templa te Not sto red in VPR JCONFIG")
  1442    D ASSERT( 0,$D(^VPRJ UTJ("TEMPL ATE")),"Te mplates ap plied to e xisting da ta")
  1443    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP error  should ha ve occured ")
  1444    D ASSERT( 273,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 273 rea son code s hould have  occurred" )
  1445    ; Cleanup  HTTPERR
  1446    K ^||TMP( "HTTPERR", $J)
  1447    ; Cleanup  Vars
  1448    K BODY,RE TURN,ARG
  1449    ;
  1450    ; Try wit h an empty  string fo r all
  1451    S BODY(1) =$$SAMPLET EMPLATE("" ,"","")
  1452    S RETURN= $$CTEMPLAT E^VPRJGDS( .ARG,.BODY )
  1453    D ASSERT( 0,$D(^VPRM ETA("templ ate","gdsu test")),"T emplate No t stored i n VPRMETA" )
  1454    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," template", "gdsutest" )),"Templa te Not sto red in VPR JCONFIG")
  1455    D ASSERT( 0,$D(^VPRJ UTJ("TEMPL ATE")),"Te mplates ap plied to e xisting da ta")
  1456    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP error  should ha ve occured ")
  1457    D ASSERT( 273,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 273 rea son code s hould have  occurred" )
  1458    ; Cleanup  HTTPERR
  1459    K ^||TMP( "HTTPERR", $J)
  1460    ; Cleanup  Vars
  1461    K BODY,RE TURN,ARG
  1462    ;
  1463    ; Try wit h a non ex istent nam e
  1464    ; "null"  is a magic  string to  the SAMPL ETEMPLATE  generator  to prevent  the field  from even  being pas sed
  1465    S BODY(1) =$$SAMPLET EMPLATE("n ull","incl ude, apply OnSave","r oles")
  1466    S RETURN= $$CTEMPLAT E^VPRJGDS( .ARG,.BODY )
  1467    D ASSERT( 0,$D(^VPRM ETA("templ ate","gdsu test")),"T emplate No t stored i n VPRMETA" )
  1468    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," template", "gdsutest" )),"Templa te Not sto red in VPR JCONFIG")
  1469    D ASSERT( 0,$D(^VPRJ UTJ("TEMPL ATE")),"Te mplates ap plied to e xisting da ta")
  1470    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP error  should ha ve occured ")
  1471    D ASSERT( 273,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 273 rea son code s hould have  occurred" )
  1472    ; Cleanup  HTTPERR
  1473    K ^||TMP( "HTTPERR", $J)
  1474    ;
  1475    ; Try wit h a non ex istent dir ectives
  1476    ; "null"  is a magic  string to  the SAMPL ETEMPLATE  generator  to prevent  the field  from even  being pas sed
  1477    S BODY(1) =$$SAMPLET EMPLATE("g dsutest"," null","rol es")
  1478    S RETURN= $$CTEMPLAT E^VPRJGDS( .ARG,.BODY )
  1479    D ASSERT( 0,$D(^VPRM ETA("templ ate","gdsu test")),"T emplate No t stored i n VPRMETA" )
  1480    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," template", "gdsutest" )),"Templa te Not sto red in VPR JCONFIG")
  1481    D ASSERT( 0,$D(^VPRJ UTJ("TEMPL ATE")),"Te mplates ap plied to e xisting da ta")
  1482    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP error  should ha ve occured ")
  1483    D ASSERT( 273,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 273 rea son code s hould have  occurred" )
  1484    ; Cleanup  HTTPERR
  1485    K ^||TMP( "HTTPERR", $J)
  1486    ;
  1487    ; Try wit h a non ex istent fie lds
  1488    ; "null"  is a magic  string to  the SAMPL ETEMPLATE  generator  to prevent  the field  from even  being pas sed
  1489    S BODY(1) =$$SAMPLET EMPLATE("g dsutest"," include, a pplyOnSave ","null")
  1490    S RETURN= $$CTEMPLAT E^VPRJGDS( .ARG,.BODY )
  1491    D ASSERT( 0,$D(^VPRM ETA("templ ate","gdsu test")),"T emplate No t stored i n VPRMETA" )
  1492    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," template", "gdsutest" )),"Templa te Not sto red in VPR JCONFIG")
  1493    D ASSERT( 0,$D(^VPRJ UTJ("TEMPL ATE")),"Te mplates ap plied to e xisting da ta")
  1494    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP error  should ha ve occured ")
  1495    D ASSERT( 273,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 273 rea son code s hould have  occurred" )
  1496    ; Cleanup  HTTPERR
  1497    K ^||TMP( "HTTPERR", $J)
  1498    Q
  1499    ;
  1500   CTEMPLATE1  ;; @TEST  Create 1 t emplate (h appy path)
  1501    N RETURN, BODY,ARG,H TTPERR
  1502    S BODY(1) =$$SAMPLET EMPLATE("g dsutest"," include, a pplyOnSave ","roles[] ")
  1503    S RETURN= $$CTEMPLAT E^VPRJGDS( .ARG,.BODY )
  1504    D ASSERT( 10,$D(^VPR META("temp late","gds utest"))," Template N ot stored  in VPRMETA ")
  1505    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  1506    D ASSERT( 10,$D(^VPR JUTJ("TEMP LATE","urn :va:ut:1", "gdsutest" )),"The gd sutest tem plate is n ot applied  as expect ed")
  1507    D ASSERT( 10,$D(^VPR JUTJ("TEMP LATE","urn :va:ut:5", "gdsutest" )),"The gd sutest tem plate is n ot applied  as expect ed")
  1508    D ASSERT( 10,$D(^VPR CONFIG("st ore","ut", "template" ,"gdsutest ")),"Templ ate Not st ored in VP RJCONFIG")
  1509    ; Cleanup  HTTPERR
  1510    K ^||TMP( "HTTPERR", $J)
  1511    Q
  1512    ;
  1513   CTEMPLATE2  ;; @TEST  Creating 2  (addition al) templa tes
  1514    N RETURN, BODY,ARG,H TTPERR
  1515    S BODY(1) =$$SAMPLET EMPLATE("g dsutest2", "include,  applyOnSav e","create Date.date" )
  1516    S RETURN= $$CTEMPLAT E^VPRJGDS( .ARG,.BODY )
  1517    D ASSERT( 10,$D(^VPR META("temp late","gds utest2")), "Template  Not stored  in VPRMET A")
  1518    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  1519    D ASSERT( 10,$D(^VPR JUTJ("TEMP LATE","urn :va:ut:1", "gdsutest2 ")),"The g dsutest2 t emplate is  not appli ed as expe cted")
  1520    D ASSERT( 10,$D(^VPR JUTJ("TEMP LATE","urn :va:ut:2", "gdsutest2 ")),"The g dsutest2 t emplate is  not appli ed as expe cted")
  1521    D ASSERT( 10,$D(^VPR CONFIG("st ore","ut", "template" ,"gdsutest 2")),"Temp late Not s tored in V PRJCONFIG" )
  1522    ; Cleanup  HTTPERR
  1523    K ^||TMP( "HTTPERR", $J)
  1524    ; Cleanup  Vars
  1525    K RETURN, BODY,ARG
  1526    ; Update  the record
  1527    S BODY(1) =$$SAMPLET EMPLATE("g dsutest3", "include,  applyOnSav e","roles[ ], createD ate.date")
  1528    S RETURN= $$CTEMPLAT E^VPRJGDS( .ARG,.BODY )
  1529    D ASSERT( 10,$D(^VPR META("temp late","gds utest3")), "Template  Not stored  in VPRMET A")
  1530    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  1531    D ASSERT( 10,$D(^VPR JUTJ("TEMP LATE","urn :va:ut:1", "gdsutest3 ")),"The g dsutest3 t emplate is  not appli ed as expe cted")
  1532    D ASSERT( 10,$D(^VPR JUTJ("TEMP LATE","urn :va:ut:2", "gdsutest3 ")),"The g dsutest3 t emplate is  not appli ed as expe cted")
  1533    D ASSERT( 10,$D(^VPR CONFIG("st ore","ut", "template" ,"gdsutest 3")),"Temp late Not s tored in V PRJCONFIG" )
  1534    ; Cleanup  HTTPERR
  1535    K ^||TMP( "HTTPERR", $J)
  1536    Q
  1537   GTEMPLATEI NDEX ;; @T EST Retrie ve data us ing previo usly built  templates  using an  index
  1538    N RETURN, ARG,BODY,D ATA,ARGS,O BJECT,ERR, HTTPERR,I, J
  1539    ;
  1540    ; Get Ind ex with eq  filter fo r an exact  match
  1541    S ARGS("i ndexName") ="gdsutest "
  1542    S ARGS("t emplate")= "gdsutest"
  1543    D INDEX^V PRJGDS(.RS P,.ARGS)
  1544    ;
  1545    ; Parse t he paged r esponse
  1546    D PARSE(. RSP,.OBJEC T)
  1547    ;
  1548    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1549    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,1,"roles" ,1)),"The  roles fiel d was not  returned c orrectly")
  1550    ;
  1551    ;
  1552    ; Cleanup  HTTPERR
  1553    K ^||TMP( "HTTPERR", $J)
  1554    K ^||TMP( $J)
  1555    ; Cleanup  Vars
  1556    K ARGS,OB JECT,RSP
  1557    ; Get Ind ex with eq  filter a  value in a n array
  1558    S ARGS("i ndexName") ="gdsutest "
  1559    S ARGS("t emplate")= "gdsutest2 "
  1560    S ARGS("f ilter")="e q(""uid"", ""urn:va:u t:2"")"
  1561    D INDEX^V PRJGDS(.RS P,.ARGS)
  1562    ;
  1563    ; Parse t he paged r esponse
  1564    D PARSE(. RSP,.OBJEC T)
  1565    ;
  1566    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1567    D ASSERT( "200001011 20000000", $G(OBJECT( "items",1, "createDat e","date") ),"The cre ateDate.da te field w as not ret urned corr ectly")
  1568    D ASSERT( "",$G(OBJE CT("items" ,1,"roles" ,1)),"The  roles fiel d was retu rned and i t shouldn' t")
  1569    ;
  1570    ;
  1571    ; Cleanup  HTTPERR
  1572    K ^||TMP( "HTTPERR", $J)
  1573    K ^||TMP( $J)
  1574    ; Cleanup  Vars
  1575    K ARGS,OB JECT,RSP
  1576    ; Get the  data we'v e stored s o far by r ange
  1577    S ARGS("i ndexName") ="gdsutest "
  1578    S ARGS("r ange")="eh mp-test"
  1579    S ARGS("t emplate")= "gdsutest3 "
  1580    D INDEX^V PRJGDS(.RS P,.ARGS)
  1581    ;
  1582    ; Parse t he paged r esponse
  1583    D PARSE(. RSP,.OBJEC T)
  1584    ;
  1585    D ASSERT( 10,$D(OBJE CT("items" )),"Data d oes not ex ist and it  should")
  1586    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1587    D ASSERT( "200001011 20000000", $G(OBJECT( "items",1, "createDat e","date") ),"The cre ateDate.da te field w as not ret urned corr ectly")
  1588    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,1,"roles" ,1)),"The  roles fiel d was not  returned c orrectly")
  1589    D ASSERT( "200001011 20000000", $G(OBJECT( "items",2, "createDat e","date") ),"The cre ateDate.da te field w as not ret urned corr ectly")
  1590    D ASSERT( "ehmp-test ",$G(OBJEC T("items", 2,"roles", 1)),"The r oles field  was not r eturned co rrectly")
  1591    ;
  1592    ; Cleanup  HTTPERR
  1593    K ^||TMP( "HTTPERR", $J)
  1594    K ^||TMP( $J)
  1595    Q
  1596    ;
  1597   GTEMPLATEI NDEXLOCK ; ; @TEST Re trieve dat a using pr eviously b uilt templ ates using  an index  and locked  record
  1598    N RETURN, ARG,BODY,D ATA,ARGS,O BJECT,ERR, HTTPERR,RS P
  1599    K ^||TMP( $J)
  1600    ;
  1601    ; Get Ind ex with eq  filter fo r an exact  match
  1602    ; 5 items  before
  1603    ; 4 items  after
  1604    ; lock ui d: urn:va: ut:1
  1605    S ARGS("u id")="urn: va:ut:1"
  1606    S ARGS("s kiplocked" )="true"
  1607    S RETURN= $$SETLOCK^ VPRJGDS(.A RGS,.BODY)
  1608    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  1609    D ASSERT( "/ut/lock/ urn:va:ut: 1",$G(RETU RN),"The r eturned lo cation hea der isn't  as expecte d")
  1610    K ARGS,BO DY,RETURN
  1611    ;
  1612    S ARGS("i ndexName") ="gdsutest "
  1613    S ARGS("t emplate")= "gdsutest"
  1614    S ARGS("s kiplocked" )="true"
  1615    D INDEX^V PRJGDS(.RS P,.ARGS)
  1616    ;
  1617    ; Parse t he paged r esponse
  1618    D PARSE(. RSP,.OBJEC T)
  1619    ;
  1620    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1621    D ASSERT( 10,$D(OBJE CT("items" )),"Data d oes not ex ist and it  should")
  1622    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,1,"roles" ,1)),"The  roles fiel d was not  returned c orrectly")
  1623    D ASSERT( 0,$D(OBJEC T("items", 5)),"Too m any items  returned")
  1624    ;
  1625    ; Cleanup  HTTPERR
  1626    K ^||TMP( "HTTPERR", $J)
  1627    K ^||TMP( $J)
  1628    ; Cleanup  Vars
  1629    K DATA,AR GS,OBJECT, ERR,RETURN ,RSP
  1630    ;
  1631    ;
  1632    ;
  1633    S ARGS("i ndexName") ="gdsutest "
  1634    S ARGS("t emplate")= "gdsutest"
  1635    D INDEX^V PRJGDS(.RS P,.ARGS)
  1636    ;
  1637    ; Parse t he paged r esponse
  1638    D PARSE(. RSP,.OBJEC T)
  1639    ;
  1640    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1641    D ASSERT( 10,$D(OBJE CT("items" )),"Data d oes not ex ist and it  should")
  1642    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,1,"roles" ,1)),"The  roles fiel d was not  returned c orrectly")
  1643    D ASSERT( 10,$D(OBJE CT("items" ,5)),"Not  enough ite ms returne d")
  1644    D ASSERT( 0,$D(OBJEC T("items", 6)),"Too m any items  returned")
  1645    ;
  1646    ; Cleanup  HTTPERR
  1647    K ^||TMP( "HTTPERR", $J)
  1648    K ^||TMP( $J)
  1649    ; Remove  the lock
  1650    K ^VPRJUT L("urn:va: ut:1")
  1651    QUIT
  1652    ;
  1653   GTEMPLATE  ;; @TEST G et Single  object wit h a templa te
  1654    N RETURN, ARG,BODY,D ATA,ARGS,O BJECT,ERR, HTTPERR
  1655    ; Get the  data we'v e stored s o far
  1656    S ARGS("u id")="urn: va:ut:7"
  1657    ; gdsutes t3 templat e only has  roles and  createDat e.date
  1658    S ARGS("t emplate")= "gdsutest3 "
  1659    D GET^VPR JGDS(.DATA ,.ARGS)
  1660    D:$D(DATA ) DECODE^V PRJSON("DA TA","OBJEC T","ERR")
  1661    D ASSERT( 10,$D(^VPR JUT("urn:v a:ut:7")), "Data does  not exist  and it sh ould")
  1662    D ASSERT( 0,$D(ERR), "A JSON De code Error  Occured")
  1663    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1664    D ASSERT( "",$G(OBJE CT("uid")) ,"The uid  field was  not return ed correct ly")
  1665    D ASSERT( "",$G(OBJE CT("lastLo gin","date ")),"The l astLogin.d ate attrib ute was no t returned  correctly ")
  1666    D ASSERT( "ehmp-prox y",$G(OBJE CT("roles" ,1)),"The  role field  was not r eturned co rrectly")
  1667    D ASSERT( "200001011 20000000", $G(OBJECT( "createDat e","date") ),"The cre ateDate.da te attribu te was not  returned  correctly" )
  1668    ; Cleanup  HTTPERR
  1669    K ^||TMP( "HTTPERR", $J)
  1670    ; Cleanup  Vars
  1671    K DATA,AR GS,OBJECT, ERR
  1672    ;
  1673    ; Get ano ther objec t
  1674    S ARGS("u id")="urn: va:ut:5"
  1675    ; gdsutes t2 templat e only has  createDat e.date
  1676    S ARGS("t emplate")= "gdsutest2 "
  1677    D GET^VPR JGDS(.DATA ,.ARGS)
  1678    D:$D(DATA ) DECODE^V PRJSON("DA TA","OBJEC T","ERR")
  1679    D ASSERT( 10,$D(^VPR JUT("urn:v a:ut:5")), "Data does  not exist  and it sh ould")
  1680    D ASSERT( 0,$D(ERR), "A JSON De code Error  Occured")
  1681    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1682    D ASSERT( "",$G(OBJE CT("uid")) ,"The uid  field was  not return ed correct ly")
  1683    D ASSERT( "200001011 20000000", $G(OBJECT( "createDat e","date") ),"The cre ateDate.da te attribu te was not  returned  correctly" )
  1684    D ASSERT( "",$G(OBJE CT("lastLo gin","date ")),"The l astLogin.d ate attrib ute was no t returned  correctly ")
  1685    D ASSERT( "",$G(OBJE CT("roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  1686    D ASSERT( "",$G(OBJE CT("roles" ,2)),"The  roles arra y (2) was  not return ed correct ly")
  1687    ; Cleanup  HTTPERR
  1688    K ^||TMP( "HTTPERR", $J)
  1689    QUIT
  1690    ;
  1691   GTEMPLATEN OID ;; @TE ST All Dat a is retur ned if no  uid passed  with a te mplate
  1692    N DATA,AR GS,OBJECT, HTTPERR
  1693    ; Try wit h a non ex istent uid  attribute
  1694    ; gdsutes t template  only has  roles[]
  1695    S ARGS("t emplate")= "gdsutest"
  1696    D GET^VPR JGDS(.DATA ,.ARGS)
  1697    ;
  1698    ; Parse t he paged r esponse
  1699    D PARSE(. DATA,.OBJE CT)
  1700    ;
  1701    D ASSERT( 11,$D(DATA ),"DATA sh ould be re turned")
  1702    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1703    D ASSERT( "",$G(OBJE CT("items" ,4,"uid")) ,"The uid  field was  not return ed correct ly")
  1704    D ASSERT( "",$G(OBJE CT("items" ,4,"lastLo gin","date ")),"The l astLogin.d ate attrib ute was no t returned  correctly ")
  1705    D ASSERT( "",$G(OBJE CT("items" ,4,"create Date","dat e")),"The  createDate .date attr ibute was  not return ed correct ly")
  1706    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,4,"roles" ,1)),"The  roles fiel d was not  returned c orrectly")
  1707    ; Cleanup  HTTPERR
  1708    K ^||TMP( "HTTPERR", $J)
  1709    ; Cleanup  Vars
  1710    K @DATA,O BJECT,ARGS ,ERR
  1711    ; Try wit h a null u id
  1712    S ARGS("u id")=""
  1713    ; gdsutes t2 templat e only has  createDat e.date
  1714    S ARGS("t emplate")= "gdsutest2 "
  1715    D GET^VPR JGDS(.DATA ,.ARGS)
  1716    ;
  1717    ; Parse t he paged r esponse
  1718    D PARSE(. DATA,.OBJE CT)
  1719    ;
  1720    D ASSERT( 11,$D(DATA ),"DATA sh ould be re turned")
  1721    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1722    D ASSERT( "",$G(OBJE CT("items" ,4,"uid")) ,"The uid  field was  not return ed correct ly")
  1723    D ASSERT( "",$G(OBJE CT("items" ,4,"lastLo gin","date ")),"The l astLogin.d ate attrib ute was no t returned  correctly ")
  1724    D ASSERT( "200001011 20000000", $G(OBJECT( "items",4, "createDat e","date") ),"The cre ateDate.da te attribu te was not  returned  correctly" )
  1725    D ASSERT( "",$G(OBJE CT("items" ,4,"roles" ,1)),"The  roles fiel d was not  returned c orrectly")
  1726    ; Cleanup  HTTPERR
  1727    K ^||TMP( "HTTPERR", $J)
  1728    QUIT
  1729    ;
  1730   GTEMPLATEF ILTER ;; @ TEST Get o bject with  filter an d template
  1731    N RETURN, ARG,BODY,D ATA,ARGS,O BJECT,ERR, HTTPERR
  1732    ; Get wit h eq filte r an exact  match
  1733    S ARGS("f ilter")="e q(""uid"", ""urn:va:u t:7"")"
  1734    ; gdsutes t template  only has  roles[]
  1735    S ARGS("t emplate")= "gdsutest"
  1736    D GET^VPR JGDS(.DATA ,.ARGS)
  1737    ;
  1738    ; Parse t he paged r esponse
  1739    D PARSE(. DATA,.OBJE CT)
  1740    ;
  1741    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1742    D ASSERT( "",$G(OBJE CT("items" ,1,"uid")) ,"The uid  field was  not return ed correct ly")
  1743    D ASSERT( "",$G(OBJE CT("items" ,1,"lastLo gin","date ")),"The l astLogin.d ate attrib ute was no t returned  correctly ")
  1744    D ASSERT( "",$G(OBJE CT("items" ,1,"create Date","dat e")),"The  createDate .date attr ibute was  not return ed correct ly")
  1745    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,1,"roles" ,1)),"The  roles fiel d was not  returned c orrectly")
  1746    ; Cleanup  HTTPERR
  1747    K ^||TMP( "HTTPERR", $J)
  1748    ; Cleanup  Vars
  1749    K @DATA,A RGS,OBJECT ,ERR
  1750    ; Get wit h eq filte r a value  in an arra y
  1751    S ARGS("f ilter")="e q(""roles[ ]"",""ehmp -proxy"")"
  1752    ; gdsutes t2 templat e only has  createDat e.date
  1753    S ARGS("t emplate")= "gdsutest2 "
  1754    D GET^VPR JGDS(.DATA ,.ARGS)
  1755    ;
  1756    ; Parse t he paged r esponse
  1757    D PARSE(. DATA,.OBJE CT)
  1758    ;
  1759    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1760    D ASSERT( "",$G(OBJE CT("items" ,1,"uid")) ,"The uid  field was  not return ed correct ly")
  1761    D ASSERT( "",$G(OBJE CT("items" ,1,"roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  1762    D ASSERT( "",$G(OBJE CT("items" ,1,"lastLo gin","date ")),"The l astLogin.d ate attrib ute was no t returned  correctly ")
  1763    D ASSERT( "200001011 20000000", $G(OBJECT( "items",1, "createDat e","date") ),"The cre ateDate.da te attribu te was not  returned  correctly" )
  1764    D ASSERT( "",$G(OBJE CT("items" ,2,"uid")) ,"The uid  field was  not return ed correct ly")
  1765    D ASSERT( "",$G(OBJE CT("items" ,2,"roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  1766    D ASSERT( "",$G(OBJE CT("items" ,2,"lastLo gin","date ")),"The l astLogin.d ate attrib ute was no t returned  correctly ")
  1767    D ASSERT( "200001011 20000000", $G(OBJECT( "items",2, "createDat e","date") ),"The cre ateDate.da te attribu te was not  returned  correctly" )
  1768    D ASSERT( "",$G(OBJE CT("items" ,3,"uid")) ,"The uid  field was  not return ed correct ly")
  1769    D ASSERT( "",$G(OBJE CT("items" ,3,"roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  1770    D ASSERT( "",$G(OBJE CT("items" ,3,"roles" ,2)),"The  roles arra y (2) was  not return ed correct ly")
  1771    D ASSERT( "",$G(OBJE CT("items" ,3,"lastLo gin","date ")),"The l astLogin.d ate attrib ute was no t returned  correctly ")
  1772    D ASSERT( "200001011 20000000", $G(OBJECT( "items",3, "createDat e","date") ),"The cre ateDate.da te attribu te was not  returned  correctly" )
  1773    D ASSERT( "",$G(OBJE CT("items" ,4,"uid")) ,"The uid  field was  not return ed correct ly")
  1774    D ASSERT( "",$G(OBJE CT("items" ,4,"roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  1775    D ASSERT( "",$G(OBJE CT("items" ,4,"lastLo gin","date ")),"The l astLogin.d ate attrib ute was no t returned  correctly ")
  1776    D ASSERT( "200001011 20000000", $G(OBJECT( "items",4, "createDat e","date") ),"The cre ateDate.da te attribu te was not  returned  correctly" )
  1777    ; Cleanup  HTTPERR
  1778    K ^||TMP( "HTTPERR", $J)
  1779    ; Cleanup  Vars
  1780    K @DATA,A RGS,OBJECT ,ERR
  1781    ; Get wit h eq filte r a value  in an arra y (two mat ches)
  1782    S ARGS("f ilter")="e q(""roles[ ]"",""ehmp -test"")"
  1783    ; gdsutes t template  only has  roles[]
  1784    S ARGS("t emplate")= "gdsutest"
  1785    D GET^VPR JGDS(.DATA ,.ARGS)
  1786    ;
  1787    ; Parse t he paged r esponse
  1788    D PARSE(. DATA,.OBJE CT)
  1789    ;
  1790    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1791    D ASSERT( "",$G(OBJE CT("items" ,1,"uid")) ,"The uid  field was  not return ed correct ly")
  1792    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,1,"roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  1793    D ASSERT( "ehmp-test ",$G(OBJEC T("items", 1,"roles", 2)),"The r oles array  (2) was n ot returne d correctl y")
  1794    D ASSERT( "",$G(OBJE CT("items" ,1,"create Date","dat e")),"The  createDate .date attr ibute was  not return ed correct ly")
  1795    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,1,"roles" ,1)),"The  roles fiel d was not  returned c orrectly")
  1796    D ASSERT( "",$G(OBJE CT("items" ,2,"uid")) ,"The uid  field was  not return ed correct ly")
  1797    D ASSERT( "ehmp-test ",$G(OBJEC T("items", 2,"roles", 1)),"The r oles array  (2) was n ot returne d correctl y")
  1798    D ASSERT( "",$G(OBJE CT("items" ,1,"create Date","dat e")),"The  createDate .date attr ibute was  not return ed correct ly")
  1799    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,1,"roles" ,1)),"The  roles fiel d was not  returned c orrectly")
  1800    ; Cleanup  HTTPERR
  1801    K ^||TMP( "HTTPERR", $J)
  1802    ; Cleanup  Vars
  1803    K @DATA,A RGS,OBJECT ,ERR
  1804    ; Get wit h complex  filter (on ly one mat ch)
  1805    ; This is  an implic it and
  1806    S ARGS("f ilter")="e q(""roles[ ]"",""ehmp -test""),e q(""uid"", ""urn:va:u t:99"")"
  1807    ; gdsutes t2 templat e only has  createDat e.date
  1808    S ARGS("t emplate")= "gdsutest2 "
  1809    D GET^VPR JGDS(.DATA ,.ARGS)
  1810    ;
  1811    ; Parse t he paged r esponse
  1812    D PARSE(. DATA,.OBJE CT)
  1813    ;
  1814    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1815    D ASSERT( "",$G(OBJE CT("items" ,1,"uid")) ,"The uid  field was  not return ed correct ly")
  1816    D ASSERT( "",$G(OBJE CT("items" ,1,"roles" ,1)),"The  roles arra y (2) was  not return ed correct ly")
  1817    D ASSERT( "",$G(OBJE CT("items" ,1,"lastLo gin","date ")),"The l astLogin.d ate attrib ute was no t returned  correctly ")
  1818    D ASSERT( "200001011 20000000", $G(OBJECT( "items",1, "createDat e","date") ),"The cre ateDate.da te attribu te was not  returned  correctly" )
  1819    ; Cleanup  HTTPERR
  1820    K ^||TMP( "HTTPERR", $J)
  1821    ; Cleanup  Vars
  1822    K @DATA,A RGS,OBJECT ,ERR
  1823    ; Get wit h complex  filter (mu ltiple mat ches)
  1824    ; This is  an implic it and
  1825    S ARGS("f ilter")="o r(eq(""rol es[]"",""e hmp-proxy" "),eq(""ui d"",""urn: va:ut:99"" ))"
  1826    ; gdsutes t3 templat e only has  roles and  createDat e.date
  1827    S ARGS("t emplate")= "gdsutest3 "
  1828    D GET^VPR JGDS(.DATA ,.ARGS)
  1829    ;
  1830    ; Parse t he paged r esponse
  1831    D PARSE(. DATA,.OBJE CT)
  1832    ;
  1833    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  1834    D ASSERT( "",$G(OBJE CT("items" ,1,"uid")) ,"The uid  field was  not return ed correct ly")
  1835    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,1,"roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  1836    D ASSERT( "",$G(OBJE CT("items" ,1,"lastLo gin","date ")),"The l astLogin.d ate attrib ute was no t returned  correctly ")
  1837    D ASSERT( "200001011 20000000", $G(OBJECT( "items",1, "createDat e","date") ),"The cre ateDate.da te attribu te was not  returned  correctly" )
  1838    D ASSERT( "",$G(OBJE CT("items" ,2,"uid")) ,"The uid  field was  not return ed correct ly")
  1839    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,2,"roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  1840    D ASSERT( "",$G(OBJE CT("items" ,2,"lastLo gin","date ")),"The l astLogin.d ate attrib ute was no t returned  correctly ")
  1841    D ASSERT( "200001011 20000000", $G(OBJECT( "items",2, "createDat e","date") ),"The cre ateDate.da te attribu te was not  returned  correctly" )
  1842    D ASSERT( "",$G(OBJE CT("items" ,3,"uid")) ,"The uid  field was  not return ed correct ly")
  1843    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,3,"roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  1844    D ASSERT( "",$G(OBJE CT("items" ,3,"lastLo gin","date ")),"The l astLogin.d ate attrib ute was no t returned  correctly ")
  1845    D ASSERT( "200001011 20000000", $G(OBJECT( "items",3, "createDat e","date") ),"The cre ateDate.da te attribu te was not  returned  correctly" )
  1846    D ASSERT( "",$G(OBJE CT("items" ,4,"uid")) ,"The uid  field was  not return ed correct ly")
  1847    D ASSERT( "ehmp-prox y",$G(OBJE CT("items" ,4,"roles" ,1)),"The  roles arra y (1) was  not return ed correct ly")
  1848    D ASSERT( "",$G(OBJE CT("items" ,4,"lastLo gin","date ")),"The l astLogin.d ate attrib ute was no t returned  correctly ")
  1849    D ASSERT( "200001011 20000000", $G(OBJECT( "items",4, "createDat e","date") ),"The cre ateDate.da te attribu te was not  returned  correctly" )
  1850    D ASSERT( "",$G(OBJE CT("items" ,5,"uid")) ,"The uid  field was  not return ed correct ly")
  1851    D ASSERT( "ehmp-test ",$G(OBJEC T("items", 5,"roles", 1)),"The r oles array  (1) was n ot returne d correctl y")
  1852    D ASSERT( "",$G(OBJE CT("items" ,5,"lastLo gin","date ")),"The l astLogin.d ate attrib ute was no t returned  correctly ")
  1853    D ASSERT( "200001011 20000000", $G(OBJECT( "items",5, "createDat e","date") ),"The cre ateDate.da te attribu te was not  returned  correctly" )
  1854    ; Cleanup  HTTPERR
  1855    K ^||TMP( "HTTPERR", $J)
  1856    QUIT
  1857    ;
  1858    ;
  1859   SETLOCKNOS TORE ;; @T EST Error  code is se t if no st ore in HTT PREQ
  1860    N DATA,OB JECT,ERR,A RGS,HTTPER R
  1861    ; Send it  to the UR L
  1862    K HTTPREQ ("store")
  1863    D SETLOCK ^VPRJGDS(. DATA,.ARGS )
  1864    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  1865    D ASSERT( 253,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 253 rea son code s hould have  occurred" )
  1866    ; Cleanup  HTTPERR
  1867    K ^||TMP( "HTTPERR", $J)
  1868    QUIT
  1869    ;
  1870   SETLOCKNOG LOBAL ;; @ TEST Error  code is s et if no g lobal is i n VPRCONFI G
  1871    N DATA,OB JECT,ERR,A RGS,HTTPER R,GLOBALSA VE
  1872    ; Kill of f the glob al area fo r the test
  1873    S GLOBALS AVE=^VPRCO NFIG("stor e","ut","g lobal")
  1874    K ^VPRCON FIG("store ","ut","gl obal")
  1875    ; Send it  to the UR L
  1876    S HTTPREQ ("store")= "ut"
  1877    D SETLOCK ^VPRJGDS(. DATA,.ARGS )
  1878    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," global")), "VPRCONFIG  global st orage area  exists an d it shoul dn't")
  1879    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  1880    D ASSERT( 253,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 253 rea son code s hould have  occurred" )
  1881    ; Cleanup  HTTPERR
  1882    K ^||TMP( "HTTPERR", $J)
  1883    ; Restore  the globa l area for  the rest  of the tes ts
  1884    S ^VPRCON FIG("store ","ut","gl obal")=GLO BALSAVE
  1885    QUIT
  1886    ;
  1887   SETLOCKIDE RR ;; @TES T Error co de is set  if no uid
  1888    N DATA,ER R,ARGS,HTT PERR
  1889    ; Try wit h a non ex istent uid
  1890    D SETLOCK ^VPRJGDS(. DATA,.ARGS )
  1891    D ASSERT( 0,$D(DATA) ,"No DATA  should be  returned")
  1892    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  1893    D ASSERT( 111,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 111 rea son code s hould have  occurred" )
  1894    ; Cleanup  HTTPERR
  1895    K ^||TMP( "HTTPERR", $J)
  1896    ; Cleanup  vars
  1897    K DATA,ER R,ARGS
  1898    ; Try wit h a blank  uid
  1899    S ARGS("u id")=""
  1900    D SETLOCK ^VPRJGDS(. DATA,.ARGS )
  1901    D ASSERT( 0,$D(DATA) ,"No DATA  should be  returned")
  1902    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  1903    D ASSERT( 111,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 111 rea son code s hould have  occurred" )
  1904    ; Cleanup  HTTPERR
  1905    K ^||TMP( "HTTPERR", $J)
  1906    QUIT
  1907    ;
  1908   SETLOCK ;;  @TEST Set  a Lock
  1909    N BODY,ER R,ARGS,RET URN,HTTPER R,TIMEOUT
  1910    ; Set the  timeout v alue to so mething sm aller so t he tests d on't take  forever
  1911    S TIMEOUT =$G(^VPRCO NFIG("stor e","ut","l ockTimeout "))
  1912    S ^VPRCON FIG("store ","ut","lo ckTimeout" )=1
  1913    ; Try wit h a uid th at isn't s tored yet
  1914    S ARGS("u id")="urn: va:ut:1338 "
  1915    S RETURN= $$SETLOCK^ VPRJGDS(.A RGS,.BODY)
  1916    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  1917    D ASSERT( "/ut/lock/ urn:va:ut: 1338",$G(R ETURN),"Th e returned  location  header isn 't as expe cted")
  1918    D ASSERT( 1,$D(^VPRJ UTL("urn:v a:ut:1338" )),"A lock  should ha ve been cr eated")
  1919    ; Note: T his only c hecks the  YYYYMMDD o f the stor ed date
  1920    D ASSERT( $E($$CURRT IME^VPRJRU T,1,8),$E( $G(^VPRJUT L("urn:va: ut:1338")) ,1,8),"A l ock time s hould have  been crea ted")
  1921    D ASSERT( 1,$G(^VPRJ UTL("urn:v a:ut:1338" ))?14N,"A  lock time  with 14 di gits shoul d have bee n created" )
  1922    ; Cleanup  HTTPERR
  1923    K ^||TMP( "HTTPERR", $J)
  1924    ; Cleanup  vars
  1925    K RETURN, ERR,ARGS
  1926    ;
  1927    ; Try wit h a uid th at is stor ed
  1928    S ARGS("u id")="urn: va:ut:23"
  1929    S RETURN= $$SETLOCK^ VPRJGDS(.A RGS,.BODY)
  1930    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  1931    D ASSERT( "/ut/lock/ urn:va:ut: 23",$G(RET URN),"The  returned l ocation he ader isn't  as expect ed")
  1932    D ASSERT( 1,$D(^VPRJ UTL("urn:v a:ut:23")) ,"A lock s hould have  been crea ted")
  1933    ; Note: T his only c hecks the  YYYYMMDD o f the stor ed date
  1934    D ASSERT( $E($$CURRT IME^VPRJRU T,1,8),$E( $G(^VPRJUT L("urn:va: ut:23")),1 ,8),"A loc k time sho uld have b een create d")
  1935    D ASSERT( 1,$G(^VPRJ UTL("urn:v a:ut:23")) ?14N,"A lo ck time wi th 14 digi ts should  have been  created")
  1936    ; Cleanup  HTTPERR
  1937    K ^||TMP( "HTTPERR", $J)
  1938    ; Cleanup  vars
  1939    K RETURN, ERR,ARGS
  1940    ;
  1941    ; Try to  set one th at is stil l locked
  1942    S ARGS("u id")="urn: va:ut:23"
  1943    S RETURN= $$SETLOCK^ VPRJGDS(.A RGS,.BODY)
  1944    D ASSERT( 1,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould have  occured")
  1945    D ASSERT( "",$G(RETU RN),"The r eturned lo cation hea der isn't  as expecte d")
  1946    D ASSERT( 500,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 500 e rror shoul d have occ ured")
  1947    D ASSERT( 272,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 272 rea son code s hould have  occurred" )
  1948    ; Cleanup  HTTPERR
  1949    K ^||TMP( "HTTPERR", $J)
  1950    ; Cleanup  vars
  1951    K RETURN, ERR,ARGS
  1952    ;
  1953    ; Try to  set one th at is afte r the time out
  1954    W "waitin g 3 sec fo r lockTime out to pas s"
  1955    H 3
  1956    S ARGS("u id")="urn: va:ut:23"
  1957    S RETURN= $$SETLOCK^ VPRJGDS(.A RGS,.BODY)
  1958    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror","code ")),"An HT TP error s hould NOT  have occur ed")
  1959    D ASSERT( "/ut/lock/ urn:va:ut: 23",$G(RET URN),"The  returned l ocation he ader isn't  as expect ed")
  1960    D ASSERT( 1,$D(^VPRJ UTL("urn:v a:ut:23")) ,"A lock s hould have  been crea ted")
  1961    ; Note: T his only c hecks the  YYYYMMDD o f the stor ed date
  1962    D ASSERT( $E($$CURRT IME^VPRJRU T,1,8),$E( $G(^VPRJUT L("urn:va: ut:23")),1 ,8),"A loc k time sho uld have b een create d")
  1963    D ASSERT( 1,$G(^VPRJ UTL("urn:v a:ut:23")) ?14N,"A lo ck time wi th 14 digi ts should  have been  created")
  1964    ; Cleanup  HTTPERR
  1965    K ^||TMP( "HTTPERR", $J)
  1966    ; Return  the store  timeout ba ck to what  it was
  1967    S ^VPRCON FIG("store ","ut","lo ckTimeout" )=TIMEOUT
  1968    QUIT
  1969    ;
  1970   GETLOCKNOS TORE ;; @T EST Error  code is se t if no st ore in HTT PREQ
  1971    N DATA,ER R,ARGS,HTT PERR
  1972    ; Send it  to the UR L
  1973    K HTTPREQ ("store")
  1974    D GETLOCK ^VPRJGDS(. DATA,.ARGS )
  1975    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  1976    D ASSERT( 253,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 253 rea son code s hould have  occurred" )
  1977    ; Cleanup  HTTPERR
  1978    K ^||TMP( "HTTPERR", $J)
  1979    QUIT
  1980    ;
  1981   GETLOCKNOG LOBAL ;; @ TEST Error  code is s et if no g lobal is i n VPRCONFI G
  1982    N DATA,ER R,ARGS,HTT PERR,GLOBA LSAVE
  1983    ; Kill of f the glob al area fo r the test
  1984    S GLOBALS AVE=^VPRCO NFIG("stor e","ut","g lobal")
  1985    K ^VPRCON FIG("store ","ut","gl obal")
  1986    ; Send it  to the UR L
  1987    S HTTPREQ ("store")= "ut"
  1988    D GETLOCK ^VPRJGDS(. DATA,.ARGS )
  1989    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," global")), "VPRCONFIG  global st orage area  exists an d it shoul dn't")
  1990    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  1991    D ASSERT( 253,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 253 rea son code s hould have  occurred" )
  1992    ; Cleanup  HTTPERR
  1993    K ^||TMP( "HTTPERR", $J)
  1994    ; Restore  the globa l area for  the rest  of the tes ts
  1995    S ^VPRCON FIG("store ","ut","gl obal")=GLO BALSAVE
  1996    QUIT
  1997    ;
  1998   GETLOCKNOI D ;; @TEST  Data is r eturned if  no uid pa ssed
  1999    N DATA,AR GS,OBJECT, HTTPERR,ER R
  2000    ; Add som e test dat a
  2001    K ^VPRJUT L
  2002    S ^VPRJUT L("urn:va: ut:1")=$$C URRTIME^VP RJRUT
  2003    S ^VPRJUT L("urn:va: ut:12")=$$ CURRTIME^V PRJRUT
  2004    S ^VPRJUT L("urn:va: ut:4")=$$C URRTIME^VP RJRUT
  2005    S ^VPRJUT L("urn:va: ut:7")=$$C URRTIME^VP RJRUT
  2006    ; Try wit h a non ex istent uid  attribute
  2007    D GETLOCK ^VPRJGDS(. DATA,.ARGS )
  2008    D:$G(DATA )'="" DECO DE^VPRJSON (DATA,"OBJ ECT","ERR" )
  2009    D ASSERT( 1,$D(DATA) ,"DATA sho uld be ret urned")
  2010    D ASSERT( 0,$D(ERR), "A JSON De code Error  Occured")
  2011    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  2012    D ASSERT( 1,$D(OBJEC T("items", 4,"urn:va: ut:7")),"T he uid was  not retur ned correc tly")
  2013    D ASSERT( 0,$D(OBJEC T("items", 5)),"Too m any entrie s were ret urned")
  2014    ; Cleanup  HTTPERR
  2015    K ^||TMP( "HTTPERR", $J)
  2016    ; Cleanup  Vars
  2017    K DATA,OB JECT,ARGS, ERR
  2018    ; Try wit h a null u id
  2019    S ARGS("u id")=""
  2020    D GETLOCK ^VPRJGDS(. DATA,.ARGS )
  2021    D:$G(DATA )'="" DECO DE^VPRJSON (DATA,"OBJ ECT","ERR" )
  2022    D ASSERT( 1,$D(DATA) ,"DATA sho uld be ret urned")
  2023    D ASSERT( 0,$D(ERR), "A JSON De code Error  Occured")
  2024    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  2025    D ASSERT( 1,$D(OBJEC T("items", 4,"urn:va: ut:7")),"T he uid was  not retur ned correc tly")
  2026    D ASSERT( 0,$D(OBJEC T("items", 5)),"Too m any entrie s were ret urned")
  2027    ; Cleanup  HTTPERR
  2028    K ^||TMP( "HTTPERR", $J)
  2029    QUIT
  2030    ;
  2031   GETLOCKUID UNK ;; @TE ST Error c ode if uid  doesn't e xist
  2032    N DATA,AR GS,HTTPERR
  2033    ; Try wit h a non ex istent uid  attribute
  2034    S ARGS("u id")="urn: va:ut:1337 "
  2035    D GETLOCK ^VPRJGDS(. DATA,.ARGS )
  2036    D ASSERT( 0,$D(DATA) ,"No DATA  should be  returned")
  2037    D ASSERT( 404,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 404 e rror shoul d have occ ured")
  2038    D ASSERT( 229,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 229 rea son code s hould have  occurred" )
  2039    ; Cleanup  HTTPERR
  2040    K ^||TMP( "HTTPERR", $J)
  2041    QUIT
  2042    ;
  2043   DELLOCKNOS TORE ;; @T EST Error  code is se t if no st ore in HTT PREQ
  2044    N DATA,ER R,ARGS,HTT PERR
  2045    ; Send it  to the UR L
  2046    K HTTPREQ ("store")
  2047    D DELLOCK ^VPRJGDS(. DATA,.ARGS )
  2048    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  2049    D ASSERT( 253,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 253 rea son code s hould have  occurred" )
  2050    ; Cleanup  HTTPERR
  2051    K ^||TMP( "HTTPERR", $J)
  2052    QUIT
  2053    ;
  2054   DELLOCKNOG LOBAL ;; @ TEST Error  code is s et if no g lobal is i n VPRCONFI G
  2055    N DATA,ER R,ARGS,HTT PERR,GLOBA LSAVE
  2056    ; Kill of f the glob al area fo r the test
  2057    S GLOBALS AVE=^VPRCO NFIG("stor e","ut","g lobal")
  2058    K ^VPRCON FIG("store ","ut","gl obal")
  2059    ; Send it  to the UR L
  2060    S HTTPREQ ("store")= "ut"
  2061    D DELLOCK ^VPRJGDS(. DATA,.ARGS )
  2062    D ASSERT( 0,$D(^VPRC ONFIG("sto re","ut"," global")), "VPRCONFIG  global st orage area  exists an d it shoul dn't")
  2063    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  2064    D ASSERT( 253,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 253 rea son code s hould have  occurred" )
  2065    ; Cleanup  HTTPERR
  2066    K ^||TMP( "HTTPERR", $J)
  2067    ; Restore  the globa l area for  the rest  of the tes ts
  2068    S ^VPRCON FIG("store ","ut","gl obal")=GLO BALSAVE
  2069    QUIT
  2070    ;
  2071   DELLOCKIDE RR ;; @TES T Error co de is set  if no uid  for lock t able
  2072    N DATA,ER R,ARGS,HTT PERR
  2073    ; Try wit h a non ex istent uid
  2074    D DELLOCK ^VPRJGDS(. DATA,.ARGS )
  2075    D ASSERT( 0,$D(DATA) ,"No DATA  should be  returned")
  2076    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  2077    D ASSERT( 111,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 111 rea son code s hould have  occurred" )
  2078    ; Cleanup  HTTPERR
  2079    K ^||TMP( "HTTPERR", $J)
  2080    ; Cleanup  vars
  2081    K DATA,OB JECT,ERR,A RGS
  2082    ; Try wit h a blank  uid
  2083    S ARGS("u id")=""
  2084    D DELLOCK ^VPRJGDS(. DATA,.ARGS )
  2085    D ASSERT( 0,$D(DATA) ,"No DATA  should be  returned")
  2086    D ASSERT( 400,$G(^|| TMP("HTTPE RR",$J,1," error","co de")),"An  HTTP 400 e rror shoul d have occ ured")
  2087    D ASSERT( 111,$G(^|| TMP("HTTPE RR",$J,1," error","er rors",1,"r eason"))," An 111 rea son code s hould have  occurred" )
  2088    ; Cleanup  HTTPERR
  2089    K ^||TMP( "HTTPERR", $J)
  2090    QUIT
  2091    ;
  2092   DELLOCK ;;  @TEST Del ete Lock
  2093    N RETURN, BODY,ARG,D ATA,ARGS,O BJECT,ERR, HTTPERR
  2094    ; delete  non-existe nt lock
  2095    S ARGS("u id")="urn: va:ut:23"
  2096    D DELLOCK ^VPRJGDS(. DATA,.ARGS )
  2097    D:$G(DATA )'="" DECO DE^VPRJSON ("DATA","O BJECT","ER R")
  2098    D ASSERT( 0,$D(ERR), "A JSON De code Error  Occured")
  2099    D ASSERT( 0,$D(^VPRJ UTL("urn:v a:ut:23")) ,"Data exi sts and it  should no t")
  2100    D ASSERT( "true",$G( OBJECT("ok ")),"No DA TA returne d from a D ELETE call  (should n ot happen) ")
  2101    ; Cleanup  HTTPERR
  2102    K ^||TMP( "HTTPERR", $J)
  2103    ;
  2104    ; Create  a lock so  we can del ete it
  2105    S ^VPRJUT L("urn:va: ut:1337")= $$CURRTIME ^VPRJRUT
  2106    ; delete  lock
  2107    S ARGS("u id")="urn: va:ut:1337 "
  2108    D DELLOCK ^VPRJGDS(. DATA,.ARGS )
  2109    D:$G(DATA )'="" DECO DE^VPRJSON ("DATA","O BJECT","ER R")
  2110    D ASSERT( 0,$D(ERR), "A JSON De code Error  Occured")
  2111    D ASSERT( 0,$D(^VPRJ UTL("urn:v a:ut:1337" )),"Data e xists and  it should  not")
  2112    D ASSERT( "true",$G( OBJECT("ok ")),"No DA TA returne d from a D ELETE call  (should n ot happen) ")
  2113    ; Cleanup  HTTPERR
  2114    K ^||TMP( "HTTPERR", $J)
  2115    QUIT
  2116    ;
  2117    ;
  2118   DELFILTER  ;; @TEST D elete Data  by filter
  2119    N RETURN, BODY,ARG,D ATA,ARGS,O BJECT,ERR, HTTPERR
  2120    ; create  some sampl e data
  2121    S BODY(1) =$$SAMPLED ATA("""ehm p-proxy""" ,"urn:va:u t:265")
  2122    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  2123    D ASSERT( "/ut/urn:v a:ut:265", RETURN,"Sa mple data  did not ge t set corr ectly")
  2124    K BODY S  BODY(1)=$$ SAMPLEDATA ("""rdk-pr oxy""","ur n:va:ut:36 6")
  2125    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  2126    D ASSERT( "/ut/urn:v a:ut:366", RETURN,"Sa mple data  did not ge t set corr ectly")
  2127    K BODY S  BODY(1)=$$ SAMPLEDATA ("""ehmp-d octor"""," urn:va:ut: 367")
  2128    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  2129    D ASSERT( "/ut/urn:v a:ut:367", RETURN,"Sa mple data  did not ge t set corr ectly")
  2130    K BODY S  BODY(1)=$$ SAMPLEDATA ("""ehmp-n urse""","u rn:va:ut:2 68")
  2131    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  2132    D ASSERT( "/ut/urn:v a:ut:268", RETURN,"Sa mple data  did not ge t set corr ectly")
  2133    ; delete  all uids t hat contai n a 3
  2134    S ARGS("f ilter")="i like(""uid "",""%3%"" )"
  2135    D DEL^VPR JGDS(.DATA ,.ARGS)
  2136    D DECODE^ VPRJSON("D ATA","OBJE CT","ERR")
  2137    D ASSERT( 0,$D(ERR), "Error ret urned from  Delete ca ll")
  2138    D ASSERT( 0,$D(^VPRJ UT("urn:va :ut:367")) !$D(^VPRJU T("urn:va: ut:366")), "Data exis ts and it  should not ")
  2139    D ASSERT( 0,$D(^VPRJ UTJ("JSON" ,"urn:va:u t:367"))!$ D(^VPRJUTJ ("JSON","u rn:va:ut:3 66")),"Dat a exists a nd it shou ld not")
  2140    D ASSERT( 1,$D(^VPRJ UT("urn:va :ut:268")) &$D(^VPRJU T("urn:va: ut:265")), "Data does n't exist  that shoul d")
  2141    D ASSERT( 1,$D(^VPRJ UTJ("JSON" ,"urn:va:u t:268"))&$ D(^VPRJUTJ ("JSON","u rn:va:ut:2 65")),"Dat a doesn't  exist that  should")
  2142    D ASSERT( "true",$G( OBJECT("ok ")),"Delet e call ret urned unex pected dat a")
  2143    ; Cleanup  HTTPERR
  2144    K ^||TMP( "HTTPERR", $J)
  2145    Q
  2146    ;
  2147   DELALL ;;  @TEST Dele te all dat a
  2148    N RETURN, BODY,ARG,D ATA,ARGS,O BJECT,ERR, HTTPERR,ST ORE
  2149    ; delete  it all
  2150    S ARGS("c onfirm")=" true"
  2151    S STORE=^ VPRCONFIG( "store","u t","global ")
  2152    D DEL^VPR JGDS(.DATA ,.ARGS)
  2153    D DECODE^ VPRJSON("D ATA","OBJE CT","ERR")
  2154    D ASSERT( 0,$D(ERR), "Error ret urned when  parsing D elete retu rn")
  2155    D ASSERT( "",$O(^VPR JUT(0)),"D ata exists  and it sh ould not")
  2156    D ASSERT( "",$O(^VPR JUTJ("JSON ",0)),"Dat a exists a nd it shou ld not")
  2157    D ASSERT( 1,$D(^VPRC ONFIG("sto re","ut"," global")), "Data stor e global n ode defini tion in ^V PRJCONFIG  was lost!" )
  2158    D ASSERT( 10,$D(^VPR CONFIG("st ore","ut", "index")), "Data stor e index de finitions  in ^VPRJCO NFIG were  lost!")
  2159    D ASSERT( 10,$D(^VPR CONFIG("st ore","ut", "template" )),"Data s tore index  definitio ns in ^VPR JCONFIG we re lost!")
  2160    D ASSERT( "true",$G( OBJECT("ok ")),"Delet e call ret urned unex pected dat a")
  2161    D ASSERT( 0,$D(@STOR E@(0)),"GD S data sto re uid cou nter was n ot reset,  and it sho uld have b een")
  2162    ; Cleanup  HTTPERR
  2163    K ^||TMP( "HTTPERR", $J)
  2164    QUIT
  2165    ;
  2166   CLR ;; @TE ST Clear A LL Generic  Data Stor e data and  route map
  2167    N RETURN, BODY,ARG,D ATA,ARGS,O BJECT,ERR, HTTPERR,UR LMAPNUM
  2168    ; Set a l ock so one  exists
  2169    S ^VPRJUT L("urn:va: ut:23")=$$ CURRTIME^V PRJRUT
  2170    D CLR^VPR JGDS(.DATA ,.ARGS)
  2171    D DECODE^ VPRJSON("D ATA","OBJE CT","ERR")
  2172    D ASSERT( "{""ok"":  true}",$G( DATA),"Inv alid DATA  returned f rom a DELE TE call")
  2173    ; Ensure  global is  cleared
  2174    D ASSERT( 0,$D(^VPRJ UT),"Data  exists and  it should  not")
  2175    D ASSERT( 0,$D(^VPRJ UTJ),"JSON  Data exis ts and it  should not ")
  2176    D ASSERT( 0,$D(^VPRJ UTX),"Inde x Data exi sts and it  should no t")
  2177    D ASSERT( 0,$D(^VPRJ UTL),"Lock  Table Dat a exists a nd it shou ld not")
  2178    ; Ensure  route map  index does n't contai n data
  2179    D ASSERT( 0,$D(^VPRC ONFIG("url map","inde x",HTTPREQ ("store")) ),"Route m ap still h as entries  for this  data store  and it sh ould not")
  2180    D ASSERT( 0,$D(^VPRC ONFIG("url map","inde x",HTTPREQ ("store")) ),"Route m ap still h as entries  for this  data store  and it sh ould not")
  2181    ; Ensure  route map  doesn't co ntain data
  2182    S URLMAPN UM=""
  2183    F  S URLM APNUM=$O(^ VPRCONFIG( "urlmap",U RLMAPNUM))  Q:URLMAPN UM=""  Q:U RLMAPNUM'= +URLMAPNUM   D
  2184    . I ^VPRC ONFIG("url map",URLMA PNUM,"stor e")=HTTPRE Q("store")  D
  2185    . . D ASS ERT(0,$D(^ VPRCONFIG( "urlmap",U RLMAPNUM," store"))," Route map  still has  entries fo r this dat a store an d it shoul d not")
  2186    ; Cleanup  HTTPERR
  2187    K ^||TMP( "HTTPERR", $J)
  2188    QUIT
  2189    ;
  2190    ;
  2191   RDKSESSION  ;; @TEST  Realistic  RDK sessio n store te st
  2192    N HTTPREQ ,HTTPERR
  2193    ; Create  Store
  2194    D ADDSTOR E^VPRJCONF IG("utses" )
  2195    K ^||TMP( "HTTPERR", $J)
  2196    ; Add sam ple sessio n
  2197    N RETURN, BODY,ARG,H TTPREQ,DAT A,ERR
  2198    S HTTPREQ ("store")= "utses"
  2199    S BODY(1) ="{""uid"" :""ZOUjqD3 uh48eOuMrB 4meSlCzcFV 9IWv-"","" expires"": ""2016-06- 09T19:02:0 9.395Z""," "session"" :{""cookie "":{""expi res"":""20 16-06-09T1 9:02:09.39 5Z"",""htt pOnly"":tr ue,""origi nalMaxAge" ":899998," "path"":"" /""},""csr f"":{""sec ret"":""v0 6210J1hu2M YpqUwg0IeJ wZ""},""jw t"":{""sec ret"":""zT AhkVWhJ4DH C13_0lNSAy W5""},""us er"":{""ac cessCode"" :"" REDACT "",""consu merType"": ""user""," "corsTabs" ":""true"" ,""dgRecor dAccess"": ""false"", ""dgSecuri tyOfficer" ":""false" ",""dgSens itiveAcces s"":""fals e"",""disa bled"":fal se,""divis ion"":""50 0"",""divi sionSelect "":false," "duz"":{"" 9E7A"":""1 0000000270 ""},""eHMP UIContext" ":[{""last Accessed"" :""2016060 9103852321 "",""patie ntId"":{"" type"":""p id"",""val ue"":""9E7 A;100022"" },""patien tIdentifie r"":""pid: 9E7A;10002 2"",""work spaceConte xt"":{""co ntextId"": ""patient" ",""worksp aceId"":"" overview"" }},{""last Accessed"" :""2016060 9115349599 "",""patie ntId"":{"" type"":""p id"",""val ue"":""9E7 A;3""},""p atientIden tifier"":" "pid:9E7A; 3"",""work spaceConte xt"":{""co ntextId"": ""patient" ",""worksp aceId"":"" overview"" }}],""expi res"":""20 16-06-09T1 9:02:09.39 5Z"",""fac ility"":"" PANORAMA"" ,""firstna me"":""PAN ORAMA"","" infoButton Oid"":""1. 3.6.1.4.1. 3768"",""l astname"": ""USER""," "password" ":"" REDACTED "",""pcmm" ":[{""role s"":[""NUR SE (RN)"", ""NURSE PR ACTITIONER "",""OIF O EF CLINICA L CASE MAN AGER"",""P HYSICIAN-A TTENDING"" ,""PHYSICI AN-PRIMARY  CARE"","" RN CARE CO ORDINATOR" ",""SOCIAL  WORKER""] ,""service "":[""HOME  TELEHEALT H"",""HOSP ITAL MEDIC INE"",""IM AGING"","" INFECTIOUS  DISEASE"" ],""team"" :[""TEAM1" ",""TEAM2" ",""TEAM3" "]}],""per missionSet s"":[""rea d-access"" ,""standar d-doctor"" ],""permis sions"":[" "read-acti ve-medicat ion"",""re ad-allergy "",""read- clinical-r eminder"", ""read-com munity-hea lth-summar y"",""read -document" ",""read-e ncounter"" ,""read-im munization "",""read- medication -review"", ""read-ord er"",""rea d-patient- history"", ""read-con dition-pro blem"",""r ead-patien t-record"" ,""access- stack-grap h"",""read -task"","" read-vital "",""read- vista-heal th-summary "",""read- stack-grap h"",""read -timeline" ",""add-ac tive-medic ation"","" add-allerg y"",""add- condition- problem"", ""add-cons ult-order" ",""add-en counter"", ""add-immu nization"" ,""add-lab -order""," "add-med-o rder"",""a dd-non-va- medication "",""add-n ote"",""ad d-note-add endum"","" add-patien t-history" ",""add-ra diology-or der"",""ad d-task""," "add-vital "",""cance l-task""," "complete- consult-or der"",""co sign-lab-o rder"",""c osign-med- order"","" cosign-not e"",""cosi gn-radiolo gy-order"" ,""delete- note"",""d iscontinue -active-me dication"" ,""discont inue-consu lt-order"" ,""discont inue-lab-o rder"",""d iscontinue -med-order "",""disco ntinue-rad iology-ord er"",""edi t-active-m edication" ",""edit-a llergy""," "edit-cond ition-prob lem"",""ed it-consult -order""," "edit-enco unter-form "",""edit- lab-order" ",""edit-m ed-order"" ,""edit-no n-va-medic ation"","" edit-note" ",""edit-n ote-addend um"",""edi t-patient- history"", ""edit-rad iology-ord er"",""edi t-task""," "eie-aller gy"",""eie -immunizat ion"",""ei e-patient- history"", ""eie-vita l"",""rele ase-lab-or der"",""re lease-med- order"","" release-ra diology-or der"",""re move-condi tion-probl em"",""sch edule-cons ult-order" ",""sign-c onsult-ord er"",""sig n-lab-orde r"",""sign -med-order "",""sign- note"",""s ign-note-a ddendum"", ""sign-rad iology-ord er"",""tri age-consul t-order"", ""abort-ta sk"",""edi t-encounte r"",""eie- encounter" ",""edit-i mmunizatio n"",""edit -vital""], ""provider "":true,"" requiresRe set"":fals e,""rptTab s"":""fals e"",""sect ion"":""Me dicine""," "sessionLe ngth"":900 000,""site "":""9E7A" ",""ssn"": 666441233, ""title"": ""Clinicia n"",""uid" ":""urn:va :user:9E7A :100000002 70"",""use rname"":"" PW           "",""verif yCode"":"" REDACTED "",""vista Keys"":["" GMRA-SUPER VISOR"","" GMRC101"", ""GMV MANA GER"",""OR ES"",""PRO VIDER"","" PSB CPRS M ED BUTTON" "],""vista UserClass" ":[{""role "":""USER" ",""uid"": ""urn:va:a su-class:9 E7A:561""} ]}}}"
  2200    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  2201    D ASSERT( 10,$D(^VPR JUTSES("ZO UjqD3uh48e OuMrB4meSl CzcFV9IWv- ")),"Data  NOT stored  when it s hould be")
  2202    ; Patch t he expires  date/time s
  2203    K BODY,AR G,RETURN
  2204    S BODY(1) ="{""expir es"": ""20 16-06-15T1 6:19:00.00 0Z"",""ses sion"": {" "cookie"":  {""expire s"":""2016 -06-15T16: 19:00.000Z ""},""user "": {""exp ires"":""2 016-06-15T 16:19:00.0 00Z""}}}"
  2205    D DECODE^ VPRJSON("B ODY","OBJE CT","ERR")
  2206    S HTTPREQ ("method") ="PATCH"
  2207    S ARG("ui d")="ZOUjq D3uh48eOuM rB4meSlCzc FV9IWv-"
  2208    S RETURN= $$SET^VPRJ GDS(.ARG,. BODY)
  2209    D ASSERT( "2016-06-1 5T16:19:00 .000Z",$G( ^VPRJUTSES ("ZOUjqD3u h48eOuMrB4 meSlCzcFV9 IWv-","exp ires")),"o bject.expi res not st ored corre ctly")
  2210    D ASSERT( "2016-06-1 5T16:19:00 .000Z",$G( ^VPRJUTSES ("ZOUjqD3u h48eOuMrB4 meSlCzcFV9 IWv-","ses sion","coo kie","expi res")),"ob ject.sessi on.cookie. expires no t stored c orrectly")
  2211    D ASSERT( "2016-06-1 5T16:19:00 .000Z",$G( ^VPRJUTSES ("ZOUjqD3u h48eOuMrB4 meSlCzcFV9 IWv-","ses sion","use r","expire s")),"obje ct.session .user.expi res not st ored corre ctly")
  2212    K BODY,AR G,RETURN,D ATA,ERR,HT TPREQ("met hod")
  2213    ; retriev e the obje ct
  2214    S ARG("ui d")="ZOUjq D3uh48eOuM rB4meSlCzc FV9IWv-"
  2215    D GET^VPR JGDS(.DATA ,.ARG)
  2216    D:$D(DATA ) DECODE^V PRJSON("DA TA","OBJEC T","ERR")
  2217    D ASSERT( 10,$D(^VPR JUTSES("ZO UjqD3uh48e OuMrB4meSl CzcFV9IWv- ")),"Data  does not e xist and i t should")
  2218    D ASSERT( 0,$D(ERR), "A JSON De code Error  Occured")
  2219    D ASSERT( 0,$D(^||TM P("HTTPERR ",$J,1,"er ror")),"An  HTTP erro r should N OT have oc cured")
  2220    D ASSERT( "ZOUjqD3uh 48eOuMrB4m eSlCzcFV9I Wv-",$G(OB JECT("uid" )),"The ui d field wa s not retu rned corre ctly")
  2221    D ASSERT( "2016-06-1 5T16:19:00 .000Z",$G( OBJECT("ex pires"))," object.exp ires not s tored corr ectly")
  2222    D ASSERT( "2016-06-1 5T16:19:00 .000Z",$G( OBJECT("se ssion","co okie","exp ires")),"o bject.sess ion.cookie .expires n ot stored  correctly" )
  2223    D ASSERT( "2016-06-1 5T16:19:00 .000Z",$G( OBJECT("se ssion","us er","expir es")),"obj ect.sessio n.user.exp ires not s tored corr ectly")
  2224    K BODY,AR G,RETURN,D ATA,ERR,HT TPREQ("met hod")
  2225    ; delete  an object
  2226    S ARGS("u id")="ZOUj qD3uh48eOu MrB4meSlCz cFV9IWv-"
  2227    D DEL^VPR JGDS(.DATA ,.ARGS)
  2228    D ASSERT( 0,$D(^VPRJ UTSES("ZOU jqD3uh48eO uMrB4meSlC zcFV9IWv-" )),"Sessio n still ex ists and s houldn't")
  2229    K ARGS,DA TA
  2230    ; Kill th e data sto res
  2231    D CLR^VPR JGDS(.DATA ,.ARGS)
  2232    D DECODE^ VPRJSON("D ATA","OBJE CT","ERR")
  2233    D ASSERT( "{""ok"":  true}",$G( DATA),"Inv alid DATA  returned f rom a DELE TE call")
  2234    QUIT