835ea4a663a69abb40b7f850b413d113542819a5
[vid.git] / vid-app-common / src / test / java / org / onap / vid / controller / open / VersionControllerTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
4  * ================================================================================
5  * Copyright (C) 2017 - 2019 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.vid.controller.open;
22
23 import org.onap.vid.controller.open.VersionController;
24 import org.testng.annotations.DataProvider;
25 import org.testng.annotations.Test;
26
27 import static org.hamcrest.CoreMatchers.is;
28 import static org.junit.Assert.assertThat;
29
30
31 public class VersionControllerTest {
32
33     @DataProvider
34     public static Object[][] majorVersionContainer() {
35         return new Object[][]{
36                 {"features.properties", "1.0.2000", "features.properties.2000"},
37                 {"", "1.0.2000", ".2000"},
38                 {"kuku", "1.0.2000", "kuku.2000"},
39                 {"/kuku", "1.0.2000", "kuku.2000"},
40                 {"1810p.features.properties", "1.0.2000", "1810p.2000"},
41                 {"/opt/app/dev.features.properties", "1.0.2000", "dev.2000"},
42                 {"foo", "2000", "foo.2000"},
43         };
44     }
45
46     final VersionController versionController = new VersionController(null);
47
48     @Test(dataProvider = "majorVersionContainer")
49     public void testGetDisplayVersion(String majorVersionContainer, String buildNumberContainer, String expected) {
50         assertThat(versionController.getDisplayVersion(majorVersionContainer, buildNumberContainer), is(expected));
51     }
52 }