From 4555a60f6fc966c9f1de451f65042e8b565df7f9 Mon Sep 17 00:00:00 2001 From: Nevena Verbic Date: Mon, 9 Dec 2024 18:59:04 +0100 Subject: [PATCH] feat: Create GET About Page test (#159) Fix PMD warnings --- .../integrationtests/CmsServiceIntegrationTest.java | 12 ++++++++++++ .../com/wcc/platform/service/CmsServiceTest.java | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/wcc/platform/integrationtests/CmsServiceIntegrationTest.java b/src/test/java/com/wcc/platform/integrationtests/CmsServiceIntegrationTest.java index 8ff6cd80..9a1992e1 100644 --- a/src/test/java/com/wcc/platform/integrationtests/CmsServiceIntegrationTest.java +++ b/src/test/java/com/wcc/platform/integrationtests/CmsServiceIntegrationTest.java @@ -1,10 +1,12 @@ package com.wcc.platform.integrationtests; +import static com.wcc.platform.domain.cms.PageType.ABOUT_US; import static com.wcc.platform.domain.cms.PageType.CODE_OF_CONDUCT; import static com.wcc.platform.domain.cms.PageType.COLLABORATOR; import static com.wcc.platform.domain.cms.PageType.FOOTER; import static com.wcc.platform.domain.cms.PageType.TEAM; import static com.wcc.platform.factories.SetupFactories.OBJECT_MAPPER; +import static com.wcc.platform.factories.SetupFactories.createAboutUsPageTest; import static com.wcc.platform.factories.SetupFactories.createCodeOfConductPageTest; import static com.wcc.platform.factories.SetupFactories.createCollaboratorPageTest; import static com.wcc.platform.factories.SetupFactories.createFooterPageTest; @@ -96,4 +98,14 @@ void testGetLandingPageFallback() { JSONAssert.assertEquals(expected, jsonResponse, false); } + + @Test + void testGetAboutUsPage() { + var result = service.getAboutUs(); + var expectedAboutUsPage = createAboutUsPageTest(ABOUT_US.getFileName()); + + assertEquals(expectedAboutUsPage.heroSection(), result.heroSection()); + assertEquals(expectedAboutUsPage.items(), result.items()); + assertEquals(expectedAboutUsPage.contact(), result.contact()); + } } diff --git a/src/test/java/com/wcc/platform/service/CmsServiceTest.java b/src/test/java/com/wcc/platform/service/CmsServiceTest.java index 4bc1ad6a..3fd46f9f 100644 --- a/src/test/java/com/wcc/platform/service/CmsServiceTest.java +++ b/src/test/java/com/wcc/platform/service/CmsServiceTest.java @@ -144,7 +144,7 @@ void whenGetLandingPageGivenValidJsonThenReturnPage() throws IOException { } @Test - void getAboutUsPageGivenInvalidJson() throws IOException { + void whenGetAboutUsPageGivenInvalidJson() throws IOException { when(objectMapper.readValue(anyString(), eq(AboutUsPage.class))) .thenThrow(new JsonProcessingException("Invalid JSON") {}); @@ -154,7 +154,7 @@ void getAboutUsPageGivenInvalidJson() throws IOException { } @Test - void getAboutUsPageGivenValidJson() throws IOException { + void whenGetAboutUsPageGivenValidJson() throws IOException { var aboutUsPage = SetupFactories.createAboutUsPageTest(); when(objectMapper.readValue(anyString(), eq(AboutUsPage.class))).thenReturn(aboutUsPage);