### Question:
EnvironmentAuthenticationValidator { public ValidationResult validate(EnvironmentDto environmentDto) { ValidationResult.ValidationResultBuilder resultBuilder = ValidationResult.builder(); AuthenticationDto authentication = environmentDto.getAuthentication(); if (!StringUtils.hasText(authentication.getPublicKeyId())) { validate(authentication.getPublicKey(), resultBuilder); } return resultBuilder.build(); }  ValidationResult validate(EnvironmentDto environmentDto);  }### Answer:
@Test void testValidateShouldReturnValidationError() { EnvironmentDto environmentDto = createEnvironmentDto(PUBLIC_KEY, null); String expected = "1. Failed to parse public key. Detailed message: Corrupt or unknown public key file format"; ValidationResult actual = underTest.validate(environmentDto); Assertions.assertEquals(expected, actual.getFormattedErrors()); }
@Test void testValidateShouldReturnWithoutError() { EnvironmentDto environmentDto = createEnvironmentDto(VALID_PUBLIC_KEY, null); ValidationResult actual = underTest.validate(environmentDto); Assertions.assertFalse(actual.hasError()); }
@Test void testValidateShouldReturnWithoutErrorWhenPublicKeyIdIsPresent() { EnvironmentDto environmentDto = createEnvironmentDto(null, "public-key-id"); ValidationResult actual = underTest.validate(environmentDto); Assertions.assertFalse(actual.hasError()); }