...
Code Block |
---|
|
@NotNull
@NotBlank
@Getter
public class PapParameterGroup extends ParameterGroupImpl {
@Valid
private RestServerParameters restServerParameters;
@Valid
private PdpParameters pdpParameters;
@Valid
private PolicyModelsProviderParameters databaseProviderParameters;
private boolean savePdpStatisticsInDb;
@Valid
private TopicParameterGroup topicParameterGroup;
// API, Distribution Health Check REST client parameters.
private List<@NotNull @Valid RestClientParameters> healthCheckRestClientParameters;
/**
* Create the pap parameter group.
*
* @param name the parameter group name
*/
public PapParameterGroup(final String name) {
super(name);
}
} |
The code shows below, is an example of Unit Test validation of the POJO PapParameterGroup:
Code Block |
---|
|
private static final Coder coder = new StandardCoder();
@Test
void testPapParameterGroup_NullName() throws Exception {
String json = commonTestData.getPapParameterGroupAsString(1).replace("\"PapGroup\"", "null");
final PapParameterGroup papParameters = coder.decode(json, PapParameterGroup.class);
final ValidationResult validationResult = papParameters.validate();
assertFalse(validationResult.isValid());
assertEquals(null, papParameters.getName());
assertThat(validationResult.getResult()).contains("is null");
} |
Using Spring boot framework
...
Code Block |
---|
|
private ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
@Test
void testParameters_NullTopicParameterGroup() {
final ClRuntimeParameterGroup parameters = CommonTestData.geParameterGroup();
parameters.setTopicParameterGroup(null);
assertThat(validatorFactory.getValidator().validate(parameters)).isNotEmpty();
}
|
Note |
---|
This page is Work in Progress |