e63b04acd1fae239d1b1cc3d578b446e7635f869
[policy/drools-applications.git] / controlloop / common / actors / actor.appclcm / src / test / java / org / onap / policy / controlloop / actor / appclcm / AppcLcmRecipeFormatterTest.java
1 /*
2  * ============LICENSE_START=======================================================
3  *
4  * ================================================================================
5  * Copyright (C) 2018 Nokia 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.policy.controlloop.actor.appclcm;
22
23 import static org.junit.Assert.assertEquals;
24
25 import org.junit.Test;
26
27
28
29 public class AppcLcmRecipeFormatterTest {
30
31     @Test
32     public void shouldCorrectlyFormatRestartRequestWhenRestartGiven() {
33         //given
34         AppcLcmRecipeFormatter recipeFormatter = new AppcLcmRecipeFormatter("Restart");
35         String expectedUrlRecipe = "restart";
36         String expectedBodyRecipe = "Restart";
37
38         //when
39         String actualUrlRecipe = recipeFormatter.getUrlRecipe();
40         String actualBodyRecipe = recipeFormatter.getBodyRecipe();
41
42         //then
43         assertEquals(expectedUrlRecipe, actualUrlRecipe);
44         assertEquals(expectedBodyRecipe, actualBodyRecipe);
45     }
46
47     @Test
48     public void shouldReturnCapitalizedBodySingleWordRecipe() {
49         //given
50         AppcLcmRecipeFormatter recipeFormatter = new AppcLcmRecipeFormatter("moDify");
51         String expectedRecipe = "Modify";
52
53         //when
54         String actualRecipe = recipeFormatter.getBodyRecipe();
55
56         //then
57         assertEquals(expectedRecipe, actualRecipe);
58     }
59
60     @Test
61     public void shouldReturnCapitalizeAndJoinedBodyMultiWordRecipe() {
62         //given
63         AppcLcmRecipeFormatter recipeFormatter = new AppcLcmRecipeFormatter("coNfig-moDify");
64         String expectedRecipe = "ConfigModify";
65
66         //when
67         String actualRecipe = recipeFormatter.getBodyRecipe();
68
69         //then
70         assertEquals(expectedRecipe, actualRecipe);
71     }
72
73     @Test
74     public void shouldReturnLowercasedUrlSingleWordRecipe() {
75         //given
76         AppcLcmRecipeFormatter recipeFormatter = new AppcLcmRecipeFormatter("ModIfy");
77         String expectedRecipe = "modify";
78
79         //when
80         String actualRecipe = recipeFormatter.getUrlRecipe();
81
82         //then
83         assertEquals(expectedRecipe, actualRecipe);
84     }
85
86     @Test
87     public void shouldReturnLowercasedDashJoinedUrlMultiWordRecipe() {
88         //given
89         AppcLcmRecipeFormatter recipeFormatter = new AppcLcmRecipeFormatter("Config-MoDify");
90         String expectedRecipe = "config-modify";
91
92         //when
93         String actualRecipe = recipeFormatter.getUrlRecipe();
94
95         //then
96         assertEquals(expectedRecipe, actualRecipe);
97     }
98 }