From 6fa8dfab42e6a2dcbbcc1e7213e50c52c30bf085 Mon Sep 17 00:00:00 2001 From: tangcent Date: Sun, 27 Aug 2023 23:30:46 +0800 Subject: [PATCH] refactor: remove usage of KV (#1020) --- .../com/itangcent/common/kit/KVUtils.kt | 26 ++-- .../com/itangcent/common/model/Request.kt | 2 +- .../kotlin/com/itangcent/http/RequestUtils.kt | 2 +- .../com/itangcent/common/kit/KitUtilsTest.kt | 3 +- gradle.properties | 2 +- .../idea/plugin/api/ClassApiExporterHelper.kt | 13 +- .../plugin/api/DefaultMethodInferHelper.kt | 12 +- .../api/export/core/RequestClassExporter.kt | 22 +-- .../SimpleGenericMethodDocClassExporter.kt | 15 +- .../export/postman/DefaultPostmanApiHelper.kt | 9 +- .../api/export/postman/PostmanFormatter.kt | 140 ++++++++++-------- .../api/export/yapi/DefaultYapiApiHelper.kt | 12 +- .../plugin/api/export/yapi/YapiFormatter.kt | 64 ++++---- .../api/export/yapi/YapiPsiClassHelper.kt | 21 ++- .../dialog/EasyApiSettingBuiltInConfigGUI.kt | 2 +- .../idea/plugin/dialog/EasyApiSettingGUI.kt | 2 +- .../dialog/EasyApiSettingRemoteConfigGUI.kt | 2 +- .../idea/plugin/rule/RuleToolUtils.kt | 41 ++--- .../helper/RecommendConfigSettingsHelper.kt | 2 +- .../idea/plugin/utils/LocalStorage.kt | 9 +- .../idea/plugin/utils/SessionStorage.kt | 9 +- .../idea/utils/ContextualPsiClassHelper.kt | 49 +++--- .../idea/utils/CustomizedPsiClassHelper.kt | 37 +++-- .../com/itangcent/intellij/util/KVKit.kt | 29 +--- .../com/itangcent/utils/ResourceUtils.kt | 59 -------- .../idea/plugin/api/call/ApiCallerTest.kt | 6 +- .../export/postman/PostmanFormatterTest.kt | 12 +- .../com/itangcent/idea/utils/KVKitTest.kt | 15 +- .../config/AutoSearchConfigReaderTest.kt | 2 +- .../com/itangcent/utils/ResourceUtilsTest.kt | 47 ------ ...piCallerTest.ExportFailedApiCallerTest.txt | 2 +- ....DirectorySpringPostmanApiExporterTest.txt | 100 ++++++------- ...terTest.ModeCopyPostmanApiExporterTest.txt | 20 +-- ...rTest.ModeUpdatePostmanApiExporterTest.txt | 20 +-- ...orterTest.SpringPostmanApiExporterTest.txt | 20 +-- ...PostmanFormatterTest.testParseRequests.txt | 20 +-- ...tterTest.testParseRequestsToCollection.txt | 20 +-- ...st.testParseRequestsWithWrapCollection.txt | 20 +-- ...DirectorySpringYapiApiExporterTest.log.txt | 2 +- ...t.GenericMethodYapiApiExporterTest.log.txt | 2 +- ...rterTest.SpringYapiApiExporterTest.log.txt | 2 +- 41 files changed, 386 insertions(+), 508 deletions(-) delete mode 100644 idea-plugin/src/main/kotlin/com/itangcent/utils/ResourceUtils.kt delete mode 100644 idea-plugin/src/test/kotlin/com/itangcent/utils/ResourceUtilsTest.kt diff --git a/common-api/src/main/kotlin/com/itangcent/common/kit/KVUtils.kt b/common-api/src/main/kotlin/com/itangcent/common/kit/KVUtils.kt index 39e93202b..8aa551c3a 100644 --- a/common-api/src/main/kotlin/com/itangcent/common/kit/KVUtils.kt +++ b/common-api/src/main/kotlin/com/itangcent/common/kit/KVUtils.kt @@ -38,9 +38,8 @@ object KVUtils { * get description of options */ fun getOptionDesc(options: List>): String? { - return options.stream() - .map { concat(it["value"]?.toString(), it["desc"]?.toString()) } - .filter { it != null } + return options.asSequence() + .mapNotNull { concat(it["value"]?.toString(), it["desc"]?.toString()) } .joinToString("\n") } @@ -48,9 +47,8 @@ object KVUtils { * get description of constants */ fun getConstantDesc(constants: List>): String? { - return constants.stream() - .map { concat(it["name"]?.toString(), it["desc"]?.toString()) } - .filter { it != null } + return constants.asSequence() + .mapNotNull { concat(it["name"]?.toString(), it["desc"]?.toString()) } .joinToString("\n") } @@ -97,11 +95,9 @@ object KVUtils { @Suppress("UNCHECKED_CAST") fun addComment(info: HashMap, field: String, comment: String?) { - var comments = info[Attrs.COMMENT_ATTR] + val comments = info[Attrs.COMMENT_ATTR] if (comments == null) { - comments = KV() - info[Attrs.COMMENT_ATTR] = comments - comments[field] = comment + info[Attrs.COMMENT_ATTR] = linkedMapOf(field to comment) } else { val oldComment = (comments as HashMap)[field] if (oldComment == null) { @@ -146,19 +142,15 @@ object KVUtils { @Suppress("UNCHECKED_CAST") fun addOptions(info: HashMap, field: String, options: ArrayList>) { - var comments = info[Attrs.COMMENT_ATTR] + val comments = info[Attrs.COMMENT_ATTR] if (comments == null) { - comments = KV() - info[Attrs.COMMENT_ATTR] = comments - comments["$field@options"] = options + info[Attrs.COMMENT_ATTR] = linkedMapOf("$field@options" to options) } else { val oldOptions = (comments as HashMap)["$field@options"] if (oldOptions == null) { comments["$field@options"] = options } else { - val mergeOptions: ArrayList = ArrayList(oldOptions as ArrayList<*>) - mergeOptions.addAll(options) - comments["$field@options"] = mergeOptions + comments["$field@options"] = (oldOptions as ArrayList<*>) + options } } } diff --git a/common-api/src/main/kotlin/com/itangcent/common/model/Request.kt b/common-api/src/main/kotlin/com/itangcent/common/model/Request.kt index 06c78b404..5c657febe 100644 --- a/common-api/src/main/kotlin/com/itangcent/common/model/Request.kt +++ b/common-api/src/main/kotlin/com/itangcent/common/model/Request.kt @@ -100,7 +100,7 @@ fun Request.header(name: String): String? { } val lowerName = name.lowercase() return this.headers!! - .stream() + .asSequence() .filter { it.name?.lowercase() == lowerName } .map { it.value } .firstOrNull() diff --git a/common-api/src/main/kotlin/com/itangcent/http/RequestUtils.kt b/common-api/src/main/kotlin/com/itangcent/http/RequestUtils.kt index b254b9e75..349e0af5c 100644 --- a/common-api/src/main/kotlin/com/itangcent/http/RequestUtils.kt +++ b/common-api/src/main/kotlin/com/itangcent/http/RequestUtils.kt @@ -33,7 +33,7 @@ object RequestUtils { return mutableBody } if (body is List<*>) { - return body.stream().map { toRawBody(it, copy) }.toList() + return body.map { toRawBody(it, copy) } } if (body is Array<*>) { return body.mapToTypedArray { toRawBody(it, copy) } diff --git a/common-api/src/test/kotlin/com/itangcent/common/kit/KitUtilsTest.kt b/common-api/src/test/kotlin/com/itangcent/common/kit/KitUtilsTest.kt index f1d6e8768..a37b56de5 100644 --- a/common-api/src/test/kotlin/com/itangcent/common/kit/KitUtilsTest.kt +++ b/common-api/src/test/kotlin/com/itangcent/common/kit/KitUtilsTest.kt @@ -1,6 +1,5 @@ package com.itangcent.common.kit -import com.itangcent.common.utils.KV import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test @@ -14,7 +13,7 @@ class KitUtilsTest { assertEquals(null, null.toJson()) assertEquals("str", "str".toJson()) assertEquals("1", 1.toJson()) - assertEquals("{\"a\":\"b\"}", KV.by("a", "b").toJson()) + assertEquals("{\"a\":\"b\"}", linkedMapOf("a" to "b").toJson()) } @Test diff --git a/gradle.properties b/gradle.properties index 89f80f071..8c7426883 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,4 +3,4 @@ plugin_version=2.6.1.212.0 kotlin.code.style=official kotlin_version=1.8.0 junit_version=5.9.2 -itangcent_intellij_version=1.5.4 \ No newline at end of file +itangcent_intellij_version=1.5.5 \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/ClassApiExporterHelper.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/ClassApiExporterHelper.kt index 03ce826dd..6a1eeeb4e 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/ClassApiExporterHelper.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/ClassApiExporterHelper.kt @@ -26,7 +26,6 @@ import com.itangcent.intellij.util.FileType import java.util.* import java.util.concurrent.BlockingQueue import java.util.concurrent.LinkedBlockingQueue -import kotlin.streams.toList @Singleton open class ClassApiExporterHelper { @@ -69,13 +68,13 @@ open class ClassApiExporterHelper { companion object : Log() - fun extractParamComment(psiMethod: PsiMethod): KV? { + fun extractParamComment(psiMethod: PsiMethod): MutableMap? { val subTagMap = docHelper!!.getSubTagMapOfDocComment(psiMethod, "param") if (subTagMap.isEmpty()) { return null } - val methodParamComment: KV = KV.create() + val methodParamComment = linkedMapOf() val parameters = psiMethod.parameterList.parameters subTagMap.entries.forEach { entry -> val name: String = entry.key @@ -115,7 +114,7 @@ open class ClassApiExporterHelper { return linkResolver!!.linkToMethod(linkMethod) } - override fun linkToUnresolved(plainText: String): String? { + override fun linkToUnresolved(plainText: String): String { return plainText } }) @@ -181,20 +180,20 @@ open class ClassApiExporterHelper { fun foreachPsiMethod(cls: PsiClass, handle: (PsiMethod) -> Unit) { actionContext.runInReadUI { jvmClassHelper!!.getAllMethods(cls) - .stream() + .asSequence() .filter { !shouldIgnore(it) } .forEach(handle) } } fun export(): List { - val docs: MutableList = Collections.synchronizedList(java.util.ArrayList()) + val docs: MutableList = Collections.synchronizedList(ArrayList()) export { docs.add(it) } return docs } fun export(handle: (Doc) -> Unit) { - logger.info("Start find apis...") + logger.info("Start export api...") val psiClassQueue: BlockingQueue = LinkedBlockingQueue() val boundary = actionContext.createBoundary() diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/DefaultMethodInferHelper.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/DefaultMethodInferHelper.kt index eb11125be..0e1d63aee 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/DefaultMethodInferHelper.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/DefaultMethodInferHelper.kt @@ -565,7 +565,7 @@ class DefaultMethodInferHelper : MethodInferHelper { obj is Variable -> valueOf(obj.getValue()) obj is ObjectHolder -> valueOf(obj.getOrResolve()) obj is MutableMap<*, *> -> { - val copy = KV.create() + val copy = linkedMapOf() obj.entries.forEach { copy[valueOf(it.key)] = valueOf(it.value) } return copy } @@ -697,7 +697,7 @@ class DefaultMethodInferHelper : MethodInferHelper { return null } actionContext!!.checkStatus() - val kv = KV.create() + val fields = linkedMapOf() for (field in jvmClassHelper!!.getAllFields(psiClass)) { if (jvmClassHelper.isStaticFinal(field)) { continue @@ -706,18 +706,18 @@ class DefaultMethodInferHelper : MethodInferHelper { val name = psiClassHelper!!.getJsonFieldName(field) if (type is PsiPrimitiveType) { //primitive Type - kv[name] = PsiTypesUtil.getDefaultValue(type) + fields[name] = PsiTypesUtil.getDefaultValue(type) continue } //reference Type if (psiClassHelper.isNormalType(type)) {//normal Type - kv[name] = psiClassHelper.getDefaultValue(type) + fields[name] = psiClassHelper.getDefaultValue(type) continue } - kv[name] = DirectVariable { getSimpleFields(type, psiClass, deep + 1) } + fields[name] = DirectVariable { getSimpleFields(type, psiClass, deep + 1) } } - return kv + return fields } private fun getSimpleFields(psiType: PsiType?, context: PsiElement): Any? { diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/core/RequestClassExporter.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/core/RequestClassExporter.kt index 684f4a6e7..336bf086d 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/core/RequestClassExporter.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/core/RequestClassExporter.kt @@ -646,10 +646,10 @@ abstract class RequestClassExporter : ClassExporter { } }) } else { - val fields = typeObject.asKV() - val comment = fields.getAsKv(Attrs.COMMENT_ATTR) - val required = fields.getAsKv(Attrs.REQUIRED_ATTR) - val defaultVal = fields.getAsKv(Attrs.DEFAULT_VALUE_ATTR) + val fields = typeObject.asHashMap() + val comment = fields.getSub(Attrs.COMMENT_ATTR) + val required = fields.getSub(Attrs.REQUIRED_ATTR) + val defaultVal = fields.getSub(Attrs.DEFAULT_VALUE_ATTR) parameterExportContext.setExt("parent", fields) fields.forEachValid { filedName, fieldVal -> parameterExportContext.setExt("key", filedName) @@ -659,7 +659,7 @@ abstract class RequestClassExporter : ClassExporter { } requestBuilderListener.addParam( parameterExportContext, - request, filedName, tinyQueryParam(fv), + request, filedName.toString(), tinyQueryParam(fv), required?.getAs(filedName) ?: false, KVUtils.getUltimateComment(comment, filedName) ) @@ -728,10 +728,10 @@ abstract class RequestClassExporter : ClassExporter { } }) } else { - val fields = typeObject.asKV() - val comment = fields.getAsKv(Attrs.COMMENT_ATTR) - val required = fields.getAsKv(Attrs.REQUIRED_ATTR) - val defaultVal = fields.getAsKv(Attrs.DEFAULT_VALUE_ATTR) + val fields = typeObject.asHashMap() + val comment = fields.getSub(Attrs.COMMENT_ATTR) + val required = fields.getSub(Attrs.REQUIRED_ATTR) + val defaultVal = fields.getSub(Attrs.DEFAULT_VALUE_ATTR) requestBuilderListener.addHeaderIfMissed( parameterExportContext, request, "Content-Type", "application/x-www-form-urlencoded" @@ -743,14 +743,14 @@ abstract class RequestClassExporter : ClassExporter { if (fv == Magics.FILE_STR) { requestBuilderListener.addFormFileParam( parameterExportContext, - request, filedName, + request, filedName.toString(), required?.getAs(filedName) ?: false, KVUtils.getUltimateComment(comment, filedName) ) } else { requestBuilderListener.addFormParam( parameterExportContext, - request, filedName, fv?.takeIfNotOriginal()?.toString(), + request, filedName.toString(), fv?.takeIfNotOriginal()?.toString(), required?.getAs(filedName) ?: false, KVUtils.getUltimateComment(comment, filedName) ) diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/generic/SimpleGenericMethodDocClassExporter.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/generic/SimpleGenericMethodDocClassExporter.kt index 445d92680..deef2afe0 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/generic/SimpleGenericMethodDocClassExporter.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/generic/SimpleGenericMethodDocClassExporter.kt @@ -6,7 +6,6 @@ import com.intellij.psi.PsiElement import com.intellij.psi.PsiMethod import com.itangcent.common.logger.traceError import com.itangcent.common.model.MethodDoc -import com.itangcent.common.utils.KV import com.itangcent.idea.plugin.api.ClassApiExporterHelper import com.itangcent.idea.plugin.api.export.Orders import com.itangcent.idea.plugin.api.export.condition.ConditionOnDoc @@ -80,13 +79,13 @@ open class SimpleGenericMethodDocClassExporter : ClassExporter { else -> { logger!!.info("search api from: $clsQualifiedName") - val kv = KV.create() + val fields = linkedMapOf() - processClass(cls, kv) + processClass(cls, fields) classApiExporterHelper.foreachPsiMethod(cls) { method -> if (isApi(method) && methodFilter?.checkMethod(method) != false) { - exportMethodApi(cls, method, kv, docHandle) + exportMethodApi(cls, method, fields, docHandle) } } } @@ -99,7 +98,7 @@ open class SimpleGenericMethodDocClassExporter : ClassExporter { } @Suppress("UNUSED") - protected fun processClass(cls: PsiClass, kv: KV) { + protected fun processClass(cls: PsiClass, fields: MutableMap) { } @Suppress("UNUSED") @@ -132,7 +131,7 @@ open class SimpleGenericMethodDocClassExporter : ClassExporter { } private fun exportMethodApi( - psiClass: PsiClass, method: PsiMethod, kv: KV, + psiClass: PsiClass, method: PsiMethod, fields: MutableMap, docHandle: DocHandle, ) { @@ -142,12 +141,12 @@ open class SimpleGenericMethodDocClassExporter : ClassExporter { methodDoc.resource = PsiMethodResource(method, psiClass) - processMethod(method, kv, methodDoc) + processMethod(method, fields, methodDoc) docHandle(methodDoc) } - protected open fun processMethod(method: PsiMethod, kv: KV, methodDoc: MethodDoc) { + protected open fun processMethod(method: PsiMethod, fields: MutableMap, methodDoc: MethodDoc) { methodDoc.name = apiHelper!!.nameOfApi(method) } } \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/DefaultPostmanApiHelper.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/DefaultPostmanApiHelper.kt index c0614cc5c..d943521be 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/DefaultPostmanApiHelper.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/DefaultPostmanApiHelper.kt @@ -13,9 +13,12 @@ import com.itangcent.http.contentType import com.itangcent.idea.plugin.settings.helper.PostmanSettingsHelper import com.itangcent.idea.utils.resolveGsonLazily import com.itangcent.intellij.context.ActionContext -import com.itangcent.intellij.extend.* +import com.itangcent.intellij.extend.acquireGreedy +import com.itangcent.intellij.extend.asJsonElement +import com.itangcent.intellij.extend.asMap import com.itangcent.intellij.extend.rx.Throttle import com.itangcent.intellij.extend.rx.ThrottleHelper +import com.itangcent.intellij.extend.sub import com.itangcent.intellij.logger.Logger import com.itangcent.suv.http.HttpClientProvider import org.apache.http.entity.ContentType @@ -118,7 +121,7 @@ open class DefaultPostmanApiHelper : PostmanApiHelper { .post(COLLECTION) .contentType(ContentType.APPLICATION_JSON) .header("x-api-key", postmanSettingsHelper.getPrivateToken()) - .body(KV.by("collection", collection)) + .body(linkedMapOf("collection" to collection)) workspaceId?.let { request.query("workspace", it) } @@ -205,7 +208,7 @@ open class DefaultPostmanApiHelper : PostmanApiHelper { val request = getHttpClient().put("$COLLECTION/$collectionId") .contentType(ContentType.APPLICATION_JSON) .header("x-api-key", postmanSettingsHelper.getPrivateToken()) - .body(GsonUtils.toJson(KV.by("collection", apiInfo)).resolveGsonLazily()) + .body(GsonUtils.toJson(linkedMapOf("collection" to apiInfo)).resolveGsonLazily()) try { beforeRequest(request) diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatter.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatter.kt index 2853e19b1..c1f432670 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatter.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatter.kt @@ -93,7 +93,7 @@ open class PostmanFormatter { } protected open fun copyItem(item: HashMap): HashMap { - val copyItem = KV.create() + val copyItem = linkedMapOf() copyItem.putAll(item) val request = HashMap(item.getAs>("request")) @@ -159,11 +159,12 @@ open class PostmanFormatter { requestInfo["header"] = headers request.headers?.forEach { headers.add( - KV.create() - .set(KEY, it.name) - .set(VALUE, it.value) - .set(TYPE, "text") - .set(DESCRIPTION, it.desc ?: "") + linkedMapOf( + KEY to it.name, + VALUE to it.value, + TYPE to "text", + DESCRIPTION to (it.desc ?: "") + ) ) } @@ -171,11 +172,12 @@ open class PostmanFormatter { url["query"] = queryList request.querys?.forEach { queryList.add( - KV.create() - .set(KEY, it.name) - .set(VALUE, it.value?.takeIfNotOriginal()?.toString() ?: "") - .set("equals", true) - .set(DESCRIPTION, it.desc) + linkedMapOf( + KEY to it.name, + VALUE to (it.value?.takeIfNotOriginal()?.toString() ?: ""), + "equals" to true, + DESCRIPTION to it.desc + ) ) } @@ -187,11 +189,12 @@ open class PostmanFormatter { val formdatas: ArrayList> = ArrayList() request.formParams!!.forEach { formdatas.add( - KV.create() - .set(KEY, it.name) - .set(VALUE, it.value.takeIfSpecial() ?: "") - .set(TYPE, it.type) - .set(DESCRIPTION, it.desc) + linkedMapOf( + KEY to it.name, + VALUE to (it.value.takeIfSpecial() ?: ""), + TYPE to it.type, + DESCRIPTION to it.desc + ) ) } body["formdata"] = formdatas @@ -201,11 +204,12 @@ open class PostmanFormatter { val urlEncodeds: ArrayList> = ArrayList() request.formParams!!.forEach { urlEncodeds.add( - KV.create() - .set(KEY, it.name) - .set(VALUE, it.value.takeIfSpecial() ?: "") - .set(TYPE, it.type) - .set(DESCRIPTION, it.desc) + linkedMapOf( + KEY to it.name, + VALUE to (it.value.takeIfSpecial() ?: ""), + TYPE to it.type, + DESCRIPTION to it.desc + ) ) } body["urlencoded"] = urlEncodeds @@ -219,7 +223,11 @@ open class PostmanFormatter { KVUtils.useAttrAsValue(it, Attrs.DEMO_ATTR) } ) - body["options"] = KV.by("raw", KV.by("language", "json")) + body["options"] = linkedMapOf( + "raw" to linkedMapOf( + "language" to "json" + ) + ) } if (body.isNotEmpty()) { @@ -231,7 +239,7 @@ open class PostmanFormatter { val responses: ArrayList> = ArrayList() val exampleName = request.name + "-Example" request.response!!.forEachIndexed { index, response -> - val responseInfo: HashMap = HashMap() + val responseInfo = linkedMapOf() if (index > 0) { responseInfo[NAME] = exampleName + (index + 1) } else { @@ -257,59 +265,59 @@ open class PostmanFormatter { if (response.headers?.any { it.name.equals("content-type", true) } == false) { responseHeader.add( - KV.create() - .set(NAME, "content-type") - .set(KEY, "content-type") - .set(VALUE, "application/json;charset=UTF-8") - .set(DESCRIPTION, "The mime type of this content") + linkedMapOf( + NAME to "content-type", + KEY to "content-type", + VALUE to "application/json;charset=UTF-8", + DESCRIPTION to "The mime type of this content" + ) ) } if (response.headers?.any { it.name.equals("date", true) } == false) { responseHeader.add( - KV.create() - .set(NAME, "date") - .set(KEY, "date") - .set( - VALUE, - systemProvider.currentTimeMillis().asDate().formatDate("EEE, dd MMM yyyyHH:mm:ss 'GMT'") - ) - .set(DESCRIPTION, "The date and time that the message was sent") + linkedMapOf( + NAME to "date", + KEY to "date", + VALUE to systemProvider.currentTimeMillis().asDate() + .formatDate("EEE, dd MMM yyyyHH:mm:ss 'GMT'"), + DESCRIPTION to "The date and time that the message was sent" + ) ) } if (response.headers?.any { it.name.equals("server", true) } == false) { responseHeader.add( - KV.create() - .set(NAME, "server") - .set(KEY, "server") - .set(VALUE, "Apache-Coyote/1.1") - .set(DESCRIPTION, "A name for the server") + linkedMapOf( + NAME to "server", + KEY to "server", + VALUE to "Apache-Coyote/1.1", + DESCRIPTION to "A name for the server" + ) ) } if (response.headers?.any { it.name.equals("transfer-encoding", true) } == false) { responseHeader.add( - KV.create() - .set(NAME, "transfer-encoding") - .set(KEY, "transfer-encoding") - .set(VALUE, "chunked") - .set( - DESCRIPTION, - "The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity." - ) + linkedMapOf( + NAME to "transfer-encoding", + KEY to "transfer-encoding", + VALUE to "chunked", + DESCRIPTION to "The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity." + ) ) } response.headers?.forEach { responseHeader.add( - KV.create() - .set(NAME, it.name) - .set(KEY, it.name) - .set(VALUE, it.value.takeIfSpecial() ?: "") - .set(DESCRIPTION, it.desc) + linkedMapOf( + NAME to it.name, + KEY to it.name, + VALUE to (it.value.takeIfSpecial() ?: ""), + DESCRIPTION to it.desc + ) ) } @@ -425,24 +433,26 @@ open class PostmanFormatter { preRequest()?.takeIf { it.notNullOrBlank() }?.let { events = ArrayList() events!!.add( - KV.any().set("listen", "prerequest") - .set( - "script", KV.any() - .set("exec", it.lines()) - .set(TYPE, "text/javascript") + linkedMapOf( + "listen" to "prerequest", + "script" to linkedMapOf( + "exec" to it.lines(), + TYPE to "text/javascript" ) + ) ) } test()?.takeIf { it.notNullOrBlank() }?.let { events = events ?: ArrayList() events!!.add( - KV.any().set("listen", "test") - .set( - "script", KV.any() - .set("exec", it.lines()) - .set(TYPE, "text/javascript") + linkedMapOf( + "listen" to "test", + "script" to linkedMapOf( + "exec" to it.lines(), + TYPE to "text/javascript" ) + ) ) } @@ -591,7 +601,7 @@ open class PostmanFormatter { @Suppress("UNCHECKED_CAST") private fun findCommonEvents(items: List<*>): List<*>? { - if (items.isNullOrEmpty()) { + if (items.isEmpty()) { return null } diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/yapi/DefaultYapiApiHelper.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/yapi/DefaultYapiApiHelper.kt index eb37fcb2b..6f1cac54b 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/yapi/DefaultYapiApiHelper.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/yapi/DefaultYapiApiHelper.kt @@ -8,7 +8,6 @@ import com.google.inject.Singleton import com.itangcent.common.logger.Log import com.itangcent.common.logger.traceError import com.itangcent.common.utils.GsonUtils -import com.itangcent.common.utils.KV import com.itangcent.common.utils.asInt import com.itangcent.common.utils.asMap import com.itangcent.http.contentType @@ -179,11 +178,12 @@ open class DefaultYapiApiHelper : AbstractYapiApiHelper(), YapiApiHelper { .post(yapiSettingsHelper.getServer(false) + ADD_CART) .contentType(ContentType.APPLICATION_JSON) .body( - KV.create() - .set("desc", desc) - .set("project_id", projectId) - .set("name", name) - .set("token", yapiSettingsHelper.rawToken(token)) + linkedMapOf( + "desc" to desc, + "project_id" to projectId, + "name" to name, + "token" to yapiSettingsHelper.rawToken(token) + ) ) .call() .use { it.string() } diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiFormatter.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiFormatter.kt index 01dec0afb..503142f36 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiFormatter.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiFormatter.kt @@ -115,12 +115,13 @@ open class YapiFormatter { item["req_query"] = queryList methodDoc.params?.forEach { queryList.add( - KV.create() - .set("name", it.name) - .set("value", parseQueryValueAsJson5(it.value)) - .set("example", parseQueryValueAsJson5(it.getExample() ?: it.value.takeIfNotOriginal())) - .set("desc", it.desc) - .set("required", it.required.asInt()) + linkedMapOf( + "name" to it.name, + "value" to parseQueryValueAsJson5(it.value), + "example" to parseQueryValueAsJson5(it.getExample() ?: it.value.takeIfNotOriginal()), + "desc" to it.desc, + "required" to it.required.asInt() + ) ) } } else { @@ -251,7 +252,7 @@ open class YapiFormatter { } protected open fun copyItem(item: HashMap): HashMap { - val copyItem = KV.create() + val copyItem = linkedMapOf() copyItem.putAll(item) val queryPath = HashMap(item.getAs>("query_path")) @@ -293,12 +294,13 @@ open class YapiFormatter { item["req_headers"] = headers request.headers?.forEach { headers.add( - KV.create() - .set("name", it.name) - .set("value", it.value) - .set("desc", it.desc) - .set("example", it.getExample() ?: it.value.takeIfSpecial()) - .set("required", it.required.asInt()) + linkedMapOf( + "name" to it.name, + "value" to it.value, + "desc" to it.desc, + "example" to (it.getExample() ?: it.value.takeIfSpecial()), + "required" to it.required.asInt() + ) ) } @@ -306,12 +308,13 @@ open class YapiFormatter { item["req_query"] = queryList request.querys?.forEach { queryList.add( - KV.create() - .set("name", it.name) - .set("value", it.value) - .set("example", it.getExample() ?: it.value.takeIfNotOriginal()?.toString()) - .set("desc", it.desc) - .set("required", it.required.asInt()) + linkedMapOf( + "name" to it.name, + "value" to it.value, + "example" to (it.getExample() ?: it.value.takeIfNotOriginal()?.toString()), + "desc" to it.desc, + "required" to it.required.asInt() + ) ) } @@ -321,12 +324,13 @@ open class YapiFormatter { item["req_body_form"] = urlencodeds request.formParams!!.forEach { urlencodeds.add( - KV.create() - .set("name", it.name) - .set("example", it.getExample() ?: it.value.takeIfSpecial()) - .set("type", it.type) - .set("required", it.required.asInt()) - .set("desc", it.desc) + linkedMapOf( + "name" to it.name, + "example" to (it.getExample() ?: it.value.takeIfSpecial()), + "type" to it.type, + "required" to it.required.asInt(), + "desc" to it.desc + ) ) } } @@ -336,10 +340,11 @@ open class YapiFormatter { item["req_params"] = pathParmas request.paths!!.forEach { pathParmas.add( - KV.create() - .set("name", it.name) - .set("example", it.getExample() ?: it.value.takeIfSpecial()) - .set("desc", it.desc) + linkedMapOf( + "name" to it.name, + "example" to (it.getExample() ?: it.value.takeIfSpecial()), + "desc" to it.desc + ) ) } } @@ -630,7 +635,6 @@ open class YapiFormatter { return json5Formatter.format(typedObject, rootDesc) } - @Suppress("UNCHECKED_CAST") private fun addMockAsProperty(path: String, typedObject: Any?): Any? { var ret = typedObject addMockAsProperty(path, typedObject) { diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiPsiClassHelper.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiPsiClassHelper.kt index 4c02ff71f..73314a38f 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiPsiClassHelper.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/api/export/yapi/YapiPsiClassHelper.kt @@ -3,7 +3,6 @@ package com.itangcent.idea.plugin.api.export.yapi import com.intellij.psi.PsiElement import com.itangcent.common.constant.Attrs import com.itangcent.common.kit.KVUtils -import com.itangcent.common.utils.KV import com.itangcent.common.utils.notNullOrEmpty import com.itangcent.common.utils.sub import com.itangcent.idea.plugin.api.export.AdditionalField @@ -45,17 +44,17 @@ class YapiPsiClassHelper : CustomizedPsiClassHelper() { fieldOrMethod: ExplicitElement<*>, resourcePsiClass: ExplicitClass, resolveContext: ResolveContext, - kv: KV, + fields: MutableMap, ) { //compute `field.mock` ruleComputer.computer(YapiClassExportRuleKeys.FIELD_MOCK, fieldOrMethod) ?.takeIf { it.isNotBlank() } ?.let { if (resolveProperty) configReader.resolveProperty(it) else it } ?.let { mockInfo -> - kv.sub(Attrs.MOCK_ATTR)[fieldName] = mockInfo + fields.sub(Attrs.MOCK_ATTR)[fieldName] = mockInfo parseAsFieldValue(mockInfo) ?.also { KVUtils.useFieldAsAttr(it, Attrs.MOCK_ATTR) } - ?.let { populateFieldValue(fieldName, fieldType, kv, it) } + ?.let { populateFieldValue(fieldName, fieldType, fields, it) } } //compute `field.advanced` @@ -64,28 +63,28 @@ class YapiPsiClassHelper : CustomizedPsiClassHelper() { fieldOrMethod ) if (advancedValue.notNullOrEmpty()) { - kv.sub(Attrs.ADVANCED_ATTR)[fieldName] = advancedValue + fields.sub(Attrs.ADVANCED_ATTR)[fieldName] = advancedValue } - super.afterParseFieldOrMethod(fieldName, fieldType, fieldOrMethod, resourcePsiClass, resolveContext, kv) + super.afterParseFieldOrMethod(fieldName, fieldType, fieldOrMethod, resourcePsiClass, resolveContext, fields) } override fun resolveAdditionalField( additionalField: AdditionalField, context: PsiElement, resolveContext: ResolveContext, - kv: KV, + fields: MutableMap, ) { - super.resolveAdditionalField(additionalField, context, resolveContext, kv) + super.resolveAdditionalField(additionalField, context, resolveContext, fields) val fieldName = additionalField.name!! additionalField.getExt(Attrs.MOCK_ATTR)?.let { - kv.sub(Attrs.MOCK_ATTR)[fieldName] = it + fields.sub(Attrs.MOCK_ATTR)[fieldName] = it } additionalField.getExt(Attrs.DEMO_ATTR)?.let { - kv.sub(Attrs.DEMO_ATTR)[fieldName] = it + fields.sub(Attrs.DEMO_ATTR)[fieldName] = it } additionalField.getExt(Attrs.ADVANCED_ATTR)?.let { - kv.sub(Attrs.ADVANCED_ATTR)[fieldName] = it + fields.sub(Attrs.ADVANCED_ATTR)[fieldName] = it } } } \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingBuiltInConfigGUI.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingBuiltInConfigGUI.kt index 31632195d..b68f45f0d 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingBuiltInConfigGUI.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingBuiltInConfigGUI.kt @@ -3,7 +3,7 @@ package com.itangcent.idea.plugin.dialog import com.itangcent.common.utils.notNullOrBlank import com.itangcent.idea.plugin.configurable.AbstractEasyApiSettingGUI import com.itangcent.idea.plugin.settings.Settings -import com.itangcent.utils.ResourceUtils +import com.itangcent.common.utils.ResourceUtils import javax.swing.JComponent import javax.swing.JPanel import javax.swing.JTextArea diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingGUI.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingGUI.kt index cdf7d8705..91344e7ce 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingGUI.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingGUI.kt @@ -30,7 +30,7 @@ import com.itangcent.intellij.context.ActionContext import com.itangcent.intellij.extend.rx.ThrottleHelper import com.itangcent.intellij.logger.Logger import com.itangcent.suv.http.ConfigurableHttpClientProvider -import com.itangcent.utils.ResourceUtils +import com.itangcent.common.utils.ResourceUtils import java.awt.event.MouseAdapter import java.awt.event.MouseEvent import java.awt.event.MouseListener diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingRemoteConfigGUI.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingRemoteConfigGUI.kt index 85be4884f..bb3091eca 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingRemoteConfigGUI.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/dialog/EasyApiSettingRemoteConfigGUI.kt @@ -12,7 +12,7 @@ import com.itangcent.idea.swing.ActiveWindowProvider import com.itangcent.idea.swing.MessagesHelper import com.itangcent.idea.swing.MutableActiveWindowProvider import com.itangcent.intellij.context.ActionContext -import com.itangcent.utils.ResourceUtils +import com.itangcent.common.utils.ResourceUtils import javax.swing.JButton import javax.swing.JComponent import javax.swing.JPanel diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/rule/RuleToolUtils.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/rule/RuleToolUtils.kt index 39d071e91..6d4c95d5e 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/rule/RuleToolUtils.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/rule/RuleToolUtils.kt @@ -1023,7 +1023,7 @@ object RuleToolUtils { } } - private fun typeName(kClass: KClass<*>): String? { + private fun typeName(kClass: KClass<*>): String { val annotation = kClass.findAnnotation() if (annotation != null) return annotation.name val qualifiedName = kClass.qualifiedName ?: return "object" @@ -1052,23 +1052,24 @@ object RuleToolUtils { private val TO_LINE_PATTERN = Pattern.compile("[A-Z]+") - private val typeMapper = KV.create() - .set("java.lang.String", "string") - .set("java.lang.Long", "long") - .set("java.lang.Double", "double") - .set("java.lang.Short", "short") - .set("java.lang.Integer", "int") - .set("java.lang.Object", "object") - .set("kotlin.String", "string") - .set("kotlin.Array", "array") - .set("kotlin.Int", "int") - .set("kotlin.Unit", "void") - .set("kotlin.collections.List", "array") - .set("kotlin.Any", "object") - .set("kotlin.Boolean", "bool") - .set("kotlin.collections.Map", "map") - .set("kotlin.collections.Set", "array") - .set("kotlin.CharArray", "array") - .set("kotlin.Function0", "func") - .set("kotlin.Function1", "func") + private val typeMapper = linkedMapOf( + "java.lang.String" to "string", + "java.lang.Long" to "long", + "java.lang.Double" to "double", + "java.lang.Short" to "short", + "java.lang.Integer" to "int", + "java.lang.Object" to "object", + "kotlin.String" to "string", + "kotlin.Array" to "array", + "kotlin.Int" to "int", + "kotlin.Unit" to "void", + "kotlin.collections.List" to "array", + "kotlin.Any" to "object", + "kotlin.Boolean" to "bool", + "kotlin.collections.Map" to "map", + "kotlin.collections.Set" to "array", + "kotlin.CharArray" to "array", + "kotlin.Function0" to "func", + "kotlin.Function1" to "func" + ) } \ No newline at end of file diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/helper/RecommendConfigSettingsHelper.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/helper/RecommendConfigSettingsHelper.kt index 96ff8dbc5..c009a902a 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/helper/RecommendConfigSettingsHelper.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/settings/helper/RecommendConfigSettingsHelper.kt @@ -6,7 +6,7 @@ import com.itangcent.common.utils.appendln import com.itangcent.common.utils.mapToTypedArray import com.itangcent.idea.plugin.settings.SettingBinder import com.itangcent.idea.plugin.settings.update -import com.itangcent.utils.ResourceUtils +import com.itangcent.common.utils.ResourceUtils import java.util.* @Singleton diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/utils/LocalStorage.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/utils/LocalStorage.kt index 7aa361af4..e9773dc8e 100755 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/utils/LocalStorage.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/utils/LocalStorage.kt @@ -3,7 +3,6 @@ package com.itangcent.idea.plugin.utils import com.google.inject.Inject import com.google.inject.Singleton import com.itangcent.annotation.script.ScriptTypeName -import com.itangcent.common.utils.KV import com.itangcent.idea.binder.DbBeanBinderFactory import com.itangcent.idea.plugin.utils.Storage.Companion.DEFAULT_GROUP import com.itangcent.intellij.file.LocalFileRepository @@ -19,9 +18,9 @@ class LocalStorage : AbstractStorage() { @Inject private val localFileRepository: LocalFileRepository? = null - private val dbBeanBinderFactory: DbBeanBinderFactory> by lazy { + private val dbBeanBinderFactory: DbBeanBinderFactory> by lazy { DbBeanBinderFactory(localFileRepository!!.getOrCreateFile(".api.local.storage.v1.1.db").path) - { KV.create() } + { linkedMapOf() } } override fun clear(group: String?) { @@ -29,14 +28,14 @@ class LocalStorage : AbstractStorage() { } override fun getCache(group: String): MutableMap { - return dbBeanBinderFactory.getBeanBinder(group).tryRead() ?: KV.create() + return dbBeanBinderFactory.getBeanBinder(group).tryRead() ?: linkedMapOf() } override fun onUpdate(group: String?, cache: MutableMap) { if (cache.isEmpty()) { dbBeanBinderFactory.deleteBinder(group ?: DEFAULT_GROUP) } else { - dbBeanBinderFactory.getBeanBinder(group ?: DEFAULT_GROUP).save(cache as KV) + dbBeanBinderFactory.getBeanBinder(group ?: DEFAULT_GROUP).save(cache as LinkedHashMap) } } } diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/utils/SessionStorage.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/utils/SessionStorage.kt index 178e207e9..1949a2622 100755 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/utils/SessionStorage.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/utils/SessionStorage.kt @@ -2,7 +2,6 @@ package com.itangcent.idea.plugin.utils import com.google.inject.Singleton import com.itangcent.annotation.script.ScriptTypeName -import com.itangcent.common.utils.KV import com.itangcent.common.utils.sub import com.itangcent.idea.plugin.utils.Storage.Companion.DEFAULT_GROUP @@ -14,17 +13,17 @@ import com.itangcent.idea.plugin.utils.Storage.Companion.DEFAULT_GROUP @ScriptTypeName("session") class SessionStorage : AbstractStorage() { - private val kv: KV by lazy { KV.create() } + private val data: MutableMap by lazy { linkedMapOf() } override fun getCache(group: String): MutableMap { - return kv.sub(group) + return data.sub(group) } override fun onUpdate(group: String?, cache: MutableMap) { if (cache.isEmpty()) { - kv.remove(group ?: DEFAULT_GROUP) + data.remove(group ?: DEFAULT_GROUP) } else { - kv[group ?: DEFAULT_GROUP] = cache + data[group ?: DEFAULT_GROUP] = cache } } } diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/utils/ContextualPsiClassHelper.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/utils/ContextualPsiClassHelper.kt index c191a640b..d07e20651 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/utils/ContextualPsiClassHelper.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/utils/ContextualPsiClassHelper.kt @@ -4,7 +4,6 @@ import com.google.inject.Inject import com.intellij.psi.PsiClass import com.intellij.psi.PsiElement import com.itangcent.common.constant.Attrs -import com.itangcent.common.utils.KV import com.itangcent.common.utils.asBool import com.itangcent.common.utils.sub import com.itangcent.idea.plugin.api.export.AdditionalField @@ -55,27 +54,27 @@ open class ContextualPsiClassHelper : DefaultPsiClassHelper() { (ruleComputeListener as? RuleComputeListenerRegistry)?.register(InnerComputeListener()) } - override fun beforeParseClass(psiClass: PsiClass, resolveContext: ResolveContext, kv: KV) { + override fun beforeParseClass(psiClass: PsiClass, resolveContext: ResolveContext, fields: MutableMap) { tryInitParseContext() ruleComputer.computer(ClassExportRuleKeys.JSON_CLASS_PARSE_BEFORE, psiClass) - super.beforeParseClass(psiClass, resolveContext, kv) + super.beforeParseClass(psiClass, resolveContext, fields) } override fun beforeParseType( psiClass: PsiClass, duckType: SingleDuckType, resolveContext: ResolveContext, - kv: KV, + fields: MutableMap, ) { tryInitParseContext() ruleComputer.computer(ClassExportRuleKeys.JSON_CLASS_PARSE_BEFORE, duckType, psiClass) - super.beforeParseType(psiClass, duckType, resolveContext, kv) + super.beforeParseType(psiClass, duckType, resolveContext, fields) } - override fun afterParseClass(psiClass: PsiClass, resolveContext: ResolveContext, kv: KV) { + override fun afterParseClass(psiClass: PsiClass, resolveContext: ResolveContext, fields: MutableMap) { try { - super.afterParseClass(psiClass, resolveContext, kv) - computeAdditionalField(psiClass, resolveContext, kv) + super.afterParseClass(psiClass, resolveContext, fields) + computeAdditionalField(psiClass, resolveContext, fields) ruleComputer.computer(ClassExportRuleKeys.JSON_CLASS_PARSE_AFTER, psiClass) } finally { tryCleanParseContext() @@ -86,11 +85,11 @@ open class ContextualPsiClassHelper : DefaultPsiClassHelper() { psiClass: PsiClass, duckType: SingleDuckType, resolveContext: ResolveContext, - kv: KV, + fields: MutableMap, ) { try { - super.afterParseType(psiClass, duckType, resolveContext, kv) - computeAdditionalField(psiClass, resolveContext, kv) + super.afterParseType(psiClass, duckType, resolveContext, fields) + computeAdditionalField(psiClass, resolveContext, fields) ruleComputer.computer(ClassExportRuleKeys.JSON_CLASS_PARSE_AFTER, duckType, psiClass) } finally { tryCleanParseContext() @@ -127,7 +126,7 @@ open class ContextualPsiClassHelper : DefaultPsiClassHelper() { fieldOrMethod: ExplicitElement<*>, resourcePsiClass: ExplicitClass, resolveContext: ResolveContext, - kv: KV, + fields: MutableMap, ): Boolean { pushField(fieldName) if (fieldOrMethod is ExplicitMethod) { @@ -136,7 +135,7 @@ open class ContextualPsiClassHelper : DefaultPsiClassHelper() { ruleComputer.computer(ClassExportRuleKeys.JSON_FIELD_PARSE_BEFORE, fieldOrMethod) } - return super.beforeParseFieldOrMethod(fieldName, fieldType, fieldOrMethod, resourcePsiClass, resolveContext, kv) + return super.beforeParseFieldOrMethod(fieldName, fieldType, fieldOrMethod, resourcePsiClass, resolveContext, fields) } private fun pushField(fieldName: String) { @@ -152,9 +151,9 @@ open class ContextualPsiClassHelper : DefaultPsiClassHelper() { fieldOrMethod: ExplicitElement<*>, resourcePsiClass: ExplicitClass, resolveContext: ResolveContext, - kv: KV, + fields: MutableMap, ) { - super.onIgnoredParseFieldOrMethod(fieldName, fieldType, fieldOrMethod, resourcePsiClass, resolveContext, kv) + super.onIgnoredParseFieldOrMethod(fieldName, fieldType, fieldOrMethod, resourcePsiClass, resolveContext, fields) popField(fieldName) } @@ -164,9 +163,9 @@ open class ContextualPsiClassHelper : DefaultPsiClassHelper() { fieldOrMethod: ExplicitElement<*>, resourcePsiClass: ExplicitClass, resolveContext: ResolveContext, - kv: KV, + fields: MutableMap, ) { - super.afterParseFieldOrMethod(fieldName, fieldType, fieldOrMethod, resourcePsiClass, resolveContext, kv) + super.afterParseFieldOrMethod(fieldName, fieldType, fieldOrMethod, resourcePsiClass, resolveContext, fields) if (fieldOrMethod is ExplicitMethod) { ruleComputer.computer(ClassExportRuleKeys.JSON_METHOD_PARSE_AFTER, fieldOrMethod) @@ -174,13 +173,13 @@ open class ContextualPsiClassHelper : DefaultPsiClassHelper() { ruleComputer.computer(ClassExportRuleKeys.JSON_FIELD_PARSE_AFTER, fieldOrMethod) } popField(fieldName) - computeAdditionalField(fieldOrMethod.psi(), resolveContext, kv) + computeAdditionalField(fieldOrMethod.psi(), resolveContext, fields) } protected open fun computeAdditionalField( context: PsiElement, resolveContext: ResolveContext, - kv: KV, + fields: MutableMap, ) { //support json.additional.field val additionalFields = ruleComputer.computer(ClassExportRuleKeys.JSON_ADDITIONAL_FIELD, context) @@ -194,11 +193,11 @@ open class ContextualPsiClassHelper : DefaultPsiClassHelper() { return } val fieldName = field.name - if (kv.containsKey(fieldName)) { + if (fields.containsKey(fieldName)) { logger.debug("additional field [$fieldName] is already existed.") continue } - resolveAdditionalField(field, context, resolveContext, kv) + resolveAdditionalField(field, context, resolveContext, fields) } } } @@ -207,17 +206,17 @@ open class ContextualPsiClassHelper : DefaultPsiClassHelper() { additionalField: AdditionalField, context: PsiElement, resolveContext: ResolveContext, - kv: KV, + fields: MutableMap, ) { val additionalFieldType = duckTypeHelper!!.resolve(additionalField.type!!, context) val fieldName = additionalField.name!! if (additionalFieldType == null) { - kv[fieldName] = null + fields[fieldName] = null } else { - kv[fieldName] = doGetTypeObject(additionalFieldType, context, resolveContext.next()) + fields[fieldName] = doGetTypeObject(additionalFieldType, context, resolveContext.next()) } if (resolveContext.option.has(JsonOption.READ_COMMENT)) { - kv.sub(Attrs.COMMENT_ATTR)[fieldName] = additionalField.desc + fields.sub(Attrs.COMMENT_ATTR)[fieldName] = additionalField.desc } } diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/utils/CustomizedPsiClassHelper.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/utils/CustomizedPsiClassHelper.kt index 59ea87726..9cd080b84 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/utils/CustomizedPsiClassHelper.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/utils/CustomizedPsiClassHelper.kt @@ -39,11 +39,11 @@ open class CustomizedPsiClassHelper : ContextualPsiClassHelper() { fieldOrMethod: ExplicitElement<*>, resourcePsiClass: ExplicitClass, resolveContext: ResolveContext, - kv: KV, + fields: MutableMap, ) { //compute `field.required` ruleComputer.computer(ClassExportRuleKeys.FIELD_REQUIRED, fieldOrMethod)?.let { required -> - kv.sub(Attrs.REQUIRED_ATTR)[fieldName] = required + fields.sub(Attrs.REQUIRED_ATTR)[fieldName] = required } //compute `field.default.value` @@ -51,13 +51,13 @@ open class CustomizedPsiClassHelper : ContextualPsiClassHelper() { if (defaultValue.isNullOrEmpty()) { if (fieldOrMethod is ExplicitField) { fieldOrMethod.psi().initializer?.let { psiExpressionResolver.process(it) }?.toPrettyString() - ?.let { kv.sub(Attrs.DEFAULT_VALUE_ATTR)[fieldName] = it } + ?.let { fields.sub(Attrs.DEFAULT_VALUE_ATTR)[fieldName] = it } } } else { - kv.sub(Attrs.DEFAULT_VALUE_ATTR)[fieldName] = defaultValue + fields.sub(Attrs.DEFAULT_VALUE_ATTR)[fieldName] = defaultValue parseAsFieldValue(defaultValue) ?.also { KVUtils.useFieldAsAttr(it, Attrs.DEFAULT_VALUE_ATTR) } - ?.let { populateFieldValue(fieldName, fieldType, kv, it) } + ?.let { populateFieldValue(fieldName, fieldType, fields, it) } } //compute `field.demo` @@ -66,25 +66,25 @@ open class CustomizedPsiClassHelper : ContextualPsiClassHelper() { fieldOrMethod ) if (demoValue.notNullOrBlank()) { - kv.sub(Attrs.DEMO_ATTR)[fieldName] = demoValue + fields.sub(Attrs.DEMO_ATTR)[fieldName] = demoValue demoValue?.let { parseAsFieldValue(it) } ?.also { KVUtils.useFieldAsAttr(it, Attrs.DEMO_ATTR) } - ?.let { populateFieldValue(fieldName, fieldType, kv, it) } + ?.let { populateFieldValue(fieldName, fieldType, fields, it) } } - super.afterParseFieldOrMethod(fieldName, fieldType, fieldOrMethod, resourcePsiClass, resolveContext, kv) + super.afterParseFieldOrMethod(fieldName, fieldType, fieldOrMethod, resourcePsiClass, resolveContext, fields) } override fun resolveAdditionalField( additionalField: AdditionalField, context: PsiElement, resolveContext: ResolveContext, - kv: KV, + fields: MutableMap, ) { - super.resolveAdditionalField(additionalField, context, resolveContext, kv) + super.resolveAdditionalField(additionalField, context, resolveContext, fields) val fieldName = additionalField.name!! - kv.sub(Attrs.REQUIRED_ATTR)[fieldName] = additionalField.required - kv.sub(Attrs.DEFAULT_VALUE_ATTR)[fieldName] = additionalField.defaultValue + fields.sub(Attrs.REQUIRED_ATTR)[fieldName] = additionalField.required + fields.sub(Attrs.DEFAULT_VALUE_ATTR)[fieldName] = additionalField.defaultValue } protected fun parseAsFieldValue( @@ -101,10 +101,10 @@ open class CustomizedPsiClassHelper : ContextualPsiClassHelper() { protected fun populateFieldValue( fieldName: String, fieldType: DuckType, - kv: KV, + fields: MutableMap, fieldValue: Any ) { - var oldValue = kv[fieldName] + var oldValue = fields[fieldName] if (oldValue is ObjectHolder) { oldValue = oldValue.getOrResolve() } @@ -112,21 +112,20 @@ open class CustomizedPsiClassHelper : ContextualPsiClassHelper() { return } if (oldValue.isOriginal()) { - kv[fieldName] = fieldValue + fields[fieldName] = fieldValue } else { - kv[fieldName] = oldValue.copy() - kv.merge(fieldName, fieldValue) + fields[fieldName] = oldValue.copy() + fields.merge(fieldName, fieldValue) } } - @Suppress("UNCHECKED_CAST") override fun resolveEnumOrStatic( context: PsiElement, cls: PsiClass?, property: String?, defaultPropertyName: String, valueTypeHandle: ((DuckType) -> Unit)?, - ): java.util.ArrayList>? { + ): ArrayList>? { EventRecords.record(EventRecords.ENUM_RESOLVE) return super.resolveEnumOrStatic(context, cls, property, defaultPropertyName, valueTypeHandle) } diff --git a/idea-plugin/src/main/kotlin/com/itangcent/intellij/util/KVKit.kt b/idea-plugin/src/main/kotlin/com/itangcent/intellij/util/KVKit.kt index 719fadfcc..3fbd69649 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/intellij/util/KVKit.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/intellij/util/KVKit.kt @@ -2,31 +2,8 @@ package com.itangcent.intellij.util import com.itangcent.common.constant.Attrs import com.itangcent.common.utils.GsonUtils -import com.itangcent.common.utils.KV import com.itangcent.common.utils.resolveCycle import com.itangcent.intellij.extend.toPrettyString -import java.util.function.BiConsumer - -fun KV.forEachValid(action: BiConsumer) { - this.forEachValid { k, v -> - action.accept(k, v) - } -} - -fun KV.forEachValid(action: (String, V) -> Unit) { - this.forEach { k, v -> - if (k.startsWith(Attrs.PREFIX)) { - return@forEach - } - if (k.isBlank()) { - if (this.size == 1) { - action("key", v) - } - return@forEach - } - action(k, v) - } -} @Suppress("UNCHECKED_CAST") fun Map.forEachValid(action: (K, V) -> Unit) { @@ -69,6 +46,7 @@ private fun flatValid(parent: Map<*, *>?, path: String, key: String, value: Any? consumer.consume(parent, path, key, null) return } + is Collection<*> -> { if (value.isEmpty()) { flatValid(parent, "$path[0]", key, null, consumer) @@ -80,6 +58,7 @@ private fun flatValid(parent: Map<*, *>?, path: String, key: String, value: Any? } } } + is Array<*> -> if (value.isEmpty()) { flatValid(parent, "$path[0]", key, null, consumer) @@ -90,6 +69,7 @@ private fun flatValid(parent: Map<*, *>?, path: String, key: String, value: Any? } } } + is Map<*, *> -> { if (value.isEmpty()) { flatValid(parent, "$path.key", "key", null, consumer) @@ -99,6 +79,7 @@ private fun flatValid(parent: Map<*, *>?, path: String, key: String, value: Any? } } } + else -> { consumer.consume(parent, path, key, value) } @@ -127,6 +108,7 @@ fun Any?.isComplex(root: Boolean = true): Boolean { } return false } + this == Magics.FILE_STR -> return !root else -> return false } @@ -156,6 +138,7 @@ private fun Any?.checkHasFile(): Boolean { } return false } + this == Magics.FILE_STR -> return true else -> return false } diff --git a/idea-plugin/src/main/kotlin/com/itangcent/utils/ResourceUtils.kt b/idea-plugin/src/main/kotlin/com/itangcent/utils/ResourceUtils.kt deleted file mode 100644 index 1aaaf5de0..000000000 --- a/idea-plugin/src/main/kotlin/com/itangcent/utils/ResourceUtils.kt +++ /dev/null @@ -1,59 +0,0 @@ -package com.itangcent.utils - -import com.itangcent.common.utils.KV -import com.itangcent.common.utils.readString -import com.itangcent.common.utils.safeComputeIfAbsent -import java.net.URL - -/** - * A utility class for reading resources from the classpath. - * - * @author tangcent - */ -object ResourceUtils { - - // A map that caches the contents of resources that have been read - private val resourceCache: KV = KV() - - // A map that caches the URLs of resources that have been found - private val resourceURLCache: KV = KV() - - /** - * Reads the contents of the specified resource from the classpath and returns it as a String. - * If the resource has already been read, then the cached value is returned. - * - * @param resourceName The name of the resource to read. - * @return The contents of the resource as a String, or an empty String if the resource could not be found. - */ - fun readResource(resourceName: String): String { - return resourceCache.safeComputeIfAbsent(resourceName) { - (ResourceUtils::class.java.classLoader.getResourceAsStream(resourceName) - ?: ResourceUtils::class.java.getResourceAsStream(resourceName)) - ?.readString(Charsets.UTF_8) ?: "" - } ?: "" - } - - /** - * Attempts to find the URL of the specified resource on the classpath. - * If the resource URL has already been found, then the cached value is returned. - * - * @param resourceName The name of the resource to find. - * @return The URL of the resource, or null if the resource could not be found. - */ - fun findResource(resourceName: String): URL? { - return resourceURLCache.safeComputeIfAbsent(resourceName) { - doFindResource(resourceName) - } - } - - /** - * Attempts to find the URL of the specified resource using the class loader. - * - * @param resourceName The name of the resource to find. - * @return The URL of the resource, or null if the resource could not be found. - */ - private fun doFindResource(resourceName: String): URL? { - return ResourceUtils::class.java.classLoader.getResource(resourceName) - ?: ResourceUtils::class.java.getResource(resourceName) - } -} \ No newline at end of file diff --git a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/call/ApiCallerTest.kt b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/call/ApiCallerTest.kt index bcfc7d40b..7252c4ead 100644 --- a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/call/ApiCallerTest.kt +++ b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/call/ApiCallerTest.kt @@ -77,7 +77,7 @@ internal abstract class ApiCallerTest : PluginContextLightCodeInsightFixtureTest apiCaller.showCallWindow() actionContext.waitComplete() assertEquals( - "[INFO]\tStart find apis...\n" + + "[INFO]\tStart export api...\n" + "[INFO]\tNo api be found to call!\n", LoggerCollector.getLog().toUnixString() ) @@ -119,7 +119,7 @@ internal abstract class ApiCallerTest : PluginContextLightCodeInsightFixtureTest apiCaller.showCallWindow() actionContext.waitComplete() assertEquals( - "[INFO]\tStart find apis...\n", + "[INFO]\tStart export api...\n", LoggerCollector.getLog().replace(Regex("\\d"), "").toUnixString() ) assertEquals(requests, requestListInUI) @@ -147,7 +147,7 @@ internal abstract class ApiCallerTest : PluginContextLightCodeInsightFixtureTest actionContext.instance(ApiCaller::class).showCallWindow() actionContext.waitComplete() assertEquals( - "[INFO]\tStart find apis...\n", + "[INFO]\tStart export api...\n", LoggerCollector.getLog().replace(Regex("\\d"), "").toUnixString() ) assertEquals(requests, requestListInUI) diff --git a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatterTest.kt b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatterTest.kt index 8b5bf1bd6..5964f4383 100644 --- a/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatterTest.kt +++ b/idea-plugin/src/test/kotlin/com/itangcent/idea/plugin/api/export/postman/PostmanFormatterTest.kt @@ -73,15 +73,15 @@ internal class PostmanFormatterTest : PostmanSpringClassExporterBaseTest() { }) } assertEquals( - "{\"request\":{\"method\":\"GET\",\"description\":\"\",\"header\":[{\"key\":\"token\",\"value\":\"\",\"type\":\"text\",\"description\":\"auth token\"}],\"url\":{\"path\":[\"user\",\"ctrl\",\"name\"],\"query\":[],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/ctrl/name\"}},\"response\":[{\"originalRequest\":{\"method\":\"GET\",\"description\":\"\",\"header\":[{\"key\":\"token\",\"value\":\"\",\"type\":\"text\",\"description\":\"auth token\"}],\"url\":{\"path\":[\"user\",\"ctrl\",\"name\"],\"query\":[],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/ctrl/name\"}},\"_postman_previewlanguage\":\"json\",\"code\":200,\"name\":\"current ctrl name-Example\",\"header\":[{\"name\":\"date\",\"key\":\"date\",\"value\":\"$date\",\"description\":\"The date and time that the message was sent\"},{\"name\":\"server\",\"key\":\"server\",\"value\":\"Apache-Coyote/1.1\",\"description\":\"A name for the server\"},{\"name\":\"transfer-encoding\",\"key\":\"transfer-encoding\",\"value\":\"chunked\",\"description\":\"The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity.\"},{\"name\":\"content-type\",\"key\":\"content-type\",\"value\":\"application/json;charset=UTF-8\"}],\"body\":\"\"}],\"name\":\"current ctrl name\",\"event\":[{\"listen\":\"prerequest\",\"script\":{\"exec\":[\"pm.environment.set(\\\"token\\\", \\\"123456\\\");\"],\"type\":\"text/javascript\"}},{\"listen\":\"test\",\"script\":{\"exec\":[\"pm.test(\\\"Successful POST request\\\", function () {\",\"pm.expect(pm.response.code).to.be.oneOf([201,202]);\",\"});\"],\"type\":\"text/javascript\"}}]}", + "{\"request\":{\"method\":\"GET\",\"description\":\"\",\"header\":[{\"key\":\"token\",\"value\":\"\",\"type\":\"text\",\"description\":\"auth token\"}],\"url\":{\"path\":[\"user\",\"ctrl\",\"name\"],\"query\":[],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/ctrl/name\"}},\"response\":[{\"name\":\"current ctrl name-Example\",\"originalRequest\":{\"method\":\"GET\",\"description\":\"\",\"header\":[{\"key\":\"token\",\"value\":\"\",\"type\":\"text\",\"description\":\"auth token\"}],\"url\":{\"path\":[\"user\",\"ctrl\",\"name\"],\"query\":[],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/ctrl/name\"}},\"code\":200,\"_postman_previewlanguage\":\"json\",\"header\":[{\"name\":\"date\",\"key\":\"date\",\"value\":\"$date\",\"description\":\"The date and time that the message was sent\"},{\"name\":\"server\",\"key\":\"server\",\"value\":\"Apache-Coyote/1.1\",\"description\":\"A name for the server\"},{\"name\":\"transfer-encoding\",\"key\":\"transfer-encoding\",\"value\":\"chunked\",\"description\":\"The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity.\"},{\"name\":\"content-type\",\"key\":\"content-type\",\"value\":\"application/json;charset=UTF-8\"}],\"body\":\"\"}],\"name\":\"current ctrl name\",\"event\":[{\"listen\":\"prerequest\",\"script\":{\"exec\":[\"pm.environment.set(\\\"token\\\", \\\"123456\\\");\"],\"type\":\"text/javascript\"}},{\"listen\":\"test\",\"script\":{\"exec\":[\"pm.test(\\\"Successful POST request\\\", function () {\",\"pm.expect(pm.response.code).to.be.oneOf([201,202]);\",\"});\"],\"type\":\"text/javascript\"}}]}", postmanFormatter.request2Item(requests[0]).toJson()!!.toUnixString() ) assertEquals( - "{\"request\":{\"method\":\"GET\",\"description\":\"not update anything\",\"header\":[],\"url\":{\"path\":[\"user\",\"greeting\"],\"query\":[],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/greeting\"}},\"response\":[{\"originalRequest\":{\"method\":\"GET\",\"description\":\"not update anything\",\"header\":[],\"url\":{\"path\":[\"user\",\"greeting\"],\"query\":[],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/greeting\"}},\"_postman_previewlanguage\":\"json\",\"code\":200,\"name\":\"say hello-Example\",\"header\":[{\"name\":\"date\",\"key\":\"date\",\"value\":\"$date\",\"description\":\"The date and time that the message was sent\"},{\"name\":\"server\",\"key\":\"server\",\"value\":\"Apache-Coyote/1.1\",\"description\":\"A name for the server\"},{\"name\":\"transfer-encoding\",\"key\":\"transfer-encoding\",\"value\":\"chunked\",\"description\":\"The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity.\"},{\"name\":\"content-type\",\"key\":\"content-type\",\"value\":\"application/json;charset=UTF-8\"}],\"body\":\"\"}],\"name\":\"say hello\",\"event\":[{\"listen\":\"prerequest\",\"script\":{\"exec\":[\"pm.environment.set(\\\"token\\\", \\\"123456\\\");\"],\"type\":\"text/javascript\"}},{\"listen\":\"test\",\"script\":{\"exec\":[\"pm.test(\\\"Successful POST request\\\", function () {\",\"pm.expect(pm.response.code).to.be.oneOf([201,202]);\",\"});\"],\"type\":\"text/javascript\"}}]}", + "{\"request\":{\"method\":\"GET\",\"description\":\"not update anything\",\"header\":[],\"url\":{\"path\":[\"user\",\"greeting\"],\"query\":[],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/greeting\"}},\"response\":[{\"name\":\"say hello-Example\",\"originalRequest\":{\"method\":\"GET\",\"description\":\"not update anything\",\"header\":[],\"url\":{\"path\":[\"user\",\"greeting\"],\"query\":[],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/greeting\"}},\"code\":200,\"_postman_previewlanguage\":\"json\",\"header\":[{\"name\":\"date\",\"key\":\"date\",\"value\":\"$date\",\"description\":\"The date and time that the message was sent\"},{\"name\":\"server\",\"key\":\"server\",\"value\":\"Apache-Coyote/1.1\",\"description\":\"A name for the server\"},{\"name\":\"transfer-encoding\",\"key\":\"transfer-encoding\",\"value\":\"chunked\",\"description\":\"The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity.\"},{\"name\":\"content-type\",\"key\":\"content-type\",\"value\":\"application/json;charset=UTF-8\"}],\"body\":\"\"}],\"name\":\"say hello\",\"event\":[{\"listen\":\"prerequest\",\"script\":{\"exec\":[\"pm.environment.set(\\\"token\\\", \\\"123456\\\");\"],\"type\":\"text/javascript\"}},{\"listen\":\"test\",\"script\":{\"exec\":[\"pm.test(\\\"Successful POST request\\\", function () {\",\"pm.expect(pm.response.code).to.be.oneOf([201,202]);\",\"});\"],\"type\":\"text/javascript\"}}]}", postmanFormatter.request2Item(requests[1]).toJson()!!.toUnixString() ) assertEquals( - "{\"request\":{\"method\":\"GET\",\"description\":\"\",\"header\":[{\"key\":\"token\",\"value\":\"\",\"type\":\"text\",\"description\":\"auth token\"}],\"url\":{\"path\":[\"user\",\"get\",\":id\"],\"query\":[{\"key\":\"id\",\"value\":\"\",\"equals\":true,\"description\":\"user id\"}],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/get/{id}\"}},\"response\":[{\"originalRequest\":{\"method\":\"GET\",\"description\":\"\",\"header\":[{\"key\":\"token\",\"value\":\"\",\"type\":\"text\",\"description\":\"auth token\"}],\"url\":{\"path\":[\"user\",\"get\",\":id\"],\"query\":[{\"key\":\"id\",\"value\":\"\",\"equals\":true,\"description\":\"user id\"}],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/get/{id}\"}},\"_postman_previewlanguage\":\"json\",\"code\":200,\"name\":\"get user info-Example\",\"header\":[{\"name\":\"date\",\"key\":\"date\",\"value\":\"$date\",\"description\":\"The date and time that the message was sent\"},{\"name\":\"server\",\"key\":\"server\",\"value\":\"Apache-Coyote/1.1\",\"description\":\"A name for the server\"},{\"name\":\"transfer-encoding\",\"key\":\"transfer-encoding\",\"value\":\"chunked\",\"description\":\"The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity.\"},{\"name\":\"content-type\",\"key\":\"content-type\",\"value\":\"application/json;charset=UTF-8\"}],\"body\":\"{\\n \\\"code\\\": 0,\\n \\\"msg\\\": \\\"success\\\",\\n \\\"data\\\": {\\n \\\"id\\\": 0,\\n \\\"type\\\": 0,\\n \\\"name\\\": \\\"Tony Stark\\\",\\n \\\"age\\\": 45,\\n \\\"sex\\\": 0,\\n \\\"birthDay\\\": \\\"\\\",\\n \\\"regtime\\\": \\\"\\\"\\n }\\n}\"}],\"name\":\"get user info\",\"event\":[{\"listen\":\"prerequest\",\"script\":{\"exec\":[\"pm.environment.set(\\\"token\\\", \\\"123456\\\");\"],\"type\":\"text/javascript\"}},{\"listen\":\"test\",\"script\":{\"exec\":[\"pm.test(\\\"Successful POST request\\\", function () {\",\"pm.expect(pm.response.code).to.be.oneOf([201,202]);\",\"});\"],\"type\":\"text/javascript\"}}]}", + "{\"request\":{\"method\":\"GET\",\"description\":\"\",\"header\":[{\"key\":\"token\",\"value\":\"\",\"type\":\"text\",\"description\":\"auth token\"}],\"url\":{\"path\":[\"user\",\"get\",\":id\"],\"query\":[{\"key\":\"id\",\"value\":\"\",\"equals\":true,\"description\":\"user id\"}],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/get/{id}\"}},\"response\":[{\"name\":\"get user info-Example\",\"originalRequest\":{\"method\":\"GET\",\"description\":\"\",\"header\":[{\"key\":\"token\",\"value\":\"\",\"type\":\"text\",\"description\":\"auth token\"}],\"url\":{\"path\":[\"user\",\"get\",\":id\"],\"query\":[{\"key\":\"id\",\"value\":\"\",\"equals\":true,\"description\":\"user id\"}],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/get/{id}\"}},\"code\":200,\"_postman_previewlanguage\":\"json\",\"header\":[{\"name\":\"date\",\"key\":\"date\",\"value\":\"$date\",\"description\":\"The date and time that the message was sent\"},{\"name\":\"server\",\"key\":\"server\",\"value\":\"Apache-Coyote/1.1\",\"description\":\"A name for the server\"},{\"name\":\"transfer-encoding\",\"key\":\"transfer-encoding\",\"value\":\"chunked\",\"description\":\"The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity.\"},{\"name\":\"content-type\",\"key\":\"content-type\",\"value\":\"application/json;charset=UTF-8\"}],\"body\":\"{\\n \\\"code\\\": 0,\\n \\\"msg\\\": \\\"success\\\",\\n \\\"data\\\": {\\n \\\"id\\\": 0,\\n \\\"type\\\": 0,\\n \\\"name\\\": \\\"Tony Stark\\\",\\n \\\"age\\\": 45,\\n \\\"sex\\\": 0,\\n \\\"birthDay\\\": \\\"\\\",\\n \\\"regtime\\\": \\\"\\\"\\n }\\n}\"}],\"name\":\"get user info\",\"event\":[{\"listen\":\"prerequest\",\"script\":{\"exec\":[\"pm.environment.set(\\\"token\\\", \\\"123456\\\");\"],\"type\":\"text/javascript\"}},{\"listen\":\"test\",\"script\":{\"exec\":[\"pm.test(\\\"Successful POST request\\\", function () {\",\"pm.expect(pm.response.code).to.be.oneOf([201,202]);\",\"});\"],\"type\":\"text/javascript\"}}]}", postmanFormatter.request2Item(requests[2]).toJson()!!.toUnixString() ) } @@ -98,15 +98,15 @@ internal class PostmanFormatterTest : PostmanSpringClassExporterBaseTest() { }) } assertEquals( - "{\"request\":{\"method\":\"GET\",\"description\":\"\",\"header\":[{\"key\":\"token\",\"value\":\"\",\"type\":\"text\",\"description\":\"auth token\"}],\"url\":{\"path\":[\"user\",\"ctrl\",\"name\"],\"query\":[],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/ctrl/name\"}},\"response\":[{\"originalRequest\":{\"method\":\"GET\",\"description\":\"\",\"header\":[{\"key\":\"token\",\"value\":\"\",\"type\":\"text\",\"description\":\"auth token\"}],\"url\":{\"path\":[\"user\",\"ctrl\",\"name\"],\"query\":[],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/ctrl/name\"}},\"_postman_previewlanguage\":\"json\",\"code\":200,\"name\":\"current ctrl name-Example\",\"header\":[{\"name\":\"date\",\"key\":\"date\",\"value\":\"$date\",\"description\":\"The date and time that the message was sent\"},{\"name\":\"server\",\"key\":\"server\",\"value\":\"Apache-Coyote/1.1\",\"description\":\"A name for the server\"},{\"name\":\"transfer-encoding\",\"key\":\"transfer-encoding\",\"value\":\"chunked\",\"description\":\"The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity.\"},{\"name\":\"content-type\",\"key\":\"content-type\",\"value\":\"application/json;charset=UTF-8\"}],\"body\":\"\\\"\\\"\"}],\"name\":\"current ctrl name\",\"event\":[{\"listen\":\"prerequest\",\"script\":{\"exec\":[\"pm.environment.set(\\\"token\\\", \\\"123456\\\");\"],\"type\":\"text/javascript\"}},{\"listen\":\"test\",\"script\":{\"exec\":[\"pm.test(\\\"Successful POST request\\\", function () {\",\"pm.expect(pm.response.code).to.be.oneOf([201,202]);\",\"});\"],\"type\":\"text/javascript\"}}]}", + "{\"request\":{\"method\":\"GET\",\"description\":\"\",\"header\":[{\"key\":\"token\",\"value\":\"\",\"type\":\"text\",\"description\":\"auth token\"}],\"url\":{\"path\":[\"user\",\"ctrl\",\"name\"],\"query\":[],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/ctrl/name\"}},\"response\":[{\"name\":\"current ctrl name-Example\",\"originalRequest\":{\"method\":\"GET\",\"description\":\"\",\"header\":[{\"key\":\"token\",\"value\":\"\",\"type\":\"text\",\"description\":\"auth token\"}],\"url\":{\"path\":[\"user\",\"ctrl\",\"name\"],\"query\":[],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/ctrl/name\"}},\"code\":200,\"_postman_previewlanguage\":\"json\",\"header\":[{\"name\":\"date\",\"key\":\"date\",\"value\":\"$date\",\"description\":\"The date and time that the message was sent\"},{\"name\":\"server\",\"key\":\"server\",\"value\":\"Apache-Coyote/1.1\",\"description\":\"A name for the server\"},{\"name\":\"transfer-encoding\",\"key\":\"transfer-encoding\",\"value\":\"chunked\",\"description\":\"The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity.\"},{\"name\":\"content-type\",\"key\":\"content-type\",\"value\":\"application/json;charset=UTF-8\"}],\"body\":\"\\\"\\\"\"}],\"name\":\"current ctrl name\",\"event\":[{\"listen\":\"prerequest\",\"script\":{\"exec\":[\"pm.environment.set(\\\"token\\\", \\\"123456\\\");\"],\"type\":\"text/javascript\"}},{\"listen\":\"test\",\"script\":{\"exec\":[\"pm.test(\\\"Successful POST request\\\", function () {\",\"pm.expect(pm.response.code).to.be.oneOf([201,202]);\",\"});\"],\"type\":\"text/javascript\"}}]}", postmanFormatter.request2Item(requests[0]).toJson()!!.toUnixString() ) assertEquals( - "{\"request\":{\"method\":\"GET\",\"description\":\"not update anything\",\"header\":[],\"url\":{\"path\":[\"user\",\"greeting\"],\"query\":[],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/greeting\"}},\"response\":[{\"originalRequest\":{\"method\":\"GET\",\"description\":\"not update anything\",\"header\":[],\"url\":{\"path\":[\"user\",\"greeting\"],\"query\":[],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/greeting\"}},\"_postman_previewlanguage\":\"json\",\"code\":200,\"name\":\"say hello-Example\",\"header\":[{\"name\":\"date\",\"key\":\"date\",\"value\":\"$date\",\"description\":\"The date and time that the message was sent\"},{\"name\":\"server\",\"key\":\"server\",\"value\":\"Apache-Coyote/1.1\",\"description\":\"A name for the server\"},{\"name\":\"transfer-encoding\",\"key\":\"transfer-encoding\",\"value\":\"chunked\",\"description\":\"The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity.\"},{\"name\":\"content-type\",\"key\":\"content-type\",\"value\":\"application/json;charset=UTF-8\"}],\"body\":\"\\\"\\\"\"}],\"name\":\"say hello\",\"event\":[{\"listen\":\"prerequest\",\"script\":{\"exec\":[\"pm.environment.set(\\\"token\\\", \\\"123456\\\");\"],\"type\":\"text/javascript\"}},{\"listen\":\"test\",\"script\":{\"exec\":[\"pm.test(\\\"Successful POST request\\\", function () {\",\"pm.expect(pm.response.code).to.be.oneOf([201,202]);\",\"});\"],\"type\":\"text/javascript\"}}]}", + "{\"request\":{\"method\":\"GET\",\"description\":\"not update anything\",\"header\":[],\"url\":{\"path\":[\"user\",\"greeting\"],\"query\":[],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/greeting\"}},\"response\":[{\"name\":\"say hello-Example\",\"originalRequest\":{\"method\":\"GET\",\"description\":\"not update anything\",\"header\":[],\"url\":{\"path\":[\"user\",\"greeting\"],\"query\":[],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/greeting\"}},\"code\":200,\"_postman_previewlanguage\":\"json\",\"header\":[{\"name\":\"date\",\"key\":\"date\",\"value\":\"$date\",\"description\":\"The date and time that the message was sent\"},{\"name\":\"server\",\"key\":\"server\",\"value\":\"Apache-Coyote/1.1\",\"description\":\"A name for the server\"},{\"name\":\"transfer-encoding\",\"key\":\"transfer-encoding\",\"value\":\"chunked\",\"description\":\"The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity.\"},{\"name\":\"content-type\",\"key\":\"content-type\",\"value\":\"application/json;charset=UTF-8\"}],\"body\":\"\\\"\\\"\"}],\"name\":\"say hello\",\"event\":[{\"listen\":\"prerequest\",\"script\":{\"exec\":[\"pm.environment.set(\\\"token\\\", \\\"123456\\\");\"],\"type\":\"text/javascript\"}},{\"listen\":\"test\",\"script\":{\"exec\":[\"pm.test(\\\"Successful POST request\\\", function () {\",\"pm.expect(pm.response.code).to.be.oneOf([201,202]);\",\"});\"],\"type\":\"text/javascript\"}}]}", postmanFormatter.request2Item(requests[1]).toJson()!!.toUnixString() ) assertEquals( - "{\"request\":{\"method\":\"GET\",\"description\":\"\",\"header\":[{\"key\":\"token\",\"value\":\"\",\"type\":\"text\",\"description\":\"auth token\"}],\"url\":{\"path\":[\"user\",\"get\",\":id\"],\"query\":[{\"key\":\"id\",\"value\":\"\",\"equals\":true,\"description\":\"user id\"}],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/get/{id}\"}},\"response\":[{\"originalRequest\":{\"method\":\"GET\",\"description\":\"\",\"header\":[{\"key\":\"token\",\"value\":\"\",\"type\":\"text\",\"description\":\"auth token\"}],\"url\":{\"path\":[\"user\",\"get\",\":id\"],\"query\":[{\"key\":\"id\",\"value\":\"\",\"equals\":true,\"description\":\"user id\"}],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/get/{id}\"}},\"_postman_previewlanguage\":\"json\",\"code\":200,\"name\":\"get user info-Example\",\"header\":[{\"name\":\"date\",\"key\":\"date\",\"value\":\"$date\",\"description\":\"The date and time that the message was sent\"},{\"name\":\"server\",\"key\":\"server\",\"value\":\"Apache-Coyote/1.1\",\"description\":\"A name for the server\"},{\"name\":\"transfer-encoding\",\"key\":\"transfer-encoding\",\"value\":\"chunked\",\"description\":\"The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity.\"},{\"name\":\"content-type\",\"key\":\"content-type\",\"value\":\"application/json;charset=UTF-8\"}],\"body\":\"{\\n \\\"code\\\": 0, //response code\\n \\\"msg\\\": \\\"success\\\", //message\\n \\\"data\\\": { //response data\\n \\\"id\\\": 0, //user id\\n /**\\n * user type\\n * 1 :administration\\n * 2 :a person, an animal or a plant\\n * 3 :Anonymous visitor\\n */\\n \\\"type\\\": 0,\\n \\\"name\\\": \\\"Tony Stark\\\", //user name\\n \\\"age\\\": 45, //user age\\n \\\"sex\\\": 0,\\n \\\"birthDay\\\": \\\"\\\", //user birthDay\\n \\\"regtime\\\": \\\"\\\" //user regtime\\n }\\n}\"}],\"name\":\"get user info\",\"event\":[{\"listen\":\"prerequest\",\"script\":{\"exec\":[\"pm.environment.set(\\\"token\\\", \\\"123456\\\");\"],\"type\":\"text/javascript\"}},{\"listen\":\"test\",\"script\":{\"exec\":[\"pm.test(\\\"Successful POST request\\\", function () {\",\"pm.expect(pm.response.code).to.be.oneOf([201,202]);\",\"});\"],\"type\":\"text/javascript\"}}]}", + "{\"request\":{\"method\":\"GET\",\"description\":\"\",\"header\":[{\"key\":\"token\",\"value\":\"\",\"type\":\"text\",\"description\":\"auth token\"}],\"url\":{\"path\":[\"user\",\"get\",\":id\"],\"query\":[{\"key\":\"id\",\"value\":\"\",\"equals\":true,\"description\":\"user id\"}],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/get/{id}\"}},\"response\":[{\"name\":\"get user info-Example\",\"originalRequest\":{\"method\":\"GET\",\"description\":\"\",\"header\":[{\"key\":\"token\",\"value\":\"\",\"type\":\"text\",\"description\":\"auth token\"}],\"url\":{\"path\":[\"user\",\"get\",\":id\"],\"query\":[{\"key\":\"id\",\"value\":\"\",\"equals\":true,\"description\":\"user id\"}],\"host\":\"{{test_default}}\",\"raw\":\"{{test_default}}/user/get/{id}\"}},\"code\":200,\"_postman_previewlanguage\":\"json\",\"header\":[{\"name\":\"date\",\"key\":\"date\",\"value\":\"$date\",\"description\":\"The date and time that the message was sent\"},{\"name\":\"server\",\"key\":\"server\",\"value\":\"Apache-Coyote/1.1\",\"description\":\"A name for the server\"},{\"name\":\"transfer-encoding\",\"key\":\"transfer-encoding\",\"value\":\"chunked\",\"description\":\"The form of encoding used to safely transfer the entity to the user. Currently defined methods are: chunked, compress, deflate, gzip, identity.\"},{\"name\":\"content-type\",\"key\":\"content-type\",\"value\":\"application/json;charset=UTF-8\"}],\"body\":\"{\\n \\\"code\\\": 0, //response code\\n \\\"msg\\\": \\\"success\\\", //message\\n \\\"data\\\": { //response data\\n \\\"id\\\": 0, //user id\\n /**\\n * user type\\n * 1 :administration\\n * 2 :a person, an animal or a plant\\n * 3 :Anonymous visitor\\n */\\n \\\"type\\\": 0,\\n \\\"name\\\": \\\"Tony Stark\\\", //user name\\n \\\"age\\\": 45, //user age\\n \\\"sex\\\": 0,\\n \\\"birthDay\\\": \\\"\\\", //user birthDay\\n \\\"regtime\\\": \\\"\\\" //user regtime\\n }\\n}\"}],\"name\":\"get user info\",\"event\":[{\"listen\":\"prerequest\",\"script\":{\"exec\":[\"pm.environment.set(\\\"token\\\", \\\"123456\\\");\"],\"type\":\"text/javascript\"}},{\"listen\":\"test\",\"script\":{\"exec\":[\"pm.test(\\\"Successful POST request\\\", function () {\",\"pm.expect(pm.response.code).to.be.oneOf([201,202]);\",\"});\"],\"type\":\"text/javascript\"}}]}", postmanFormatter.request2Item(requests[2]).toJson()!!.toUnixString() ) } diff --git a/idea-plugin/src/test/kotlin/com/itangcent/idea/utils/KVKitTest.kt b/idea-plugin/src/test/kotlin/com/itangcent/idea/utils/KVKitTest.kt index 4f3b87aa8..5d1ae9984 100644 --- a/idea-plugin/src/test/kotlin/com/itangcent/idea/utils/KVKitTest.kt +++ b/idea-plugin/src/test/kotlin/com/itangcent/idea/utils/KVKitTest.kt @@ -5,7 +5,6 @@ import com.itangcent.intellij.util.* import org.junit.* import org.junit.jupiter.api.Assertions.* import org.junit.jupiter.api.Test -import java.util.function.BiConsumer /** @@ -15,20 +14,20 @@ class KVKitTest { @Test fun testForEachValid() { - KV.by("a", "A").forEachValid(BiConsumer { t, u -> + KV.by("a", "A").forEachValid { t, u -> assertEquals("a", t) assertEquals("A", u) - }) + } - KV.by("", "A").forEachValid(BiConsumer { t, u -> + KV.by("", "A").forEachValid { t, u -> assertEquals("key", t) assertEquals("A", u) - }) + } - KV.by("a", "A").set("@a", "").forEachValid(BiConsumer { t, u -> + linkedMapOf("a" to "A", "@a" to "").forEachValid { t, u -> assertEquals("a", t) assertEquals("A", u) - }) + } KV.by("a", "A").forEachValid { t, u -> assertEquals("a", t) @@ -40,7 +39,7 @@ class KVKitTest { assertEquals("A", u) } - KV.by("a", "A").set("@a", "").forEachValid { t, u -> + linkedMapOf("a" to "A", "@a" to "").forEachValid { t, u -> assertEquals("a", t) assertEquals("A", u) } diff --git a/idea-plugin/src/test/kotlin/com/itangcent/intellij/config/AutoSearchConfigReaderTest.kt b/idea-plugin/src/test/kotlin/com/itangcent/intellij/config/AutoSearchConfigReaderTest.kt index 8c1808218..1bb274487 100644 --- a/idea-plugin/src/test/kotlin/com/itangcent/intellij/config/AutoSearchConfigReaderTest.kt +++ b/idea-plugin/src/test/kotlin/com/itangcent/intellij/config/AutoSearchConfigReaderTest.kt @@ -8,7 +8,7 @@ import com.itangcent.intellij.extend.guice.with import com.itangcent.intellij.psi.ContextSwitchListener import com.itangcent.mock.AdvancedContextTest import com.itangcent.utils.Initializable -import com.itangcent.utils.ResourceUtils +import com.itangcent.common.utils.ResourceUtils import org.mockito.Mockito import java.io.File import kotlin.reflect.KClass diff --git a/idea-plugin/src/test/kotlin/com/itangcent/utils/ResourceUtilsTest.kt b/idea-plugin/src/test/kotlin/com/itangcent/utils/ResourceUtilsTest.kt deleted file mode 100644 index 05017b9ab..000000000 --- a/idea-plugin/src/test/kotlin/com/itangcent/utils/ResourceUtilsTest.kt +++ /dev/null @@ -1,47 +0,0 @@ -package com.itangcent.utils - -import org.junit.jupiter.api.Assertions.assertEquals -import org.junit.jupiter.api.Assertions.assertNotNull -import org.junit.jupiter.api.Test -import java.net.URL -import kotlin.test.assertNull - - -/** - * Test case for [ResourceUtils] - * - * @author tangcent - */ -class ResourceUtilsTest { - - @Test - fun testReadResource() { - // Test reading a valid resource - val contents = ResourceUtils.readResource("demo.properties") - assertEquals("token=111111", contents) - - // Test reading a non-existent resource - val nonExistentContents = ResourceUtils.readResource("does-not-exist.properties") - assertEquals("", nonExistentContents) - - // Test reading the same resource twice to ensure caching - val cachedContents = ResourceUtils.readResource("demo.properties") - assertEquals("token=111111", cachedContents) - } - - @Test - fun testFindResource() { - // Test finding a valid resource - val resourceURL: URL? = ResourceUtils.findResource("demo.properties") - assertNotNull(resourceURL) - - // Test finding a non-existent resource - val nonExistentResourceURL: URL? = ResourceUtils.findResource("does-not-exist.properties") - assertNull(nonExistentResourceURL) - - // Test finding the same resource URL twice to ensure caching - val cachedResourceURL: URL? = ResourceUtils.findResource("demo.properties") - assertNotNull(cachedResourceURL) - assertEquals(resourceURL, cachedResourceURL) - } -} \ No newline at end of file diff --git a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.call.ApiCallerTest.ExportFailedApiCallerTest.txt b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.call.ApiCallerTest.ExportFailedApiCallerTest.txt index 71570f99e..c719c6262 100644 --- a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.call.ApiCallerTest.ExportFailedApiCallerTest.txt +++ b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.call.ApiCallerTest.ExportFailedApiCallerTest.txt @@ -1,4 +1,4 @@ -[INFO] Start find apis... +[INFO] Start export api... [ERROR] Apis exported failed [TRACE] java.lang.RuntimeException: export time out diff --git a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.DirectorySpringPostmanApiExporterTest.txt b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.DirectorySpringPostmanApiExporterTest.txt index 7da1d7973..f16e33978 100644 --- a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.DirectorySpringPostmanApiExporterTest.txt +++ b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.DirectorySpringPostmanApiExporterTest.txt @@ -27,6 +27,7 @@ }, "response": [ { + "name": "current ctrl name-Example", "originalRequest": { "method": "GET", "description": "", @@ -49,9 +50,8 @@ "raw": "{{test_default}}/test/ctrl/name" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "current ctrl name-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -113,6 +113,7 @@ }, "response": [ { + "name": "test RequestHeader-Example", "originalRequest": { "method": "GET", "description": "", @@ -141,9 +142,8 @@ "raw": "{{test_default}}/test/header" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "test RequestHeader-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -211,6 +211,7 @@ }, "response": [ { + "name": "test query with array parameters-Example", "originalRequest": { "method": "GET", "description": "", @@ -245,9 +246,8 @@ "raw": "{{test_default}}/test/arrays" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "test query with array parameters-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -302,6 +302,7 @@ }, "response": [ { + "name": "test ignored method-Example", "originalRequest": { "method": "GET", "description": "", @@ -323,9 +324,8 @@ "raw": "{{test_default}}/test/ignore" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "test ignored method-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -380,6 +380,7 @@ }, "response": [ { + "name": "test query with javax.servlet.http.HttpServletRequest-Example", "originalRequest": { "method": "GET", "description": "", @@ -401,9 +402,8 @@ "raw": "{{test_default}}/test/httpServletRequest" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "test query with javax.servlet.http.HttpServletRequest-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -458,6 +458,7 @@ }, "response": [ { + "name": "test query with javax.servlet.http.HttpServletResponse-Example", "originalRequest": { "method": "GET", "description": "", @@ -479,9 +480,8 @@ "raw": "{{test_default}}/test/httpServletResponse" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "test query with javax.servlet.http.HttpServletResponse-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -537,6 +537,7 @@ }, "response": [ { + "name": "test api return void-Example", "originalRequest": { "method": "GET", "description": "", @@ -559,9 +560,8 @@ "raw": "{{test_default}}/test/return/void" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "test api return void-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -617,6 +617,7 @@ }, "response": [ { + "name": "test api return Void-Example", "originalRequest": { "method": "GET", "description": "", @@ -639,9 +640,8 @@ "raw": "{{test_default}}/test/return/Void" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "test api return Void-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -698,6 +698,7 @@ }, "response": [ { + "name": "test api return Result-Example", "originalRequest": { "method": "GET", "description": "", @@ -721,9 +722,8 @@ "raw": "{{test_default}}/test/return/result/Void" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "test api return Result-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -779,6 +779,7 @@ }, "response": [ { + "name": "test api return Enum-Example", "originalRequest": { "method": "GET", "description": "", @@ -801,9 +802,8 @@ "raw": "{{test_default}}/test/return/enum" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "test api return Enum-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -860,6 +860,7 @@ }, "response": [ { + "name": "test api return Result-Example", "originalRequest": { "method": "GET", "description": "", @@ -883,9 +884,8 @@ "raw": "{{test_default}}/test/return/result/enum" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "test api return Result-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -942,6 +942,7 @@ }, "response": [ { + "name": "test api return Enum field-Example", "originalRequest": { "method": "GET", "description": "", @@ -965,9 +966,8 @@ "raw": "{{test_default}}/test/return/enum/field" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "test api return Enum field-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -1025,6 +1025,7 @@ }, "response": [ { + "name": "test api return Result-Example", "originalRequest": { "method": "GET", "description": "", @@ -1049,9 +1050,8 @@ "raw": "{{test_default}}/test/return/result/enum/field" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "test api return Result-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -1107,6 +1107,7 @@ }, "response": [ { + "name": "return nested node-Example", "originalRequest": { "method": "GET", "description": "", @@ -1129,9 +1130,8 @@ "raw": "{{test_default}}/test/return/node" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "return nested node-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -1187,6 +1187,7 @@ }, "response": [ { + "name": "return root with nested nodes-Example", "originalRequest": { "method": "GET", "description": "", @@ -1209,9 +1210,8 @@ "raw": "{{test_default}}/test/return/root" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "return root with nested nodes-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -1267,6 +1267,7 @@ }, "response": [ { + "name": "return customMap-Example", "originalRequest": { "method": "GET", "description": "", @@ -1289,9 +1290,8 @@ "raw": "{{test_default}}/test/return/customMap" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "return customMap-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -1348,6 +1348,7 @@ }, "response": [ { + "name": "user page query-Example", "originalRequest": { "method": "GET", "description": "", @@ -1371,9 +1372,8 @@ "raw": "{{test_default}}/test/call/page/user" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "user page query-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -1437,6 +1437,7 @@ }, "response": [ { + "name": "user page query with ModelAttribute-Example", "originalRequest": { "method": "POST", "description": "", @@ -1467,9 +1468,8 @@ "raw": "{{test_default}}/test/call/page/user/form" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "user page query with ModelAttribute-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -1533,6 +1533,7 @@ }, "response": [ { + "name": "user page query with POST-Example", "originalRequest": { "method": "POST", "description": "", @@ -1563,9 +1564,8 @@ "raw": "{{test_default}}/test/call/page/user/post" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "user page query with POST-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -1666,6 +1666,7 @@ }, "response": [ { + "name": "user page query with array-Example", "originalRequest": { "method": "GET", "description": "", @@ -1733,9 +1734,8 @@ "raw": "{{test_default}}/test/call/page/user/array" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "user page query with array-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -1797,6 +1797,7 @@ }, "response": [ { + "name": "current ctrl name-Example", "originalRequest": { "method": "GET", "description": "", @@ -1819,9 +1820,8 @@ "raw": "{{test_default}}/user/ctrl/name" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "current ctrl name-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -1869,6 +1869,7 @@ }, "response": [ { + "name": "say hello-Example", "originalRequest": { "method": "GET", "description": "not update anything", @@ -1883,9 +1884,8 @@ "raw": "{{test_default}}/user/greeting" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "say hello-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -1948,6 +1948,7 @@ }, "response": [ { + "name": "get user info-Example", "originalRequest": { "method": "GET", "description": "", @@ -1977,9 +1978,8 @@ "raw": "{{test_default}}/user/get/{id}" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "get user info-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -2049,6 +2049,7 @@ }, "response": [ { + "name": "create an user-Example", "originalRequest": { "method": "POST", "description": "", @@ -2085,9 +2086,8 @@ "raw": "{{test_default}}/user/add" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "create an user-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -2195,6 +2195,7 @@ }, "response": [ { + "name": "update user info-Example", "originalRequest": { "method": "PUT", "description": "", @@ -2269,9 +2270,8 @@ "raw": "{{test_default}}/user/update" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "update user info-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", diff --git a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.ModeCopyPostmanApiExporterTest.txt b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.ModeCopyPostmanApiExporterTest.txt index f64c93670..3f2f6ca3a 100644 --- a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.ModeCopyPostmanApiExporterTest.txt +++ b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.ModeCopyPostmanApiExporterTest.txt @@ -25,6 +25,7 @@ }, "response": [ { + "name": "current ctrl name-Example", "originalRequest": { "method": "GET", "description": "", @@ -47,9 +48,8 @@ "raw": "{{test_default}}/user/ctrl/name" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "current ctrl name-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -97,6 +97,7 @@ }, "response": [ { + "name": "say hello-Example", "originalRequest": { "method": "GET", "description": "not update anything", @@ -111,9 +112,8 @@ "raw": "{{test_default}}/user/greeting" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "say hello-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -176,6 +176,7 @@ }, "response": [ { + "name": "get user info-Example", "originalRequest": { "method": "GET", "description": "", @@ -205,9 +206,8 @@ "raw": "{{test_default}}/user/get/{id}" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "get user info-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -277,6 +277,7 @@ }, "response": [ { + "name": "create an user-Example", "originalRequest": { "method": "POST", "description": "", @@ -313,9 +314,8 @@ "raw": "{{test_default}}/user/add" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "create an user-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -423,6 +423,7 @@ }, "response": [ { + "name": "update user info-Example", "originalRequest": { "method": "PUT", "description": "", @@ -497,9 +498,8 @@ "raw": "{{test_default}}/user/update" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "update user info-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", diff --git a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.ModeUpdatePostmanApiExporterTest.txt b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.ModeUpdatePostmanApiExporterTest.txt index b725f9a3a..9620e2975 100644 --- a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.ModeUpdatePostmanApiExporterTest.txt +++ b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.ModeUpdatePostmanApiExporterTest.txt @@ -19,6 +19,7 @@ }, "response": [ { + "name": "say hello-Example", "originalRequest": { "method": "GET", "description": "not update anything", @@ -33,9 +34,8 @@ "raw": "{{test_default}}/user/greeting" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "say hello-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -558,6 +558,7 @@ }, "response": [ { + "name": "current ctrl name-Example", "originalRequest": { "method": "GET", "description": "", @@ -580,9 +581,8 @@ "raw": "{{test_default}}/user/ctrl/name" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "current ctrl name-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -645,6 +645,7 @@ }, "response": [ { + "name": "get user info-Example", "originalRequest": { "method": "GET", "description": "", @@ -674,9 +675,8 @@ "raw": "{{test_default}}/user/get/{id}" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "get user info-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -746,6 +746,7 @@ }, "response": [ { + "name": "create an user-Example", "originalRequest": { "method": "POST", "description": "", @@ -782,9 +783,8 @@ "raw": "{{test_default}}/user/add" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "create an user-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -892,6 +892,7 @@ }, "response": [ { + "name": "update user info-Example", "originalRequest": { "method": "PUT", "description": "", @@ -966,9 +967,8 @@ "raw": "{{test_default}}/user/update" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "update user info-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", diff --git a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.SpringPostmanApiExporterTest.txt b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.SpringPostmanApiExporterTest.txt index f64c93670..3f2f6ca3a 100644 --- a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.SpringPostmanApiExporterTest.txt +++ b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanApiExporterTest.SpringPostmanApiExporterTest.txt @@ -25,6 +25,7 @@ }, "response": [ { + "name": "current ctrl name-Example", "originalRequest": { "method": "GET", "description": "", @@ -47,9 +48,8 @@ "raw": "{{test_default}}/user/ctrl/name" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "current ctrl name-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -97,6 +97,7 @@ }, "response": [ { + "name": "say hello-Example", "originalRequest": { "method": "GET", "description": "not update anything", @@ -111,9 +112,8 @@ "raw": "{{test_default}}/user/greeting" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "say hello-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -176,6 +176,7 @@ }, "response": [ { + "name": "get user info-Example", "originalRequest": { "method": "GET", "description": "", @@ -205,9 +206,8 @@ "raw": "{{test_default}}/user/get/{id}" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "get user info-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -277,6 +277,7 @@ }, "response": [ { + "name": "create an user-Example", "originalRequest": { "method": "POST", "description": "", @@ -313,9 +314,8 @@ "raw": "{{test_default}}/user/add" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "create an user-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -423,6 +423,7 @@ }, "response": [ { + "name": "update user info-Example", "originalRequest": { "method": "PUT", "description": "", @@ -497,9 +498,8 @@ "raw": "{{test_default}}/user/update" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "update user info-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", diff --git a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequests.txt b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequests.txt index 136938796..b8b8a8092 100644 --- a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequests.txt +++ b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequests.txt @@ -34,6 +34,7 @@ }, "response": [ { + "name": "get user info-Example", "originalRequest": { "method": "GET", "description": "", @@ -63,9 +64,8 @@ "raw": "{{test_default}}/user/get/{id}" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "get user info-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -149,6 +149,7 @@ }, "response": [ { + "name": "current ctrl name-Example", "originalRequest": { "method": "GET", "description": "", @@ -171,9 +172,8 @@ "raw": "{{test_default}}/user/ctrl/name" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "current ctrl name-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -243,6 +243,7 @@ }, "response": [ { + "name": "say hello-Example", "originalRequest": { "method": "GET", "description": "not update anything", @@ -257,9 +258,8 @@ "raw": "{{test_default}}/user/greeting" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "say hello-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -351,6 +351,7 @@ }, "response": [ { + "name": "create an user-Example", "originalRequest": { "method": "POST", "description": "", @@ -387,9 +388,8 @@ "raw": "{{test_default}}/user/add" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "create an user-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -519,6 +519,7 @@ }, "response": [ { + "name": "update user info-Example", "originalRequest": { "method": "PUT", "description": "", @@ -593,9 +594,8 @@ "raw": "{{test_default}}/user/update" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "update user info-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", diff --git a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsToCollection.txt b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsToCollection.txt index 58eff0a58..01726fbec 100644 --- a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsToCollection.txt +++ b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsToCollection.txt @@ -19,6 +19,7 @@ }, "response": [ { + "name": "say hello-Example", "originalRequest": { "method": "GET", "description": "not update anything", @@ -33,9 +34,8 @@ "raw": "{{test_default}}/user/greeting" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "say hello-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -558,6 +558,7 @@ }, "response": [ { + "name": "current ctrl name-Example", "originalRequest": { "method": "GET", "description": "", @@ -580,9 +581,8 @@ "raw": "{{test_default}}/user/ctrl/name" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "current ctrl name-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -674,6 +674,7 @@ }, "response": [ { + "name": "create an user-Example", "originalRequest": { "method": "POST", "description": "", @@ -710,9 +711,8 @@ "raw": "{{test_default}}/user/add" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "create an user-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -842,6 +842,7 @@ }, "response": [ { + "name": "update user info-Example", "originalRequest": { "method": "PUT", "description": "", @@ -916,9 +917,8 @@ "raw": "{{test_default}}/user/update" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "update user info-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -1009,6 +1009,7 @@ }, "response": [ { + "name": "get user info-Example", "originalRequest": { "method": "GET", "description": "", @@ -1038,9 +1039,8 @@ "raw": "{{test_default}}/user/get/{id}" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "get user info-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", diff --git a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsWithWrapCollection.txt b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsWithWrapCollection.txt index 420c06e34..b3430fa94 100644 --- a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsWithWrapCollection.txt +++ b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.postman.PostmanFormatterTest.testParseRequestsWithWrapCollection.txt @@ -36,6 +36,7 @@ }, "response": [ { + "name": "get user info-Example", "originalRequest": { "method": "GET", "description": "", @@ -65,9 +66,8 @@ "raw": "{{test_default}}/user/get/{id}" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "get user info-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -151,6 +151,7 @@ }, "response": [ { + "name": "current ctrl name-Example", "originalRequest": { "method": "GET", "description": "", @@ -173,9 +174,8 @@ "raw": "{{test_default}}/user/ctrl/name" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "current ctrl name-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -245,6 +245,7 @@ }, "response": [ { + "name": "say hello-Example", "originalRequest": { "method": "GET", "description": "not update anything", @@ -259,9 +260,8 @@ "raw": "{{test_default}}/user/greeting" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "say hello-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -353,6 +353,7 @@ }, "response": [ { + "name": "create an user-Example", "originalRequest": { "method": "POST", "description": "", @@ -389,9 +390,8 @@ "raw": "{{test_default}}/user/add" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "create an user-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", @@ -521,6 +521,7 @@ }, "response": [ { + "name": "update user info-Example", "originalRequest": { "method": "PUT", "description": "", @@ -595,9 +596,8 @@ "raw": "{{test_default}}/user/update" } }, - "_postman_previewlanguage": "json", "code": 200, - "name": "update user info-Example", + "_postman_previewlanguage": "json", "header": [ { "name": "date", diff --git a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.yapi.YapiApiExporterTest.DirectorySpringYapiApiExporterTest.log.txt b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.yapi.YapiApiExporterTest.DirectorySpringYapiApiExporterTest.log.txt index e51df8a99..c77af2813 100644 --- a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.yapi.YapiApiExporterTest.DirectorySpringYapiApiExporterTest.log.txt +++ b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.yapi.YapiApiExporterTest.DirectorySpringYapiApiExporterTest.log.txt @@ -1,4 +1,4 @@ -[INFO] Start find apis... +[INFO] Start export api... [INFO] search api from: com.itangcent.api.TestCtrl [INFO] search api from: com.itangcent.api.UserCtrl [INFO] Export to http://127.0.0.1:3088/project/12345/interface/api/cat_222222 success diff --git a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.yapi.YapiApiExporterTest.GenericMethodYapiApiExporterTest.log.txt b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.yapi.YapiApiExporterTest.GenericMethodYapiApiExporterTest.log.txt index 42f1ef824..764ed2e8a 100644 --- a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.yapi.YapiApiExporterTest.GenericMethodYapiApiExporterTest.log.txt +++ b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.yapi.YapiApiExporterTest.GenericMethodYapiApiExporterTest.log.txt @@ -1,4 +1,4 @@ -[INFO] Start find apis... +[INFO] Start export api... [INFO] search api from: com.itangcent.client.UserClient [INFO] Export to http://127.0.0.1:3088/project/12345/interface/api/cat_333333 success [INFO] Apis exported completed diff --git a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.yapi.YapiApiExporterTest.SpringYapiApiExporterTest.log.txt b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.yapi.YapiApiExporterTest.SpringYapiApiExporterTest.log.txt index 6cf85f627..d78d28453 100644 --- a/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.yapi.YapiApiExporterTest.SpringYapiApiExporterTest.log.txt +++ b/idea-plugin/src/test/resources/result/com.itangcent.idea.plugin.api.export.yapi.YapiApiExporterTest.SpringYapiApiExporterTest.log.txt @@ -1,4 +1,4 @@ -[INFO] Start find apis... +[INFO] Start export api... [INFO] search api from: com.itangcent.api.UserCtrl [INFO] Export to http://127.0.0.1:3088/project/12345/interface/api/cat_111111 success [INFO] try infer return type of method[com.itangcent.api.UserCtrl#get(java.lang.Long)]