Update third party versions in ccsdk/apps
[ccsdk/apps.git] / ms / neng / src / test / java / org / onap / ccsdk / apps / ms / neng / core / policy / RecipeParserTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : CCSDK.apps
4  * ================================================================================
5  * Copyright (C) 2018 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.ccsdk.apps.ms.neng.core.policy;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.mockito.Mockito.mock;
25
26 import org.junit.Test;
27 import org.junit.runner.RunWith;
28 import org.mockito.Mock;
29 import org.mockito.junit.MockitoJUnitRunner;
30
31 @RunWith(MockitoJUnitRunner.class)
32 public class RecipeParserTest {
33     @Mock
34     private PolicyParameters params = mock(PolicyParameters.class);
35
36     @Test
37     public void parseRecipe() throws Exception {
38         assertEquals(0, RecipeParser.parseRecipe(params, "").size());
39         assertEquals("[]", RecipeParser.parseRecipe(params, "").toString());
40
41         assertEquals(1, RecipeParser.parseRecipe(params, "a").size());
42         assertEquals("[a]", RecipeParser.parseRecipe(params, "a").toString());
43
44         assertEquals(2, RecipeParser.parseRecipe(params, "a,b").size());
45         assertEquals(2, RecipeParser.parseRecipe(params, "a|b").size());
46         assertEquals(2, RecipeParser.parseRecipe(params, "a:b").size());
47
48         assertEquals("[a, b]", RecipeParser.parseRecipe(params, "a,b").toString());
49         assertEquals("[a, b]", RecipeParser.parseRecipe(params, "a|b").toString());
50         assertEquals("[a, b]", RecipeParser.parseRecipe(params, "a:b").toString());
51
52         assertEquals(3, RecipeParser.parseRecipe(params, "a,b,c").size());
53         assertEquals(3, RecipeParser.parseRecipe(params, "a|b|c").size());
54         assertEquals(3, RecipeParser.parseRecipe(params, "a:b:c").size());
55
56         assertEquals("[a, b, c]", RecipeParser.parseRecipe(params, "a,b,c").toString());
57         assertEquals("[a, b, c]", RecipeParser.parseRecipe(params, "a|b|c").toString());
58         assertEquals("[a, b, c]", RecipeParser.parseRecipe(params, "a:b:c").toString());
59     }
60 }