Skip to content

Having knowledges about missing/unexpected properties in a config file at deserialization time #374

Answered by Djaytan
Djaytan asked this question in Support
Discussion options

You must be logged in to vote

For missing fields, @Required annotation add the sought constraint. By taking back the example provided in the question, we obtain this result:

@ConfigSerializable
// Lombok annotations...
public final class HostValidatingProperties
    extends ValidatingConvertibleProperties<HostProperties> {

  @Required
  private String hostname;

  @Required
  private int port;

  @Required
  private boolean isSslEnabled;

  // Other methods...
}

Following test pass now:

class DbmsHostValidatingPropertiesTest {

    /* Other tests */

    @DisplayName("With missing content")
    @Test
    void withMissingContent_shouldThrowSerializationException() {
      // Given
      String yamlFileName = "whenDese…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Djaytan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant