use of org.apache.commons.lang.RandomStringUtils.randomAlphanumeric in project sonarqube by SonarSource.
the class SafeModeHealthActionTest method request_returns_status_and_causes_from_HealthChecker_checkNode_method.
@Test
public void request_returns_status_and_causes_from_HealthChecker_checkNode_method() {
authenticateWithPasscode();
Health.Status randomStatus = Health.Status.values()[new Random().nextInt(Health.Status.values().length)];
Health.Builder builder = newHealthCheckBuilder().setStatus(randomStatus);
IntStream.range(0, new Random().nextInt(5)).mapToObj(i -> RandomStringUtils.randomAlphanumeric(3)).forEach(builder::addCause);
Health health = builder.build();
when(healthChecker.checkNode()).thenReturn(health);
TestRequest request = underTest.newRequest();
System.HealthResponse healthResponse = request.executeProtobuf(System.HealthResponse.class);
assertThat(healthResponse.getHealth().name()).isEqualTo(randomStatus.name());
assertThat(health.getCauses()).isEqualTo(health.getCauses());
}
use of org.apache.commons.lang.RandomStringUtils.randomAlphanumeric in project sonarqube by SonarSource.
the class HealthActionTest method request_returns_status_and_causes_from_HealthChecker_checkNode_method_when_standalone.
@Test
public void request_returns_status_and_causes_from_HealthChecker_checkNode_method_when_standalone() {
authenticateWithRandomMethod();
Health.Status randomStatus = Health.Status.values()[new Random().nextInt(Health.Status.values().length)];
Health.Builder builder = newHealthCheckBuilder().setStatus(randomStatus);
IntStream.range(0, new Random().nextInt(5)).mapToObj(i -> RandomStringUtils.randomAlphanumeric(3)).forEach(builder::addCause);
Health health = builder.build();
when(healthChecker.checkNode()).thenReturn(health);
when(webServer.isStandalone()).thenReturn(true);
TestRequest request = underTest.newRequest();
System.HealthResponse healthResponse = request.executeProtobuf(System.HealthResponse.class);
assertThat(healthResponse.getHealth().name()).isEqualTo(randomStatus.name());
assertThat(health.getCauses()).isEqualTo(health.getCauses());
}
Aggregations