Skip to content

Commit

Permalink
#30411 adding fixes for it test
Browse files Browse the repository at this point in the history
  • Loading branch information
jdotcms committed Nov 29, 2024
1 parent 1ff54d8 commit 783a7d8
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.dotmarketing.beans.Host;
import com.dotmarketing.business.APILocator;
import com.dotmarketing.exception.DotDataException;
import com.dotmarketing.exception.DotSecurityException;
import com.dotmarketing.portlets.contentlet.model.Contentlet;
import com.dotmarketing.portlets.contentlet.model.IndexPolicy;
import com.dotmarketing.portlets.htmlpageasset.model.HTMLPageAsset;
Expand Down Expand Up @@ -70,7 +71,7 @@ public static void prepare() throws Exception {
* </ul>
*/
@Test
public void testPageDetailCollector() throws DotDataException, UnknownHostException {
public void testPageDetailCollector() throws DotDataException, UnknownHostException, DotSecurityException {
final HttpServletResponse response = mock(HttpServletResponse.class);
final String requestId = UUIDUtil.uuid();
final HttpServletRequest request = Util.mockHttpRequestObj(response,
Expand Down Expand Up @@ -100,15 +101,21 @@ public void testPageDetailCollector() throws DotDataException, UnknownHostExcept
ContentletDataGen.publish(newsTestContent);

final Map<String, Object> expectedDataMap = Map.of(
"event_type", EventType.PAGE_REQUEST.getType(),
"host", testSite.getHostname(),
"language", language.getIsoCode(),
"url", TEST_URL_MAP_DETAIL_PAGE_URL,
"object", Map.of(
"id", testDetailPage.getIdentifier(),
"title", testDetailPage.getTitle(),
"url", TEST_URL_MAP_DETAIL_PAGE_URL,
"detail_page_url", testDetailPage.getURI())
Collector.EVENT_TYPE, EventType.PAGE_REQUEST.getType(),
Collector.SITE_NAME, testSite.getHostname(),
Collector.LANGUAGE, language.getIsoCode(),
Collector.URL, TEST_URL_MAP_DETAIL_PAGE_URL,
Collector.OBJECT, Map.of(
Collector.ID, testDetailPage.getIdentifier(),
Collector.TITLE, testDetailPage.getTitle(),
Collector.URL, TEST_URL_MAP_DETAIL_PAGE_URL,
Collector.CONTENT_TYPE_ID, testDetailPage.getContentType().id(),
Collector.CONTENT_TYPE_NAME, testDetailPage.getContentType().name(),
Collector.CONTENT_TYPE_VAR_NAME, testDetailPage.getContentType().variable(),
Collector.BASE_TYPE, testDetailPage.getContentType().baseType().name(),
Collector.LIVE, testDetailPage.isLive(),
Collector.WORKING, testDetailPage.isWorking(),
Collector.DETAIL_PAGE_URL, testDetailPage.getURI())
);

final Collector collector = new PageDetailCollector();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void prepare() throws Exception {
* </ul>
*/
@Test
public void collectPageData() throws DotDataException, UnknownHostException {
public void collectPageData() throws Exception {
final HttpServletResponse response = mock(HttpServletResponse.class);
final String requestId = UUIDUtil.uuid();
final HttpServletRequest request = Util.mockHttpRequestObj(response, TEST_PAGE_URL,
Expand All @@ -82,14 +82,21 @@ public void collectPageData() throws DotDataException, UnknownHostException {
final HTMLPageAsset testPage = Util.createTestHTMLPage(testSite, TEST_PAGE_NAME);

final Map<String, Object> expectedDataMap = Map.of(
"event_type", EventType.PAGE_REQUEST.getType(),
"host", testSite.getHostname(),
"language", APILocator.getLanguageAPI().getDefaultLanguage().getIsoCode(),
"url", TEST_PAGE_URL,
"object", Map.of(
"id", testPage.getIdentifier(),
"title", testPage.getTitle(),
"url", testPage.getURI())
Collector.EVENT_TYPE, EventType.PAGE_REQUEST.getType(),
Collector.SITE_NAME, testSite.getHostname(),
Collector.LANGUAGE, APILocator.getLanguageAPI().getDefaultLanguage().getIsoCode(),
Collector.URL, TEST_PAGE_URL,
Collector.OBJECT, Map.of(
Collector.ID, testPage.getIdentifier(),
Collector.TITLE, testPage.getTitle(),
Collector.URL, TEST_PAGE_URL,
Collector.CONTENT_TYPE_ID, testPage.getContentType().id(),
Collector.CONTENT_TYPE_NAME, testPage.getContentType().name(),
Collector.CONTENT_TYPE_VAR_NAME, testPage.getContentType().variable(),
Collector.BASE_TYPE, testPage.getContentType().baseType().name(),
Collector.LIVE, testPage.isLive(),
Collector.WORKING, testPage.isWorking(),
Collector.DETAIL_PAGE_URL, testPage.getURI())
);

final Collector collector = new PagesCollector();
Expand All @@ -116,7 +123,7 @@ public void collectPageData() throws DotDataException, UnknownHostException {
* </ul>
*/
@Test
public void collectUrlMapPageData() throws DotDataException, UnknownHostException {
public void collectUrlMapPageData() throws Exception {
final HttpServletResponse response = mock(HttpServletResponse.class);
final String requestId = UUIDUtil.uuid();
final HttpServletRequest request = Util.mockHttpRequestObj(response,
Expand Down Expand Up @@ -148,17 +155,22 @@ public void collectUrlMapPageData() throws DotDataException, UnknownHostExceptio
ContentletDataGen.publish(newsTestContent);

final Map<String, Object> expectedDataMap = Map.of(
"event_type", EventType.URL_MAP.getType(),
"host", testSite.getHostname(),
"language", APILocator.getLanguageAPI().getDefaultLanguage().getIsoCode(),
"url", TEST_URL_MAP_DETAIL_PAGE_URL,
"object", Map.of(
"content_type_var_name", urlMappedContentType.variable(),
"content_type_id", urlMappedContentType.id(),
"id", newsTestContent.getIdentifier(),
"content_type_name", urlMappedContentType.name(),
"title", urlTitle,
"url", TEST_URL_MAP_DETAIL_PAGE_URL)
Collector.EVENT_TYPE, EventType.URL_MAP.getType(),
Collector.SITE_NAME, testSite.getHostname(),
Collector.LANGUAGE, APILocator.getLanguageAPI().getDefaultLanguage().getIsoCode(),
Collector.URL, TEST_URL_MAP_DETAIL_PAGE_URL,
Collector.OBJECT, Map.of(
Collector.ID, newsTestContent.getIdentifier(),
Collector.TITLE, urlTitle,
Collector.URL, TEST_URL_MAP_DETAIL_PAGE_URL,
Collector.CONTENT_TYPE_ID, urlMappedContentType.id(),
Collector.CONTENT_TYPE_NAME, urlMappedContentType.name(),
Collector.CONTENT_TYPE_VAR_NAME, urlMappedContentType.variable(),
Collector.BASE_TYPE, testDetailPage.getContentType().baseType().name(),
Collector.LIVE, newsTestContent.isLive(),
Collector.WORKING, newsTestContent.isWorking(),
Collector.DETAIL_PAGE_URL, testDetailPage.getURI()
)
);

final Collector collector = new PagesCollector();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ public void collectSyncVanityData() throws DotDataException, IOException, DotSec
assertTrue("Resolved vanity url must be present", resolvedVanity.isPresent());

final Map<String, Object> expectedDataMap = Map.of(
"site", testSite.getIdentifier(),
"event_type", EventType.VANITY_REQUEST.getType(),
"language", defaultLanguage.getIsoCode(),
"vanity_url", TEST_PAGE_URL,
"language_id", defaultLanguage.getId(),
"url", URI,
"object", Map.of(
"forward_to", TEST_PAGE_URL,
"response", "200",
"id", resolvedVanity.get().vanityUrlId,
"url", URI)
Collector.SITE_ID, testSite.getIdentifier(),
Collector.EVENT_TYPE, EventType.VANITY_REQUEST.getType(),
Collector.LANGUAGE, defaultLanguage.getIsoCode(),
Collector.VANITY_URL_KEY, TEST_PAGE_URL,
Collector.LANGUAGE_ID, defaultLanguage.getId(),
Collector.URL, URI,
Collector.OBJECT, Map.of(
Collector.FORWARD_TO, TEST_PAGE_URL,
Collector.RESPONSE, "200",
Collector.ID, resolvedVanity.get().vanityUrlId,
Collector.URL, URI)
);

final Collector collector = new SyncVanitiesCollector();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public void testPagesCollector() throws DotDataException, IOException {
* </ul>
*/
@Test
public void testPageDetailCollector() throws DotDataException, IOException {
public void testPageDetailCollector() throws Exception {
testDetailPage = null != testDetailPage ? testDetailPage : Util.createTestHTMLPage(testSite, TEST_URL_MAP_PAGE_NAME, PARENT_FOLDER_1_NAME);

final String urlTitle = "mynews";
Expand All @@ -243,15 +243,24 @@ public void testPageDetailCollector() throws DotDataException, IOException {
final Contentlet newsTestContent = contentletDataGen.nextPersisted();
ContentletDataGen.publish(newsTestContent);
final Map<String, Object> expectedDataMap = Map.of(
"event_type", EventType.PAGE_REQUEST.getType(),
"host", testSite.getHostname(),
"language", language.getIsoCode(),
"url", TEST_URL_MAP_DETAIL_PAGE_URL,
"object", Map.of(
"id", testDetailPage.getIdentifier(),
"title", testDetailPage.getTitle(),
"url", TEST_URL_MAP_DETAIL_PAGE_URL,
"detail_page_url", testDetailPage.getURI())
Collector.EVENT_TYPE, EventType.PAGE_REQUEST.getType(),
Collector.SITE_NAME, testSite.getHostname(),
Collector.LANGUAGE, language.getIsoCode(),
Collector.URL, TEST_URL_MAP_DETAIL_PAGE_URL,
Collector.OBJECT, Map.of(
Collector.ID, testDetailPage.getIdentifier(),
Collector.TITLE, testDetailPage.getTitle(),
Collector.URL, TEST_URL_MAP_DETAIL_PAGE_URL,
Collector.CONTENT_TYPE_ID, testDetailPage.getContentType().id(),
Collector.CONTENT_TYPE_NAME, testDetailPage.getContentType().name(),
Collector.CONTENT_TYPE_VAR_NAME, testDetailPage.getContentType().variable(),
Collector.BASE_TYPE, testDetailPage.getContentType().baseType().name(),
Collector.LIVE, testDetailPage.isLive(),
Collector.WORKING, testDetailPage.isWorking(),
Collector.DETAIL_PAGE_URL, testDetailPage.getURI()


)
);

final TestEventLogSubmitter submitter = new TestEventLogSubmitter();
Expand Down Expand Up @@ -293,17 +302,17 @@ public void testSyncVanitiesCollector() throws DotDataException, IOException, Do
assertTrue(resolvedVanity.isPresent(), "Test resolved vanity url must be present");

final Map<String, Object> expectedDataMap = Map.of(
"site", testSite.getIdentifier(),
"event_type", EventType.VANITY_REQUEST.getType(),
"language", defaultLanguage.getIsoCode(),
"vanity_url", TEST_PAGE_URL,
"language_id", (int) defaultLanguage.getId(),
"url", URI,
"object", Map.of(
"forward_to", TEST_PAGE_URL,
"response", "200",
"id", resolvedVanity.get().vanityUrlId,
"url", URI)
Collector.SITE_ID, testSite.getIdentifier(),
Collector.EVENT_TYPE, EventType.VANITY_REQUEST.getType(),
Collector.LANGUAGE, defaultLanguage.getIsoCode(),
Collector.VANITY_URL_KEY, TEST_PAGE_URL,
Collector.LANGUAGE_ID, (int) defaultLanguage.getId(),
Collector.URL, URI,
Collector.OBJECT, Map.of(
Collector.FORWARD_TO, TEST_PAGE_URL,
Collector.RESPONSE, "200",
Collector.ID, resolvedVanity.get().vanityUrlId,
Collector.URL, URI)
);

final TestEventLogSubmitter submitter = new TestEventLogSubmitter();
Expand Down Expand Up @@ -352,15 +361,22 @@ public void testAsyncVanitiesCollector() throws DotDataException, IOException, D
assertTrue(resolvedVanity.isPresent(), "Test resolved vanity url must be present");

final Map<String, Object> expectedDataMap = Map.of(
"event_type", EventType.PAGE_REQUEST.getType(),
"host", testSite.getHostname(),
"comeFromVanityURL", true,
"language", defaultLanguage.getIsoCode(),
"url", TEST_PAGE_URL,
"object", Map.of(
"id", testPage.getIdentifier(),
"title", TEST_PAGE_NAME,
"url", TEST_PAGE_URL)
Collector.EVENT_TYPE, EventType.PAGE_REQUEST.getType(),
Collector.SITE_NAME, testSite.getHostname(),
Collector.COME_FROM_VANITY_URL, true,
Collector.LANGUAGE, defaultLanguage.getIsoCode(),
Collector.URL, TEST_PAGE_URL,
Collector.OBJECT, Map.of(
Collector.ID, testPage.getIdentifier(),
Collector.TITLE, TEST_PAGE_NAME,
Collector.URL, TEST_PAGE_URL,
Collector.CONTENT_TYPE_ID, testPage.getContentType().id(),
Collector.CONTENT_TYPE_NAME, testPage.getContentType().name(),
Collector.CONTENT_TYPE_VAR_NAME, testPage.getContentType().variable(),
Collector.BASE_TYPE, testPage.getContentType().baseType().name(),
Collector.LIVE, testPage.isLive(),
Collector.WORKING, testPage.isWorking(),
Collector.DETAIL_PAGE_URL, testPage.getURI())
);

final TestEventLogSubmitter submitter = new TestEventLogSubmitter();
Expand Down

0 comments on commit 783a7d8

Please sign in to comment.