diff --git a/applications/app/controllers/ImageContentController.scala b/applications/app/controllers/ImageContentController.scala index a324a08b82d6..f061c3b4a876 100644 --- a/applications/app/controllers/ImageContentController.scala +++ b/applications/app/controllers/ImageContentController.scala @@ -1,7 +1,6 @@ package controllers -import com.gu.contentapi.client.Parameter -import com.gu.contentapi.client.model.SearchQueryBase +import com.gu.contentapi.client.model.{Direction, FollowingSearchQuery, SearchQuery, SearchQueryBase} import com.gu.contentapi.client.model.v1.{ItemResponse, Content => ApiContent} import common._ import conf.switches.Switches @@ -53,11 +52,11 @@ class ImageContentController( def getNextLightboxJson(path: String, tag: String, direction: String): Action[AnyContent] = Action.async { implicit request => - val capiQuery: ContentApiNavQuery = ContentApiNavQuery(currentId = path, direction = direction) - .tag(tag) - .showTags("all") - .showElements("image") - .pageSize(contentApi.nextPreviousPageSize) + val capiQuery = FollowingSearchQuery( + SearchQuery().tag(tag).showTags("all").showElements("image").pageSize(contentApi.nextPreviousPageSize), + path, + Direction.forPathSegment(direction), + ) contentApiClient.thriftClient.getResponse(capiQuery).map { response => val lightboxJson = response.results.flatMap(result => @@ -70,10 +69,3 @@ class ImageContentController( } } } - -case class ContentApiNavQuery(parameterHolder: Map[String, Parameter] = Map.empty, currentId: String, direction: String) - extends SearchQueryBase[ContentApiNavQuery] { - def withParameters(parameterMap: Map[String, Parameter]): ContentApiNavQuery = copy(parameterMap) - - override def pathSegment: String = s"content/$currentId/$direction" -} diff --git a/facia-press/test/frontpress/FaciaClientTest.scala b/facia-press/test/frontpress/FaciaClientTest.scala new file mode 100644 index 000000000000..2a8391974a4e --- /dev/null +++ b/facia-press/test/frontpress/FaciaClientTest.scala @@ -0,0 +1,31 @@ +package frontpress + +import com.gu.contentapi.client.ContentApiClient +import com.gu.contentapi.client.model.SearchQuery +import org.scalatest.flatspec._ +import org.scalatest.matchers.should.Matchers +import org.scalatestplus.mockito.MockitoSugar + +class FaciaClientTest extends AsyncFlatSpec with Matchers with MockitoSugar { + + "FAPI Client" should "send a CAPI client request without a runtime error like java.lang.NoSuchMethodError" in { + // The FAPI client uses the Content API client. If this test fails with a java.lang.NoSuchMethodError, the + // versions of FAPI client and CAPI client we are using are incompatible - the FAPI client will have been + // compiled against a different version of the CAPI client. + + val mockContentApiClient = mock[ContentApiClient] + + // This is only exercising the code to send the request, not recieve the result, but it's enough to trigger the + // java.lang.NoSuchMethodError seen in https://github.com/guardian/frontend/pull/25139#issuecomment-1163407402 + noException shouldBe thrownBy( + com.gu.facia.api.contentapi.ContentApi.getHydrateResponse( + mockContentApiClient, + Seq( + SearchQuery().tag("profile/roberto-tyley"), + SearchQuery().tag("stage/comedy"), + ), + ), + ) + } + +} diff --git a/project/Dependencies.scala b/project/Dependencies.scala index fc6d6b33f7b6..6a1be2aa3eca 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -5,8 +5,8 @@ import sbt._ object Dependencies { val identityLibVersion = "3.254" val awsVersion = "1.12.205" - val capiVersion = "18.0.1" - val faciaVersion = "3.3.12" + val capiVersion = "19.0.0" + val faciaVersion = "4.0.0" val dispatchVersion = "0.13.1" val romeVersion = "1.0" val jerseyVersion = "1.19.4"