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
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.distribution.reception.parameters;
24 import static org.assertj.core.api.Assertions.assertThat;
26 import org.junit.Test;
27 import org.onap.policy.distribution.reception.handling.DummyDecoder;
30 * Class for unit testing PolicyDecoderParameters class.
32 * @author Adheli Tavares (adheli.tavares@est.tech)
35 public class TestPolicyDecoderParameters {
37 static final String DECODER_CLASS_NAME = DummyDecoder.class.getName();
38 static final String DECODER_CONFIG = "decoderConfigName";
39 static final String DECODER_TYPE = "DummyDecoder";
42 public void testValidate_DecoderTypeEmptyNull() {
43 PolicyDecoderParameters sutParams = new PolicyDecoderParameters(null, DECODER_CLASS_NAME, DECODER_CONFIG);
45 assertThat(sutParams.validate().getResult()).contains("\"decoderType\" value \"null\" INVALID, is null");
47 sutParams.setName("");
49 assertThat(sutParams.validate().getResult()).contains("\"decoderType\" value \"\" INVALID, is blank")
50 .doesNotContain("not found in classpath");
54 public void testValidate_ClassNameEmptyNull() {
55 PolicyDecoderParameters nullClassName = new PolicyDecoderParameters(DECODER_TYPE, null, DECODER_CONFIG);
57 assertThat(nullClassName.validate().getResult())
58 .contains("\"decoderClassName\" value \"null\" INVALID, is null");
60 PolicyDecoderParameters emptyClassName = new PolicyDecoderParameters(DECODER_TYPE, "", DECODER_CONFIG);
62 assertThat(emptyClassName.validate().getResult()).contains("\"decoderClassName\" value \"\" INVALID, is blank");