Search in sources :

Example 1 with IssueServiceConfiguration

use of net.nemerosa.ontrack.extension.issues.model.IssueServiceConfiguration in project ontrack by nemerosa.

the class GitLabIssueServiceExtensionTest method issueServiceIdentifierContainsBothConfigurationAndRepository.

@Test
public void issueServiceIdentifierContainsBothConfigurationAndRepository() {
    when(configurationService.getConfiguration("Test")).thenReturn(new GitLabConfiguration("Test", "https://gitlab.test.com", null, null, false));
    IssueServiceConfiguration configuration = extension.getConfigurationByName("Test:nemerosa/ontrack");
    assertEquals("gitlab", configuration.getServiceId());
    assertEquals("Test:nemerosa/ontrack", configuration.getName());
    assertTrue(configuration instanceof GitLabIssueServiceConfiguration);
    GitLabIssueServiceConfiguration issueServiceConfiguration = (GitLabIssueServiceConfiguration) configuration;
    assertEquals("Test", issueServiceConfiguration.getConfiguration().getName());
    assertEquals("https://gitlab.test.com", issueServiceConfiguration.getConfiguration().getUrl());
    assertEquals("nemerosa/ontrack", issueServiceConfiguration.getRepository());
}
Also used : GitLabConfiguration(net.nemerosa.ontrack.extension.gitlab.model.GitLabConfiguration) GitLabIssueServiceConfiguration(net.nemerosa.ontrack.extension.gitlab.model.GitLabIssueServiceConfiguration) GitLabIssueServiceConfiguration(net.nemerosa.ontrack.extension.gitlab.model.GitLabIssueServiceConfiguration) IssueServiceConfiguration(net.nemerosa.ontrack.extension.issues.model.IssueServiceConfiguration) Test(org.junit.Test)

Example 2 with IssueServiceConfiguration

use of net.nemerosa.ontrack.extension.issues.model.IssueServiceConfiguration in project ontrack by nemerosa.

the class IndexationServiceImpl method indexIssues.

private void indexIssues(SVNRepository repository, SVNLogEntry logEntry) {
    // Is the repository associated with any issue service?
    ConfiguredIssueService configuredIssueService = repository.getConfiguredIssueService();
    if (configuredIssueService != null) {
        IssueServiceExtension issueServiceExtension = configuredIssueService.getIssueServiceExtension();
        IssueServiceConfiguration issueServiceConfiguration = configuredIssueService.getIssueServiceConfiguration();
        // Revision information to scan
        long revision = logEntry.getRevision();
        String message = logEntry.getMessage();
        // Cache for issues
        Set<String> revisionIssues = new HashSet<>();
        // Gets all issues from the message
        Set<String> issues = issueServiceExtension.extractIssueKeysFromMessage(issueServiceConfiguration, message);
        // For each issue in the message
        issues.stream().filter(issueKey -> !revisionIssues.contains(issueKey)).forEach(issueKey -> {
            revisionIssues.add(issueKey);
            logger.info(String.format("     Indexing revision %d <-> %s", revision, issueKey));
            // Indexes this issue
            issueRevisionDao.link(repository.getId(), revision, issueKey);
        });
    }
}
Also used : java.util(java.util) SVNUtils(net.nemerosa.ontrack.extension.svn.support.SVNUtils) LoggerFactory(org.slf4j.LoggerFactory) LocalDateTime(java.time.LocalDateTime) Autowired(org.springframework.beans.factory.annotation.Autowired) org.tmatesoft.svn.core(org.tmatesoft.svn.core) StringUtils(org.apache.commons.lang3.StringUtils) net.nemerosa.ontrack.extension.svn.db(net.nemerosa.ontrack.extension.svn.db) Transaction(net.nemerosa.ontrack.tx.Transaction) Service(org.springframework.stereotype.Service) StartupService(net.nemerosa.ontrack.model.support.StartupService) net.nemerosa.ontrack.job(net.nemerosa.ontrack.job) SVNConfiguration(net.nemerosa.ontrack.extension.svn.model.SVNConfiguration) Ack(net.nemerosa.ontrack.model.Ack) Logger(org.slf4j.Logger) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult) IssueServiceExtension(net.nemerosa.ontrack.extension.issues.IssueServiceExtension) GlobalSettings(net.nemerosa.ontrack.model.security.GlobalSettings) ConfigurationServiceListener(net.nemerosa.ontrack.model.support.ConfigurationServiceListener) LastRevisionInfo(net.nemerosa.ontrack.extension.svn.model.LastRevisionInfo) IssueServiceRegistry(net.nemerosa.ontrack.extension.issues.IssueServiceRegistry) ApplicationContext(org.springframework.context.ApplicationContext) Collectors(java.util.stream.Collectors) SVNClient(net.nemerosa.ontrack.extension.svn.client.SVNClient) ConfiguredIssueService(net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService) Consumer(java.util.function.Consumer) SecurityService(net.nemerosa.ontrack.model.security.SecurityService) Time(net.nemerosa.ontrack.common.Time) SVNIndexationException(net.nemerosa.ontrack.extension.svn.model.SVNIndexationException) PlatformTransactionManager(org.springframework.transaction.PlatformTransactionManager) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) TransactionTemplate(org.springframework.transaction.support.TransactionTemplate) TransactionStatus(org.springframework.transaction.TransactionStatus) TransactionService(net.nemerosa.ontrack.tx.TransactionService) IssueServiceConfiguration(net.nemerosa.ontrack.extension.issues.model.IssueServiceConfiguration) ConfiguredIssueService(net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService) IssueServiceExtension(net.nemerosa.ontrack.extension.issues.IssueServiceExtension) IssueServiceConfiguration(net.nemerosa.ontrack.extension.issues.model.IssueServiceConfiguration)

Example 3 with IssueServiceConfiguration

use of net.nemerosa.ontrack.extension.issues.model.IssueServiceConfiguration in project ontrack by nemerosa.

the class GitHubIssueServiceExtensionTest method issueServiceIdentifierContainsBothConfigurationAndRepository.

@Test
public void issueServiceIdentifierContainsBothConfigurationAndRepository() {
    when(configurationService.getConfiguration("Test")).thenReturn(new GitHubEngineConfiguration("Test", null, null, null, null));
    IssueServiceConfiguration configuration = extension.getConfigurationByName("Test:nemerosa/ontrack");
    assertEquals("github", configuration.getServiceId());
    assertEquals("Test:nemerosa/ontrack", configuration.getName());
    assertTrue(configuration instanceof GitHubIssueServiceConfiguration);
    GitHubIssueServiceConfiguration issueServiceConfiguration = (GitHubIssueServiceConfiguration) configuration;
    assertEquals("Test", issueServiceConfiguration.getConfiguration().getName());
    assertEquals("https://github.com", issueServiceConfiguration.getConfiguration().getUrl());
    assertEquals("nemerosa/ontrack", issueServiceConfiguration.getRepository());
}
Also used : GitHubIssueServiceConfiguration(net.nemerosa.ontrack.extension.github.service.GitHubIssueServiceConfiguration) IssueServiceConfiguration(net.nemerosa.ontrack.extension.issues.model.IssueServiceConfiguration) GitHubEngineConfiguration(net.nemerosa.ontrack.extension.github.model.GitHubEngineConfiguration) GitHubIssueServiceConfiguration(net.nemerosa.ontrack.extension.github.service.GitHubIssueServiceConfiguration) Test(org.junit.Test)

Example 4 with IssueServiceConfiguration

use of net.nemerosa.ontrack.extension.issues.model.IssueServiceConfiguration in project ontrack by nemerosa.

the class GitLabIssueServiceExtensionTest method get_configuration_by_name.

@Test
public void get_configuration_by_name() {
    when(configurationService.getConfiguration("test")).thenReturn(engineConfiguration);
    IssueServiceConfiguration configuration = extension.getConfigurationByName("test:nemerosa/ontrack");
    assertNotNull(configuration);
    assertEquals("test:nemerosa/ontrack", configuration.getName());
    assertEquals("gitlab", configuration.getServiceId());
}
Also used : GitLabIssueServiceConfiguration(net.nemerosa.ontrack.extension.gitlab.model.GitLabIssueServiceConfiguration) IssueServiceConfiguration(net.nemerosa.ontrack.extension.issues.model.IssueServiceConfiguration) Test(org.junit.Test)

Aggregations

IssueServiceConfiguration (net.nemerosa.ontrack.extension.issues.model.IssueServiceConfiguration)4 Test (org.junit.Test)3 GitLabIssueServiceConfiguration (net.nemerosa.ontrack.extension.gitlab.model.GitLabIssueServiceConfiguration)2 LocalDateTime (java.time.LocalDateTime)1 java.util (java.util)1 Consumer (java.util.function.Consumer)1 Collectors (java.util.stream.Collectors)1 Time (net.nemerosa.ontrack.common.Time)1 GitHubEngineConfiguration (net.nemerosa.ontrack.extension.github.model.GitHubEngineConfiguration)1 GitHubIssueServiceConfiguration (net.nemerosa.ontrack.extension.github.service.GitHubIssueServiceConfiguration)1 GitLabConfiguration (net.nemerosa.ontrack.extension.gitlab.model.GitLabConfiguration)1 IssueServiceExtension (net.nemerosa.ontrack.extension.issues.IssueServiceExtension)1 IssueServiceRegistry (net.nemerosa.ontrack.extension.issues.IssueServiceRegistry)1 ConfiguredIssueService (net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService)1 SVNClient (net.nemerosa.ontrack.extension.svn.client.SVNClient)1 net.nemerosa.ontrack.extension.svn.db (net.nemerosa.ontrack.extension.svn.db)1 LastRevisionInfo (net.nemerosa.ontrack.extension.svn.model.LastRevisionInfo)1 SVNConfiguration (net.nemerosa.ontrack.extension.svn.model.SVNConfiguration)1 SVNIndexationException (net.nemerosa.ontrack.extension.svn.model.SVNIndexationException)1 SVNUtils (net.nemerosa.ontrack.extension.svn.support.SVNUtils)1