package Ġcom . ic apps . n idd ler . lib . debugger . model Ċ Ċ import Ġcom . ic apps . n idd ler . lib . debugger . N idd ler Debugger Connection Ċ import Ġio . mock k . Runs Ċ import Ġio . mock k . every Ċ import Ġio . mock k . just Ċ import Ġio . mock k . mock k Ċ import Ġio . mock k . verify Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test ĊĊ Ċ /** Ċ Ġ* Ġ@ author Ġnic ola ver bee ck Ċ Ġ*/ Ċ internal Ġclass ĠDebugger Service Test Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġmock ing ed Connection : ĠN idd ler Debugger Connection ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġservice : ĠDebugger Service ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock ing ed Connection Ġ= Ġmock k () ĊĠĠĠĠĠĠĠ Ġservice Ġ= ĠDebugger Service ( mock ing ed Connection ) ĊĠĠĠĠĠĠĠ Ġevery Ġ{ Ġmock ing ed Connection . sendMessage ( any ()) Ġ} Ġjust ĠRuns ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġadd Black list Item () Ġ{ ĊĠĠĠĠĠĠĠ Ġservice . add Black list Item (" .* \\ .* md p ") ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġmock ing ed Connection . sendMessage ("{ \" control Type \":\" add Black list \",\" payload \":{\" regex \":\" .* \\\\ .* md p \" }, \" type \":\" control Debug \" }") Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġremove Black list Item () Ġ{ ĊĠĠĠĠĠĠĠ Ġservice . remove Black list Item (" .* \\ .* md p ") ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġmock ing ed Connection . sendMessage ("{ \" control Type \":\" remove Black list \",\" payload \":{\" regex \":\" .* \\\\ .* md p \" }, \" type \":\" control Debug \" }") Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġadd Default Response () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġid Ġ= Ġservice . add Default Response (" 2 9 9 - 2 9 9 1 - 1 - 3 3 1 ", Ġ" GET ", ĠDebug Response ( 2 0 0 , Ġ" OK ", Ġmap Of (" X - Client - Id " Ġto ĠlistOf (" 2 3 0 1 9 - 1 0 ")), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" ew 0 K CS J 0 b 2 tl bi I 6 IC Ix Mj M 4 Nz Y 3 OD gx OD gy OS INC n 0 =", Ġ" application / json "), Ġtrue ) ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġmock ing ed Connection . sendMessage ("{ \" control Type \":\" add Default Response \",\" payload \":{\" regex \":\" 2 9 9 - 2 9 9 1 - 1 - 3 3 1 \",\" match Method \":\" GET \",\" id \":\" $ id \",\" active \": true ,\" code \": 2 0 0 ,\" message \":\" OK \",\" headers \":{\" X - Client - Id \":[\" 2 3 0 1 9 - 1 0 \"] }, \" encoded Body \":\" ew 0 K CS J 0 b 2 tl bi I 6 IC Ix Mj M 4 Nz Y 3 OD gx OD gy OS INC n 0 = \",\" body MimeType \":\" application / json \" }, \" type \":\" control Debug \" }") Ġ} ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġadd Request Intercept () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġid Ġ= Ġservice . add Request Intercept (" .* \\ .* md p ", Ġ" HEAD ", Ġtrue ) ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġmock ing ed Connection . sendMessage ("{ \" control Type \":\" add Request \",\" payload \":{\" regex \":\" .* \\\\ .* md p \",\" match Method \":\" HEAD \",\" id \":\" $ id \",\" active \": true }, \" type \":\" control Debug \" }") Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġadd Response Intercept () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġid Ġ= Ġservice . add Response Intercept (" .* \\ .* md p ", Ġ" POST ", Ġ 4 0 3 , Ġtrue ) ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġmock ing ed Connection . sendMessage ("{ \" control Type \":\" add Response \",\" payload \":{\" regex \":\" .* \\\\ .* md p \",\" match Method \":\" POST \",\" response Code \": 4 0 3 ,\" id \":\" $ id \",\" active \": true }, \" type \":\" control Debug \" }") Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġrespond To () Ġ{ ĊĠĠĠĠĠĠĠ Ġservice . respond To (" 2 9 9 - 2 9 9 1 - 1 - 3 3 1 ", ĠDebug Response ( 2 0 0 , Ġ" OK ", Ġnull , Ġnull , Ġnull )) ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġmock ing ed Connection . sendMessage ("{ \" control Type \":\" debug Reply \",\" payload \":{\" code \": 2 0 0 ,\" message \":\" OK \" }, \" message Id \":\" 2 9 9 - 2 9 9 1 - 1 - 3 3 1 \",\" type \":\" control Debug \" }") Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġmute Action () Ġ{ ĊĠĠĠĠĠĠĠ Ġservice . mute Action (" ww - ff - qq ") ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġmock ing ed Connection . sendMessage ("{ \" control Type \":\" deactivate Action \",\" payload \":{\" id \":\" ww - ff - qq \" }, \" type \":\" control Debug \" }") Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġun mute Action () Ġ{ ĊĠĠĠĠĠĠĠ Ġservice . un mute Action (" ww - ff - qq ") ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġmock ing ed Connection . sendMessage ("{ \" control Type \":\" activate Action \",\" payload \":{\" id \":\" ww - ff - qq \" }, \" type \":\" control Debug \" }") Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġremove Request Action () Ġ{ ĊĠĠĠĠĠĠĠ Ġservice . remove Request Action (" ww - ff - qq ") ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġmock ing ed Connection . sendMessage ("{ \" control Type \":\" remove Request \",\" payload \":{\" id \":\" ww - ff - qq \" }, \" type \":\" control Debug \" }") Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġremove Response Action () Ġ{ ĊĠĠĠĠĠĠĠ Ġservice . remove Response Action (" ww - ff - qq ") ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġmock ing ed Connection . sendMessage ("{ \" control Type \":\" remove Response \",\" payload \":{\" id \":\" ww - ff - qq \" }, \" type \":\" control Debug \" }") Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġupdate Del ays () Ġ{ ĊĠĠĠĠĠĠĠ Ġservice . update Del ays ( Debugger Del ays ( 1 2 3 , Ġ 4 5 6 , Ġ 7 8 9 )) ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġmock ing ed Connection . sendMessage ("{ \" control Type \":\" update Del ays \",\" payload \":{\" pre Black list \": 1 2 3 ,\" post Black list \": 4 5 6 ,\" time Per Call \": 7 8 9 }, \" type \":\" control Debug \" }") Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġset All Actions Mut ed () Ġ{ ĊĠĠĠĠĠĠĠ Ġservice . set All Actions Mut ed ( true ) ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġmock ing ed Connection . sendMessage ("{ \" control Type \":\" mute Actions \",\" type \":\" control Debug \" }") Ġ} ĊĊĠĠĠĠĠĠĠ Ġservice . set All Actions Mut ed ( false ) ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġmock ing ed Connection . sendMessage ("{ \" control Type \":\" un mute Actions \",\" type \":\" control Debug \" }") Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġadd Default Request Override () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġid Ġ= Ġservice . add Default Request Override (" 2 9 9 - 2 9 9 1 - 1 - 3 3 1 ", Ġ" POST ", ĠDebug Request (" https :// www . google . com ", Ġ" GET ", Ġmap Of (" X - Client - Id " Ġto ĠlistOf (" 2 3 0 1 9 - 1 0 ")), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ" ew 0 K CS J 0 b 2 tl bi I 6 IC Ix Mj M 4 Nz Y 3 OD gx OD gy OS INC n 0 =", Ġ" application / json "), Ġtrue ) ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġmock ing ed Connection . sendMessage ("{ \" control Type \":\" add Default Request Override \",\" payload \":{\" regex \":\" 2 9 9 - 2 9 9 1 - 1 - 3 3 1 \",\" match Method \":\" POST \",\" id \":\" $ id \",\" active \": true ,\" url \":\" https :// www . google . com \",\" method \":\" GET \",\" headers \":{\" X - Client - Id \":[\" 2 3 0 1 9 - 1 0 \"] }, \" encoded Body \":\" ew 0 K CS J 0 b 2 tl bi I 6 IC Ix Mj M 4 Nz Y 3 OD gx OD gy OS INC n 0 = \",\" body MimeType \":\" application / json \" }, \" type \":\" control Debug \" }") Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġadd Request Override () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġid Ġ= Ġservice . add Request Override (" 2 9 9 - 2 9 9 1 - 1 - 3 3 1 ", Ġmethod Ġ= Ġ" subscribe ", Ġactive Ġ= Ġtrue ) ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġmock ing ed Connection . sendMessage ("{ \" control Type \":\" add Request Override \",\" payload \":{\" regex \":\" 2 9 9 - 2 9 9 1 - 1 - 3 3 1 \",\" match Method \":\" subscribe \",\" id \":\" $ id \",\" active \": true }, \" type \":\" control Debug \" }") Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġremove Request Override Method () Ġ{ ĊĠĠĠĠĠĠĠ Ġservice . remove Request Override Method (" ww - ff - qq ") ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġmock ing ed Connection . sendMessage ("{ \" control Type \":\" remove Request Override \",\" payload \":{\" id \":\" ww - ff - qq \" }, \" type \":\" control Debug \" }") Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġset Active () Ġ{ ĊĠĠĠĠĠĠĠ Ġservice . setActive ( true ) ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġmock ing ed Connection . sendMessage ("{ \" control Type \":\" activate \",\" type \":\" control Debug \" }") Ġ} ĊĊĠĠĠĠĠĠĠ Ġservice . setActive ( false ) ĊĠĠĠĠĠĠĠ Ġverify Ġ{ Ġmock ing ed Connection . sendMessage ("{ \" control Type \":\" deactivate \",\" type \":\" control Debug \" }") Ġ} ĊĠĠĠ Ġ} Ċ Ċ }