test/fixed the failed test for getCustomerAccountLinksByAccountId

This commit is contained in:
hongwei 2022-12-12 10:13:08 +01:00
parent 5e77707507
commit 067601b653
9 changed files with 34 additions and 10 deletions

View File

@ -3797,8 +3797,8 @@ object NewStyle extends MdcLoggable{
i => (unboxFullOrFail(i._1, callContext, GetCustomerAccountLinksError), i._2)
}
def getCustomerAccountLinksByAccountId(accountId: String, callContext: Option[CallContext]): OBPReturnType[List[CustomerAccountLinkTrait]] =
Connector.connector.vend.getCustomerAccountLinksByAccountId(accountId: String, callContext: Option[CallContext]) map {
def getCustomerAccountLinksByBankIdAccountId(bankId: String, accountId: String, callContext: Option[CallContext]): OBPReturnType[List[CustomerAccountLinkTrait]] =
Connector.connector.vend.getCustomerAccountLinksByBankIdAccountId(bankId, accountId: String, callContext: Option[CallContext]) map {
i => (unboxFullOrFail(i._1, callContext, GetCustomerAccountLinksError), i._2)
}

View File

@ -1894,9 +1894,9 @@ trait APIMethods500 {
}
staticResourceDocs += ResourceDoc(
getCustomerAccountLinksByAccountId,
getCustomerAccountLinksByBankIdAccountId,
implementedInApiVersion,
nameOf(getCustomerAccountLinksByAccountId),
nameOf(getCustomerAccountLinksByBankIdAccountId),
"GET",
"/banks/BANK_ID/accounts/ACCOUNT_ID/customer-account-links",
"Get Customer Account Links by ACCOUNT_ID",
@ -1916,12 +1916,12 @@ trait APIMethods500 {
),
List(apiTagCustomer, apiTagNewStyle),
Some(List(canGetCustomerAccountLinks)))
lazy val getCustomerAccountLinksByAccountId : OBPEndpoint = {
case "banks" :: BankId(bankId) :: "accounts" :: accountId :: "customer-account-links" :: Nil JsonGet _ => {
lazy val getCustomerAccountLinksByBankIdAccountId : OBPEndpoint = {
case "banks" :: bankId :: "accounts" :: accountId :: "customer-account-links" :: Nil JsonGet _ => {
cc =>
for {
(_, _,callContext) <- SS.userBank
(customerAccountLinks, callContext) <- NewStyle.function.getCustomerAccountLinksByAccountId(accountId, callContext)
(customerAccountLinks, callContext) <- NewStyle.function.getCustomerAccountLinksByBankIdAccountId(bankId, accountId, callContext)
} yield {
(JSONFactory500.createCustomerAccountLinksJon(customerAccountLinks), HttpCode.`200`(callContext))
}

View File

@ -2603,7 +2603,7 @@ trait Connector extends MdcLoggable {
def getCustomerAccountLinksByCustomerId(customerId: String, callContext: Option[CallContext]): OBPReturnType[Box[List[CustomerAccountLinkTrait]]] = Future{(Failure(setUnimplementedError), callContext)}
def getCustomerAccountLinksByAccountId(accountId: String, callContext: Option[CallContext]): OBPReturnType[Box[List[CustomerAccountLinkTrait]]] = Future{(Failure(setUnimplementedError), callContext)}
def getCustomerAccountLinksByBankIdAccountId(bankId: String, accountId: String, callContext: Option[CallContext]): OBPReturnType[Box[List[CustomerAccountLinkTrait]]] = Future{(Failure(setUnimplementedError), callContext)}
def getCustomerAccountLinkById(customerAccountLinkId: String, callContext: Option[CallContext]): OBPReturnType[Box[CustomerAccountLinkTrait]] = Future{(Failure(setUnimplementedError), callContext)}

View File

@ -5700,6 +5700,10 @@ object LocalMappedConnector extends Connector with MdcLoggable {
(CustomerAccountLinkTrait.customerAccountLink.vend.getCustomerAccountLinkById(customerAccountLinkId),callContext)
}
override def getCustomerAccountLinksByBankIdAccountId(bankId: String, accountId: String, callContext: Option[CallContext])= Future{
(CustomerAccountLinkTrait.customerAccountLink.vend.getCustomerAccountLinksByBankIdAccountId(bankId, accountId),callContext)
}
override def deleteCustomerAccountLinkById(customerAccountLinkId: String, callContext: Option[CallContext]) =
CustomerAccountLinkTrait.customerAccountLink.vend.deleteCustomerAccountLinkById(customerAccountLinkId).map {(_, callContext)}

View File

@ -24,6 +24,7 @@ trait CustomerAccountLinkProvider {
def createCustomerAccountLink(customerId: String, bankId: String, accountId: String, relationshipType: String): Box[CustomerAccountLinkTrait]
def getOrCreateCustomerAccountLink(customerId: String, bankId: String, accountId: String, relationshipType: String): Box[CustomerAccountLinkTrait]
def getCustomerAccountLinkByCustomerId(customerId: String): Box[CustomerAccountLinkTrait]
def getCustomerAccountLinksByBankIdAccountId(bankId: String, accountId: String): Box[List[CustomerAccountLinkTrait]]
def getCustomerAccountLinksByCustomerId(customerId: String): Box[List[CustomerAccountLinkTrait]]
def getCustomerAccountLinksByAccountId(bankId: String, accountId: String): Box[List[CustomerAccountLinkTrait]]
def getCustomerAccountLinkById(customerAccountLinkId: String): Box[CustomerAccountLinkTrait]
@ -37,6 +38,7 @@ class RemotedataCustomerAccountLinkProviderCaseClass {
case class createCustomerAccountLink(customerId: String, bankId: String, accountId: String, relationshipType: String)
case class getOrCreateCustomerAccountLink(customerId: String, bankId: String, accountId: String, relationshipType: String)
case class getCustomerAccountLinkByCustomerId(customerId: String)
case class getCustomerAccountLinksByBankIdAccountId(bankId: String, accountId: String)
case class getCustomerAccountLinksByCustomerId(customerId: String)
case class getCustomerAccountLinksByAccountId(bankId: String, accountId: String)
case class getCustomerAccountLinkById(customerAccountLinkId: String)

View File

@ -43,6 +43,16 @@ object MappedCustomerAccountLinkProvider extends CustomerAccountLinkProvider {
By(CustomerAccountLink.CustomerId, customerId))
}
override def getCustomerAccountLinksByBankIdAccountId(bankId: String, accountId: String): Box[List[CustomerAccountLinkTrait]] = {
tryo {
CustomerAccountLink.findAll(
By(CustomerAccountLink.BankId, bankId),
By(CustomerAccountLink.AccountId, accountId)
)
}
}
override def getCustomerAccountLinksByCustomerId(customerId: String): Box[List[CustomerAccountLinkTrait]] = {
tryo {
CustomerAccountLink.findAll(

View File

@ -22,6 +22,10 @@ object RemotedataCustomerAccountLinks extends ObpActorInit with CustomerAccountL
def getCustomerAccountLinkByCustomerId(customerId: String): Box[CustomerAccountLinkTrait] = getValueFromFuture(
(actor ? cc.getCustomerAccountLinkByCustomerId(customerId)).mapTo[Box[CustomerAccountLinkTrait]]
)
def getCustomerAccountLinksByBankIdAccountId(bankId: String, accountId: String): Box[List[CustomerAccountLinkTrait]] = getValueFromFuture(
(actor ? cc.getCustomerAccountLinksByBankIdAccountId(bankId: String, accountId: String)).mapTo[Box[List[CustomerAccountLinkTrait]]]
)
def getCustomerAccountLinksByCustomerId(customerId: String): Box[List[CustomerAccountLinkTrait]] = getValueFromFuture(
(actor ? cc.getCustomerAccountLinksByCustomerId(customerId)).mapTo[Box[List[CustomerAccountLinkTrait]]]
)

View File

@ -26,6 +26,10 @@ class RemotedataCustomerAccountLinksActor extends Actor with ObpActorHelper with
logger.debug(s"getCustomerAccountLinkByCustomerId($customerId)")
sender ! (mapper.getCustomerAccountLinkByCustomerId(customerId))
case cc.getCustomerAccountLinksByBankIdAccountId(bankId: String, accountId: String)=>
logger.debug(s"getCustomerAccountLinksByBankIdAccountId(bankId($bankId), accountId($accountId))")
sender ! (mapper.getCustomerAccountLinksByBankIdAccountId(bankId: String, accountId: String))
case cc.getCustomerAccountLinksByCustomerId(customerId: String) =>
logger.debug(s"getCustomerAccountLinksByCustomerId($customerId)")
sender ! (mapper.getCustomerAccountLinksByCustomerId(customerId))

View File

@ -21,7 +21,7 @@ class CustomerAccountLinkTest extends V500ServerSetup with DefaultUsers {
object ApiEndpoint2 extends Tag(nameOf(Implementations5_0_0.getCustomerAccountLinkById))
object ApiEndpoint3 extends Tag(nameOf(Implementations5_0_0.updateCustomerAccountLinkById))
object ApiEndpoint4 extends Tag(nameOf(Implementations5_0_0.getCustomerAccountLinksByCustomerId))
object ApiEndpoint5 extends Tag(nameOf(Implementations5_0_0.getCustomerAccountLinksByAccountId))
object ApiEndpoint5 extends Tag(nameOf(Implementations5_0_0.getCustomerAccountLinksByBankIdAccountId))
object ApiEndpoint6 extends Tag(nameOf(Implementations5_0_0.deleteCustomerAccountLinkById))
@ -159,7 +159,7 @@ class CustomerAccountLinkTest extends V500ServerSetup with DefaultUsers {
lazy val testBankId = randomBankId
lazy val testAccountId = testAccountId1
val customerId = createAndGetCustomerIdViaEndpoint(testBankId, user1)
lazy val createCustomerAccountLinkJson = SwaggerDefinitionsJSON.createCustomerAccountLinkJson.copy(customer_id = customerId, account_id= testAccountId.value)
lazy val createCustomerAccountLinkJson = SwaggerDefinitionsJSON.createCustomerAccountLinkJson.copy(customer_id = customerId, bank_id = testBankId, account_id= testAccountId.value)
lazy val updateCustomerAccountLinkJson = SwaggerDefinitionsJSON.updateCustomerAccountLinkJson.copy(relationship_type ="test")