use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices in project stackgres by ongres.
the class DistributedLogsPostgresServicesConverterTest method shouldTranslateFromDistributedLogsPostgresServices_toSgDLogsPgServices.
@Test
void shouldTranslateFromDistributedLogsPostgresServices_toSgDLogsPgServices() {
StackGresDistributedLogsPostgresServices postgresServices = converter.to(new DistributedLogsPostgresServicesFixture().withPrimary().withReplicas().build());
assertNotNull(postgresServices.getPrimary());
assertNotNull(postgresServices.getReplicas());
}
use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices in project stackgres by ongres.
the class DistributedLogsPostgresServicesConverterTest method shouldTranslateDistributedLogsPostgresServices_toSgDLogsPgServicesWithOnlyPrimaryInstace.
@Test
void shouldTranslateDistributedLogsPostgresServices_toSgDLogsPgServicesWithOnlyPrimaryInstace() {
StackGresDistributedLogsPostgresServices postgresServices = converter.to(new DistributedLogsPostgresServicesFixture().withPrimary().build());
assertNotNull(postgresServices.getPrimary());
assertNull(postgresServices.getReplicas());
}
use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices in project stackgres by ongres.
the class DistributedLogsPostgresServicesConverterTest method shouldTranslateANullDistributedLogsPostgresServices_toNullSgDLogsPgServicesObject.
@Test
void shouldTranslateANullDistributedLogsPostgresServices_toNullSgDLogsPgServicesObject() {
StackGresDistributedLogsPostgresServices postgresServices = converter.to(null);
assertNull(postgresServices);
}
use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices in project stackgres by ongres.
the class DefaultPostgresServicesMutator method validatePgServices.
private ImmutableList<JsonPatchOperation> validatePgServices(ImmutableList.Builder<JsonPatchOperation> operations, StackGresDistributedLogsSpec spec) {
return Optional.ofNullable(spec.getPostgresServices()).map(pgServices -> {
mapPgPrimaryService(pgServices);
mapPgReplicasService(pgServices);
JsonNode target = JSON_MAPPER.valueToTree(pgServices);
operations.add(applyReplaceValue(postgresServicesPointer, target));
return operations.build();
}).orElseGet(() -> {
StackGresDistributedLogsPostgresServices pgServices = new StackGresDistributedLogsPostgresServices();
pgServices.setPrimary(createPostgresServicePrimary());
pgServices.setReplicas(createPostgresServiceReplicas());
JsonNode target = JSON_MAPPER.valueToTree(pgServices);
operations.add(applyAddValue(postgresServicesPointer, target));
return operations.build();
});
}
use of io.stackgres.common.crd.sgdistributedlogs.StackGresDistributedLogsPostgresServices in project stackgres by ongres.
the class DistributedLogsPostgresServicesConverterTest method shouldPgServicePrimaryBeConvertedSuccessfully_fromSgDistributedLogsPgServicePrimary.
@Test
void shouldPgServicePrimaryBeConvertedSuccessfully_fromSgDistributedLogsPgServicePrimary() {
StackGresDistributedLogsPostgresServices sgPostgresServices = new StackGresDistributedLogsPostgresServicesFixture().withPrimary().build();
DistributedLogsPostgresServices pgServicesConverted = converter.from(sgPostgresServices);
StackGresPostgresService sgPgPrimary = sgPostgresServices.getPrimary();
PostgresService dlPgPrimary = pgServicesConverted.getPrimary();
assertEquals(sgPgPrimary.getEnabled(), dlPgPrimary.getEnabled());
assertEquals(sgPgPrimary.getType(), dlPgPrimary.getType());
assertNull(pgServicesConverted.getReplicas());
}
Aggregations