-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update CAPI & FAPI clients (also remove Lightbox hack)
The latest version of the CAPI client (v19) includes guardian/content-api-scala-client#359, which we can use to replace the pagination code based on `play-iteratees` (https://github.com/playframework/play-iteratees - introduced in July 2014 with #5199), currently blocking the Scala 2.13 upgrade for Frontend (see #24817). The updated CAPI client is binary-incompatible with previous versions of the CAPI client, meaning we also need to update the FAPI client as it also uses CAPI. The updates to the CAPI client also support `previous`/`next` search functionality, as used by the Lightbox, meaning that the small `ContentApiNavQuery` hack for the Lightbox (introduced here: #20462) can now be removed. A similar PR updating FAPI & CAPI in Ophan is at guardian/ophan#4719. Co-authored-by: Roberto Tyley <roberto.tyley@guardian.co.uk> We're adding a test that will break at build time rather than runtime if our versions of the FAPI & CAPI clients are incompatible. See also: * #25139 (comment) * https://github.com/guardian/ophan/pull/4719/files#diff-ee7f97c92065084bba37d70d043ad0daa0d7745f235d0ad3206b59f073829529
- Loading branch information
Showing
3 changed files
with
39 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"), | ||
), | ||
), | ||
) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters