2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021-2022 Nordix Foundation.
4 * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.clamp.acm.participant.kubernetes.parameters;
24 import static org.assertj.core.api.Assertions.assertThat;
26 import jakarta.validation.ConstraintViolation;
27 import jakarta.validation.Validation;
28 import jakarta.validation.ValidatorFactory;
30 import org.junit.jupiter.api.Test;
32 class ParticipantK8sParametersTest {
34 private final CommonTestData commonTestData = new CommonTestData();
35 private final ValidatorFactory validatorFactory = Validation.buildDefaultValidatorFactory();
38 void testParticipantPolicyParameters() {
39 final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters();
40 assertThat(validatorFactory.getValidator().validate(participantParameters)).isNullOrEmpty();
44 void testParticipantK8sParameters_NullTopicSinks() {
45 final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters();
46 participantParameters.getIntermediaryParameters().getClampAutomationCompositionTopics().setTopicSinks(null);
47 assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
51 void testParticipantK8sParameters_NullTopicSources() {
52 final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters();
53 participantParameters.getIntermediaryParameters().getClampAutomationCompositionTopics().setTopicSources(null);
54 assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
58 void testParticipantK8sParameters_BlankLocalChartDirParameter() {
59 final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters();
60 participantParameters.setLocalChartDirectory(" ");
61 Set<ConstraintViolation<ParticipantK8sParameters>> violations = validatorFactory.getValidator()
62 .validate(participantParameters);
63 assertThat(violations).hasSize(1);
67 void testParticipantK8sParameters_BlankInfoFileParameter() {
68 final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters();
69 participantParameters.setInfoFileName("");
70 Set<ConstraintViolation<ParticipantK8sParameters>> violations = validatorFactory.getValidator()
71 .validate(participantParameters);
72 assertThat(violations).hasSize(1);
76 void testNoIntermediaryParameters() {
77 final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters();
78 participantParameters.setIntermediaryParameters(null);
79 assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();
83 void testNoParticipantId() {
84 final ParticipantK8sParameters participantParameters = commonTestData.getParticipantK8sParameters();
85 participantParameters.getIntermediaryParameters().setParticipantId(null);
86 assertThat(validatorFactory.getValidator().validate(participantParameters)).isNotEmpty();