use of io.stackgres.operator.common.StackGresClusterReview in project stackgres by ongres.
the class DistributedLogsReferenceValidatorTest method giveAnAttemptToUpdateToAnKnownProfile_shouldNotFail.
@Test
void giveAnAttemptToUpdateToAnKnownProfile_shouldNotFail() throws ValidationFailed {
final StackGresClusterReview review = JsonUtil.readFromJson("cluster_allow_requests/distributed_logs_update.json", StackGresClusterReview.class);
String distributedLogsName = review.getRequest().getObject().getSpec().getDistributedLogs().getDistributedLogs();
String namespace = review.getRequest().getObject().getMetadata().getNamespace();
StackGresDistributedLogs distributedLogs = JsonUtil.readFromJson("distributedlogs/default.json", StackGresDistributedLogs.class);
when(distributedLogsFinder.findByNameAndNamespace(distributedLogsName, namespace)).thenReturn(Optional.of(distributedLogs));
validator.validate(review);
verify(distributedLogsFinder).findByNameAndNamespace(anyString(), anyString());
}
use of io.stackgres.operator.common.StackGresClusterReview in project stackgres by ongres.
the class DistributedLogsReferenceValidatorTest method giveAnAttemptToDelete_shouldNotFail.
@Test
void giveAnAttemptToDelete_shouldNotFail() throws ValidationFailed {
final StackGresClusterReview review = JsonUtil.readFromJson("cluster_allow_requests/distributed_logs_update.json", StackGresClusterReview.class);
review.getRequest().setOperation(Operation.DELETE);
validator.validate(review);
verify(distributedLogsFinder, never()).findByNameAndNamespace(anyString(), anyString());
}
use of io.stackgres.operator.common.StackGresClusterReview in project stackgres by ongres.
the class DistributedLogsReferenceValidatorTest method giveAnAttemptToUpdateToAnUnknownProfile_shouldFail.
@Test
void giveAnAttemptToUpdateToAnUnknownProfile_shouldFail() {
final StackGresClusterReview review = JsonUtil.readFromJson("cluster_allow_requests/distributed_logs_update.json", StackGresClusterReview.class);
String distributedLogsName = review.getRequest().getObject().getSpec().getDistributedLogs().getDistributedLogs();
String namespace = review.getRequest().getObject().getMetadata().getNamespace();
when(distributedLogsFinder.findByNameAndNamespace(distributedLogsName, namespace)).thenReturn(Optional.empty());
ValidationFailed ex = assertThrows(ValidationFailed.class, () -> {
validator.validate(review);
});
String resultMessage = ex.getMessage();
assertEquals("Distributed logs " + distributedLogsName + " not found", resultMessage);
verify(distributedLogsFinder).findByNameAndNamespace(anyString(), anyString());
}
use of io.stackgres.operator.common.StackGresClusterReview in project stackgres by ongres.
the class PoolingValidatorTest method giveAnAttemptToUpdateToAnKnownPooling_shouldNotFail.
@Test
void giveAnAttemptToUpdateToAnKnownPooling_shouldNotFail() throws ValidationFailed {
final StackGresClusterReview review = JsonUtil.readFromJson("cluster_allow_requests/connectionpooling_config_update.json", StackGresClusterReview.class);
String poolingConfig = review.getRequest().getObject().getSpec().getConfiguration().getConnectionPoolingConfig();
String namespace = review.getRequest().getObject().getMetadata().getNamespace();
when(configFinder.findByNameAndNamespace(poolingConfig, namespace)).thenReturn(Optional.of(pgbouncerConfig));
validator.validate(review);
verify(configFinder).findByNameAndNamespace(eq(poolingConfig), eq(namespace));
}
use of io.stackgres.operator.common.StackGresClusterReview in project stackgres by ongres.
the class PoolingValidatorTest method giveAnAttemptToDelete_shouldNotFail.
@Test
void giveAnAttemptToDelete_shouldNotFail() throws ValidationFailed {
final StackGresClusterReview review = JsonUtil.readFromJson("cluster_allow_requests/connectionpooling_config_update.json", StackGresClusterReview.class);
review.getRequest().setOperation(Operation.DELETE);
String poolingConfig = review.getRequest().getObject().getSpec().getConfiguration().getConnectionPoolingConfig();
String namespace = review.getRequest().getObject().getMetadata().getNamespace();
validator.validate(review);
verify(configFinder, never()).findByNameAndNamespace(eq(poolingConfig), eq(namespace));
}
Aggregations