Skip to content

Commit 8967249

Browse files
authored
Merge branch 'qa-master' into resolved-conflict
Signed-off-by: rapkalya <74697698+rapkalya@users.noreply.github.com>
2 parents 4a8dbab + 7113fea commit 8967249

File tree

126 files changed

+14803
-30
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+14803
-30
lines changed

.github/workflows/Processors_CI_Workflow.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ jobs:
8080
8181
- name: Build & Test Jira Processor
8282
run: |
83-
mvn clean install -Pjira-processor -Ddockerfile.skip=true
83+
mvn clean install -Pjira-processor -Ddockerfile.skip=true
84+
85+
- name: Build & Test Rally Processor
86+
run: |
87+
mvn clean install -Prally-processor -Ddockerfile.skip=true
8488
8589
- name: Build & Test Azure Board Processor
8690
run: mvn clean install -Pazure-board-processor -Ddockerfile.skip=true

azure-boards/src/main/java/com/publicissapient/kpidashboard/azure/client/azureissue/ScrumAzureIssueClientImpl.java

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.time.format.DateTimeFormatter;
2424
import java.util.ArrayList;
2525
import java.util.Arrays;
26+
import java.util.Collections;
2627
import java.util.HashMap;
2728
import java.util.HashSet;
2829
import java.util.LinkedHashSet;
@@ -153,8 +154,8 @@ public int processesAzureIssues(ProjectConfFieldMapping projectConfig, String pr
153154

154155
Map<String, LocalDateTime> startTimesByIssueType = new HashMap<>();
155156

156-
maxChangeDatesByIssueType
157-
.forEach((k, v) -> startTimesByIssueType.put(k, v.minusMinutes(azureProcessorConfig.getMinsToReduce())));
157+
maxChangeDatesByIssueType.forEach(
158+
(k, v) -> startTimesByIssueType.put(k, v.minusMinutes(azureProcessorConfig.getMinsToReduce())));
158159

159160
int pageSize = azureAdapter.getPageSize();
160161

@@ -390,6 +391,7 @@ public int saveAzureIssueDetails(List<Value> currentPagedAzureRs, ProjectConfFie
390391

391392
// ADD Production Incident field to feature
392393
setProdIncidentIdentificationField(fieldMapping, issue, azureIssue, fieldsMap);
394+
setLateRefinement188(fieldMapping, azureIssue, fieldsMap);
393395

394396
setIssueTechStoryType(fieldMapping, issue, azureIssue, fieldsMap);
395397

@@ -1209,4 +1211,50 @@ private void saveExecutionTraceLog(ProcessorExecutionTraceLog processorExecution
12091211
processorExecutionTraceLog.setExecutionEndedAt(System.currentTimeMillis());
12101212
processorExecutionTraceLogService.save(processorExecutionTraceLog);
12111213
}
1214+
1215+
private void setLateRefinement188(FieldMapping fieldMapping, JiraIssue azureIssue, Map<String, Object> fieldsMap) {
1216+
azureIssue.setUnRefinedValue188(null);
1217+
if (!isCustomFieldCriteriaValid(fieldMapping, fieldsMap)) {
1218+
return;
1219+
}
1220+
1221+
String azureValue = fieldsMap.get(fieldMapping.getJiraRefinementByCustomFieldKPI188().trim()).toString();
1222+
if (StringUtils.isBlank(azureValue)) {
1223+
azureIssue.setUnRefinedValue188(Collections.singleton("No Value"));
1224+
return;
1225+
}
1226+
1227+
Set<String> customFieldSet = Arrays.stream(azureValue.toLowerCase().split("\\s+")).collect(Collectors.toSet());
1228+
if (StringUtils.isNotEmpty(fieldMapping.getJiraRefinementMinLengthKPI188())
1229+
&& CollectionUtils.isNotEmpty(customFieldSet)) {
1230+
int i = Integer.parseInt(fieldMapping.getJiraRefinementMinLengthKPI188());
1231+
if (customFieldSet.size() >= i
1232+
&& CollectionUtils.isNotEmpty(fieldMapping.getJiraRefinementKeywordsKPI188())) {
1233+
Set<String> fieldMappingSet = fieldMapping.getJiraRefinementKeywordsKPI188().stream()
1234+
.map(String::toLowerCase).collect(Collectors.toSet());
1235+
if (!checkKeyWords(customFieldSet, fieldMappingSet)) {
1236+
// when fields are not matching then we will set values
1237+
azureIssue.setUnRefinedValue188(customFieldSet);
1238+
}
1239+
}
1240+
} else {
1241+
azureIssue.setUnRefinedValue188(customFieldSet);
1242+
}
1243+
1244+
}
1245+
1246+
private static boolean checkKeyWords(Set<String> stringSet, Set<String> fieldMappingSet) {
1247+
for (String keyword : fieldMappingSet) {
1248+
if (!stringSet.contains(keyword.toLowerCase())) {
1249+
return false;
1250+
}
1251+
}
1252+
return true;
1253+
}
1254+
1255+
private boolean isCustomFieldCriteriaValid(FieldMapping fieldMapping, Map<String, Object> fieldsMap) {
1256+
return StringUtils.isNotEmpty(fieldMapping.getJiraRefinementCriteriaKPI188())
1257+
&& CommonConstant.CUSTOM_FIELD.equalsIgnoreCase(fieldMapping.getJiraRefinementCriteriaKPI188())
1258+
&& fieldsMap.get(fieldMapping.getJiraRefinementByCustomFieldKPI188().trim()) != null;
1259+
}
12121260
}

azure-boards/src/main/java/com/publicissapient/kpidashboard/azure/client/metadata/MetaDataClientImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,10 @@ private FieldMapping mapFieldMapping(Map<String, List<String>> issueTypeMap, Map
271271
fieldMapping.setStoryFirstStatusKPI171(firstStatusList.get(0));
272272
fieldMapping.setStoryFirstStatusKPI148(firstStatusList.get(0));
273273
fieldMapping.setJiraDefectCreatedStatusKPI14(firstStatusList.get(0));
274+
fieldMapping.setJiraStatusKPI187(firstStatusList);
274275
} else {
275276
fieldMapping.setStoryFirstStatus(CommonConstant.OPEN);
277+
fieldMapping.setJiraStatusKPI187(firstStatusList);
276278
fieldMapping.setStoryFirstStatusKPI171(CommonConstant.OPEN);
277279
fieldMapping.setStoryFirstStatusKPI148(CommonConstant.OPEN);
278280
fieldMapping.setJiraDefectCreatedStatusKPI14(CommonConstant.OPEN);

azure-boards/src/test/java/com/publicissapient/kpidashboard/azure/client/azureissue/ScrumAzureIssueClientImplTest.java

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.publicissapient.kpidashboard.azure.client.azureissue;
22

3+
import static org.junit.Assert.assertNotNull;
4+
import static org.junit.Assert.assertTrue;
35
import static org.mockito.ArgumentMatchers.any;
46
import static org.mockito.ArgumentMatchers.anyBoolean;
57
import static org.mockito.ArgumentMatchers.anyString;
@@ -450,4 +452,86 @@ private void createIssue() throws URISyntaxException, JSONException {
450452
issues.add(issue1);
451453
issue1.setFields(fields);
452454
}
455+
456+
@Test
457+
public void testSetLateRefinement188() throws Exception {
458+
// Arrange
459+
FieldMapping fieldMapping = new FieldMapping();
460+
fieldMapping.setJiraRefinementCriteriaKPI188(CommonConstant.CUSTOM_FIELD);
461+
fieldMapping.setJiraRefinementByCustomFieldKPI188("customfield_14141");
462+
fieldMapping.setJiraRefinementMinLengthKPI188("2");
463+
fieldMapping.setJiraRefinementKeywordsKPI188(Arrays.asList("keyword1", "keyword2"));
464+
465+
JiraIssue jiraIssue = new JiraIssue();
466+
467+
Map<String, Object> fieldsMap = new HashMap<>();
468+
fieldsMap.put("customfield_14141", "keyword1 keyword3");
469+
470+
// Use reflection to access the private method
471+
java.lang.reflect.Method method = ScrumAzureIssueClientImpl.class.getDeclaredMethod(
472+
"setLateRefinement188", FieldMapping.class, JiraIssue.class, Map.class);
473+
method.setAccessible(true);
474+
475+
// Act
476+
method.invoke(scrumIssueClientImpl, fieldMapping, jiraIssue, fieldsMap);
477+
478+
// Assert
479+
assertNotNull(jiraIssue.getUnRefinedValue188());
480+
assertTrue(jiraIssue.getUnRefinedValue188().contains("keyword3"));
481+
}
482+
483+
@Test
484+
public void testSetLateRefinement188_NoValue() throws Exception {
485+
// Arrange
486+
FieldMapping fieldMapping = new FieldMapping();
487+
fieldMapping.setJiraRefinementCriteriaKPI188(CommonConstant.CUSTOM_FIELD);
488+
fieldMapping.setJiraRefinementByCustomFieldKPI188("customfield_14141");
489+
490+
JiraIssue jiraIssue = new JiraIssue();
491+
492+
Map<String, Object> fieldsMap = new HashMap<>();
493+
fieldsMap.put("customfield_14141", "");
494+
495+
// Act
496+
java.lang.reflect.Method method = ScrumAzureIssueClientImpl.class.getDeclaredMethod(
497+
"setLateRefinement188", FieldMapping.class, JiraIssue.class, Map.class);
498+
method.setAccessible(true);
499+
500+
// Act
501+
method.invoke(scrumIssueClientImpl, fieldMapping, jiraIssue, fieldsMap);
502+
503+
504+
// Assert
505+
assertNotNull(jiraIssue.getUnRefinedValue188());
506+
assertTrue(jiraIssue.getUnRefinedValue188().contains("No Value"));
507+
}
508+
509+
@Test
510+
public void testSetLateRefinement188_NoMatchingKeywords() throws Exception{
511+
// Arrange
512+
FieldMapping fieldMapping = new FieldMapping();
513+
fieldMapping.setJiraRefinementCriteriaKPI188(CommonConstant.CUSTOM_FIELD);
514+
fieldMapping.setJiraRefinementByCustomFieldKPI188("customfield_14141");
515+
fieldMapping.setJiraRefinementMinLengthKPI188("2");
516+
fieldMapping.setJiraRefinementKeywordsKPI188(Arrays.asList("keyword1", "keyword2"));
517+
518+
JiraIssue jiraIssue = new JiraIssue();
519+
520+
Map<String, Object> fieldsMap = new HashMap<>();
521+
fieldsMap.put("customfield_14141", "keyword3 keyword4");
522+
523+
// Act
524+
java.lang.reflect.Method method = ScrumAzureIssueClientImpl.class.getDeclaredMethod(
525+
"setLateRefinement188", FieldMapping.class, JiraIssue.class, Map.class);
526+
method.setAccessible(true);
527+
528+
// Act
529+
method.invoke(scrumIssueClientImpl, fieldMapping, jiraIssue, fieldsMap);
530+
531+
532+
// Assert
533+
assertNotNull(jiraIssue.getUnRefinedValue188());
534+
assertTrue(jiraIssue.getUnRefinedValue188().contains("keyword3"));
535+
assertTrue(jiraIssue.getUnRefinedValue188().contains("keyword4"));
536+
}
453537
}

jira/src/main/java/com/publicissapient/kpidashboard/jira/processor/JiraIssueProcessorImpl.java

Lines changed: 123 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import static com.publicissapient.kpidashboard.jira.helper.JiraHelper.getFieldValue;
2323
import static com.publicissapient.kpidashboard.jira.helper.JiraHelper.getLabelsList;
2424

25+
import java.lang.reflect.Method;
2526
import java.text.ParseException;
2627
import java.util.ArrayList;
2728
import java.util.Arrays;
@@ -89,8 +90,9 @@
8990
@Slf4j
9091
@Service
9192
public class JiraIssueProcessorImpl implements JiraIssueProcessor {
92-
private static final String TEST_PHASE = "TestPhase";
93-
private static final String UAT_PHASE = "UAT";
93+
private static final String TEST_PHASE = "TestPhase";
94+
private static final String UAT_PHASE = "UAT";
95+
private static final String NO_VALUE = "No Value";
9496

9597
AssigneeDetails assigneeDetails;
9698
@Autowired
@@ -197,6 +199,7 @@ public JiraIssue convertToJiraIssue(Issue issue, ProjectConfFieldMapping project
197199
// ADD Production Incident field to feature
198200
setProdIncidentIdentificationField(fieldMapping, issue, jiraIssue, fields);
199201
setIssueTechStoryType(fieldMapping, issue, jiraIssue, fields);
202+
setLateRefinement188(fieldMapping, jiraIssue, fields, issue);
200203
jiraIssue.setAffectedVersions(getAffectedVersions(issue));
201204
setIssueEpics(issueEpics, epic, jiraIssue);
202205
setJiraIssueValues(jiraIssue, issue, fieldMapping, fields);
@@ -963,5 +966,123 @@ private void setProdIncidentIdentificationField(FieldMapping featureConfig, Issu
963966
} catch (Exception e) {
964967
log.error("Error while parsing Production Incident field", e);
965968
}
969+
970+
}
971+
972+
private void setLateRefinement188(FieldMapping fieldMapping, JiraIssue jiraIssue, Map<String, IssueField> fields, Issue issue) {
973+
jiraIssue.setUnRefinedValue188(null);
974+
975+
String refinementCriteria = StringUtils.trimToNull(fieldMapping.getJiraRefinementCriteriaKPI188());
976+
String refinementField = StringUtils.trimToNull(fieldMapping.getJiraRefinementByCustomFieldKPI188());
977+
978+
if (refinementCriteria == null || refinementField == null) {
979+
return;
980+
}
981+
982+
if (!CommonConstant.CUSTOM_FIELD.equalsIgnoreCase(refinementCriteria)) {
983+
return;
984+
}
985+
986+
Object value = Optional.ofNullable(fields.get(refinementField))
987+
.map(IssueField::getValue)
988+
.orElseGet(() -> getStandardFieldValue(issue, refinementField));
989+
990+
if (value == null) {
991+
setUnrefinedValueReason(jiraIssue, NO_VALUE);
992+
return;
993+
}
994+
995+
List<String> customFieldValue = getCustomFieldValue(value);
996+
if (CollectionUtils.isEmpty(customFieldValue)) {
997+
setUnrefinedValueReason(jiraIssue, NO_VALUE);
998+
return;
999+
}
1000+
1001+
Set<String> customFieldSet = Arrays.stream(String.join(" ", customFieldValue).toLowerCase().split("\\s+"))
1002+
.filter(StringUtils::isNotBlank)
1003+
.collect(Collectors.toSet());
1004+
1005+
if (CollectionUtils.isEmpty(customFieldSet)) {
1006+
setUnrefinedValueReason(jiraIssue, NO_VALUE);
1007+
return;
1008+
}
1009+
1010+
int minLength = parseMinLength(fieldMapping.getJiraRefinementMinLengthKPI188());
1011+
if (customFieldSet.size() < minLength) {
1012+
jiraIssue.setUnRefinedValue188(customFieldSet);
1013+
return;
1014+
}
1015+
1016+
Set<String> keywords = Optional.ofNullable(fieldMapping.getJiraRefinementKeywordsKPI188())
1017+
.orElse(Collections.emptyList())
1018+
.stream()
1019+
.map(String::toLowerCase)
1020+
.collect(Collectors.toSet());
1021+
1022+
if (CollectionUtils.isEmpty(keywords) || !checkKeyWords(customFieldSet, keywords)) {
1023+
jiraIssue.setUnRefinedValue188(customFieldSet);
1024+
}
1025+
}
1026+
1027+
1028+
private Object getStandardFieldValue(Issue issue, String fieldName) {
1029+
try {
1030+
Method getter = Issue.class.getMethod("get" + StringUtils.capitalize(fieldName));
1031+
return getter.invoke(issue);
1032+
} catch (Exception e) {
1033+
log.debug("Could not find or invoke getter for field: {}", fieldName, e);
1034+
return null;
1035+
}
1036+
}
1037+
1038+
private void setUnrefinedValueReason(JiraIssue jiraIssue, String value) {
1039+
jiraIssue.setUnRefinedValue188(Collections.singleton(value));
9661040
}
1041+
1042+
1043+
private int parseMinLength(String minLengthStr) {
1044+
try {
1045+
return StringUtils.isNotBlank(minLengthStr) ? Integer.parseInt(minLengthStr) : 0;
1046+
} catch (NumberFormatException e) {
1047+
return 0;
1048+
}
1049+
}
1050+
1051+
1052+
1053+
private static boolean checkKeyWords(Set<String> stringSet, Set<String> fieldMappingSet) {
1054+
1055+
for (String keyword : fieldMappingSet) {
1056+
if (!stringSet.contains(keyword.toLowerCase())) {
1057+
return false;
1058+
}
1059+
}
1060+
return true;
1061+
}
1062+
1063+
private ArrayList<String> getCustomFieldValue(Object issueFieldValue) {
1064+
JSONParser parser = new JSONParser();
1065+
ArrayList<String> customValue = new ArrayList<>();
1066+
try {
1067+
if (issueFieldValue instanceof org.codehaus.jettison.json.JSONArray) {
1068+
JSONArray array = (JSONArray) parser.parse(issueFieldValue.toString());
1069+
for (Object o : array) {
1070+
org.json.simple.JSONObject jsonObject = (org.json.simple.JSONObject) parser.parse(o.toString());
1071+
customValue.add(jsonObject.get(JiraConstants.VALUE).toString());
1072+
}
1073+
} else if (issueFieldValue instanceof org.codehaus.jettison.json.JSONObject) {
1074+
String jsonObjectValue = ((org.codehaus.jettison.json.JSONObject) issueFieldValue)
1075+
.get(JiraConstants.VALUE).toString();
1076+
customValue.add(jsonObjectValue);
1077+
} else if (StringUtils.isNotEmpty(issueFieldValue.toString())
1078+
&& StringUtils.isNotBlank(issueFieldValue.toString())) {
1079+
customValue.add(issueFieldValue.toString());
1080+
}
1081+
1082+
} catch (org.json.simple.parser.ParseException | JSONException e) {
1083+
log.error("JIRA Processor | Error while parsing custom field field {}", e);
1084+
}
1085+
return customValue;
1086+
}
1087+
9671088
}

0 commit comments

Comments
 (0)