From 3a57178d8b09eadb6ccb1d01ee66c5accacd53af Mon Sep 17 00:00:00 2001 From: Robert Kenny Date: Wed, 4 Sep 2024 08:42:44 +0100 Subject: [PATCH] dry up some notrequestable messages --- .../rules/RulesForRequestingResult.scala | 9 ++++++-- .../rules/SierraRulesForRequesting.scala | 22 +++++-------------- .../rules/SierraRulesForRequestingTest.scala | 6 ++--- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/common/source_model/src/main/scala/weco/catalogue/source_model/sierra/rules/RulesForRequestingResult.scala b/common/source_model/src/main/scala/weco/catalogue/source_model/sierra/rules/RulesForRequestingResult.scala index ddb471d4a2..9b48fc6f60 100644 --- a/common/source_model/src/main/scala/weco/catalogue/source_model/sierra/rules/RulesForRequestingResult.scala +++ b/common/source_model/src/main/scala/weco/catalogue/source_model/sierra/rules/RulesForRequestingResult.scala @@ -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 diff --git a/common/source_model/src/main/scala/weco/catalogue/source_model/sierra/rules/SierraRulesForRequesting.scala b/common/source_model/src/main/scala/weco/catalogue/source_model/sierra/rules/SierraRulesForRequesting.scala index a0c517b7f7..940b2703b1 100644 --- a/common/source_model/src/main/scala/weco/catalogue/source_model/sierra/rules/SierraRulesForRequesting.scala +++ b/common/source_model/src/main/scala/weco/catalogue/source_model/sierra/rules/SierraRulesForRequesting.scala @@ -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") => @@ -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: // @@ -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: // @@ -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: // @@ -230,9 +224,7 @@ object SierraRulesForRequesting { .containsAnyOf( "harcl" ) => - NotRequestable.ItemUnavailable( - "This item is unavailable." - ) + NotRequestable.ItemUnavailable() // These cases cover the lines: // @@ -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: // diff --git a/common/source_model/src/test/scala/weco/catalogue/source_model/sierra/rules/SierraRulesForRequestingTest.scala b/common/source_model/src/test/scala/weco/catalogue/source_model/sierra/rules/SierraRulesForRequestingTest.scala index aa1bf26f30..937e9fe6b4 100644 --- a/common/source_model/src/test/scala/weco/catalogue/source_model/sierra/rules/SierraRulesForRequestingTest.scala +++ b/common/source_model/src/test/scala/weco/catalogue/source_model/sierra/rules/SierraRulesForRequestingTest.scala @@ -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." ) ) } @@ -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." ) ) )