Merge "Changes to Regex for Name and version Issue-ID: DCAEGEN2-1867"
[dcaegen2/platform.git] / mod / bpgenerator / onap / src / test / java / org / onap / blueprintgenerator / test / ExternalCertificateParametersFactoryServiceTest.java
1 /*============LICENSE_START=======================================================
2  org.onap.dcae
3  ================================================================================
4  Copyright (c) 2020 Nokia Intellectual Property. All rights reserved.
5  Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
6  ================================================================================
7  Licensed under the Apache License, Version 2.0 (the "License");
8  you may not use this file except in compliance with the License.
9  You may obtain a copy of the License at
10
11  http://www.apache.org/licenses/LICENSE-2.0
12
13  Unless required by applicable law or agreed to in writing, software
14  distributed under the License is distributed on an "AS IS" BASIS,
15  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  See the License for the specific language governing permissions and
17  limitations under the License.
18  ============LICENSE_END=========================================================
19  */
20
21 package org.onap.blueprintgenerator.test;
22
23 import org.onap.blueprintgenerator.constants.Constants;
24 import org.onap.blueprintgenerator.model.common.ExternalCertificateParameters;
25 import org.onap.blueprintgenerator.service.common.ExternalCertificateParametersFactoryService;
26 import org.junit.Test;
27 import org.springframework.beans.factory.annotation.Autowired;
28
29
30 import java.util.LinkedHashMap;
31 import java.util.Map;
32
33 import static org.junit.Assert.assertEquals;
34 import static org.onap.blueprintgenerator.constants.Constants.COMMON_NAME_FIELD;
35 import static org.onap.blueprintgenerator.constants.Constants.SANS_FIELD;
36
37 public class ExternalCertificateParametersFactoryServiceTest extends BlueprintGeneratorTests{
38
39     private static final String PREFIXED_COMMON_NAME_FIELD = Constants.INPUT_PREFIX + COMMON_NAME_FIELD;
40     private static final String PREFIXED_SANS_FIELD = Constants.INPUT_PREFIX + SANS_FIELD;
41     private static final String DEFAULT = "default";
42
43     @Autowired
44     private ExternalCertificateParametersFactoryService externalCertificateParametersFactoryService;
45
46     @Test
47     public void shouldCreateExternalCertificatePropertiesObject() {
48
49         ExternalCertificateParameters result = externalCertificateParametersFactoryService.create();
50         assertEquals(result.getCommonName().getBpInputName(), PREFIXED_COMMON_NAME_FIELD);
51         assertEquals(result.getSans().getBpInputName(), PREFIXED_SANS_FIELD);
52     }
53
54     @Test
55     public void shouldCreateCorrectInputListWithDefaultValuesTakenFromComponentSpec() {
56
57         Map<String, LinkedHashMap<String, Object>> result = externalCertificateParametersFactoryService.createInputList();
58         assertEquals(Constants.DEFAULT_COMMON_NAME, result.get(PREFIXED_COMMON_NAME_FIELD).get(DEFAULT));
59         assertEquals(Constants.DEFAULT_SANS, result.get(PREFIXED_SANS_FIELD).get(DEFAULT));
60     }
61 }