package com.za.servicing

import com.alibaba.fastjson.JSON
import com.za.call.CallLogManager
import org.junit.Test

import org.junit.Assert.*

/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
class ExampleUnitTest {
	@Test
	fun addition_isCorrect() {
		assertEquals(4, 2 + 2)
	}

	@Test
	fun stringToObject() {
	}

	@Test
	fun listOTString() {
		val string =
			"[{\"realTakePhotoTime\":\"2024-11-21 16:23:39\",\"path\":\"http://file.sino-assist.com/group1/M00/04/38/wKgBzGc-7lyAbSCzAAY62uaY4eM042.jpg?date=2024-11-21\",\"address\":\"\",\"lng\":121.50693,\"time\":\"2024-11-21 16:23:39\",\"photoSource\":0,\"lat\":31.184183}\n" + ",{\"realTakePhotoTime\":\"2024-11-21 16:23:39\",\"path\":\"http://file.sino-assist.com/group1/M00/04/38/wKgBzGc-7lyAbSCzAAY62uaY4eM042.jpg?date=2024-11-21\",\"address\":\"\",\"lng\":121.50693,\"time\":\"2024-11-21 16:23:39\",\"photoSource\":0,\"lat\":31.184183},null,\n" + "{\"realTakePhotoTime\":\"2024-11-21 16:23:39\",\"path\":\"http://file.sino-assist.com/group1/M00/04/38/wKgBzGc-7lyAbSCzAAY62uaY4eM042.jpg?date=2024-11-21\",\"address\":\"\",\"lng\":121.50693,\"time\":\"2024-11-21 16:23:39\",\"photoSource\":0,\"lat\":31.184183}\n" + ",{\"realTakePhotoTime\":\"2024-11-21 16:23:39\",\"path\":\"http://file.sino-assist.com/group1/M00/04/38/wKgBzGc-7lyAbSCzAAY62uaY4eM042.jpg?date=2024-11-21\",\"address\":\"\",\"lng\":121.50693,\"time\":\"2024-11-21 16:23:39\",\"photoSource\":0,\"lat\":31.184183}\n" + "]"

		println(JSON.parseArray(string, String::class.java)[0])
	}

	@Test
	fun stringTOList() {
		val string =
			arrayListOf("{\n" + "        \"realTakePhotoTime\": \"2024-11-21 16:23:39\",\n" + "        \"path\": \"http://file.sino-assist.com/group1/M00/04/38/wKgBzGc-7lyAbSCzAAY62uaY4eM042.jpg?date=2024-11-21\",\n" + "        \"address\": \"\",\n" + "        \"lng\": 121.50693,\n" + "        \"time\": \"2024-11-21 16:23:39\",\n" + "        \"photoSource\": 0,\n" + "        \"lat\": 31.184183\n" + "    }",
				"{\n" + "        \"realTakePhotoTime\": \"2024-11-21 16:23:39\",\n" + "        \"path\": \"http://file.sino-assist.com/group1/M00/04/38/wKgBzGc-7lyAbSCzAAY62uaY4eM042.jpg?date=2024-11-21\",\n" + "        \"address\": \"\",\n" + "        \"lng\": 121.50693,\n" + "        \"time\": \"2024-11-21 16:23:39\",\n" + "        \"photoSource\": 0,\n" + "        \"lat\": 31.184183\n" + "    }",
				"{\n" + "        \"realTakePhotoTime\": \"2024-11-21 16:23:39\",\n" + "        \"path\": \"http://file.sino-assist.com/group1/M00/04/38/wKgBzGc-7lyAbSCzAAY62uaY4eM042.jpg?date=2024-11-21\",\n" + "        \"address\": \"\",\n" + "        \"lng\": 121.50693,\n" + "        \"time\": \"2024-11-21 16:23:39\",\n" + "        \"photoSource\": 0,\n" + "        \"lat\": 31.184183\n" + "    }")

		println(JSON.parseArray(JSON.toJSONString(string), String::class.java))
	}

	@Test
	fun dataFormatFriendly() {
		val result = CallLogManager.formatDuration(9000)
		println(result)
		assertEquals("1小时", result)
	}
}