Skip to content

Commit

Permalink
fixed failing tests
Browse files Browse the repository at this point in the history
Signed-off-by: Santhosh Gandhe <1909520+san81@users.noreply.github.com>
  • Loading branch information
san81 committed Feb 10, 2025
1 parent aaaf3fc commit b68fd99
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private StringBuilder createContentFilterCriteria(ConfluenceSourceConfig configu
if (!CollectionUtils.isEmpty(ConfluenceConfigHelper.getContentTypeIncludeFilter(configuration)) || !CollectionUtils.isEmpty(ConfluenceConfigHelper.getContentTypeExcludeFilter(configuration))) {
validatePageTypeFilters(configuration);
}

String formattedTimeStamp = LocalDateTime.ofInstant(ts, ZoneId.systemDefault())
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"));
StringBuilder cQl = new StringBuilder(LAST_MODIFIED + GREATER_THAN_EQUALS + "\"" + formattedTimeStamp + "\"");
Expand Down Expand Up @@ -187,7 +187,7 @@ private void validatePageTypeFilters(ConfluenceSourceConfig configuration) {
includedPageType.add(pageTypeFilter);
}
});
ConfluenceConfigHelper.getContentTypeIncludeFilter(configuration).forEach(pageTypeFilter -> {
ConfluenceConfigHelper.getContentTypeExcludeFilter(configuration).forEach(pageTypeFilter -> {
if (includedPageType.contains(pageTypeFilter)) {
includedAndExcludedPageType.add(pageTypeFilter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -102,7 +101,7 @@ public static ConfluenceSourceConfig createConfluenceConfigurationFromYaml(Strin
}

public static ConfluenceSourceConfig createConfluenceConfiguration(String auth_type,
List<String> issueType,
List<String> pageTypes,
List<String> projectKey) throws JsonProcessingException {
PluginConfigVariable pcvAccessToken = null;
PluginConfigVariable pcvRefreshToken = null;
Expand Down Expand Up @@ -130,7 +129,7 @@ public static ConfluenceSourceConfig createConfluenceConfiguration(String auth_t
Map<String, Object> spacesMap = new HashMap<>();
Map<String, Object> contentTypeMap = new HashMap<>();

contentTypeMap.put("include", issueType);
contentTypeMap.put("include", pageTypes);
filterMap.put("page_type", contentTypeMap);

Map<String, Object> nameMap = new HashMap<>();
Expand Down Expand Up @@ -178,17 +177,17 @@ void testJiraServiceInitialization() throws JsonProcessingException {
public void testGetPages() throws JsonProcessingException {
List<String> contentType = new ArrayList<>();
List<String> spaceKey = new ArrayList<>();
contentType.add("page");
contentType.add("PAGE");
spaceKey.add("KAN");
ConfluenceSourceConfig confluenceSourceConfig = createConfluenceConfiguration(BASIC, contentType, spaceKey);
ConfluenceService confluenceService = spy(new ConfluenceService(confluenceSourceConfig, confluenceRestClient, pluginMetrics));
List<ConfluenceItem> mockPages = new ArrayList<>();
ConfluenceItem issue1 = createConfluenceItemBean();
mockPages.add(issue1);
ConfluenceItem issue2 = createConfluenceItemBean();
mockPages.add(issue2);
ConfluenceItem issue3 = createConfluenceItemBean();
mockPages.add(issue3);
ConfluenceItem item1 = createConfluenceItemBean();
mockPages.add(item1);
ConfluenceItem item2 = createConfluenceItemBean();
mockPages.add(item2);
ConfluenceItem item3 = createConfluenceItemBean();
mockPages.add(item3);

ConfluenceSearchResults mockConfluenceSearchResults = mock(ConfluenceSearchResults.class);
when(mockConfluenceSearchResults.getResults()).thenReturn(mockPages);
Expand All @@ -203,10 +202,10 @@ public void testGetPages() throws JsonProcessingException {

@Test
public void buildIssueItemInfoMultipleFutureThreads() throws JsonProcessingException {
List<String> issueType = new ArrayList<>();
List<String> pageType = new ArrayList<>();
List<String> projectKey = new ArrayList<>();
issueType.add("Task");
ConfluenceSourceConfig confluenceSourceConfig = createConfluenceConfiguration(BASIC, issueType, projectKey);
pageType.add("PAGE");
ConfluenceSourceConfig confluenceSourceConfig = createConfluenceConfiguration(BASIC, pageType, projectKey);
ConfluenceService confluenceService = spy(new ConfluenceService(confluenceSourceConfig, confluenceRestClient, pluginMetrics));
List<ConfluenceItem> mockIssues = new ArrayList<>();
Random random = new Random();
Expand All @@ -228,17 +227,15 @@ public void buildIssueItemInfoMultipleFutureThreads() throws JsonProcessingExcep

@Test
public void testBadProjectKeys() throws JsonProcessingException {
List<String> issueType = new ArrayList<>();
List<String> issueStatus = new ArrayList<>();
List<String> pageType = new ArrayList<>();
List<String> projectKey = new ArrayList<>();
issueType.add("Task");
issueStatus.add("Done");
pageType.add("PAGE");
projectKey.add("Bad Project Key");
projectKey.add("A");
projectKey.add("!@#$");
projectKey.add("AAAAAAAAAAAAAA");

ConfluenceSourceConfig confluenceSourceConfig = createConfluenceConfiguration(BASIC, issueType, projectKey);
ConfluenceSourceConfig confluenceSourceConfig = createConfluenceConfiguration(BASIC, pageType, projectKey);
ConfluenceService confluenceService = new ConfluenceService(confluenceSourceConfig, confluenceRestClient, pluginMetrics);

Instant timestamp = Instant.ofEpochSecond(0);
Expand All @@ -249,15 +246,12 @@ public void testBadProjectKeys() throws JsonProcessingException {

@Test
public void testGetPagesException() throws JsonProcessingException {
List<String> issueType = new ArrayList<>();
List<String> issueStatus = new ArrayList<>();
List<String> pageType = new ArrayList<>();
List<String> projectKey = new ArrayList<>();
issueType.add("Task");
ConfluenceSourceConfig confluenceSourceConfig = createConfluenceConfiguration(BASIC, issueType, projectKey);
pageType.add("Task");
ConfluenceSourceConfig confluenceSourceConfig = createConfluenceConfiguration(BASIC, pageType, projectKey);
ConfluenceService confluenceService = spy(new ConfluenceService(confluenceSourceConfig, confluenceRestClient, pluginMetrics));

doThrow(RuntimeException.class).when(confluenceRestClient).getAllContent(any(StringBuilder.class), anyInt());

Instant timestamp = Instant.ofEpochSecond(0);
Queue<ItemInfo> itemInfoQueue = new ConcurrentLinkedQueue<>();

Expand Down

0 comments on commit b68fd99

Please sign in to comment.