0f893eb0d10d2ea33b07a8a108091ffb232a43bb
[portal/sdk.git] /
1 /*******************************************************************************
2  * Copyright © 2018 IBM.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************
16  *
17  *
18  */
19
20 package org.onap.portalsdk.analytics.model.search;
21
22 import static org.junit.Assert.assertEquals;
23 import static org.junit.Assert.assertTrue;
24
25 import org.junit.Assert;
26 import org.junit.Before;
27 import org.junit.Test;
28
29 public class SearchResultFieldTest {
30     private SearchResultField searchResultField;
31
32     @Before
33     public void setUp() {
34         searchResultField = new SearchResultField();
35     }
36
37      @Test
38     public void testSetConfirmationText() {
39         searchResultField.setConfirmationText("test");
40         String expected;
41         expected=searchResultField.getConfirmationText();
42         assertEquals(expected,"test");
43     }
44     
45     @Test
46     public void testSetDrillDownImage() {
47         searchResultField.setDrillDownImage("confirm");
48         String expected;
49         expected=searchResultField.getDrillDownImage();
50         assertEquals(expected,"confirm");
51     }
52
53     @Test
54     public void testValuesWhenColumnIdIsEdit() {
55         SearchResultColumn col = new SearchResultColumn("edit", "Column1", "10", "left",
56                 "url", "column1", "linkForm", "linkConfirmMsg",
57                 "linkImg", "10", "10", true,
58                 true, false, true);
59         SearchResultField field = new SearchResultField("displayValue", "linkIdValue", col, true);
60         Assert.assertEquals("report#/report_wizard/linkIdValue", field.getDrillDownLink());
61         Assert.assertEquals("linkImg", field.getDrillDownImage());
62         Assert.assertEquals(null, field.getConfirmationText());
63     }
64
65     @Test
66     public void testValuesWhenColumnIdIsCopy() {
67         SearchResultColumn col = new SearchResultColumn("copy", "Column1", "10", "left",
68                 "url", "column1", "linkForm", "linkConfirmMsg",
69                 "linkImg", "10", "10", true,
70                 true, false, true);
71         SearchResultField field = new SearchResultField("displayValue", "linkIdValue", col, true);
72         Assert.assertEquals("report#/report_wizard/copy/linkIdValue", field.getDrillDownLink());
73         Assert.assertEquals("linkImg", field.getDrillDownImage());
74         Assert.assertEquals("linkConfirmMsg", field.getConfirmationText());
75     }
76
77     @Test
78     public void testValuesWhenColumnIdIsDelete() {
79         SearchResultColumn col = new SearchResultColumn("delete", "Column1", "10", "left",
80                 "url", "column1", "linkForm", "linkConfirmMsg",
81                 "linkImg", "10", "10", true,
82                 true, false, true);
83         SearchResultField field = new SearchResultField("displayValue", "linkIdValue", col, true);
84         Assert.assertEquals("raptor.htm?action=report.delete&c_master=linkIdValue", field.getDrillDownLink());
85         Assert.assertEquals("linkImg", field.getDrillDownImage());
86         Assert.assertEquals("linkConfirmMsg", field.getConfirmationText());
87     }
88 }