use of jetbrains.buildServer.serverSide.mute.CurrentMuteInfo in project teamcity-rest by JetBrains.
the class TestFinder method getFilter.
@NotNull
@Override
public ItemFilter<STest> getFilter(@NotNull final Locator locator) {
final MultiCheckerFilter<STest> result = new MultiCheckerFilter<>();
final String nameDimension = locator.getSingleDimensionValue(NAME);
if (nameDimension != null) {
ValueCondition nameCondition = ParameterCondition.createValueConditionFromPlainValueOrCondition(nameDimension);
result.add(item -> nameCondition.matches(item.getName().getAsString()));
}
final Boolean currentlyInvestigatedDimension = locator.getSingleDimensionValueAsBoolean(CURRENTLY_INVESTIGATED);
if (currentlyInvestigatedDimension != null) {
result.add(item -> {
// todo: check investigation in affected Project/buildType only, if set
return FilterUtil.isIncludedByBooleanFilter(currentlyInvestigatedDimension, item.getAllResponsibilities().stream().noneMatch(t -> t.getState().isActive()));
});
}
final Boolean currentlyMutedDimension = locator.getSingleDimensionValueAsBoolean(CURRENTLY_MUTED);
if (currentlyMutedDimension != null) {
result.add(item -> {
// todo: check mute in affected Project/buildType only, if set
return FilterUtil.isIncludedByBooleanFilter(currentlyMutedDimension, item.getCurrentMuteInfo() != null);
});
}
final String muteAffectedLocatorText = locator.getSingleDimensionValue(MUTE_AFFECTED);
if (muteAffectedLocatorText != null) {
Locator muteAffectedLocator = new Locator(muteAffectedLocatorText, "buildType", "project");
String muteAffectedBuildTypeLocatorText = muteAffectedLocator.getSingleDimensionValue("buildType");
if (muteAffectedBuildTypeLocatorText != null) {
final List<SBuildType> buildTypes = myBuildTypeFinder.getBuildTypes(null, muteAffectedBuildTypeLocatorText);
result.add(item -> {
CurrentMuteInfo muteInfo = item.getCurrentMuteInfo();
if (muteInfo == null)
return false;
Set<SProject> mutedInProjects = muteInfo.getProjectsMuteInfo().keySet();
Set<SBuildType> mutedInBuildTypes = muteInfo.getBuildTypeMuteInfo().keySet();
for (SBuildType buildType : buildTypes) {
if (buildType == null)
continue;
if (mutedInBuildTypes.contains(buildType))
return true;
if (ProjectFinder.isSameOrParent(mutedInProjects, buildType.getProject()))
return true;
}
return false;
});
}
String muteAffectedProjectLocatorText = muteAffectedLocator.getSingleDimensionValue("project");
if (muteAffectedProjectLocatorText != null) {
List<SProject> projects = myProjectFinder.getItems(muteAffectedProjectLocatorText).myEntries;
result.add(item -> {
CurrentMuteInfo muteInfo = item.getCurrentMuteInfo();
if (muteInfo == null)
return false;
Set<SProject> mutedInProjects = muteInfo.getProjectsMuteInfo().keySet();
return projects.stream().anyMatch(project -> ProjectFinder.isSameOrParent(mutedInProjects, project));
});
}
muteAffectedLocator.checkLocatorFullyProcessed();
}
if (locator.isUnused(BUILD)) {
String buildLocator = locator.getSingleDimensionValue(BUILD);
if (buildLocator != null) {
final TreeSet<STest> tests = getTestsByBuilds(buildLocator);
result.add(tests::contains);
}
}
return result;
}
use of jetbrains.buildServer.serverSide.mute.CurrentMuteInfo in project teamcity-rest by JetBrains.
the class ProblemWrapper method getMutes.
@NotNull
public List<MuteInfo> getMutes() {
// this returns not full mute data, but only confined to the problem (MuteInfo.getBuildProblemIds() will not return all the problems affected by the mute)
if (mutes == null) {
Set<MuteInfo> mutesSet = new TreeSet<MuteInfo>();
final SProject rootProject = myServiceLocator.getSingletonService(ProjectManager.class).getRootProject();
final CurrentMuteInfo currentMuteInfo = myServiceLocator.getSingletonService(ProblemMutingService.class).getBuildProblemCurrentMuteInfo(rootProject.getProjectId(), id);
if (currentMuteInfo != null) {
mutesSet.addAll(currentMuteInfo.getProjectsMuteInfo().values());
mutesSet.addAll(currentMuteInfo.getBuildTypeMuteInfo().values());
}
mutes = new ArrayList<MuteInfo>(mutesSet);
}
return mutes;
}
use of jetbrains.buildServer.serverSide.mute.CurrentMuteInfo in project teamcity-rest by JetBrains.
the class TestOccurrenceFinder method isCurrentlyMuted.
public boolean isCurrentlyMuted(@NotNull final STestRun item) {
// todo: TeamCity API (MP): is there an API way to figure out there is an investigation for a STestRun ?
final CurrentMuteInfo currentMuteInfo = item.getTest().getCurrentMuteInfo();
if (currentMuteInfo == null) {
return false;
}
final SBuildType buildType = item.getBuild().getBuildType();
if (buildType == null) {
// might need to log this
return false;
}
if (currentMuteInfo.getBuildTypeMuteInfo().containsKey(buildType))
return true;
final Set<SProject> projects = currentMuteInfo.getProjectsMuteInfo().keySet();
return ProjectFinder.isSameOrParent(projects, buildType.getProject());
}
Aggregations