Skip to content

Commit

Permalink
dry up some notrequestable messages
Browse files Browse the repository at this point in the history
  • Loading branch information
kenoir committed Sep 4, 2024
1 parent 185c131 commit 3a57178
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ case object Requestable extends RulesForRequestingResult
sealed trait NotRequestable extends RulesForRequestingResult

object NotRequestable {
case class NeedsManualRequest(message: String) extends NotRequestable
val defaultManualRequestMessage =
"This item cannot be requested online. Please place a manual request."
val defaultItemUnavailableMessage =
"This item is unavailable."

case class NeedsManualRequest(message: String = defaultManualRequestMessage) extends NotRequestable

case class ItemClosed(message: String) extends NotRequestable
case class SafeguardedItem(message: String) extends NotRequestable
case class ItemMissing(message: String) extends NotRequestable
case class ItemOnSearch(message: String) extends NotRequestable
case class ItemUnavailable(message: String) extends NotRequestable
case class ItemUnavailable(message: String = defaultItemUnavailableMessage) extends NotRequestable
case class ItemWithdrawn(message: String) extends NotRequestable

case class ContactUs(message: String) extends NotRequestable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ object SierraRulesForRequesting {
case i if i.fixedField("88").contains("x") =>
NotRequestable.ItemWithdrawn("This item is withdrawn.")
case i if i.fixedField("88").contains("r") =>
NotRequestable.ItemUnavailable("This item is unavailable.")
NotRequestable.ItemUnavailable()
case i if i.fixedField("88").contains("z") =>
NotRequestable.NoPublicMessage("fixed field 88 = z")
case i if i.fixedField("88").contains("v") =>
Expand Down Expand Up @@ -140,9 +140,7 @@ object SierraRulesForRequesting {
if i
.fixedField("108")
.containsAnyOf("n", "a", "p") =>
NotRequestable.NeedsManualRequest(
"This item cannot be requested online. Please place a manual request."
)
NotRequestable.NeedsManualRequest()

// These cases cover the lines:
//
Expand All @@ -152,9 +150,7 @@ object SierraRulesForRequesting {
if i
.fixedField("108")
.contains("u") =>
NotRequestable.ItemUnavailable(
"This item is unavailable."
)
NotRequestable.ItemUnavailable()

// These cases cover the lines:
//
Expand Down Expand Up @@ -215,9 +211,7 @@ object SierraRulesForRequesting {
"gblip",
"ofvds"
) =>
NotRequestable.NeedsManualRequest(
"This item cannot be requested online. Please place a manual request."
)
NotRequestable.NeedsManualRequest()

// These cases cover the lines:
//
Expand All @@ -230,9 +224,7 @@ object SierraRulesForRequesting {
.containsAnyOf(
"harcl"
) =>
NotRequestable.ItemUnavailable(
"This item is unavailable."
)
NotRequestable.ItemUnavailable()

// These cases cover the lines:
//
Expand Down Expand Up @@ -353,9 +345,7 @@ object SierraRulesForRequesting {
"sompr",
"somsy"
) =>
NotRequestable.NeedsManualRequest(
"Please complete a manual request slip. This item cannot be requested online."
)
NotRequestable.NeedsManualRequest()

// This case covers the line:
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class SierraRulesForRequestingTest
assertBlockedWith(
_,
expectedResult = NotRequestable.NeedsManualRequest(
"Please complete a manual request slip. This item cannot be requested online."
"This item cannot be requested online. Please place a manual request."
)
)
}
Expand Down Expand Up @@ -325,13 +325,13 @@ class SierraRulesForRequestingTest
(
"4",
NotRequestable.NeedsManualRequest(
"Please complete a manual request slip. This item cannot be requested online."
"This item cannot be requested online. Please place a manual request."
)
),
(
"14",
NotRequestable.NeedsManualRequest(
"Please complete a manual request slip. This item cannot be requested online."
"This item cannot be requested online. Please place a manual request."
)
)
)
Expand Down

0 comments on commit 3a57178

Please sign in to comment.