@@ -0,0 +1,3386 @@
+/*%0A * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.%0A *%0A * WSO2 Inc. licenses this file to you under the Apache License,%0A * Version 2.0 (the %22License%22); you may not use this file except%0A * in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing,%0A * software distributed under the License is distributed on an%0A * %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY%0A * KIND, either express or implied. See the License for the%0A * specific language governing permissions and limitations%0A * under the License.%0A */%0A%0Apackage org.wso2.carbon.device.mgt.core.authorization;%0A%0Aimport org.apache.commons.logging.Log;%0Aimport org.apache.commons.logging.LogFactory;%0Aimport org.mockito.Mock;%0Aimport org.testng.Assert;%0Aimport org.testng.annotations.BeforeClass;%0Aimport org.testng.annotations.Test;%0Aimport org.wso2.carbon.device.mgt.common.Device;%0Aimport org.wso2.carbon.device.mgt.common.DeviceIdentifier;%0Aimport org.wso2.carbon.device.mgt.common.EnrolmentInfo;%0Aimport org.wso2.carbon.device.mgt.core.common.BaseDeviceManagementTest;%0Aimport org.wso2.carbon.device.mgt.core.dao.*;%0Aimport org.wso2.carbon.device.mgt.core.dto.DeviceType;%0Aimport org.wso2.carbon.user.api.UserStoreManager;%0A%0Aimport static org.mockito.Matchers.anyString;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;%0A%0A%0Apublic class DeviceAccessAuthorizationServiceTest extends BaseDeviceManagementTest %7B%0A    private static final Log log = LogFactory.getLog(DeviceAccessAuthorizationServiceTest.class);%0A    DeviceDAO deviceDAO;%0A    DeviceTypeDAO deviceTypeDAO;%0A    DeviceAccessAuthorizationServiceImpl deviceAccessAuthorizationService = new DeviceAccessAuthorizationServiceImpl();%0A%0A   // UserStoreManager userStoreManager = mock(UserStoreManager.class);%0A%0A    @BeforeClass%0A    @Override%0A    public void init() throws Exception %7B%0A        this.initDataSource();%0A        deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();%0A        deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();%0A    %7D%0A%0A    @Test(groups = %22device.mgt.test%22, description = %22Testing the first test case with testng.%22)%0A    public void setUp() throws Exception %7B%0A        log.info(%22test start%22);%0A%0A        DeviceManagementDAOFactory.beginTransaction();%0A        DeviceType deviceType = new DeviceType();%0A        deviceType.setName(%22Sample%22);%0A%0A        deviceTypeDAO.addDeviceType(deviceType, -1234, true);%0A        deviceType = deviceTypeDAO.getDeviceType(%22Sample%22, -1234);%0A        log.info(deviceType.getId());%0A        Assert.assertEquals(deviceType.getName(), %22Sample%22);%0A%0A        Device device = new Device();%0A        device.setId(1);%0A        device.setDeviceIdentifier(%22device1%22);%0A        device.setName(%22sample device%22);%0A        device.setType(%22Sample%22);%0A%0A        EnrolmentInfo enrolmentInfo = new EnrolmentInfo();%0A        enrolmentInfo.setOwner(%22Lahiru%22);%0A        device.setEnrolmentInfo(enrolmentInfo);%0A        deviceDAO.addDevice(1,device,-1234);%0A%0A        DeviceManagementDAOFactory.closeConnection();%0A        DeviceIdentifier deviceIdentifier = new DeviceIdentifier();%0A        deviceIdentifier.setId(%221%22);%0A        deviceIdentifier.setType(%22Sample%22);%0A%0A     //   Assert.assertTrue(deviceAccessAuthorizationService.isUserAuthorized(deviceIdentifier,%22Lahiru%22));%0A%0A    %7D%0A%0A%0A%7D%0A

Add test class