Skip to content

Commit

Permalink
Merge branch 'PIN-4023' into PIN-3996
Browse files Browse the repository at this point in the history
  • Loading branch information
nttdata-rtorsoli authored Sep 28, 2023
2 parents 9e6fa24 + ada4c7e commit efc0eac
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ final case class ProcessApiServiceImpl(
riskAnalysisUuid <- riskAnalysisId.toFutureUUID
catalogItem <- catalogManagementService.getEServiceById(eServiceUuid)
_ <- isDraftEService(catalogItem)
_ <- isReceiveEService(catalogItem)
_ <- catalogManagementService.deleteRiskAnalysis(eServiceUuid, riskAnalysisUuid)
} yield ()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ object ResponseHandlers extends AkkaResponses {
case Failure(ex: EServiceNotFound) => notFound(ex, logMessage)
case Failure(ex: EServiceRiskAnalysisNotFound) => notFound(ex, logMessage)
case Failure(ex: EServiceNotInDraftState) => badRequest(ex, logMessage)
case Failure(ex: EServiceNotInReceiveMode) => badRequest(ex, logMessage)
case Failure(ex) => internalServerError(ex, logMessage)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3129,5 +3129,29 @@ class CatalogProcessSpec extends SpecHelper with AnyWordSpecLike with ScalatestR
problem.errors.head.code shouldBe "009-0012"
}
}
"fail if EService is not Receive" in {
val requesterId = UUID.randomUUID()

implicit val context: Seq[(String, String)] =
Seq("bearer" -> bearerToken, USER_ROLES -> "admin", ORGANIZATION_ID_CLAIM -> requesterId.toString)

val descriptor =
SpecData.catalogDescriptor.copy(state = Draft)

val eService = SpecData.catalogItem.copy(descriptors = Seq(descriptor), producerId = requesterId, mode = Deliver)

(mockCatalogManagementService
.getEServiceById(_: UUID)(_: ExecutionContext, _: ReadModelService))
.expects(eService.id, *, *)
.once()
.returns(Future.successful(eService))

Post() ~> service.deleteRiskAnalysis(eService.id.toString, UUID.randomUUID().toString) ~> check {
status shouldEqual StatusCodes.BadRequest
val problem = responseAs[Problem]
problem.status shouldBe StatusCodes.BadRequest.intValue
problem.errors.head.code shouldBe "009-0013"
}
}
}
}

0 comments on commit efc0eac

Please sign in to comment.