Search in sources :

Example 1 with GitHubProjectConfigurationProperty

use of net.nemerosa.ontrack.extension.github.property.GitHubProjectConfigurationProperty in project ontrack by nemerosa.

the class GitHubEngineConfigurationMigrationActionIT method migration.

/**
 * Test of the migration.
 * <p>
 * An old GitHub configuration is created with name "OntrackTest"
 * (see {@link TestGitHubEngineConfigurationMigrationPreparationAction})
 * <p>
 * A project P is created, using this configuration.
 * <p>
 * The test must check that the old configuration has been migrated and that the project
 * is now using a configuration including the repository, the indexation interval.
 */
@Test
public void migration() throws Exception {
    // Gets the project
    Project project = asUser().with(ProjectList.class).call(() -> structureService.findProjectByName("GitHubEngineConfigurationMigrationAction")).orElseThrow(() -> new ProjectNotFoundException("GitHubEngineConfigurationMigrationAction"));
    // Gets the migrated configuration
    GitHubEngineConfiguration gitHubEngineConfiguration = configurationRepository.find(GitHubEngineConfiguration.class, "OntrackTest").orElseThrow(() -> new RuntimeException("Cannot find \"OntrackTest\" configuration"));
    assertEquals("OntrackTest", gitHubEngineConfiguration.getName());
    assertEquals("https://github.com", gitHubEngineConfiguration.getUrl());
    assertEquals("user", gitHubEngineConfiguration.getUser());
    assertEquals("password", encryptionService.decrypt(gitHubEngineConfiguration.getPassword()));
    assertEquals("token", gitHubEngineConfiguration.getOauth2Token());
    // Gets the GitHub project property
    GitHubProjectConfigurationProperty configurationProperty = asUser().withView(project).call(() -> propertyService.getProperty(project, GitHubProjectConfigurationPropertyType.class).option()).orElseThrow(() -> new RuntimeException("Missing GitHub property on project"));
    assertEquals("OntrackTest", configurationProperty.getConfiguration().getName());
    assertEquals("nemerosa/ontrack", configurationProperty.getRepository());
    assertEquals(30, configurationProperty.getIndexationInterval());
}
Also used : Project(net.nemerosa.ontrack.model.structure.Project) ProjectNotFoundException(net.nemerosa.ontrack.model.exceptions.ProjectNotFoundException) GitHubProjectConfigurationProperty(net.nemerosa.ontrack.extension.github.property.GitHubProjectConfigurationProperty) GitHubProjectConfigurationPropertyType(net.nemerosa.ontrack.extension.github.property.GitHubProjectConfigurationPropertyType) GitHubEngineConfiguration(net.nemerosa.ontrack.extension.github.model.GitHubEngineConfiguration) Test(org.junit.Test)

Aggregations

GitHubEngineConfiguration (net.nemerosa.ontrack.extension.github.model.GitHubEngineConfiguration)1 GitHubProjectConfigurationProperty (net.nemerosa.ontrack.extension.github.property.GitHubProjectConfigurationProperty)1 GitHubProjectConfigurationPropertyType (net.nemerosa.ontrack.extension.github.property.GitHubProjectConfigurationPropertyType)1 ProjectNotFoundException (net.nemerosa.ontrack.model.exceptions.ProjectNotFoundException)1 Project (net.nemerosa.ontrack.model.structure.Project)1 Test (org.junit.Test)1