f0fdc0ff3e4b406401dd83187904c1764281c754
[integration.git] /
1 /*
2  * ============LICENSE_START=======================================================
3  * PNF-REGISTRATION-HANDLER
4  * ================================================================================
5  * Copyright (C) 2018 Nokia. 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.pnfsimulator.simulator;
22
23 import static org.junit.jupiter.api.Assertions.assertEquals;
24 import static org.onap.pnfsimulator.simulator.KeywordsValueProvider.DEFAULT_STRING_LENGTH;
25
26 import java.util.Arrays;
27 import java.util.Collection;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.junit.runner.RunWith;
31 import org.junit.runners.Parameterized;
32
33 @RunWith(Parameterized.class)
34 public class KeywordsExtractorValidRandomStringTest {
35
36     private final String keyword;
37     private final int length;
38     private KeywordsExtractor keywordsExtractor;
39
40     private static final Collection VALID_STRING_KEYWORDS = Arrays.asList(new Object[][]{
41         {"#RandomString", DEFAULT_STRING_LENGTH},
42         {"1#RandomString2", 1 + DEFAULT_STRING_LENGTH + 1},
43         {"#RandomString(23)", 23},
44         {"#RandomString(11)12", 11 + 2},
45         {"1#RandomString(11)", 1 + 11},
46         {"1#RandomString(11)2", 1 + 11 + 1}
47     });
48
49     public KeywordsExtractorValidRandomStringTest(String keyword, int length) {
50         this.keyword = keyword;
51         this.length = length;
52     }
53
54     @Before
55     public void setUp() {
56         this.keywordsExtractor = new KeywordsExtractor();
57     }
58
59     @Parameterized.Parameters
60     public static Collection data() {
61         return VALID_STRING_KEYWORDS;
62     }
63
64     @Test
65     public void checkValidRandomStringKeyword() {
66         assertEquals(keywordsExtractor.substituteStringKeyword(this.keyword, 1).length(), this.length);
67     }
68
69 }