Class TestHistoryImpl

  • All Implemented Interfaces:
    TestHistory

    public class TestHistoryImpl
    extends Object
    implements TestHistory
    This is facade class that should accumulate all methods to write and access test information. Internally uses caching to speedup avoid slow database operations. TODO: extract and document public interface and contract State is changed:
    • running build state restored
    • running inserts test
    • lisneter.buildFailed
    • lisneter.buildCancelled
    State used:
    • calculating first failed in/fixed in for builds
    I beleive that
    • we should monitor running build directly tests
    • fixed/failed information should be written into database
    • Method Detail

      • resetCaches

        public void resetCaches()
      • unregisterBuildTypeTests

        public void unregisterBuildTypeTests​(@NotNull
                                             String buildTypeId)
      • getBuild2StatusMapForTest

        public Long2StatusCollection getBuild2StatusMapForTest​(long testNameId,
                                                               @NotNull
                                                               Set<String> buildTypeIds,
                                                               long minBuildId)
        Description copied from interface: TestHistory
        Loads test statuses across all builds in the given build configurations.

        Return a map structure: buildId -> Status for test statuses of a test with given testNameId, in no particular order

        Specified by:
        getBuild2StatusMapForTest in interface TestHistory
        minBuildId - Minimal value of buildId for which the data will be obtained (inclusive)
        Returns:
        see above
      • getRelevantBuildTypes

        @NotNull
        public Collection<SBuildType> getRelevantBuildTypes​(@NotNull
                                                            SBuild build)
        Description copied from interface: TestHistory
        Return build types which should be treated equally when calculating "isNew" and "isFixedIn" status for a test.
        Specified by:
        getRelevantBuildTypes in interface TestHistory
        Parameters:
        build - build for which the scope should be calculated. This build may belong to any of the configurations from the scope, or maybe some parent configuration.
        Returns:
        see above
        See Also:
        BuildTypesTestScope
      • hasBuildsWithTests

        public boolean hasBuildsWithTests​(@NotNull
                                          BuildType buildType)
        Returns the number of builds of the given Build Type that have at leat one test run.
        Specified by:
        hasBuildsWithTests in interface TestHistory
        Parameters:
        buildType - Build Type
        Returns:
        true if build configuration has builds with tests.
      • getLastBuildsForTestsDefaultBranch

        @NotNull
        public Collection<SBuild> getLastBuildsForTestsDefaultBranch​(@NotNull
                                                                     Collection<Long> testNameIds,
                                                                     @Nullable
                                                                     SProject project)
        Returns the last finished builds in the project that have any of the tests specified either passed or failed (ignored tests are not considered).
        Specified by:
        getLastBuildsForTestsDefaultBranch in interface TestHistory
        Parameters:
        testNameIds - the ids of the tests
        project - the project to search in, `null` project means all active build types under `root` project on buildserver
        Returns:
        required builds
      • getBuildTypesForTests

        @NotNull
        public Collection<SBuildType> getBuildTypesForTests​(@NotNull
                                                            Collection<Long> testNameIds,
                                                            @Nullable
                                                            SProject project)
        Returns the collection of build types, in which the tests that correspond to testNameIds were executed (the union, not intersection). If the project is specified, the result is filtered by it.

        Currently running builds are not considered.

        Specified by:
        getBuildTypesForTests in interface TestHistory
        Parameters:
        testNameIds - the tests collection
        project - the project (nullable)
        Returns:
        collection of build types
        Since:
        7.1
      • getBuildTypesForTests

        @NotNull
        public Collection<SBuildType> getBuildTypesForTests​(@NotNull
                                                            Collection<STest> tests)
        Returns the collection of build types, in which the tests were executed (the union, not intersection). If all tests are from one project, the result is filtered by it.

        Currently running builds are not considered.

        Specified by:
        getBuildTypesForTests in interface TestHistory
        Parameters:
        tests - the tests collection
        Returns:
        collection of build types
        Since:
        7.1
      • getBuildTypesForTests

        @NotNull
        public Collection<SBuildType> getBuildTypesForTests​(@Nullable
                                                            SProject project,
                                                            @NotNull
                                                            Collection<TestName> testNames)
        Returns the collection of build types, in which the tests that correspond to testNames were executed (the union, not intersection). If the project is specified, the result is filtered by it.

        Currently running builds are not considered.

        Specified by:
        getBuildTypesForTests in interface TestHistory
        Parameters:
        project - the project (nullable)
        testNames - the tests collection
        Returns:
        collection of build types
        Since:
        7.1
      • getTestStatuses

        public Long2StatusCollection getTestStatuses​(@NotNull
                                                     Collection<Long> testNameIds,
                                                     long buildId,
                                                     boolean cacheResults)
        Return a Long2StatusCollection which contains statuses of test runs for build from testNameIds collection
        Specified by:
        getTestStatuses in interface TestHistory
        Parameters:
        buildId - build to analyze
        testNameIds - collection of tests
        cacheResults - should be false if build is running
        Returns:
        see above
      • getTestHistory

        @NotNull
        public List<STestRun> getTestHistory​(long testNameId,
                                             @NotNull
                                             String buildTypeId,
                                             long userId,
                                             @Nullable
                                             String branchName)
        Description copied from interface: TestHistory
        Order of the returned TestRuns is recent runs first, according to the starting order of the builds. Multiple test runs in the build are NOT wrapped into MultiRun class, i.e. each test run is returned independently
        Specified by:
        getTestHistory in interface TestHistory
        buildTypeId - required to set the build configuration for the test history
        userId - if > 0, includes personal builds of the given user
        branchName - if not null, returns only builds which match given branchName
        Returns:
        Test run objects for given test, recent builds go first
      • getTestHistory

        @NotNull
        public List<STestRun> getTestHistory​(long testNameId,
                                             @NotNull
                                             String buildTypeId,
                                             Filter<STestRun> filter)
        Description copied from interface: TestHistory
        Order of the returned TestRuns is recent runs first, according to the starting order of the builds. Multiple test runs in the build are NOT wrapped into MultiRun class, i.e. each test run is returned independently
        Specified by:
        getTestHistory in interface TestHistory
        buildTypeId - required to set the build configuration for the test history
        filter - additional filter for the returned test runs
        Returns:
        Test run objects for given test, recent builds go first
      • getTestHistory

        @NotNull
        public List<STestRun> getTestHistory​(long testNameId,
                                             @NotNull
                                             SProject project,
                                             long userId,
                                             @Nullable
                                             String branchName)
        Description copied from interface: TestHistory
        Order of the returned TestRuns is recent runs first, according to the starting order of the builds. Multiple test runs in the build are NOT wrapped into MultiRun class, i.e. each test run is returned independently
        Specified by:
        getTestHistory in interface TestHistory
        project - required to set the parent project, all returned test runs will belong to build configurations under this project and its subprojects
        userId - if > 0, includes personal builds of the given user
        branchName - if not null, returns only builds which match given branchName
        Returns:
        Test run objects for given test, recent builds go first
      • getTestHistory

        @NotNull
        public List<STestRun> getTestHistory​(long testNameId,
                                             @NotNull
                                             SProject project,
                                             Filter<STestRun> filter)
        Description copied from interface: TestHistory
        Order of the returned TestRuns is recent runs first, according to the starting order of the builds. Multiple test runs in the build are NOT wrapped into MultiRun class, i.e. each test run is returned independently
        Specified by:
        getTestHistory in interface TestHistory
        project - required to set the parent project, all returned test runs will belong to build configurations under this project and its subprojects
        filter - additional filter for the returned test runs
        Returns:
        Test run objects for given test, recent builds go first