Search in sources :

Example 1 with TestFinder

use of jetbrains.buildServer.server.rest.data.problem.TestFinder in project teamcity-rest by JetBrains.

the class BuildPromotionFinder method getBuildFilter.

@NotNull
private MultiCheckerFilter<SBuild> getBuildFilter(@NotNull final Locator locator) {
    final MultiCheckerFilter<SBuild> result = new MultiCheckerFilter<SBuild>();
    final String buildNumber = locator.getSingleDimensionValue(NUMBER);
    if (buildNumber != null) {
        result.add(new FilterConditionChecker<SBuild>() {

            public boolean isIncluded(@NotNull final SBuild item) {
                return buildNumber.equals(item.getBuildNumber());
            }
        });
    }
    final String status = locator.getSingleDimensionValue(STATUS);
    if (status != null) {
        result.add(new FilterConditionChecker<SBuild>() {

            public boolean isIncluded(@NotNull final SBuild item) {
                return status.equalsIgnoreCase(item.getStatusDescriptor().getStatus().getText());
            }
        });
    }
    final Boolean pinned = locator.getSingleDimensionValueAsBoolean(PINNED);
    if (pinned != null) {
        result.add(new FilterConditionChecker<SBuild>() {

            public boolean isIncluded(@NotNull final SBuild item) {
                return FilterUtil.isIncludedByBooleanFilter(pinned, item.isPinned());
            }
        });
    }
    final Boolean hanging = locator.getSingleDimensionValueAsBoolean(HANGING);
    if (hanging != null) {
        result.add(new FilterConditionChecker<SBuild>() {

            public boolean isIncluded(@NotNull final SBuild item) {
                if (item.isFinished())
                    return !hanging;
                return FilterUtil.isIncludedByBooleanFilter(hanging, ((SRunningBuild) item).isProbablyHanging());
            }
        });
    }
    if (locator.isUnused(AGENT_NAME)) {
        final String agentName = locator.getSingleDimensionValue(AGENT_NAME);
        if (agentName != null) {
            final ValueCondition agentNameCondition = ParameterCondition.createValueCondition(agentName);
            result.add(item -> agentNameCondition.matches(item.getAgentName()));
        }
    }
    if (locator.isUnused(AGENT_TYPE_ID)) {
        final Long agentTypeId = locator.getSingleDimensionValueAsLong(AGENT_TYPE_ID);
        if (agentTypeId != null) {
            result.add(item -> agentTypeId.intValue() == item.getAgent().getAgentTypeId());
        }
    }
    // see also settings cut off date in main filter
    final Date sinceDate = DataProvider.parseDate(locator.getSingleDimensionValue(SINCE_DATE));
    if (sinceDate != null) {
        result.add(new FilterConditionChecker<SBuild>() {

            public boolean isIncluded(@NotNull final SBuild item) {
                return sinceDate.before(item.getStartDate());
            }
        });
    }
    final Date untilDate = DataProvider.parseDate(locator.getSingleDimensionValue(UNTIL_DATE));
    if (untilDate != null) {
        result.add(new FilterConditionChecker<SBuild>() {

            public boolean isIncluded(@NotNull final SBuild item) {
                return !(untilDate.before(item.getStartDate()));
            }
        });
    }
    final List<String> statisticValues = locator.getDimensionValue(STATISTIC_VALUE);
    if (!statisticValues.isEmpty()) {
        final Matcher<ParametersProvider> parameterCondition = ParameterCondition.create(statisticValues);
        result.add(new FilterConditionChecker<SBuild>() {

            public boolean isIncluded(@NotNull final SBuild item) {
                return parameterCondition.matches(new AbstractMapParametersProvider(Build.getBuildStatisticsValues(item)));
            }
        });
    }
    if (locator.isUnused(TEST_OCCURRENCE)) {
        final String testOccurrence = locator.getSingleDimensionValue(TEST_OCCURRENCE);
        if (testOccurrence != null) {
            TestOccurrenceFinder testOccurrenceFinder = myServiceLocator.getSingletonService(TestOccurrenceFinder.class);
            Set<Long> buildPromotionIds = testOccurrenceFinder.getItems(testOccurrence).myEntries.stream().map(sTestRun -> sTestRun.getBuild().getBuildPromotion().getId()).collect(Collectors.toSet());
            result.add(new FilterConditionChecker<SBuild>() {

                public boolean isIncluded(@NotNull final SBuild item) {
                    return buildPromotionIds.contains(item.getBuildPromotion().getId());
                }
            });
        }
    }
    final String test = locator.getSingleDimensionValue(TEST);
    if (test != null) {
        TestFinder testFinder = myServiceLocator.getSingletonService(TestFinder.class);
        result.add(new FilterConditionChecker<SBuild>() {

            public boolean isIncluded(@NotNull final SBuild item) {
                String locator = new Locator(test).setDimension(TestFinder.BUILD, getLocator(item.getBuildPromotion())).setDimension(PagerData.COUNT, "1").getStringRepresentation();
                return !testFinder.getItems(locator).myEntries.isEmpty();
            }
        });
    }
    return result;
}
Also used : LocatorProcessException(jetbrains.buildServer.server.rest.errors.LocatorProcessException) MetadataStorageEx(jetbrains.buildServer.serverSide.metadata.impl.MetadataStorageEx) Filter(jetbrains.buildServer.util.filters.Filter) java.util(java.util) LocatorName(jetbrains.buildServer.server.rest.swagger.constants.LocatorName) LocatorResource(jetbrains.buildServer.server.rest.swagger.annotations.LocatorResource) Agent(jetbrains.buildServer.server.rest.model.agent.Agent) BuildDependency(jetbrains.buildServer.serverSide.dependency.BuildDependency) Converter(jetbrains.buildServer.util.Converter) ParametersProvider(jetbrains.buildServer.parameters.ParametersProvider) BadRequestException(jetbrains.buildServer.server.rest.errors.BadRequestException) LocatorDimensionDataType(jetbrains.buildServer.server.rest.swagger.constants.LocatorDimensionDataType) AbstractMapParametersProvider(jetbrains.buildServer.parameters.impl.AbstractMapParametersProvider) TestOccurrenceFinder(jetbrains.buildServer.server.rest.data.problem.TestOccurrenceFinder) AccessDeniedException(jetbrains.buildServer.serverSide.auth.AccessDeniedException) ErrorData(jetbrains.buildServer.messages.ErrorData) StringUtil(jetbrains.buildServer.util.StringUtil) Build(jetbrains.buildServer.server.rest.model.build.Build) Logger(com.intellij.openapi.diagnostic.Logger) CollectionsUtil(jetbrains.buildServer.util.CollectionsUtil) jetbrains.buildServer.server.rest.data.util(jetbrains.buildServer.server.rest.data.util) PagerData(jetbrains.buildServer.server.rest.model.PagerData) SVcsRoot(jetbrains.buildServer.vcs.SVcsRoot) PatternSyntaxException(java.util.regex.PatternSyntaxException) Constants(jetbrains.buildServer.server.rest.request.Constants) ServiceLocator(jetbrains.buildServer.ServiceLocator) jetbrains.buildServer.serverSide(jetbrains.buildServer.serverSide) ItemsProviders(jetbrains.buildServer.server.rest.model.ItemsProviders) TagFinder(jetbrains.buildServer.server.rest.data.build.TagFinder) ItemProcessor(jetbrains.buildServer.util.ItemProcessor) StreamUtil(jetbrains.buildServer.server.rest.util.StreamUtil) Collectors(java.util.stream.Collectors) Nullable(org.jetbrains.annotations.Nullable) CommonLocatorDimensionsList(jetbrains.buildServer.server.rest.swagger.constants.CommonLocatorDimensionsList) Stream(java.util.stream.Stream) LocatorDimension(jetbrains.buildServer.server.rest.swagger.annotations.LocatorDimension) Util(jetbrains.buildServer.server.rest.model.Util) Permission(jetbrains.buildServer.serverSide.auth.Permission) NotFoundException(jetbrains.buildServer.server.rest.errors.NotFoundException) TestFinder(jetbrains.buildServer.server.rest.data.problem.TestFinder) BuildMetadataEntry(jetbrains.buildServer.serverSide.metadata.BuildMetadataEntry) Pattern(java.util.regex.Pattern) NotNull(org.jetbrains.annotations.NotNull) SUser(jetbrains.buildServer.users.SUser) TestOccurrenceFinder(jetbrains.buildServer.server.rest.data.problem.TestOccurrenceFinder) ParametersProvider(jetbrains.buildServer.parameters.ParametersProvider) AbstractMapParametersProvider(jetbrains.buildServer.parameters.impl.AbstractMapParametersProvider) AbstractMapParametersProvider(jetbrains.buildServer.parameters.impl.AbstractMapParametersProvider) ServiceLocator(jetbrains.buildServer.ServiceLocator) TestFinder(jetbrains.buildServer.server.rest.data.problem.TestFinder) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with TestFinder

use of jetbrains.buildServer.server.rest.data.problem.TestFinder in project teamcity-rest by JetBrains.

the class BaseTestScopesCollectorTest method setUp.

@BeforeMethod(alwaysRun = true)
@Override
protected void setUp() throws Exception {
    super.setUp();
    myTimeCondition = new TimeCondition(myFixture);
    myFixture.addService(myTimeCondition);
    myPermissionChecker = new PermissionChecker(myServer.getSecurityContext(), myProjectManager);
    myFixture.addService(myPermissionChecker);
    myProjectFinder = new ProjectFinder(myProjectManager, myPermissionChecker, myServer);
    myFixture.addService(myProjectFinder);
    myGroupFinder = new UserGroupFinder(getUserGroupManager());
    myFixture.addService(myGroupFinder);
    myUserFinder = new UserFinder(getUserModelEx(), myGroupFinder, myProjectFinder, myTimeCondition, myFixture.getRolesManager(), myPermissionChecker, myServer.getSecurityContext(), myServer);
    myAgentFinder = new AgentFinder(myAgentManager, myFixture);
    myFixture.addService(myAgentFinder);
    myBuildTypeFinder = new BuildTypeFinder(myProjectManager, myProjectFinder, myAgentFinder, myPermissionChecker, myFixture);
    myBranchFinder = new BranchFinder(myBuildTypeFinder, myFixture);
    final VcsRootIdentifiersManagerImpl vcsRootIdentifiersManager = myFixture.getSingletonService(VcsRootIdentifiersManagerImpl.class);
    myVcsRootFinder = new VcsRootFinder(myFixture.getVcsManager(), myProjectFinder, myBuildTypeFinder, myProjectManager, vcsRootIdentifiersManager, myPermissionChecker);
    myFixture.addService(myVcsRootFinder);
    myBuildPromotionFinder = new BuildPromotionFinder(myFixture.getBuildPromotionManager(), myFixture.getBuildQueue(), myServer, myVcsRootFinder, myProjectFinder, myBuildTypeFinder, myUserFinder, myAgentFinder, myBranchFinder, myTimeCondition, myPermissionChecker, null, myFixture);
    myFixture.addService(myBuildPromotionFinder);
    myBuildFinder = new BuildFinder(myFixture, myBuildTypeFinder, myProjectFinder, myUserFinder, myBuildPromotionFinder, myAgentFinder);
    final TestName2Index testName2Index = myFixture.getSingletonService(TestName2Index.class);
    final ProblemMutingService problemMutingService = myFixture.getSingletonService(ProblemMutingService.class);
    myTestFinder = new TestFinder(myProjectFinder, myBuildTypeFinder, myBuildPromotionFinder, myFixture.getTestManager(), testName2Index, myFixture.getCurrentProblemsManager(), problemMutingService);
    myFixture.addService(myTestFinder);
    TestScopeFilterProducer testScopesFilterProducer = new TestScopeFilterProducer(myBuildTypeFinder);
    final CurrentProblemsManager currentProblemsManager = myServer.getSingletonService(CurrentProblemsManager.class);
    myTestOccurrenceFinder = new TestOccurrenceFinder(myServer.getSecurityContext(), myTestFinder, myBuildFinder, myBuildTypeFinder, myProjectFinder, myFixture.getTestsHistory(), currentProblemsManager, myBranchFinder, testScopesFilterProducer);
    myFixture.addService(myTestOccurrenceFinder);
    myTestScopesCollector = new TestScopesCollector(myTestOccurrenceFinder, testScopesFilterProducer);
}
Also used : TestScopesCollector(jetbrains.buildServer.server.rest.data.problem.scope.TestScopesCollector) CurrentProblemsManager(jetbrains.buildServer.serverSide.CurrentProblemsManager) VcsRootIdentifiersManagerImpl(jetbrains.buildServer.serverSide.identifiers.VcsRootIdentifiersManagerImpl) TestName2Index(jetbrains.buildServer.serverSide.TestName2Index) TestOccurrenceFinder(jetbrains.buildServer.server.rest.data.problem.TestOccurrenceFinder) TestScopeFilterProducer(jetbrains.buildServer.server.rest.data.problem.scope.TestScopeFilterProducer) TestFinder(jetbrains.buildServer.server.rest.data.problem.TestFinder) ProblemMutingService(jetbrains.buildServer.serverSide.mute.ProblemMutingService) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 3 with TestFinder

use of jetbrains.buildServer.server.rest.data.problem.TestFinder in project teamcity-rest by JetBrains.

the class BaseFinderTest method initFinders.

protected void initFinders() {
    myVcsManager = myFixture.getVcsManager();
    myFixture.addService(myVcsManager);
    myFixture.addService(myProjectManager);
    myPermissionChecker = new PermissionChecker(myServer.getSecurityContext(), myProjectManager);
    myFixture.addService(myPermissionChecker);
    myTimeCondition = new TimeCondition(myFixture);
    myFixture.addService(myTimeCondition);
    myProjectFinder = new ProjectFinder(myProjectManager, myPermissionChecker, myServer);
    myFixture.addService(myProjectFinder);
    myAgentFinder = new AgentFinder(myAgentManager, myFixture);
    myFixture.addService(myAgentFinder);
    myAgentPoolFinder = new AgentPoolFinder(myFixture.getAgentPoolManager(), myAgentFinder, myFixture);
    myFixture.addService(myAgentPoolFinder);
    myBuildTypeFinder = new BuildTypeFinder(myProjectManager, myProjectFinder, myAgentFinder, myPermissionChecker, myServer);
    myFixture.addService(myBuildTypeFinder);
    final VcsRootIdentifiersManagerImpl vcsRootIdentifiersManager = myFixture.getSingletonService(VcsRootIdentifiersManagerImpl.class);
    myVcsRootFinder = new VcsRootFinder(myVcsManager, myProjectFinder, myBuildTypeFinder, myProjectManager, vcsRootIdentifiersManager, myPermissionChecker);
    myFixture.addService(myVcsRootFinder);
    myVcsRootInstanceFinder = new VcsRootInstanceFinder(myVcsRootFinder, myVcsManager, myProjectFinder, myBuildTypeFinder, myProjectManager, myFixture.getSingletonService(VersionedSettingsManager.class), myTimeCondition, myPermissionChecker, myServer);
    myFixture.addService(myVcsRootInstanceFinder);
    myGroupFinder = new UserGroupFinder(getUserGroupManager());
    myFixture.addService(myGroupFinder);
    myUserFinder = new UserFinder(getUserModelEx(), myGroupFinder, myProjectFinder, myTimeCondition, myFixture.getRolesManager(), myPermissionChecker, myServer.getSecurityContext(), myServer);
    myFixture.addService(myUserFinder);
    myBranchFinder = new BranchFinder(myBuildTypeFinder, myFixture);
    myBuildPromotionFinder = new BuildPromotionFinder(myFixture.getBuildPromotionManager(), myFixture.getBuildQueue(), myServer, myVcsRootFinder, myProjectFinder, myBuildTypeFinder, myUserFinder, myAgentFinder, myBranchFinder, myTimeCondition, myPermissionChecker, null, myFixture);
    myFixture.addService(myBuildPromotionFinder);
    myBuildFinder = new BuildFinder(myServer, myBuildTypeFinder, myProjectFinder, myUserFinder, myBuildPromotionFinder, myAgentFinder);
    myFixture.addService(myBuildFinder);
    final TestName2Index testName2Index = myFixture.getSingletonService(TestName2Index.class);
    final ProblemMutingService problemMutingService = myFixture.getSingletonService(ProblemMutingService.class);
    myTestFinder = new TestFinder(myProjectFinder, myBuildTypeFinder, myBuildPromotionFinder, myFixture.getTestManager(), testName2Index, myFixture.getCurrentProblemsManager(), problemMutingService);
    myFixture.addService(myTestFinder);
    TestScopeFilterProducer filterProducer = new TestScopeFilterProducer(myBuildTypeFinder);
    final CurrentProblemsManager currentProblemsManager = myServer.getSingletonService(CurrentProblemsManager.class);
    myTestOccurrenceFinder = new TestOccurrenceFinder(myServer.getSecurityContext(), myTestFinder, myBuildFinder, myBuildTypeFinder, myProjectFinder, myFixture.getTestsHistory(), currentProblemsManager, myBranchFinder, filterProducer);
    myFixture.addService(myTestOccurrenceFinder);
    final BuildProblemManager buildProblemManager = myFixture.getSingletonService(BuildProblemManager.class);
    myProblemFinder = new ProblemFinder(myProjectFinder, myBuildPromotionFinder, buildProblemManager, myProjectManager, myFixture, problemMutingService);
    myFixture.addService(myProblemFinder);
    myProblemOccurrenceFinder = new ProblemOccurrenceFinder(myProjectFinder, myBuildFinder, myProblemFinder, buildProblemManager, myProjectManager, myFixture);
    myFixture.addService(myProblemOccurrenceFinder);
    final ResponsibilityFacadeEx responsibilityFacade = myFixture.getResponsibilityFacadeEx();
    myInvestigationFinder = new InvestigationFinder(myProjectFinder, myBuildTypeFinder, myProblemFinder, myTestFinder, myUserFinder, responsibilityFacade, responsibilityFacade, responsibilityFacade);
    myFixture.addService(myInvestigationFinder);
    myMuteFinder = new MuteFinder(myProjectFinder, myTimeCondition, myPermissionChecker, problemMutingService, (LowLevelProblemMutingServiceImpl) myFixture.getSingletonService(LowLevelProblemMutingService.class), myFixture);
    myFixture.addService(myMuteFinder);
    myQueuedBuildFinder = new QueuedBuildFinder(myServer.getQueue(), myProjectFinder, myBuildTypeFinder, myUserFinder, myAgentFinder, myAgentPoolFinder, myFixture.getBuildPromotionManager(), myServer);
    myFixture.addService(myQueuedBuildFinder);
    myChangeFinder = new ChangeFinder(myProjectFinder, myBuildFinder, myBuildPromotionFinder, myBuildTypeFinder, myVcsRootFinder, myVcsRootInstanceFinder, myUserFinder, myVcsManager, myFixture.getVcsHistory(), myBranchFinder, myFixture, myPermissionChecker);
    myFixture.addService(myChangeFinder);
    myFixture.addService(new HealthItemFinder(myFixture.getSingletonService(HealthStatusProvider.class), myFixture.getSingletonService(HealthStatusReportLocator.class), myFixture));
}
Also used : LowLevelProblemMutingService(jetbrains.buildServer.serverSide.mute.LowLevelProblemMutingService) ResponsibilityFacadeEx(jetbrains.buildServer.responsibility.ResponsibilityFacadeEx) VcsRootIdentifiersManagerImpl(jetbrains.buildServer.serverSide.identifiers.VcsRootIdentifiersManagerImpl) InvestigationFinder(jetbrains.buildServer.server.rest.data.investigations.InvestigationFinder) MuteFinder(jetbrains.buildServer.server.rest.data.mutes.MuteFinder) LowLevelProblemMutingService(jetbrains.buildServer.serverSide.mute.LowLevelProblemMutingService) ProblemMutingService(jetbrains.buildServer.serverSide.mute.ProblemMutingService) BuildProblemManager(jetbrains.buildServer.serverSide.problems.BuildProblemManager) CurrentProblemsManager(jetbrains.buildServer.serverSide.CurrentProblemsManager) TestName2Index(jetbrains.buildServer.serverSide.TestName2Index) TestOccurrenceFinder(jetbrains.buildServer.server.rest.data.problem.TestOccurrenceFinder) ProblemOccurrenceFinder(jetbrains.buildServer.server.rest.data.problem.ProblemOccurrenceFinder) TestScopeFilterProducer(jetbrains.buildServer.server.rest.data.problem.scope.TestScopeFilterProducer) TestFinder(jetbrains.buildServer.server.rest.data.problem.TestFinder) ProblemFinder(jetbrains.buildServer.server.rest.data.problem.ProblemFinder) LowLevelProblemMutingServiceImpl(jetbrains.buildServer.serverSide.mute.LowLevelProblemMutingServiceImpl)

Aggregations

TestFinder (jetbrains.buildServer.server.rest.data.problem.TestFinder)3 TestOccurrenceFinder (jetbrains.buildServer.server.rest.data.problem.TestOccurrenceFinder)3 TestScopeFilterProducer (jetbrains.buildServer.server.rest.data.problem.scope.TestScopeFilterProducer)2 CurrentProblemsManager (jetbrains.buildServer.serverSide.CurrentProblemsManager)2 TestName2Index (jetbrains.buildServer.serverSide.TestName2Index)2 VcsRootIdentifiersManagerImpl (jetbrains.buildServer.serverSide.identifiers.VcsRootIdentifiersManagerImpl)2 ProblemMutingService (jetbrains.buildServer.serverSide.mute.ProblemMutingService)2 Logger (com.intellij.openapi.diagnostic.Logger)1 java.util (java.util)1 Pattern (java.util.regex.Pattern)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 ServiceLocator (jetbrains.buildServer.ServiceLocator)1 ErrorData (jetbrains.buildServer.messages.ErrorData)1 ParametersProvider (jetbrains.buildServer.parameters.ParametersProvider)1 AbstractMapParametersProvider (jetbrains.buildServer.parameters.impl.AbstractMapParametersProvider)1 ResponsibilityFacadeEx (jetbrains.buildServer.responsibility.ResponsibilityFacadeEx)1 TagFinder (jetbrains.buildServer.server.rest.data.build.TagFinder)1 InvestigationFinder (jetbrains.buildServer.server.rest.data.investigations.InvestigationFinder)1