making required changes

merge-requests/1/head
Nirothipan 7 years ago
parent a6eb95e2e8
commit 046fad6bdb

@ -20,6 +20,7 @@ import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
import org.wso2.carbon.device.mgt.common.notification.mgt.Notification;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import java.util.ArrayList;
@ -52,6 +53,19 @@ public class TestDataHolder {
return device;
}
public static Notification getNotification(int notificationId, String status, String deviceId, String deviceName,
int operationId, String deviceType){
Notification notification = new Notification();
notification.setNotificationId(notificationId);
notification.setStatus(status);
notification.setDeviceIdentifier(deviceId);
notification.setDescription("test description");
notification.setDeviceName(deviceName);
notification.setOperationId(operationId);
notification.setDeviceType(deviceType);
return notification;
}
public static List<Device> generateDummyDeviceData(List<DeviceIdentifier> deviceIds) {
List<Device> devices = new ArrayList<>();
for (DeviceIdentifier deviceId : deviceIds) {

@ -31,7 +31,6 @@ import org.wso2.carbon.device.mgt.core.common.TestDataHolder;
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent;
import org.wso2.carbon.device.mgt.core.search.util.MockNotification;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderServiceImpl;
@ -47,6 +46,9 @@ import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
/**
* This class is used to test NotificationManagementServiceImpl.
*/
public class NotificationManagementTests {
private static final Log log = LogFactory.getLog(NotificationManagementTests.class);
@ -54,7 +56,6 @@ public class NotificationManagementTests {
private static final String DEVICE_ID_PREFIX = "NOTIFICATION-TEST-DEVICE-ID-";
private static final int NO_OF_DEVICES = 10;
private List<DeviceIdentifier> deviceIds = new ArrayList<>();
private MockNotification mockNotification = new MockNotification();
@BeforeClass
public void init() throws Exception {
@ -95,14 +96,15 @@ public class NotificationManagementTests {
return context.getEmbeddedRegistryService();
}
@Test
@Test(description = "Add notifications using addNotification method and check whether it returns true.")
public void addNotification() throws Exception {
for (int i = 0; i < NO_OF_DEVICES; i++) {
DeviceIdentifier testDeviceIdentifier = new DeviceIdentifier(DEVICE_ID_PREFIX + i, DEVICE_TYPE);
Notification notification = mockNotification.getNotification(i, "CHECKED",
Notification notification = TestDataHolder.getNotification(i, "CHECKED",
testDeviceIdentifier.toString(), DEVICE_ID_PREFIX + i, 1, DEVICE_TYPE);
NotificationManagementServiceImpl notificationManagementService = new NotificationManagementServiceImpl();
Assert.assertTrue(notificationManagementService.addNotification(testDeviceIdentifier, notification));
}
}
}

@ -1,37 +0,0 @@
/*
* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.search.util;
import org.wso2.carbon.device.mgt.common.notification.mgt.Notification;
public class MockNotification {
public Notification getNotification(int notificationId,String status,String deviceId,String deviceName,
int operationId, String deviceType){
Notification notification = new Notification();
notification.setNotificationId(notificationId);
notification.setStatus(status);
notification.setDeviceIdentifier(deviceId);
notification.setDescription("test description");
notification.setDeviceName(deviceName);
notification.setOperationId(operationId);
notification.setDeviceType(deviceType);
return notification;
}
}
Loading…
Cancel
Save