Skip to content

Commit

Permalink
PIN-4657 Resolved PR issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nttdata-rtorsoli committed Mar 16, 2024
1 parent 2171a75 commit a460e84
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ object PurposePersistentBehavior {
Effect.none[PurposeVersionDeleted, State]
} { v =>
v.state match {
case Draft | WaitingForApproval | Rejected =>
case Draft | WaitingForApproval =>
Effect
.persist(PurposeVersionDeleted(purposeId, versionId))
.thenRun((_: State) => replyTo ! StatusReply.Success(()))
case versionState =>
case versionState =>
replyTo ! StatusReply.Error[Unit](NotAllowedForPurposeVersionState(purposeId, versionId, versionState))
Effect.none[PurposeVersionDeleted, State]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ object PersistentSerializationSpec {
(updatedAt, updatedAtV1) <- Gen.option(offsetDatetimeGen).map(_.separate)
(firstActivationAt, firstActivationAtV1) <- Gen.option(offsetDatetimeGen).map(_.separate)
(suspendedAt, suspendedAtV1) <- Gen.option(offsetDatetimeGen).map(_.separate)
rejectionReason <- if (state == Rejected) Gen.some(stringGen) else Gen.option(stringGen)
rejectionReason <- if (state == Rejected) Gen.some(stringGen) else Gen.fail
} yield (
PersistentPurposeVersion(
id = id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,6 @@ class PurposePersistentBehaviorSpec extends ScalaTestWithActorTestKit(SpecConfig
result shouldBe expected
}

"change state from Active to Rejected" in {
val version = versionTemplate.copy(state = Active)
val purpose = purposeTemplate

(() => mockDateTimeSupplier.get()).expects().returning(newTimestamp).once()

val result = updatePurposeFromState(
purpose,
version,
newVersionState = Rejected,
stateChangeDetails = StateChangeDetails(CONSUMER, newTimestamp)
)

val expectedVersion =
version.copy(state = Rejected, updatedAt = Some(newTimestamp))
val expected =
purpose.copy(versions = Seq(expectedVersion), suspendedByConsumer = Some(false), updatedAt = Some(newTimestamp))

result shouldBe expected
}

"change state from Active to Suspended by Consumer" in {
val version = versionTemplate.copy(state = Active)
val purpose = purposeTemplate
Expand Down

0 comments on commit a460e84

Please sign in to comment.