Search in sources :

Example 1 with SCMTrait

use of jenkins.scm.api.trait.SCMTrait in project configuration-as-code-plugin by jenkinsci.

the class GiteaOrganisationFolderTest method configure_gitea_organisation_folder_seed_job.

@Test
@WithPlugin({ "branch-api.jpi", "cloudbees-folder.jpi", "scm-api.jpi", "structs.jpi" })
@ConfiguredWithCode("SeedJobTest_withGiteaOrganisation.yml")
public void configure_gitea_organisation_folder_seed_job() {
    OrganizationFolder folder = (OrganizationFolder) r.jenkins.getItem("Gitea Organization Folder");
    assertNotNull(folder);
    GiteaSCMNavigator organization = (GiteaSCMNavigator) folder.getNavigators().get(0);
    assertNotNull(organization);
    assertEquals("gitea-token", organization.getCredentialsId());
    assertEquals("https://git.example.com", organization.getServerUrl());
    assertEquals("OWN", organization.getRepoOwner());
    List<SCMTrait<?>> traits = organization.getTraits();
    assertEquals(7, traits.size());
    assertEquals(ExcludeArchivedRepositoriesTrait.class, traits.get(0).getClass());
    assertEquals(TagDiscoveryTrait.class, traits.get(1).getClass());
    SCMTrait<?> trait2 = traits.get(2);
    assertEquals(BranchDiscoveryTrait.class, trait2.getClass());
    assertEquals(1, ((BranchDiscoveryTrait) trait2).getStrategyId());
    SCMTrait<?> trait3 = traits.get(3);
    assertEquals(OriginPullRequestDiscoveryTrait.class, trait3.getClass());
    assertEquals(2, ((OriginPullRequestDiscoveryTrait) trait3).getStrategyId());
    SCMTrait<?> trait4 = traits.get(4);
    assertEquals(ForkPullRequestDiscoveryTrait.class, trait4.getClass());
    assertEquals(1, ((ForkPullRequestDiscoveryTrait) trait4).getStrategyId());
    assertEquals(ForkPullRequestDiscoveryTrait.TrustContributors.class, ((ForkPullRequestDiscoveryTrait) trait4).getTrust().getClass());
    SCMTrait<?> trait5 = traits.get(5);
    assertEquals(WebhookRegistrationTrait.class, trait5.getClass());
    assertEquals("ITEM", ((WebhookRegistrationTrait) trait5).getMode().name());
    SCMTrait<?> trait6 = traits.get(6);
    assertEquals(SSHCheckoutTrait.class, trait6.getClass());
    assertEquals("ssh-gitea", ((SSHCheckoutTrait) trait6).getCredentialsId());
}
Also used : ForkPullRequestDiscoveryTrait(org.jenkinsci.plugin.gitea.ForkPullRequestDiscoveryTrait) OrganizationFolder(jenkins.branch.OrganizationFolder) WebhookRegistrationTrait(org.jenkinsci.plugin.gitea.WebhookRegistrationTrait) GiteaSCMNavigator(org.jenkinsci.plugin.gitea.GiteaSCMNavigator) SCMTrait(jenkins.scm.api.trait.SCMTrait) Test(org.junit.Test) WithPlugin(org.jvnet.hudson.test.recipes.WithPlugin) ConfiguredWithCode(io.jenkins.plugins.casc.misc.ConfiguredWithCode)

Aggregations

ConfiguredWithCode (io.jenkins.plugins.casc.misc.ConfiguredWithCode)1 OrganizationFolder (jenkins.branch.OrganizationFolder)1 SCMTrait (jenkins.scm.api.trait.SCMTrait)1 ForkPullRequestDiscoveryTrait (org.jenkinsci.plugin.gitea.ForkPullRequestDiscoveryTrait)1 GiteaSCMNavigator (org.jenkinsci.plugin.gitea.GiteaSCMNavigator)1 WebhookRegistrationTrait (org.jenkinsci.plugin.gitea.WebhookRegistrationTrait)1 Test (org.junit.Test)1 WithPlugin (org.jvnet.hudson.test.recipes.WithPlugin)1