0bfa747b6e6a738c23e94a6f195ae4df7a562bc9
[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 testValuesWhenColumnIdIsEdit() {
39         SearchResultColumn col = new SearchResultColumn("edit", "Column1", "10", "left",
40                 "url", "column1", "linkForm", "linkConfirmMsg",
41                 "linkImg", "10", "10", true,
42                 true, false, true);
43         SearchResultField field = new SearchResultField("displayValue", "linkIdValue", col, true);
44         Assert.assertEquals("report#/report_wizard/linkIdValue", field.getDrillDownLink());
45         Assert.assertEquals("linkImg", field.getDrillDownImage());
46         Assert.assertEquals(null, field.getConfirmationText());
47     }
48
49     @Test
50     public void testValuesWhenColumnIdIsCopy() {
51         SearchResultColumn col = new SearchResultColumn("copy", "Column1", "10", "left",
52                 "url", "column1", "linkForm", "linkConfirmMsg",
53                 "linkImg", "10", "10", true,
54                 true, false, true);
55         SearchResultField field = new SearchResultField("displayValue", "linkIdValue", col, true);
56         Assert.assertEquals("report#/report_wizard/copy/linkIdValue", field.getDrillDownLink());
57         Assert.assertEquals("linkImg", field.getDrillDownImage());
58         Assert.assertEquals("linkConfirmMsg", field.getConfirmationText());
59     }
60
61     @Test
62     public void testValuesWhenColumnIdIsDelete() {
63         SearchResultColumn col = new SearchResultColumn("delete", "Column1", "10", "left",
64                 "url", "column1", "linkForm", "linkConfirmMsg",
65                 "linkImg", "10", "10", true,
66                 true, false, true);
67         SearchResultField field = new SearchResultField("displayValue", "linkIdValue", col, true);
68         Assert.assertEquals("raptor.htm?action=report.delete&c_master=linkIdValue", field.getDrillDownLink());
69         Assert.assertEquals("linkImg", field.getDrillDownImage());
70         Assert.assertEquals("linkConfirmMsg", field.getConfirmationText());
71     }
72 }