@Test void shouldBeInactiveIfGatesAreEmpty() { Logger logger = new Logger(); IssuesStatisticsBuilder builder = new IssuesStatisticsBuilder(); QualityGateEvaluator qualityGate = new QualityGateEvaluator(); assertThat(qualityGate.evaluate(builder.build(), logger)).isEqualTo(QualityGateStatus.INACTIVE); assertThat(logger.getMessages()).containsExactly( "-> INACTIVE - No quality gate defined"); }
public QualityGateStatus evaluate(final IssuesStatistics report, final FormattedLogger logger) { if (qualityGates.isEmpty()) { logger.print("-> INACTIVE - No quality gate defined"); return QualityGateStatus.INACTIVE; } QualityGateStatus status = QualityGateStatus.PASSED; for (QualityGate qualityGate : qualityGates) { int actualSize = qualityGate.getActualSizeMethodReference().apply(report); if (actualSize >= qualityGate.getThreshold()) { logger.print("-> %s - %s: %d - Quality QualityGate: %d", qualityGate.getStatus(), qualityGate.getName(), actualSize, qualityGate.getThreshold()); if (qualityGate.getStatus().isWorseThan(status)) { status = qualityGate.getStatus(); } } else { logger.print("-> PASSED - %s: %d - Quality QualityGate: %d", qualityGate.getName(), actualSize, qualityGate.getThreshold()); } } return status; }
QualityGateEvaluator { public QualityGateStatus evaluate(final IssuesStatistics report, final FormattedLogger logger) { if (qualityGates.isEmpty()) { logger.print("-> INACTIVE - No quality gate defined"); return QualityGateStatus.INACTIVE; } QualityGateStatus status = QualityGateStatus.PASSED; for (QualityGate qualityGate : qualityGates) { int actualSize = qualityGate.getActualSizeMethodReference().apply(report); if (actualSize >= qualityGate.getThreshold()) { logger.print("-> %s - %s: %d - Quality QualityGate: %d", qualityGate.getStatus(), qualityGate.getName(), actualSize, qualityGate.getThreshold()); if (qualityGate.getStatus().isWorseThan(status)) { status = qualityGate.getStatus(); } } else { logger.print("-> PASSED - %s: %d - Quality QualityGate: %d", qualityGate.getName(), actualSize, qualityGate.getThreshold()); } } return status; } }
QualityGateEvaluator { public QualityGateStatus evaluate(final IssuesStatistics report, final FormattedLogger logger) { if (qualityGates.isEmpty()) { logger.print("-> INACTIVE - No quality gate defined"); return QualityGateStatus.INACTIVE; } QualityGateStatus status = QualityGateStatus.PASSED; for (QualityGate qualityGate : qualityGates) { int actualSize = qualityGate.getActualSizeMethodReference().apply(report); if (actualSize >= qualityGate.getThreshold()) { logger.print("-> %s - %s: %d - Quality QualityGate: %d", qualityGate.getStatus(), qualityGate.getName(), actualSize, qualityGate.getThreshold()); if (qualityGate.getStatus().isWorseThan(status)) { status = qualityGate.getStatus(); } } else { logger.print("-> PASSED - %s: %d - Quality QualityGate: %d", qualityGate.getName(), actualSize, qualityGate.getThreshold()); } } return status; }  }
QualityGateEvaluator { public QualityGateStatus evaluate(final IssuesStatistics report, final FormattedLogger logger) { if (qualityGates.isEmpty()) { logger.print("-> INACTIVE - No quality gate defined"); return QualityGateStatus.INACTIVE; } QualityGateStatus status = QualityGateStatus.PASSED; for (QualityGate qualityGate : qualityGates) { int actualSize = qualityGate.getActualSizeMethodReference().apply(report); if (actualSize >= qualityGate.getThreshold()) { logger.print("-> %s - %s: %d - Quality QualityGate: %d", qualityGate.getStatus(), qualityGate.getName(), actualSize, qualityGate.getThreshold()); if (qualityGate.getStatus().isWorseThan(status)) { status = qualityGate.getStatus(); } } else { logger.print("-> PASSED - %s: %d - Quality QualityGate: %d", qualityGate.getName(), actualSize, qualityGate.getThreshold()); } } return status; }  QualityGateStatus evaluate(final IssuesStatistics report, final FormattedLogger logger); void add(final int size, final QualityGateType type, final QualityGateResult strength); void addAll(final Collection<? extends QualityGate> additionalQualityGates); boolean isEnabled(); }
QualityGateEvaluator { public QualityGateStatus evaluate(final IssuesStatistics report, final FormattedLogger logger) { if (qualityGates.isEmpty()) { logger.print("-> INACTIVE - No quality gate defined"); return QualityGateStatus.INACTIVE; } QualityGateStatus status = QualityGateStatus.PASSED; for (QualityGate qualityGate : qualityGates) { int actualSize = qualityGate.getActualSizeMethodReference().apply(report); if (actualSize >= qualityGate.getThreshold()) { logger.print("-> %s - %s: %d - Quality QualityGate: %d", qualityGate.getStatus(), qualityGate.getName(), actualSize, qualityGate.getThreshold()); if (qualityGate.getStatus().isWorseThan(status)) { status = qualityGate.getStatus(); } } else { logger.print("-> PASSED - %s: %d - Quality QualityGate: %d", qualityGate.getName(), actualSize, qualityGate.getThreshold()); } } return status; }  QualityGateStatus evaluate(final IssuesStatistics report, final FormattedLogger logger); void add(final int size, final QualityGateType type, final QualityGateResult strength); void addAll(final Collection<? extends QualityGate> additionalQualityGates); boolean isEnabled();  }