feature/add_dynamic_endpoints_with_swagger: fix fail unit test.

This commit is contained in:
shuang 2020-03-30 14:51:00 +08:00
parent 8db9bab85b
commit 757506f3dd
2 changed files with 14 additions and 5 deletions

View File

@ -19,7 +19,7 @@ import scala.collection.mutable.ArrayBuffer
import scala.reflect.runtime.universe.{MethodSymbol, Type, typeOf}
import code.api.util.ErrorMessages.InvalidConnectorResponseForMissingRequiredValues
import code.api.util.APIUtil.fullBoxOrException
import com.openbankproject.commons.util.ApiVersion
import com.openbankproject.commons.util.{ApiVersion, ReflectUtils}
import com.openbankproject.commons.util.ReflectUtils._
import com.openbankproject.commons.util.Functions.Implicits._
import net.liftweb.util.ThreadGlobal
@ -193,7 +193,8 @@ package object bankconnectors extends MdcLoggable {
processObj match {
case None => None
case Some(value) => {
case Some(value) if ReflectUtils.isObpObject(value) => {
val argNameToValues: Map[String, Any] = getConstructorArgs(value)
//find from current object constructor args
// orElse: if current object constructor args not found value, recursive search args
@ -206,6 +207,8 @@ package object bankconnectors extends MdcLoggable {
.find(it => it.isDefined)
}
}
case _ => None
}
}

View File

@ -6,6 +6,7 @@ import java.net.URI
import code.bankconnectors.rest.RestConnector_vMar2019
import code.connector.RestConnector_vMar2019_FrozenUtil.{connectorMethodNames, persistFilePath, typeNameToFieldsInfo}
import com.openbankproject.commons.util.ReflectUtils
import net.liftweb.common.Logger
import org.apache.commons.io.IOUtils
import org.scalatest.matchers.{MatchResult, Matcher}
import org.scalatest.{BeforeAndAfter, FlatSpec, Matchers, Tag}
@ -19,14 +20,19 @@ import scala.reflect.runtime.universe._
class RestConnector_vMar2019_FrozenTest extends FlatSpec with Matchers with BeforeAndAfter {
private var connectorMethodNamesPersisted: List[String] = _
private var typeNameToFieldsInfoPersisted: Map[String, Map[String, String]] = _
private val logger = Logger(classOf[RestConnector_vMar2019_FrozenTest])
before {
val in = new ObjectInputStream(new FileInputStream(persistFilePath))
var in: ObjectInputStream = null
try {
in = new ObjectInputStream(new FileInputStream(persistFilePath))
in.readUTF()
connectorMethodNamesPersisted = in.readObject().asInstanceOf[List[String]]
typeNameToFieldsInfoPersisted = in.readObject().asInstanceOf[Map[String, Map[String, String]]]
} finally {
} catch {
case e: Throwable =>
logger.error("read frozen file fail.", e)
}finally {
IOUtils.closeQuietly(in)
}
}
@ -85,7 +91,7 @@ object RestConnector_vMar2019_FrozenUtil {
.filter(_.overrides.nonEmpty)
.filter(_.paramLists.flatten.nonEmpty)
.map(_.name.toString)
.toList
.toList.filterNot(_ == "dynamicEndpointProcess")
// typeNameToFieldsInfo sturcture is: (typeFullName, Map(fieldName->fieldTypeName))
val typeNameToFieldsInfo: Map[String, Map[String, String]] = {