2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
38 package org.onap.portalapp.portal.domain;
40 import static org.junit.Assert.*;
41 import static org.junit.Assert.assertEquals;
43 import java.util.HashSet;
46 import org.junit.Test;
47 import org.onap.portalapp.portal.domain.App;
48 import org.onap.portalapp.portal.domain.RoleApp;
49 import org.onap.portalapp.portal.domain.WidgetCatalog;
51 public class WidgetCatalogTest {
53 public WidgetCatalog mockWidgetCatalog() {
55 WidgetCatalog widgetCatalog = new WidgetCatalog();
57 Set<RoleApp> roleAppSet = new HashSet<RoleApp>();
60 app.setAppId((long) 1);
61 app.setAppName("test");
64 RoleApp roleApp = new RoleApp();
65 roleApp.setRoleId((long) 1);
66 roleApp.setRoleName("test");
68 roleApp.setWidgets(null);
70 roleAppSet.add(roleApp);
72 widgetCatalog.setId((long) 1);
73 widgetCatalog.setName("test");
74 widgetCatalog.setDesc("test");
75 widgetCatalog.setFileLocation("test");
76 widgetCatalog.setAllowAllUser("test");
77 widgetCatalog.setServiceId((long) 1);
78 widgetCatalog.setSortOrder("test");
79 widgetCatalog.setStatusCode("test");
81 widgetCatalog.setWidgetRoles(roleAppSet);
88 public void widgetCatalogTest() {
92 app.setAppId((long) 1);
93 app.setAppName("test");
95 Set<RoleApp> roleAppSet = new HashSet<RoleApp>();
97 RoleApp roleApp = new RoleApp();
98 roleApp.setRoleId((long) 1);
99 roleApp.setRoleName("test");
101 roleApp.setWidgets(null);
103 roleAppSet.add(roleApp);
105 WidgetCatalog widgetCatalog = mockWidgetCatalog();
108 assertEquals(widgetCatalog.getId(), (long)1);
109 assertEquals(widgetCatalog.getName(), "test");
110 assertEquals(widgetCatalog.getDesc(), "test");
111 assertEquals(widgetCatalog.getFileLocation(), "test");
112 assertEquals(widgetCatalog.getAllowAllUser(), "test");
113 assertEquals(widgetCatalog.getServiceId(), new Long (1));
114 assertEquals(widgetCatalog.getSortOrder(), "test");
115 assertEquals(widgetCatalog.getStatusCode(), "test");
116 assertEquals(widgetCatalog.getWidgetRoles().size(),1);
118 assertEquals("WidgetCatalog [id=1, name=test, desc=test, fileLocation=test, allowAllUser=test]", widgetCatalog.toString());