[{"data":1,"prerenderedAt":1873},["ShallowReactive",2],{"navigation":3,"\u002Ftesting":43,"\u002Ftesting-surround":1868},[4,8,13,18,23,28,33,38],{"title":5,"path":6,"stem":7},"Getting started","\u002F","index",{"title":9,"path":10,"stem":11,"order":12},"Numbers","\u002Fnumbers","numbers",1,{"title":14,"path":15,"stem":16,"order":17},"Rent","\u002Frent","rent",2,{"title":19,"path":20,"stem":21,"order":22},"User","\u002Fuser","user",3,{"title":24,"path":25,"stem":26,"order":27},"Free numbers","\u002Ffree","free",4,{"title":29,"path":30,"stem":31,"order":32},"Webhooks","\u002Fwebhooks","webhooks",5,{"title":34,"path":35,"stem":36,"order":37},"Testing","\u002Ftesting","testing",6,{"title":39,"path":40,"stem":41,"order":42},"Changelog","\u002Fchangelog","changelog",7,{"id":44,"title":34,"body":45,"description":1862,"extension":1863,"meta":1864,"navigation":1865,"path":35,"seo":1866,"stem":36,"__hash__":1867},"docs\u002Ftesting.md",{"type":46,"value":47,"toc":1854},"minimark",[48,85,90,167,292,412,431,490,494,516,832,849,875,879,907,1148,1208,1212,1244,1464,1468,1654,1658,1850],[49,50,51,55,56,59,60,68,69,72,73,76,77,80,81,84],"p",{},[52,53,54],"code",{},"MockOnlineSim"," (package ",[52,57,58],{},"ru.onlinesim.kotlin.mock",") is an in-process fake of the OnlineSim API. It is the Java SDK's ",[61,62,66],"a",{"href":63,"rel":64},"https:\u002F\u002Fs00d.github.io\u002Fonlinesim-java-api\u002Ftesting",[65],"nofollow",[52,67,54],{}," with a Kotlin face: named options, ",[52,70,71],{},"mock.client()"," returning the Kotlin client. It is a ",[52,74,75],{},"Transport"," that answers like the real backend — same shapes, same error codes, HTTP 456 for a wrong key and HTTP 200 ",[52,78,79],{},"ERROR_WRONG_KEY"," for a missing one — and keeps a balance, operations and rents. Your code talks to a normal ",[52,82,83],{},"OnlineSim"," client, so nothing in it changes for tests. It is deterministic: no randomness, no clock, numbers and ids come from a counter. Thread-safe.",[86,87,89],"h2",{"id":88},"setup","Setup",[91,92,97],"pre",{"className":93,"code":94,"language":95,"meta":96,"style":96},"language-kotlin shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import ru.onlinesim.kotlin.mock.MockOnlineSim\n\nval mock = MockOnlineSim(balance = 10.0)\nval client = mock.client() \u002F\u002F an OnlineSim wired to the mock\n","kotlin","",[52,98,99,111,117,145],{"__ignoreMap":96},[100,101,103,107],"span",{"class":102,"line":12},"line",[100,104,106],{"class":105},"sMK4o","import",[100,108,110],{"class":109},"sBMFI"," ru.onlinesim.kotlin.mock.MockOnlineSim\n",[100,112,113],{"class":102,"line":17},[100,114,116],{"emptyLinePlaceholder":115},true,"\n",[100,118,119,122,126,129,133,136,138,142],{"class":102,"line":22},[100,120,121],{"class":105},"val",[100,123,125],{"class":124},"sTEyZ"," mock ",[100,127,128],{"class":105},"=",[100,130,132],{"class":131},"s2Zo4"," MockOnlineSim",[100,134,135],{"class":124},"(balance ",[100,137,128],{"class":105},[100,139,141],{"class":140},"sbssI"," 10.0",[100,143,144],{"class":124},")\n",[100,146,147,149,152,154,157,160,163],{"class":102,"line":27},[100,148,121],{"class":105},[100,150,151],{"class":124}," client ",[100,153,128],{"class":105},[100,155,156],{"class":124}," mock.",[100,158,159],{"class":131},"client",[100,161,162],{"class":124},"() ",[100,164,166],{"class":165},"sHwdD","\u002F\u002F an OnlineSim wired to the mock\n",[91,168,170],{"className":93,"code":169,"language":95,"meta":96,"style":96},"MockOnlineSim(\n    apiKey: String = \"mock-key\",\n    balance: Double = 100.0,\n    prices: Map\u003CInt, Map\u003CString, Double>> = \u002F* see below *\u002F,\n    rentTariffs: Map\u003CInt, MockRentTariff> = \u002F* see below *\u002F,\n    guardInterval: Int = 0,\n)\n",[52,171,172,179,197,212,249,274,288],{"__ignoreMap":96},[100,173,174,176],{"class":102,"line":12},[100,175,54],{"class":131},[100,177,178],{"class":124},"(\n",[100,180,181,184,187,190,194],{"class":102,"line":17},[100,182,183],{"class":124},"    apiKey: ",[100,185,186],{"class":109},"String",[100,188,189],{"class":105}," =",[100,191,193],{"class":192},"sfazB"," \"mock-key\"",[100,195,196],{"class":124},",\n",[100,198,199,202,205,207,210],{"class":102,"line":22},[100,200,201],{"class":124},"    balance: ",[100,203,204],{"class":109},"Double",[100,206,189],{"class":105},[100,208,209],{"class":140}," 100.0",[100,211,196],{"class":124},[100,213,214,217,220,223,226,229,231,233,235,237,239,242,244,247],{"class":102,"line":27},[100,215,216],{"class":124},"    prices: ",[100,218,219],{"class":109},"Map",[100,221,222],{"class":124},"\u003C",[100,224,225],{"class":109},"Int",[100,227,228],{"class":124},", ",[100,230,219],{"class":109},[100,232,222],{"class":124},[100,234,186],{"class":109},[100,236,228],{"class":124},[100,238,204],{"class":109},[100,240,241],{"class":124},">> ",[100,243,128],{"class":105},[100,245,246],{"class":165}," \u002F* see below *\u002F",[100,248,196],{"class":124},[100,250,251,254,256,258,260,262,265,268,270,272],{"class":102,"line":32},[100,252,253],{"class":124},"    rentTariffs: ",[100,255,219],{"class":109},[100,257,222],{"class":124},[100,259,225],{"class":109},[100,261,228],{"class":124},[100,263,264],{"class":109},"MockRentTariff",[100,266,267],{"class":124},"> ",[100,269,128],{"class":105},[100,271,246],{"class":165},[100,273,196],{"class":124},[100,275,276,279,281,283,286],{"class":102,"line":37},[100,277,278],{"class":124},"    guardInterval: ",[100,280,225],{"class":109},[100,282,189],{"class":105},[100,284,285],{"class":140}," 0",[100,287,196],{"class":124},[100,289,290],{"class":102,"line":42},[100,291,144],{"class":124},[293,294,295,311],"table",{},[296,297,298],"thead",{},[299,300,301,305,308],"tr",{},[302,303,304],"th",{},"Option",[302,306,307],{},"Default",[302,309,310],{},"Description",[312,313,314,337,352,371,390],"tbody",{},[299,315,316,322,327],{},[317,318,319],"td",{},[52,320,321],{},"apiKey",[317,323,324],{},[52,325,326],{},"\"mock-key\"",[317,328,329,330,332,333,336],{},"Key the mock accepts. ",[52,331,71],{}," uses it; ",[52,334,335],{},"mock.client(apiKey = \"x\")"," tests a wrong key.",[299,338,339,344,349],{},[317,340,341],{},[52,342,343],{},"balance",[317,345,346],{},[52,347,348],{},"100.0",[317,350,351],{},"Starting balance, USD.",[299,353,354,359,364],{},[317,355,356],{},[52,357,358],{},"prices",[317,360,361],{},[52,362,363],{},"{7: {vkcom: 0.5, telegram: 1.2, google: 0.3}, 44: {google: 0.2, vkcom: 0.36}}",[317,365,366,367,370],{},"Number prices; replaces the defaults. Also feeds ",[52,368,369],{},"numbers.tariffs()",".",[299,372,373,378,383],{},[317,374,375],{},[52,376,377],{},"rentTariffs",[317,379,380],{},[52,381,382],{},"{7: MockRentTariff({1: 1.0, 3: 2.5, 7: 5.0}, extend = true)}",[317,384,385,386,389],{},"Rent prices; ",[52,387,388],{},"extend = false"," makes rents of that country non-extendable.",[299,391,392,397,402],{},[317,393,394],{},[52,395,396],{},"guardInterval",[317,398,399],{},[52,400,401],{},"0",[317,403,404,407,408,411],{},[52,405,406],{},"> 0",": an operation without SMS, or an unconfirmed rent without any SMS, cannot be closed (",[52,409,410],{},"NO_COMPLETE_TZID",").",[49,413,414,417,418,422,423,426,427,430],{},[52,415,416],{},"mock.client(apiKey, lang, devId, timeout, dispatcher)"," takes the usual ",[61,419,421],{"href":420},"\u002F#client-options","client options","; the transport is always the mock's. To build the client yourself, pass ",[52,424,425],{},"mock.transport","; any ",[52,428,429],{},"baseUrl"," works:",[91,432,434],{"className":93,"code":433,"language":95,"meta":96,"style":96},"import ru.onlinesim.kotlin.OnlineSim\nimport ru.onlinesim.kotlin.mock.MockOnlineSim\n\nval mock = MockOnlineSim()\nval client = OnlineSim(\"mock-key\", transport = mock.transport)\n",[52,435,436,443,449,453,466],{"__ignoreMap":96},[100,437,438,440],{"class":102,"line":12},[100,439,106],{"class":105},[100,441,442],{"class":109}," ru.onlinesim.kotlin.OnlineSim\n",[100,444,445,447],{"class":102,"line":17},[100,446,106],{"class":105},[100,448,110],{"class":109},[100,450,451],{"class":102,"line":22},[100,452,116],{"emptyLinePlaceholder":115},[100,454,455,457,459,461,463],{"class":102,"line":27},[100,456,121],{"class":105},[100,458,125],{"class":124},[100,460,128],{"class":105},[100,462,132],{"class":131},[100,464,465],{"class":124},"()\n",[100,467,468,470,472,474,477,480,482,485,487],{"class":102,"line":32},[100,469,121],{"class":105},[100,471,151],{"class":124},[100,473,128],{"class":105},[100,475,476],{"class":131}," OnlineSim",[100,478,479],{"class":124},"(",[100,481,326],{"class":192},[100,483,484],{"class":124},", transport ",[100,486,128],{"class":105},[100,488,489],{"class":124}," mock.transport)\n",[86,491,493],{"id":492},"a-full-example","A full example",[49,495,496,497,500,501,504,505,507,508,511,512,515],{},"Order a number, let an SMS arrive while ",[52,498,499],{},"waitCode"," polls, check the code and the money. Under ",[52,502,503],{},"runTest",", give the client the test dispatcher: then the mock calls run on the test scheduler and ",[52,506,499],{},"'s ",[52,509,510],{},"delay"," uses virtual time — the 5 s interval passes instantly, and nothing races the timeout. ",[52,513,514],{},"addSmsAfter"," delivers the SMS after a number of polls, so the test needs no clock at all.",[91,517,519],{"className":93,"code":518,"language":95,"meta":96,"style":96},"import kotlinx.coroutines.test.StandardTestDispatcher\nimport kotlinx.coroutines.test.runTest\nimport ru.onlinesim.kotlin.mock.MockOnlineSim\nimport kotlin.test.Test\nimport kotlin.test.assertEquals\n\nclass ReceiveCodeTest {\n    @Test\n    fun receivesTheCode() = runTest {\n        val mock = MockOnlineSim(balance = 10.0)\n        val client = mock.client(dispatcher = StandardTestDispatcher(testScheduler))\n\n        val order = client.numbers.getWithNumber(\"google\", 44)\n        assertEquals(\"+44900000001\", order.number())\n\n        mock.addSmsAfter(order.tzid(), \"Your Google code: 123-456\", 2) \u002F\u002F the third poll sees it\n        val code = client.numbers.waitCode(order.tzid()) \u002F\u002F 10 s of virtual time\n\n        assertEquals(\"123456\", code)\n        assertEquals(\"TZ_OVER_OK\", mock.operations()[0].status()) \u002F\u002F waitCode closed it\n        assertEquals(9.8, mock.balance()) \u002F\u002F the price is spent once an SMS arrived\n    }\n}\n",[52,520,521,528,535,541,548,555,559,570,576,594,614,638,643,671,691,696,727,751,756,769,801,820,826],{"__ignoreMap":96},[100,522,523,525],{"class":102,"line":12},[100,524,106],{"class":105},[100,526,527],{"class":109}," kotlinx.coroutines.test.StandardTestDispatcher\n",[100,529,530,532],{"class":102,"line":17},[100,531,106],{"class":105},[100,533,534],{"class":109}," kotlinx.coroutines.test.runTest\n",[100,536,537,539],{"class":102,"line":22},[100,538,106],{"class":105},[100,540,110],{"class":109},[100,542,543,545],{"class":102,"line":27},[100,544,106],{"class":105},[100,546,547],{"class":109}," kotlin.test.Test\n",[100,549,550,552],{"class":102,"line":32},[100,551,106],{"class":105},[100,553,554],{"class":109}," kotlin.test.assertEquals\n",[100,556,557],{"class":102,"line":37},[100,558,116],{"emptyLinePlaceholder":115},[100,560,561,564,567],{"class":102,"line":42},[100,562,563],{"class":105},"class",[100,565,566],{"class":109}," ReceiveCodeTest",[100,568,569],{"class":124}," {\n",[100,571,573],{"class":102,"line":572},8,[100,574,575],{"class":109},"    @Test\n",[100,577,579,582,585,587,589,592],{"class":102,"line":578},9,[100,580,581],{"class":105},"    fun",[100,583,584],{"class":131}," receivesTheCode",[100,586,162],{"class":124},[100,588,128],{"class":105},[100,590,591],{"class":131}," runTest",[100,593,569],{"class":124},[100,595,597,600,602,604,606,608,610,612],{"class":102,"line":596},10,[100,598,599],{"class":105},"        val",[100,601,125],{"class":124},[100,603,128],{"class":105},[100,605,132],{"class":131},[100,607,135],{"class":124},[100,609,128],{"class":105},[100,611,141],{"class":140},[100,613,144],{"class":124},[100,615,617,619,621,623,625,627,630,632,635],{"class":102,"line":616},11,[100,618,599],{"class":105},[100,620,151],{"class":124},[100,622,128],{"class":105},[100,624,156],{"class":124},[100,626,159],{"class":131},[100,628,629],{"class":124},"(dispatcher ",[100,631,128],{"class":105},[100,633,634],{"class":131}," StandardTestDispatcher",[100,636,637],{"class":124},"(testScheduler))\n",[100,639,641],{"class":102,"line":640},12,[100,642,116],{"emptyLinePlaceholder":115},[100,644,646,648,651,653,656,659,661,664,666,669],{"class":102,"line":645},13,[100,647,599],{"class":105},[100,649,650],{"class":124}," order ",[100,652,128],{"class":105},[100,654,655],{"class":124}," client.numbers.",[100,657,658],{"class":131},"getWithNumber",[100,660,479],{"class":124},[100,662,663],{"class":192},"\"google\"",[100,665,228],{"class":124},[100,667,668],{"class":140},"44",[100,670,144],{"class":124},[100,672,674,677,679,682,685,688],{"class":102,"line":673},14,[100,675,676],{"class":131},"        assertEquals",[100,678,479],{"class":124},[100,680,681],{"class":192},"\"+44900000001\"",[100,683,684],{"class":124},", order.",[100,686,687],{"class":131},"number",[100,689,690],{"class":124},"())\n",[100,692,694],{"class":102,"line":693},15,[100,695,116],{"emptyLinePlaceholder":115},[100,697,699,702,704,707,710,713,716,718,721,724],{"class":102,"line":698},16,[100,700,701],{"class":124},"        mock.",[100,703,514],{"class":131},[100,705,706],{"class":124},"(order.",[100,708,709],{"class":131},"tzid",[100,711,712],{"class":124},"(), ",[100,714,715],{"class":192},"\"Your Google code: 123-456\"",[100,717,228],{"class":124},[100,719,720],{"class":140},"2",[100,722,723],{"class":124},") ",[100,725,726],{"class":165},"\u002F\u002F the third poll sees it\n",[100,728,730,732,735,737,739,741,743,745,748],{"class":102,"line":729},17,[100,731,599],{"class":105},[100,733,734],{"class":124}," code ",[100,736,128],{"class":105},[100,738,655],{"class":124},[100,740,499],{"class":131},[100,742,706],{"class":124},[100,744,709],{"class":131},[100,746,747],{"class":124},"()) ",[100,749,750],{"class":165},"\u002F\u002F 10 s of virtual time\n",[100,752,754],{"class":102,"line":753},18,[100,755,116],{"emptyLinePlaceholder":115},[100,757,759,761,763,766],{"class":102,"line":758},19,[100,760,676],{"class":131},[100,762,479],{"class":124},[100,764,765],{"class":192},"\"123456\"",[100,767,768],{"class":124},", code)\n",[100,770,772,774,776,779,782,785,788,790,793,796,798],{"class":102,"line":771},20,[100,773,676],{"class":131},[100,775,479],{"class":124},[100,777,778],{"class":192},"\"TZ_OVER_OK\"",[100,780,781],{"class":124},", mock.",[100,783,784],{"class":131},"operations",[100,786,787],{"class":124},"()[",[100,789,401],{"class":140},[100,791,792],{"class":124},"].",[100,794,795],{"class":131},"status",[100,797,747],{"class":124},[100,799,800],{"class":165},"\u002F\u002F waitCode closed it\n",[100,802,804,806,808,811,813,815,817],{"class":102,"line":803},21,[100,805,676],{"class":131},[100,807,479],{"class":124},[100,809,810],{"class":140},"9.8",[100,812,781],{"class":124},[100,814,343],{"class":131},[100,816,747],{"class":124},[100,818,819],{"class":165},"\u002F\u002F the price is spent once an SMS arrived\n",[100,821,823],{"class":102,"line":822},22,[100,824,825],{"class":124},"    }\n",[100,827,829],{"class":102,"line":828},23,[100,830,831],{"class":124},"}\n",[49,833,834,835,837,838,228,841,844,845,848],{},"Outside ",[52,836,503],{}," (a ",[52,839,840],{},"main",[52,842,843],{},"runBlocking","), ",[52,846,847],{},"waitCode(tzid, interval = Duration.ZERO)"," polls back to back with no waiting.",[49,850,851,852,855,856,859,860,863,864,867,868,871,872,874],{},"The ",[52,853,854],{},"msg"," of an operation is the code by default: the first run of 4–8 digits, with spaces and dashes between digits removed (",[52,857,858],{},"123-456"," → ",[52,861,862],{},"123456","); a text without such a run comes back whole. ",[52,865,866],{},"messageToCode = false"," (or ",[52,869,870],{},"fullMessage = true"," in ",[52,873,499],{},") gives the full text.",[86,876,878],{"id":877},"errors","Errors",[49,880,881,884,885,888,889,867,892,895,896,899,900,903,904,411],{},[52,882,883],{},"failNext(code)"," makes the next request answer ",[52,886,887],{},"{\"response\": code}"," — the client turns it into ",[52,890,891],{},"ApiException",[52,893,894],{},"NoNumberException",") exactly as for the real server. Pass ",[52,897,898],{},"endpoint"," to fail only that endpoint. ",[52,901,902],{},"failNextTransport()"," makes the next request fail with a non-JSON HTTP 502 (",[52,905,906],{},"TransportException",[91,908,910],{"className":93,"code":909,"language":95,"meta":96,"style":96},"import kotlinx.coroutines.test.StandardTestDispatcher\nimport kotlinx.coroutines.test.runTest\nimport ru.onlinesim.kotlin.NoNumberException\nimport ru.onlinesim.kotlin.TransportException\nimport ru.onlinesim.kotlin.mock.MockOnlineSim\nimport kotlin.test.Test\nimport kotlin.test.assertEquals\nimport kotlin.test.assertFailsWith\n\nclass FailuresTest {\n    @Test\n    fun handlesAMissingNumberAndANetworkHiccup() = runTest {\n        val mock = MockOnlineSim()\n        val client = mock.client(dispatcher = StandardTestDispatcher(testScheduler))\n\n        mock.failNext(\"NO_NUMBER\", endpoint = \"getNum.php\")\n        assertFailsWith\u003CNoNumberException> { client.numbers.get(\"google\") }\n\n        mock.failNextTransport(status = 503)\n        assertFailsWith\u003CTransportException> { client.user.balance() }\n\n        assertEquals(100.0, client.user.balance().balance()) \u002F\u002F one-shot\n    }\n}\n",[52,911,912,918,924,931,938,944,950,956,963,967,976,980,995,1007,1027,1031,1053,1075,1079,1096,1112,1116,1139,1143],{"__ignoreMap":96},[100,913,914,916],{"class":102,"line":12},[100,915,106],{"class":105},[100,917,527],{"class":109},[100,919,920,922],{"class":102,"line":17},[100,921,106],{"class":105},[100,923,534],{"class":109},[100,925,926,928],{"class":102,"line":22},[100,927,106],{"class":105},[100,929,930],{"class":109}," ru.onlinesim.kotlin.NoNumberException\n",[100,932,933,935],{"class":102,"line":27},[100,934,106],{"class":105},[100,936,937],{"class":109}," ru.onlinesim.kotlin.TransportException\n",[100,939,940,942],{"class":102,"line":32},[100,941,106],{"class":105},[100,943,110],{"class":109},[100,945,946,948],{"class":102,"line":37},[100,947,106],{"class":105},[100,949,547],{"class":109},[100,951,952,954],{"class":102,"line":42},[100,953,106],{"class":105},[100,955,554],{"class":109},[100,957,958,960],{"class":102,"line":572},[100,959,106],{"class":105},[100,961,962],{"class":109}," kotlin.test.assertFailsWith\n",[100,964,965],{"class":102,"line":578},[100,966,116],{"emptyLinePlaceholder":115},[100,968,969,971,974],{"class":102,"line":596},[100,970,563],{"class":105},[100,972,973],{"class":109}," FailuresTest",[100,975,569],{"class":124},[100,977,978],{"class":102,"line":616},[100,979,575],{"class":109},[100,981,982,984,987,989,991,993],{"class":102,"line":640},[100,983,581],{"class":105},[100,985,986],{"class":131}," handlesAMissingNumberAndANetworkHiccup",[100,988,162],{"class":124},[100,990,128],{"class":105},[100,992,591],{"class":131},[100,994,569],{"class":124},[100,996,997,999,1001,1003,1005],{"class":102,"line":645},[100,998,599],{"class":105},[100,1000,125],{"class":124},[100,1002,128],{"class":105},[100,1004,132],{"class":131},[100,1006,465],{"class":124},[100,1008,1009,1011,1013,1015,1017,1019,1021,1023,1025],{"class":102,"line":673},[100,1010,599],{"class":105},[100,1012,151],{"class":124},[100,1014,128],{"class":105},[100,1016,156],{"class":124},[100,1018,159],{"class":131},[100,1020,629],{"class":124},[100,1022,128],{"class":105},[100,1024,634],{"class":131},[100,1026,637],{"class":124},[100,1028,1029],{"class":102,"line":693},[100,1030,116],{"emptyLinePlaceholder":115},[100,1032,1033,1035,1038,1040,1043,1046,1048,1051],{"class":102,"line":698},[100,1034,701],{"class":124},[100,1036,1037],{"class":131},"failNext",[100,1039,479],{"class":124},[100,1041,1042],{"class":192},"\"NO_NUMBER\"",[100,1044,1045],{"class":124},", endpoint ",[100,1047,128],{"class":105},[100,1049,1050],{"class":192}," \"getNum.php\"",[100,1052,144],{"class":124},[100,1054,1055,1058,1060,1062,1065,1068,1070,1072],{"class":102,"line":729},[100,1056,1057],{"class":131},"        assertFailsWith",[100,1059,222],{"class":124},[100,1061,894],{"class":109},[100,1063,1064],{"class":124},"> { client.numbers.",[100,1066,1067],{"class":131},"get",[100,1069,479],{"class":124},[100,1071,663],{"class":192},[100,1073,1074],{"class":124},") }\n",[100,1076,1077],{"class":102,"line":753},[100,1078,116],{"emptyLinePlaceholder":115},[100,1080,1081,1083,1086,1089,1091,1094],{"class":102,"line":758},[100,1082,701],{"class":124},[100,1084,1085],{"class":131},"failNextTransport",[100,1087,1088],{"class":124},"(status ",[100,1090,128],{"class":105},[100,1092,1093],{"class":140}," 503",[100,1095,144],{"class":124},[100,1097,1098,1100,1102,1104,1107,1109],{"class":102,"line":771},[100,1099,1057],{"class":131},[100,1101,222],{"class":124},[100,1103,906],{"class":109},[100,1105,1106],{"class":124},"> { client.user.",[100,1108,343],{"class":131},[100,1110,1111],{"class":124},"() }\n",[100,1113,1114],{"class":102,"line":803},[100,1115,116],{"emptyLinePlaceholder":115},[100,1117,1118,1120,1122,1124,1127,1129,1132,1134,1136],{"class":102,"line":822},[100,1119,676],{"class":131},[100,1121,479],{"class":124},[100,1123,348],{"class":140},[100,1125,1126],{"class":124},", client.user.",[100,1128,343],{"class":131},[100,1130,1131],{"class":124},"().",[100,1133,343],{"class":131},[100,1135,747],{"class":124},[100,1137,1138],{"class":165},"\u002F\u002F one-shot\n",[100,1140,1141],{"class":102,"line":828},[100,1142,825],{"class":124},[100,1144,1146],{"class":102,"line":1145},24,[100,1147,831],{"class":124},[49,1149,1150,1151,1154,1155,1158,1159,1162,1163,1166,1167,1170,1171,1174,1175,1178,1179,1182,1183,844,1185,1166,1187,1190,1191,1194,1195,228,1198,1201,1202,228,1205,1207],{},"The state itself produces the real error codes too: ",[52,1152,1153],{},"WARNING_LOW_BALANCE"," when the balance is short, ",[52,1156,1157],{},"NO_NUMBER"," when ",[52,1160,1161],{},"reject"," matches the next number, ",[52,1164,1165],{},"UNDEFINED_COUNTRY"," \u002F ",[52,1168,1169],{},"ERROR_NO_SERVICE"," for unknown prices, ",[52,1172,1173],{},"ERROR_WRONG_TZID"," for an unknown or closed operation (",[52,1176,1177],{},"next"," too; ",[52,1180,1181],{},"ERROR_NO_TZID"," for tzid ",[52,1184,401],{},[52,1186,1165],{},[52,1188,1189],{},"UNDEFINED_DAYS"," for an unknown rent country or period, ",[52,1192,1193],{},"TRY_AGAIN_LATER"," for every refused ",[52,1196,1197],{},"rent.extend",[52,1199,1200],{},"ERROR_NO_OPERATIONS"," for an unknown rent in ",[52,1203,1204],{},"rent.close",[52,1206,79],{}," for a wrong key (HTTP 456) or no key (HTTP 200).",[86,1209,1211],{"id":1210},"inspecting-requests","Inspecting requests",[49,1213,1214,1217,1218,1221,1222,228,1225,1228,1229,844,1232,1235,1236,1239,1240,1243],{},[52,1215,1216],{},"mock.requests()"," lists every request received as ",[52,1219,1220],{},"MockRequest",": ",[52,1223,1224],{},"method()",[52,1226,1227],{},"path()"," (relative to ",[52,1230,1231],{},"\u002Fapi\u002F",[52,1233,1234],{},"query()"," (decoded, in the order sent) and ",[52,1237,1238],{},"body()"," (the JSON of a POST as sent, ",[52,1241,1242],{},"null"," for a GET).",[91,1245,1247],{"className":93,"code":1246,"language":95,"meta":96,"style":96},"import kotlinx.coroutines.test.runTest\nimport ru.onlinesim.kotlin.mock.MockOnlineSim\nimport kotlin.test.Test\nimport kotlin.test.assertEquals\n\nclass RejectTest {\n    @Test\n    fun sendsRejectAsACommaList() = runTest {\n        val mock = MockOnlineSim()\n        mock.client().numbers.get(\"google\", 44, reject = listOf(\"4470\", \"4471\"))\n\n        val req = mock.requests()[0]\n        assertEquals(\"getNum.php\", req.path())\n        assertEquals(mapOf(\"service\" to \"google\", \"country\" to \"44\", \"reject\" to \"4470,4471\", \"lang\" to \"en\"), req.query())\n    }\n}\n",[52,1248,1249,1255,1261,1267,1273,1277,1286,1290,1305,1317,1357,1361,1382,1399,1456,1460],{"__ignoreMap":96},[100,1250,1251,1253],{"class":102,"line":12},[100,1252,106],{"class":105},[100,1254,534],{"class":109},[100,1256,1257,1259],{"class":102,"line":17},[100,1258,106],{"class":105},[100,1260,110],{"class":109},[100,1262,1263,1265],{"class":102,"line":22},[100,1264,106],{"class":105},[100,1266,547],{"class":109},[100,1268,1269,1271],{"class":102,"line":27},[100,1270,106],{"class":105},[100,1272,554],{"class":109},[100,1274,1275],{"class":102,"line":32},[100,1276,116],{"emptyLinePlaceholder":115},[100,1278,1279,1281,1284],{"class":102,"line":37},[100,1280,563],{"class":105},[100,1282,1283],{"class":109}," RejectTest",[100,1285,569],{"class":124},[100,1287,1288],{"class":102,"line":42},[100,1289,575],{"class":109},[100,1291,1292,1294,1297,1299,1301,1303],{"class":102,"line":572},[100,1293,581],{"class":105},[100,1295,1296],{"class":131}," sendsRejectAsACommaList",[100,1298,162],{"class":124},[100,1300,128],{"class":105},[100,1302,591],{"class":131},[100,1304,569],{"class":124},[100,1306,1307,1309,1311,1313,1315],{"class":102,"line":578},[100,1308,599],{"class":105},[100,1310,125],{"class":124},[100,1312,128],{"class":105},[100,1314,132],{"class":131},[100,1316,465],{"class":124},[100,1318,1319,1321,1323,1326,1328,1330,1332,1334,1336,1339,1341,1344,1346,1349,1351,1354],{"class":102,"line":596},[100,1320,701],{"class":124},[100,1322,159],{"class":131},[100,1324,1325],{"class":124},"().numbers.",[100,1327,1067],{"class":131},[100,1329,479],{"class":124},[100,1331,663],{"class":192},[100,1333,228],{"class":124},[100,1335,668],{"class":140},[100,1337,1338],{"class":124},", reject ",[100,1340,128],{"class":105},[100,1342,1343],{"class":131}," listOf",[100,1345,479],{"class":124},[100,1347,1348],{"class":192},"\"4470\"",[100,1350,228],{"class":124},[100,1352,1353],{"class":192},"\"4471\"",[100,1355,1356],{"class":124},"))\n",[100,1358,1359],{"class":102,"line":616},[100,1360,116],{"emptyLinePlaceholder":115},[100,1362,1363,1365,1368,1370,1372,1375,1377,1379],{"class":102,"line":640},[100,1364,599],{"class":105},[100,1366,1367],{"class":124}," req ",[100,1369,128],{"class":105},[100,1371,156],{"class":124},[100,1373,1374],{"class":131},"requests",[100,1376,787],{"class":124},[100,1378,401],{"class":140},[100,1380,1381],{"class":124},"]\n",[100,1383,1384,1386,1388,1391,1394,1397],{"class":102,"line":645},[100,1385,676],{"class":131},[100,1387,479],{"class":124},[100,1389,1390],{"class":192},"\"getNum.php\"",[100,1392,1393],{"class":124},", req.",[100,1395,1396],{"class":131},"path",[100,1398,690],{"class":124},[100,1400,1401,1403,1405,1408,1410,1413,1416,1418,1420,1423,1425,1428,1430,1433,1435,1438,1440,1443,1445,1448,1451,1454],{"class":102,"line":673},[100,1402,676],{"class":131},[100,1404,479],{"class":124},[100,1406,1407],{"class":131},"mapOf",[100,1409,479],{"class":124},[100,1411,1412],{"class":192},"\"service\"",[100,1414,1415],{"class":124}," to ",[100,1417,663],{"class":192},[100,1419,228],{"class":124},[100,1421,1422],{"class":192},"\"country\"",[100,1424,1415],{"class":124},[100,1426,1427],{"class":192},"\"44\"",[100,1429,228],{"class":124},[100,1431,1432],{"class":192},"\"reject\"",[100,1434,1415],{"class":124},[100,1436,1437],{"class":192},"\"4470,4471\"",[100,1439,228],{"class":124},[100,1441,1442],{"class":192},"\"lang\"",[100,1444,1415],{"class":124},[100,1446,1447],{"class":192},"\"en\"",[100,1449,1450],{"class":124},"), req.",[100,1452,1453],{"class":131},"query",[100,1455,690],{"class":124},[100,1457,1458],{"class":102,"line":693},[100,1459,825],{"class":124},[100,1461,1462],{"class":102,"line":698},[100,1463,831],{"class":124},[86,1465,1467],{"id":1466},"control-api","Control API",[293,1469,1470,1479],{},[296,1471,1472],{},[299,1473,1474,1477],{},[302,1475,1476],{},"Member",[302,1478,310],{},[312,1480,1481,1494,1506,1523,1551,1569,1581,1598,1619,1631,1641],{},[299,1482,1483,1488],{},[317,1484,1485],{},[52,1486,1487],{},"client(apiKey, lang, devId, timeout, dispatcher)",[317,1489,1490,1491,1493],{},"A normal ",[52,1492,83],{}," wired to the mock; every argument has a default.",[299,1495,1496,1501],{},[317,1497,1498],{},[52,1499,1500],{},"transport",[317,1502,1503,1504,370],{},"The fake ",[52,1505,75],{},[299,1507,1508,1513],{},[317,1509,1510],{},[52,1511,1512],{},"addSms(tzid, text, service = null)",[317,1514,1515,1516,1518,1519,1522],{},"An SMS arrives now at a number operation or a rent (detected by ",[52,1517,709],{},"). Throws ",[52,1520,1521],{},"IllegalStateException"," for an unknown or closed one.",[299,1524,1525,1530],{},[317,1526,1527],{},[52,1528,1529],{},"addSmsAfter(tzid, text, polls, service = null)",[317,1531,1532,1533,1536,1537,1539,1540,6,1543,228,1546,6,1549,411],{},"The SMS arrives after ",[52,1534,1535],{},"polls"," state requests for ",[52,1538,709],{}," (",[52,1541,1542],{},"numbers.state",[52,1544,1545],{},"stateOne",[52,1547,1548],{},"rent.state",[52,1550,1545],{},[299,1552,1553,1558],{},[317,1554,1555],{},[52,1556,1557],{},"failNext(code, endpoint = null)",[317,1559,1560,1561,1563,1564,1566,1567,370],{},"The next request (to ",[52,1562,898],{}," only, e.g. ",[52,1565,1390],{},") answers ",[52,1568,887],{},[299,1570,1571,1576],{},[317,1572,1573],{},[52,1574,1575],{},"failNextTransport(status = 502, endpoint = null)",[317,1577,1578,1579,370],{},"The next request fails with a non-JSON body and HTTP ",[52,1580,795],{},[299,1582,1583,1591],{},[317,1584,1585,1166,1588],{},[52,1586,1587],{},"setBalance(usd)",[52,1589,1590],{},"balance()",[317,1592,1593,1594,1597],{},"Set \u002F read the total balance, USD (it includes the part frozen by open operations and unconfirmed rents, as ",[52,1595,1596],{},"user.balance()"," reports it).",[299,1599,1600,1608],{},[317,1601,1602,1166,1605],{},[52,1603,1604],{},"operations()",[52,1606,1607],{},"rents()",[317,1609,1610,1611,1614,1615,1618],{},"Snapshots of the current number operations (",[52,1612,1613],{},"MockOperation",") \u002F open rents (",[52,1616,1617],{},"MockRent","), for assertions.",[299,1620,1621,1626],{},[317,1622,1623],{},[52,1624,1625],{},"requests()",[317,1627,1628,1629,411],{},"Log of the requests received (",[52,1630,1220],{},[299,1632,1633,1638],{},[317,1634,1635],{},[52,1636,1637],{},"reset()",[317,1639,1640],{},"Back to the constructor's state.",[299,1642,1643,1648],{},[317,1644,1645],{},[52,1646,1647],{},"java",[317,1649,1650,1651,370],{},"The underlying Java ",[52,1652,1653],{},"ru.onlinesim.mock.MockOnlineSim",[86,1655,1657],{"id":1656},"what-the-mock-does","What the mock does",[1659,1660,1661,1696,1767,1820,1833],"ul",{},[1662,1663,1664,1221,1667,1669,1670,1673,1674,1676,1677,1680,1681,1684,1685,1688,1689,1691,1692,1695],"li",{},[1665,1666,9],"strong",{},[52,1668,1067],{}," freezes the price; ",[52,1671,1672],{},"close"," after an SMS spends it, ",[52,1675,1672],{}," without one refunds it; ",[52,1678,1679],{},"ban"," after an SMS answers ",[52,1682,1683],{},"\"0\"",", like the server. Numbers are ",[52,1686,1687],{},"+\u003Ccountry>9000000NN",", ids count from 1. ",[52,1690,1177],{}," switches to the following SMS. The operation's ",[52,1693,1694],{},"time"," stays at 1200 s — there is no clock.",[1662,1697,1698,1221,1700,1702,1703,1706,1707,228,1709,1706,1712,1715,1716,1719,1720,1723,1724,1706,1726,1729,1730,1733,1734,1737,1738,1706,1740,1742,1743,1746,1747,1749,1750,1753,1754,6,1756,1758,1759,1762,1763,1766],{},[1665,1699,14],{},[52,1701,1067],{}," reserves the price (",[52,1704,1705],{},"status()"," ",[52,1708,401],{},[52,1710,1711],{},"checked()",[52,1713,1714],{},"false",") and keeps the ",[52,1717,1718],{},"extension"," flag; the first SMS that is not ",[52,1721,1722],{},"notify"," confirms the rent (",[52,1725,1705],{},[52,1727,1728],{},"1",", also ",[52,1731,1732],{},"MockRent.status()",") and charges it — ",[52,1735,1736],{},"addSms(tzid, text, service = \"notify\")"," adds a notice with ",[52,1739,52],{},[52,1741,1683],{}," that confirms nothing. ",[52,1744,1745],{},"extend"," works on a confirmed rent and charges at once. ",[52,1748,1672],{}," releases the reservation of an unconfirmed rent and gives no refund for a confirmed one. ",[52,1751,1752],{},"sum"," is a number in ",[52,1755,1067],{},[52,1757,1745],{}," and a decimal string on the wire of ",[52,1760,1761],{},"state",", like the server. SMS appear in ",[52,1764,1765],{},"messages()",", newest first.",[1662,1768,1769,1221,1771,1773,1774,1777,1778,1781,1782,1785,1786,1789,1790,1794,1795,1798,1799,1706,1801,1804,1805,1807,1808,1811,1812,1815,1816,1819],{},[1665,1770,19],{},[52,1772,343],{}," (frozen part included), a fixed profile, ",[52,1775,1776],{},"setWebhookUrl"," accepts any ",[52,1779,1780],{},"scheme:\u002F\u002F…"," URL (",[52,1783,1784],{},"VALIDATION_ERROR"," otherwise), ",[52,1787,1788],{},"webhookLogs"," lists the deliveries the mock ",[1791,1792,1793],"em",{},"recorded"," when an SMS arrived while a webhook URL was set — it makes no HTTP call; their ",[52,1796,1797],{},"params"," follow the real payload (",[52,1800,52],{},[52,1802,1803],{},"\"\""," without a code, rent ",[52,1806,687],{}," in digits without ",[52,1809,1810],{},"+",", rent ",[52,1813,1814],{},"timeLeft"," in minutes). ",[52,1817,1818],{},"paymentHistory"," has no orders.",[1662,1821,1822,1221,1825,1828,1829,1832],{},[1665,1823,1824],{},"Free",[52,1826,1827],{},"free.list()"," returns two fixed countries (44 first) with one number and a few SMS each; ",[52,1830,1831],{},"count"," is clamped to 10..500.",[1662,1834,1835,1836,1539,1839,1842,1843,1845,1846,1849],{},"Not imitated: anything that needs real time — the 5 s lock after ",[52,1837,1838],{},"setOperationOk",[52,1840,1841],{},"INTERVAL_CONCURRENT_REQUESTS_ERROR","), the 10 s lock of ",[52,1844,1197],{},", the 120 s before an unconfirmed rent may be closed and its 20-minute wait for the first SMS. ",[52,1847,1848],{},"guardInterval > 0"," stands in for \"too early to close\".",[1851,1852,1853],"style",{},"html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}",{"title":96,"searchDepth":17,"depth":17,"links":1855},[1856,1857,1858,1859,1860,1861],{"id":88,"depth":17,"text":89},{"id":492,"depth":17,"text":493},{"id":877,"depth":17,"text":878},{"id":1210,"depth":17,"text":1211},{"id":1466,"depth":17,"text":1467},{"id":1656,"depth":17,"text":1657},"Test your integration offline with MockOnlineSim — no network, key or money.","md",{},{"order":37},{"title":34,"description":1862},"efW2WeubWAoLTc1MwNCiJKx7K-VkvMUIkzoIlHAOw44",[1869,1871],{"title":14,"path":15,"stem":16,"description":1870,"order":17},"Rent a number for days and receive every SMS sent to it — client.rent.",{"title":19,"path":20,"stem":21,"description":1872,"order":22},"Balance, profile, payments and the webhook URL — client.user.",1795165467554]