Added oparent to sdc main
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / utils / UtilsTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 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.openecomp.sdc.be.components.utils;
22
23 import org.junit.Test;
24
25 import java.util.ArrayList;
26 import java.util.Arrays;
27 import java.util.List;
28
29 import static org.assertj.core.api.Assertions.assertThat;
30
31 public class UtilsTest {
32
33     @Test
34     public void testThatEmptyListReturns0() {
35         List<String> existingResourceNames = new ArrayList<>();
36         int counter = Utils.getNextCounter(existingResourceNames);
37         assertThat(counter).isZero();
38     }
39
40     @Test
41     public void testListWithValidValue() {
42         List<String> existingResourceNames = Arrays.asList("d7f886ce-7e32-4b1f-bfd8-f664b03fee09.ruti..NetworkCollection..0");
43         int counter = Utils.getNextCounter(existingResourceNames);
44         assertThat(counter).isEqualTo(1);
45     }
46
47     @Test
48     public void testListWithInvalidSingleValue() {
49         List<String> existingResourceNames = Arrays.asList("d7f886ce-7e32-4b1f-bfd8-f664b03fee09.ruti..NetworkCollection");
50         int counter = Utils.getNextCounter(existingResourceNames);
51         assertThat(counter).isEqualTo(1);
52     }
53
54     @Test
55     public void testListWithValidValues() {
56         List<String> existingResourceNames = Arrays.asList("d7f886ce-7e32-4b1f-bfd8-f664b03fee09.ruti..NetworkCollection..0",
57                 "d7f886ce-7e32-4b1f-bfd8-f664b03fee09.ruti..NetworkCollection..10",
58                 "d7f886ce-7e32-4b1f-bfd8-f664b03fee09.ruti..NetworkCollection..15",
59                 "d7f886ce-7e32-4b1f-bfd8-f664b03fee09.ruti..NetworkCollection..2");
60         int counter = Utils.getNextCounter(existingResourceNames);
61         assertThat(counter).isEqualTo(16);
62     }
63
64     @Test
65     public void testListWithInvalidValue() {
66         List<String> existingResourceNames = Arrays.asList("d7f886ce-7e32-4b1f-bfd8-f664b03fee09.ruti..NetworkCollection..0",
67                 "d7f886ce-7e32-4b1f-bfd8-f664b03fee09.ruti..NetworkCollection..10",
68                 "d7f886ce-7e32-4b1f-bfd8-f664b03fee09.ruti..NetworkCollection..15",
69                 "d7f886ce-7e32-4b1f-bfd8-f664b03fee09.ruti..NetworkCollection");
70         int counter = Utils.getNextCounter(existingResourceNames);
71         assertThat(counter).isEqualTo(16);
72     }
73 }