use of net.nemerosa.ontrack.extension.jira.tx.JIRASession in project ontrack by nemerosa.
the class JIRAServiceExtension method followLinks.
/**
* Given an issue seed, and a list of link names, follows the given links recursively and
* puts the associated issues into the {@code collectedIssues} map.
*
* @param configuration JIRA configuration to use to load the issues
* @param seed Issue to start from.
* @param linkNames Links to follow
* @param collectedIssues Collected issues, indexed by their key
*/
public void followLinks(JIRAConfiguration configuration, JIRAIssue seed, Set<String> linkNames, Map<String, JIRAIssue> collectedIssues) {
try (Transaction tx = transactionService.start()) {
JIRASession session = getJIRASession(tx, configuration);
// Gets the client from the current session
JIRAClient client = session.getClient();
// Puts the seed into the list
collectedIssues.put(seed.getKey(), seed);
// Gets the linked issue keys
seed.getLinks().stream().filter(linkedIssue -> linkNames.contains(linkedIssue.getLinkName())).filter(linkedIssue -> !collectedIssues.containsKey(linkedIssue.getKey())).map(linkedIssue -> client.getIssue(linkedIssue.getKey(), configuration)).forEach(linkedIssue -> followLinks(configuration, linkedIssue, linkNames, collectedIssues));
}
}
use of net.nemerosa.ontrack.extension.jira.tx.JIRASession in project ontrack by nemerosa.
the class JIRAServiceTest method before.
@Before
public void before() {
SecurityService securityService = mock(SecurityService.class);
configurationRepository = mock(ConfigurationRepository.class);
encryptionService = mock(EncryptionService.class);
JIRASession jiraSession = mock(JIRASession.class);
when(jiraSession.getClient()).thenReturn(mock(JIRAClient.class));
JIRASessionFactory jiraSessionFactory = mock(JIRASessionFactory.class);
when(jiraSessionFactory.create(any(JIRAConfiguration.class))).thenReturn(jiraSession);
OntrackConfigProperties ontrackConfigProperties = new OntrackConfigProperties();
jiraService = new JIRAConfigurationServiceImpl(configurationRepository, securityService, encryptionService, mock(EventPostService.class), mock(EventFactory.class), jiraSessionFactory, ontrackConfigProperties);
}
Aggregations