2  * ================================================================================
\r 
   4  * ================================================================================
\r 
   5  * Copyright (C) 2017 AT&T Intellectual Property
\r 
   6  * ================================================================================
\r 
   7  * Licensed under the Apache License, Version 2.0 (the "License");
\r 
   8  * you may not use this file except in compliance with the License.
\r 
   9  * You may obtain a copy of the License at
\r 
  11  *      http://www.apache.org/licenses/LICENSE-2.0
\r 
  13  * Unless required by applicable law or agreed to in writing, software
\r 
  14  * distributed under the License is distributed on an "AS IS" BASIS,
\r 
  15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r 
  16  * See the License for the specific language governing permissions and
\r 
  17  * limitations under the License.
\r 
  18  * ================================================================================
\r 
  20 package org.openecomp.portalapp.portal.test.service;
\r 
  22 import static org.junit.Assert.assertEquals;
\r 
  23 import static org.junit.Assert.assertTrue;
\r 
  25 import java.util.ArrayList;
\r 
  26 import java.util.HashMap;
\r 
  27 import java.util.List;
\r 
  28 import java.util.Map;
\r 
  30 import org.junit.Test;
\r 
  31 import org.openecomp.portalapp.portal.service.FunctionalMenuService;
\r 
  32 import org.openecomp.portalapp.portal.test.framework.ApplicationCommonContextTestSuite;
\r 
  33 import org.openecomp.portalapp.portal.transport.BusinessCardApplicationRole;
\r 
  34 import org.openecomp.portalapp.portal.transport.FunctionalMenuRole;
\r 
  35 import org.springframework.beans.factory.annotation.Autowired;
\r 
  40 public class FunctionalMenuServiceImplTest extends ApplicationCommonContextTestSuite{
\r 
  44          FunctionalMenuService functionalMenuService;
\r 
  49           public void getAppListTestService() throws Exception {
\r 
  51                 String userId ="guest";
\r 
  52                 List<BusinessCardApplicationRole> userAppRolesActualResult = null;
\r 
  54                 List<BusinessCardApplicationRole> userAppRolesExpectedResult = new ArrayList<BusinessCardApplicationRole>();
\r 
  55                 BusinessCardApplicationRole businessCardApplicationRole= new BusinessCardApplicationRole();
\r 
  56                 businessCardApplicationRole.setAppName("ECOMP Portal");
\r 
  57                 businessCardApplicationRole.setRoleName("System Administrator");        
\r 
  58                 userAppRolesExpectedResult.add(businessCardApplicationRole);
\r 
  59                 Map<String, String> params = new HashMap<String, String>();
\r 
  60                 params.put("userId", userId);
\r 
  61                 userAppRolesActualResult =functionalMenuService.getUserAppRolesList(userId);
\r 
  62                 assertTrue(userAppRolesActualResult.contains(businessCardApplicationRole));
\r 
  69           public void getFunctionalMenuRoleTest() throws Exception {
\r 
  71                 FunctionalMenuRole expectedFunctionalMenuRole = new FunctionalMenuRole();
\r 
  73                 expectedFunctionalMenuRole.setId(new Integer(99999999)) ;
\r 
  74                 expectedFunctionalMenuRole.setMenuId((long) 137);
\r 
  75                 expectedFunctionalMenuRole.setAppId(new Integer(456));
\r 
  76                 expectedFunctionalMenuRole.setRoleId(new Integer(6214));
\r 
  77                 List<FunctionalMenuRole> actualFunctionalMenuRoleList = null;
\r 
  78                 actualFunctionalMenuRoleList =  functionalMenuService.getFunctionalMenuRole();
\r 
  79                 assertEquals(expectedFunctionalMenuRole.getAppId(),actualFunctionalMenuRoleList.get(actualFunctionalMenuRoleList.size()-1).getAppId());
\r 
  80                 assertEquals(expectedFunctionalMenuRole.getMenuId(),actualFunctionalMenuRoleList.get(actualFunctionalMenuRoleList.size()-1).getMenuId());
\r 
  81                 assertEquals(expectedFunctionalMenuRole.getId(),actualFunctionalMenuRoleList.get(actualFunctionalMenuRoleList.size()-1).getId());
\r 
  82                 assertEquals(expectedFunctionalMenuRole.getRoleId(),actualFunctionalMenuRoleList.get(actualFunctionalMenuRoleList.size()-1).getRoleId());
\r