dae91abfcc985a7feea57d9029ae12a75566269b
[policy/distribution.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2021 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
9  *
10  *      http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  * SPDX-License-Identifier: Apache-2.0
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.distribution.reception.parameters;
23
24 import static org.assertj.core.api.Assertions.assertThat;
25
26 import org.junit.Test;
27 import org.onap.policy.distribution.reception.handling.DummyDecoder;
28
29 /**
30  * Class for unit testing PolicyDecoderParameters class.
31  *
32  * @author Adheli Tavares (adheli.tavares@est.tech)
33  *
34  */
35 public class TestPolicyDecoderParameters {
36
37     static final String DECODER_CLASS_NAME = DummyDecoder.class.getName();
38     static final String DECODER_CONFIG = "decoderConfigName";
39     static final String DECODER_TYPE = "DummyDecoder";
40
41     @Test
42     public void testValidate_DecoderTypeEmptyNull() {
43         PolicyDecoderParameters sutParams = new PolicyDecoderParameters(null, DECODER_CLASS_NAME, DECODER_CONFIG);
44
45         assertThat(sutParams.validate().getResult()).contains("\"decoderType\" value \"null\" INVALID, is null");
46
47         sutParams.setName("");
48
49         assertThat(sutParams.validate().getResult()).contains("\"decoderType\" value \"\" INVALID, is blank")
50                         .doesNotContain("not found in classpath");
51     }
52
53     @Test
54     public void testValidate_ClassNameEmptyNull() {
55         PolicyDecoderParameters nullClassName = new PolicyDecoderParameters(DECODER_TYPE, null, DECODER_CONFIG);
56
57         assertThat(nullClassName.validate().getResult())
58                         .contains("\"decoderClassName\" value \"null\" INVALID, is null");
59
60         PolicyDecoderParameters emptyClassName = new PolicyDecoderParameters(DECODER_TYPE, "", DECODER_CONFIG);
61
62         assertThat(emptyClassName.validate().getResult()).contains("\"decoderClassName\" value \"\" INVALID, is blank");
63     }
64 }