Skip to content

Commit 109a79b

Browse files
committed
update detailedMatchStatus
1 parent 19f641b commit 109a79b

2 files changed

Lines changed: 18 additions & 12 deletions

File tree

football/src/main/scala/com/gu/mobile/notifications/football/notificationbuilders/MatchStatusNotificationBuilder.scala

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class MatchStatusNotificationBuilder(mapiHost: String) {
104104
eventId = UUID.nameUUIDFromBytes(triggeringEvent.eventId.getBytes).toString,
105105
kickOffTimestamp = Some(matchInfo.date.toEpochSecond),
106106
lineupsAvailable = Some(matchInfo.lineupsAvailable),
107-
detailedMatchStatus = Some(detailedMatchStatus(triggeringEvent, matchInfo.matchStatus)),
107+
detailedMatchStatus = Some(MatchStatus.fromString(matchInfo.matchStatus).status),
108108
debug = false,
109109
dryRun = None
110110
)
@@ -113,15 +113,6 @@ class MatchStatusNotificationBuilder(mapiHost: String) {
113113

114114
def transformTeamName(name: String): String = name.replace(" Ladies", "")
115115

116-
private def detailedMatchStatus(triggeringEvent: FootballMatchEvent, paStatus: String): String =
117-
triggeringEvent match {
118-
case _: KickOff => "FIRST_HALF"
119-
case _: HalfTime => "HALF_TIME"
120-
case _: SecondHalf => "SECOND_HALF"
121-
case _: FullTime => "FULL_TIME"
122-
case _ => MatchStatus.fromString(paStatus).status
123-
}
124-
125116
private def goalDescription(goal: Goal) = {
126117
val extraInfo = {
127118
val goalTypeInfo = condOpt(goal.goalType) {

football/src/test/scala/com/gu/mobile/notifications/football/notificationbuilders/MatchStatusNotificationBuilderSpec.scala

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import java.util.UUID
77
import com.gu.mobile.notifications.client.models.Importance.{Major, Minor}
88
import com.gu.mobile.notifications.client.models._
99
import com.gu.mobile.notifications.football.lib.SyntheticMatchEventGenerator
10-
import com.gu.mobile.notifications.football.models.{Dismissal, FootballMatchEvent, Goal, GoalContext, KickOff, PenaltyShootoutKick, Score}
10+
import com.gu.mobile.notifications.football.models.{Dismissal, FootballMatchEvent, FullTime, Goal, GoalContext, KickOff, PenaltyShootoutKick, Score}
1111
import org.specs2.mutable.Specification
1212
import org.specs2.specification.Scope
1313
import pa.{Competition, MatchDay, MatchDayTeam, Parser, Round, Stage, Venue}
@@ -57,7 +57,7 @@ class MatchStatusNotificationBuilderSpec extends Specification {
5757

5858
"Include detailedMatchStatus for kick off" in new MatchEventsContext {
5959
val kickOff = KickOff("")
60-
val notification = builder.build(kickOff, matchInfo.copy(matchStatus = "Fixture"), List.empty, None).asInstanceOf[FootballMatchStatusPayload]
60+
val notification = builder.build(kickOff, matchInfo.copy(matchStatus = "KO"), List.empty, None).asInstanceOf[FootballMatchStatusPayload]
6161
notification.detailedMatchStatus shouldEqual Some("FIRST_HALF")
6262
}
6363

@@ -73,6 +73,21 @@ class MatchStatusNotificationBuilderSpec extends Specification {
7373
notification.detailedMatchStatus shouldEqual Some("EXTRA_TIME_HALF_TIME")
7474
}
7575

76+
"Include detailedMatchStatus EXTRA_TIME_TO_BE_PLAYED for a full time event when match status is FTET" in new MatchEventsContext {
77+
val notification = builder.build(fullTime, matchInfo.copy(matchStatus = "FTET"), List.empty, None).asInstanceOf[FootballMatchStatusPayload]
78+
notification.detailedMatchStatus shouldEqual Some("EXTRA_TIME_TO_BE_PLAYED")
79+
}
80+
81+
"Include detailedMatchStatus EXTRA_TIME_FIRST_HALF for a goal during extra time" in new MatchEventsContext {
82+
val notification = builder.build(baseGoal, matchInfo.copy(matchStatus = "ETS"), List.empty, None).asInstanceOf[FootballMatchStatusPayload]
83+
notification.detailedMatchStatus shouldEqual Some("EXTRA_TIME_FIRST_HALF")
84+
}
85+
86+
"Include detailedMatchStatus EXTRA_TIME_SECOND_HALF for a goal during extra time second half" in new MatchEventsContext {
87+
val notification = builder.build(baseGoal, matchInfo.copy(matchStatus = "ETSHS"), List.empty, None).asInstanceOf[FootballMatchStatusPayload]
88+
notification.detailedMatchStatus shouldEqual Some("EXTRA_TIME_SECOND_HALF")
89+
}
90+
7691
"Include lineupsAvailable true from matchInfo" in new MatchEventsContext {
7792
val matchInfoWithLineups = matchInfo.copy(lineupsAvailable = true)
7893
val notification = builder.build(baseGoal, matchInfoWithLineups, List.empty, None).asInstanceOf[FootballMatchStatusPayload]

0 commit comments

Comments
 (0)