src/test/java/com/cloudbees/jenkins/support/impl/AbstractItemComponentTest.java
@Test
    public void addContentsFromFolderWithIncludes() throws Exception {
        MockFolder f = j.createFolder(FOLDER_NAME);
        MockFolder subFolder = f.createProject(MockFolder.class, "subFolder");
        FreeStyleProject p = subFolder.createProject(FreeStyleProject.class, JOB_NAME);
        j.waitForCompletion(Optional.ofNullable(p.scheduleBuild2(0))
                .orElseThrow(AssertionFailedError::new).waitForStart());
        j.waitUntilNoActivity();

        Map<String, String> output = SupportTestUtils.invokeComponentToMap(
                new AbstractItemDirectoryComponent("**/config.xml, **/jobs/*.xml", "", true, 10), f);

        String prefix = "items/" + FOLDER_NAME;
        assertTrue(output.containsKey(prefix + "/config.xml"));
        assertTrue(output.containsKey(prefix + "/jobs/subFolder/config.xml"));
        assertTrue(output.containsKey(prefix + "/jobs/subFolder/jobs/" + JOB_NAME + "/config.xml"));
        assertFalse(output.containsKey(prefix + "/jobs/subFolder/jobs/" + JOB_NAME + "/nextBuildNumber"));
        assertFalse(output.containsKey(prefix + "/jobs/subFolder/jobs/" + JOB_NAME + "/1/build.xml"));
        assertFalse(output.containsKey(prefix + "/jobs/subFolder/jobs/" + JOB_NAME + "/1/log"));
    }
/*
     * Test adding item directory content with includes patterns for a folder.
     */
Test adding item directory content with includes patterns for a folder.
Test adding item directory content with includes patterns for a folder .
@Test
    public void addContentsFromFolderWithIncludes() throws Exception {
        MockFolder f = j.createFolder(FOLDER_NAME);
        MockFolder subFolder = f.createProject(MockFolder.class, "subFolder");
        FreeStyleProject p = subFolder.createProject(FreeStyleProject.class, JOB_NAME);
        j.waitForCompletion(Optional.ofNullable(p.scheduleBuild2(0))
                .orElseThrow(AssertionFailedError::new).waitForStart());
        j.waitUntilNoActivity();
        Map<String, String> output = SupportTestUtils.invokeComponentToMap(
                new AbstractItemDirectoryComponent("**/config.xml, **/jobs/*.xml", "", true, 10), f);
        String prefix = "items/" + FOLDER_NAME;
        assertTrue(output.containsKey(prefix + "/config.xml"));
        assertTrue(output.containsKey(prefix + "/jobs/subFolder/config.xml"));
        assertTrue(output.containsKey(prefix + "/jobs/subFolder/jobs/" + JOB_NAME + "/config.xml"));
        assertFalse(output.containsKey(prefix + "/jobs/subFolder/jobs/" + JOB_NAME + "/nextBuildNumber"));
        assertFalse(output.containsKey(prefix + "/jobs/subFolder/jobs/" + JOB_NAME + "/1/build.xml"));
        assertFalse(output.containsKey(prefix + "/jobs/subFolder/jobs/" + JOB_NAME + "/1/log"));
    }
@ Test public void addContentsFromFolderWithIncludes ( ) throws Exception { MockFolder f = j . createFolder ( FOLDER_NAME ) ; MockFolder subFolder = f . createProject ( MockFolder . class , "subFolder" ) ; FreeStyleProject p = subFolder . createProject ( FreeStyleProject . class , JOB_NAME ) ; j . waitForCompletion ( Optional . ofNullable ( p . scheduleBuild2 ( 0 ) ) . orElseThrow ( AssertionFailedError :: new ) . waitForStart ( ) ) ; j . waitUntilNoActivity ( ) ; Map < String , String > output = SupportTestUtils . invokeComponentToMap ( new AbstractItemDirectoryComponent ( "**/config.xml, **/jobs/*.xml" , "" , true , 10 ) , f ) ; String prefix = "items/" + FOLDER_NAME ; assertTrue ( output . containsKey ( prefix + "/config.xml" ) ) ; assertTrue ( output . containsKey ( prefix + "/jobs/subFolder/config.xml" ) ) ; assertTrue ( output . containsKey ( prefix + "/jobs/subFolder/jobs/" + JOB_NAME + "/config.xml" ) ) ; assertFalse ( output . containsKey ( prefix + "/jobs/subFolder/jobs/" + JOB_NAME + "/nextBuildNumber" ) ) ; assertFalse ( output . containsKey ( prefix + "/jobs/subFolder/jobs/" + JOB_NAME + "/1/build.xml" ) ) ; assertFalse ( output . containsKey ( prefix + "/jobs/subFolder/jobs/" + JOB_NAME + "/1/log" ) ) ; }
Test adding item directory content with includes patterns for a folder.
Test adding item directory content with includes patterns for a folder .