From d495e43b68b4c2e9ef28af15d522a5dbe841c6b7 Mon Sep 17 00:00:00 2001 From: Neil Frow <675806+worthydolt@users.noreply.github.com> Date: Fri, 9 Dec 2022 12:01:55 +0000 Subject: [PATCH] APID-647: add logging of incoming request, stop scheduled jobs logging noise at info, tidy (#63) --- .../controllers/OutboundController.scala | 6 ++++-- .../apiplatformoutboundsoap/models/MessageRequest.scala | 2 +- .../scheduled/RunningOfScheduledJobs.scala | 4 ++-- .../repositories/OutboundMessageRepositoryISpec.scala | 5 +++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/uk/gov/hmrc/apiplatformoutboundsoap/controllers/OutboundController.scala b/app/uk/gov/hmrc/apiplatformoutboundsoap/controllers/OutboundController.scala index 4fec9c9..7b07beb 100644 --- a/app/uk/gov/hmrc/apiplatformoutboundsoap/controllers/OutboundController.scala +++ b/app/uk/gov/hmrc/apiplatformoutboundsoap/controllers/OutboundController.scala @@ -25,9 +25,10 @@ import uk.gov.hmrc.apiplatformoutboundsoap.services.OutboundService import uk.gov.hmrc.http.NotFoundException import uk.gov.hmrc.play.bootstrap.backend.controller.BackendController import uk.gov.hmrc.play.bootstrap.backend.http.ErrorResponse - import javax.inject.{Inject, Singleton} import javax.wsdl.WSDLException +import play.api.Logging + import scala.concurrent.ExecutionContext @Singleton @@ -35,10 +36,11 @@ class OutboundController @Inject()(cc: ControllerComponents, appConfig: AppConfig, outboundService: OutboundService) (implicit ec: ExecutionContext) - extends BackendController(cc) { + extends BackendController(cc) with Logging { def message(): Action[JsValue] = Action.async(parse.json) { implicit request => withJsonBody[MessageRequest] { messageRequest => + logger.info(s"Received request to send message to CCN2. Message body is $messageRequest") val codValue = messageRequest.confirmationOfDelivery match { case Some(cod) => cod case None => appConfig.confirmationOfDelivery diff --git a/app/uk/gov/hmrc/apiplatformoutboundsoap/models/MessageRequest.scala b/app/uk/gov/hmrc/apiplatformoutboundsoap/models/MessageRequest.scala index 9e6a967..f957f75 100644 --- a/app/uk/gov/hmrc/apiplatformoutboundsoap/models/MessageRequest.scala +++ b/app/uk/gov/hmrc/apiplatformoutboundsoap/models/MessageRequest.scala @@ -18,7 +18,7 @@ package uk.gov.hmrc.apiplatformoutboundsoap.models import uk.gov.hmrc.apiplatformoutboundsoap.utils.Require.validate -case class MessageRequest(wsdlUrl: String, +case class MessageRequest(wsdlUrl: String, wsdlOperation: String, messageBody: String, addressing: Addressing, diff --git a/app/uk/gov/hmrc/apiplatformoutboundsoap/scheduled/RunningOfScheduledJobs.scala b/app/uk/gov/hmrc/apiplatformoutboundsoap/scheduled/RunningOfScheduledJobs.scala index b7d9776..5d62fbb 100644 --- a/app/uk/gov/hmrc/apiplatformoutboundsoap/scheduled/RunningOfScheduledJobs.scala +++ b/app/uk/gov/hmrc/apiplatformoutboundsoap/scheduled/RunningOfScheduledJobs.scala @@ -43,12 +43,12 @@ trait RunningOfScheduledJobs extends Logging { scheduler.scheduleWithFixedDelay(job.initialDelay, job.interval)(() => { val stopWatch = new StopWatch stopWatch.start() - logger.info(s"Executing job ${job.name}") + logger.debug(s"Executing job ${job.name}") job.execute.onComplete { case Success(job.Result(message)) => stopWatch.stop() - logger.info(s"Completed job ${job.name} in $stopWatch: $message") + logger.debug(s"Completed job ${job.name} in $stopWatch: $message") case Failure(throwable) => stopWatch.stop() logger.error(s"Exception running job ${job.name} after $stopWatch", throwable) diff --git a/it/uk/gov/hmrc/apiplatformoutboundsoap/repositories/OutboundMessageRepositoryISpec.scala b/it/uk/gov/hmrc/apiplatformoutboundsoap/repositories/OutboundMessageRepositoryISpec.scala index 2394159..4d031c9 100644 --- a/it/uk/gov/hmrc/apiplatformoutboundsoap/repositories/OutboundMessageRepositoryISpec.scala +++ b/it/uk/gov/hmrc/apiplatformoutboundsoap/repositories/OutboundMessageRepositoryISpec.scala @@ -31,12 +31,13 @@ import play.api.test.Helpers.{await, defaultAwaitTimeout} import uk.gov.hmrc.apiplatformoutboundsoap.models._ import uk.gov.hmrc.mongo.play.json.PlayMongoRepository import uk.gov.hmrc.mongo.test.PlayMongoRepositorySupport - import java.time.{Duration, Instant} import java.util.UUID.randomUUID +import org.scalatest.concurrent.IntegrationPatience + class OutboundMessageRepositoryISpec extends AnyWordSpec with PlayMongoRepositorySupport[OutboundSoapMessage] with - Matchers with BeforeAndAfterEach with GuiceOneAppPerSuite { + Matchers with BeforeAndAfterEach with GuiceOneAppPerSuite with IntegrationPatience { val serviceRepo = repository.asInstanceOf[OutboundMessageRepository] override implicit lazy val app: Application = appBuilder.build()