Closes #116 - Kafka connector : If non existing transaction_id is requested we should through 404 instead of 500

This commit is contained in:
Marko Milic 2016-08-02 13:27:04 +02:00
parent 625c63212f
commit 8d4a6f08c6
2 changed files with 10 additions and 4 deletions

View File

@ -106,6 +106,8 @@ object ErrorMessages {
val InvalidAccountType = "OBP-30108: Invalid Account Type."
val InitialBalanceMustBeZero = "OBP-30109: Initial Balance of Account must be Zero (0)."
val ConnectorEmptyResponse = "OBP-30200: Connector cannot return the data we requested."
val InvalidGetBankAccountsConnectorResponse = "OBP-30201: Connector did not return the set of accounts we requested."
val InvalidGetBankAccountConnectorResponse = "OBP-30202: Connector did not return the account we requested."
val InvalidGetTransactionConnectorResponse = "OBP-30203: Connector did not return the transaction we requested."

View File

@ -223,10 +223,14 @@ object KafkaMappedConnector extends Connector with CreateViewImpls with Loggable
"transactionId" -> transactionId.toString )
// Since result is single account, we need only first list entry
implicit val formats = net.liftweb.json.DefaultFormats
val r = process(reqId, "getTransaction", argList).extract[KafkaInboundTransaction]
// Check does the response data match the requested data
if (transactionId.value != r.id) throw new Exception(ErrorMessages.InvalidGetTransactionConnectorResponse)
createNewTransaction(r)
val r = process(reqId, "getTransaction", argList).extractOpt[KafkaInboundTransaction]
r match {
// Check does the response data match the requested data
case Some(x) if transactionId.value != x.id => Failure(ErrorMessages.InvalidGetTransactionConnectorResponse, Empty, Empty)
case Some(x) if transactionId.value == x.id => createNewTransaction(x)
case _ => Failure(ErrorMessages.ConnectorEmptyResponse, Empty, Empty)
}
}
override def getTransactions(bankId: BankId, accountID: AccountId, queryParams: OBPQueryParam*): Box[List[Transaction]] = {