Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/src/main/scala/models/Topic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import play.api.libs.json._
import cats.syntax.all._


case class Topic(`type`: TopicType, name: String) {
case class Topic(`type`: TopicType, name: String, title: Option[String] = None) {
override def toString: String = fullName
def toFirebaseString: String = toString.replaceAll("/", "%")
lazy val id: String = md5Hex(toString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ class MainControllerSpec extends PlaySpecification with JsonMatchers with Mockit
val Some(register) = route(app, FakeRequest(POST, "/legacy/device/register").withJsonBody(Json.parse(legacyAndroidRegistrationJson)))
status(register) must equalTo(BAD_REQUEST)
}

////// NEW ENDPOINT ///////

"new /device/register endpoint returns expected response" in new RegistrationsContext {
val Some(result) = route(app, FakeRequest(POST, "/device/register").withJsonBody(Json.parse(newRegistrationJson)))
println(Json.prettyPrint(Json.parse(contentAsString(result))))

status(result) must equalTo(OK)
contentAsString(result) must /("provider" -> "Guardian")
contentAsString(result) must /("deviceId" -> "TEST-TOKEN-ID")
contentAsString(result) must /("platform" -> "ios")
contentAsString(result) must (/("topics") andHave size(4))
}
}

trait RegistrationsContext extends RegistrationsBase with withMockedWSClient {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ import cats.syntax.all._
import com.gu.DevIdentity
import db.{DatabaseConfig, JdbcConfig, RegistrationService}
import doobie.util.transactor.Transactor
import error.NotificationsError
import models.Provider.Unknown
import models.TopicTypes.{Breaking, FootballMatch}
import models._
import play.api.ApplicationLoader.Context
import play.api.{BuiltInComponents, Logger, Configuration => PlayConfig}
import play.api.libs.ws.WSClient
import providers.ProviderError
import registration.RegistrationApplicationComponents
import registration.services.NotificationRegistrar.RegistrarResponse
import registration.services.topic.{TopicValidator, TopicValidatorError}
Expand Down Expand Up @@ -165,6 +163,37 @@ trait RegistrationsJson {
|}
""".stripMargin

val newRegistrationJson =
"""
|{
| "deviceToken": "TEST-TOKEN-ID",
| "platform": "ios",
| "buildTier": "debug",
| "appVersion": "1.0.0",
| "topics": [
| {
| "name": "4501006",
| "title": "Burnley vs Leeds (2025-10-18)",
| "type": "football-match"
| },
| {
| "name": "profile/jane-doe",
| "title": "Jane Doe",
| "type": "tag-contributor"
| },
| {
| "name": "uk-sport",
| "title": "UK sport notifications",
| "type": "breaking"
| },
| {
| "name": "uk",
| "type": "breaking"
| }
| ]
|}
""".stripMargin

val registrationJson =
"""
|{
Expand Down