From e20673af02f22d6dc5ff8e58595e90ec36b7c048 Mon Sep 17 00:00:00 2001 From: pahnjy Date: Thu, 8 Dec 2016 15:25:24 +0900 Subject: [PATCH] =?UTF-8?q?Device=20Subscription=EC=97=90=20=EB=94=B0?= =?UTF-8?q?=EB=A5=B8=20=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD=20#291?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../so/device/entity/DeviceStatusData.java | 16 +---- .../device/entity/DeviceSubscriptionData.java | 15 ++++- .../icbms/so/device/logic/DeviceManager.java | 2 +- .../so/device/logic/DeviceManagerLogic.java | 61 +++++++++++++++--- .../so/device/proxy/DeviceControlProxy.java | 2 +- .../icbms/so/device/proxy/DeviceSIProxy.java | 5 +- .../device/store/DeviceSubscriptionStore.java | 10 +++ .../mongo/DeviceSubscriptionMongoStore.java | 37 +++++++++++ .../store/mongo/DeviceSubscriptionObject.java | 64 +++++++++++++++++++ .../mongo/DeviceSubscriptionRepository.java | 9 +++ .../icbms/so/device/util/ClientProfile.java | 20 ++++++ .../so/device/logic/DeviceManagerTest.java | 20 ++++++ .../so/device/proxy/DeviceSDAProxyTest.java | 60 ----------------- 13 files changed, 229 insertions(+), 92 deletions(-) create mode 100644 so-device/src/main/java/com/pineone/icbms/so/device/store/DeviceSubscriptionStore.java create mode 100644 so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionMongoStore.java create mode 100644 so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionObject.java create mode 100644 so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionRepository.java diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/entity/DeviceStatusData.java b/so-device/src/main/java/com/pineone/icbms/so/device/entity/DeviceStatusData.java index 05528d0a..06cff417 100644 --- a/so-device/src/main/java/com/pineone/icbms/so/device/entity/DeviceStatusData.java +++ b/so-device/src/main/java/com/pineone/icbms/so/device/entity/DeviceStatusData.java @@ -15,11 +15,6 @@ public class DeviceStatusData { */ private String _uri; - /** - * Device를 제어 했을시 제어 항목 - */ - private String _command; - /** * Device의 상태 값 */ @@ -33,10 +28,9 @@ public class DeviceStatusData { public DeviceStatusData() { } - public DeviceStatusData(String _commandId, String _uri, String _command, String deviceStatus, String timestamp) { + public DeviceStatusData(String _commandId, String _uri, String deviceStatus, String timestamp) { this._commandId = _commandId; this._uri = _uri; - this._command = _command; this.deviceStatus = deviceStatus; this.timestamp = timestamp; } @@ -57,13 +51,6 @@ public void set_uri(String _uri) { this._uri = _uri; } - public String get_command() { - return _command; - } - - public void set_command(String _command) { - this._command = _command; - } public String getDeviceStatus() { return deviceStatus; @@ -91,7 +78,6 @@ public String toString() { return "DeviceStatusData{" + "_commandId='" + _commandId + '\'' + ", _uri='" + _uri + '\'' + - ", _command='" + _command + '\'' + ", deviceStatus='" + deviceStatus + '\'' + ", timestamp='" + timestamp + '\'' + '}'; diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/entity/DeviceSubscriptionData.java b/so-device/src/main/java/com/pineone/icbms/so/device/entity/DeviceSubscriptionData.java index 0bd07ae6..98fa2f5e 100644 --- a/so-device/src/main/java/com/pineone/icbms/so/device/entity/DeviceSubscriptionData.java +++ b/so-device/src/main/java/com/pineone/icbms/so/device/entity/DeviceSubscriptionData.java @@ -3,13 +3,15 @@ public class DeviceSubscriptionData { // private String _uri; - private String _notificationUri; + private String _commandId; + private String _notificationUri; public DeviceSubscriptionData() { } - public DeviceSubscriptionData(String _uri, String _notificationUri) { + public DeviceSubscriptionData(String _uri, String _commandId, String _notificationUri) { this._uri = _uri; + this._commandId = _commandId; this._notificationUri = _notificationUri; } @@ -21,6 +23,14 @@ public void set_uri(String _uri) { this._uri = _uri; } + public String get_commandId() { + return _commandId; + } + + public void set_commandId(String _commandId) { + this._commandId = _commandId; + } + public String get_notificationUri() { return _notificationUri; } @@ -33,6 +43,7 @@ public void set_notificationUri(String _notificationUri) { public String toString() { return "DeviceSubscriptionData{" + "_uri='" + _uri + '\'' + + ", _commandId='" + _commandId + '\'' + ", _notificationUri='" + _notificationUri + '\'' + '}'; } diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManager.java b/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManager.java index 425404ff..a88f4a4b 100644 --- a/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManager.java +++ b/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManager.java @@ -17,6 +17,6 @@ public interface DeviceManager { String searchOperation(String de, String deviceService); List searchDeviceList(); void deviceUpdate(DeviceStatusData deviceStatusData); - String deviceSubscription(String uri); + String deviceSubscription(String uri, String commandId); String deviceSubscriptionRelease(String uri); } diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManagerLogic.java b/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManagerLogic.java index 37096902..6b032dae 100644 --- a/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManagerLogic.java +++ b/so-device/src/main/java/com/pineone/icbms/so/device/logic/DeviceManagerLogic.java @@ -5,6 +5,8 @@ import com.pineone.icbms.so.device.proxy.DeviceICollectionProxy; import com.pineone.icbms.so.device.store.DeviceResultStore; import com.pineone.icbms.so.device.store.DeviceStore; +import com.pineone.icbms.so.device.store.DeviceSubscriptionStore; +import com.pineone.icbms.so.device.store.mongo.DeviceSubscriptionObject; import com.pineone.icbms.so.device.util.ClientProfile; import com.pineone.icbms.so.util.address.AddressStore; import com.pineone.icbms.so.util.address.ContextAddress; @@ -21,7 +23,6 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; -import java.util.concurrent.TimeUnit; @Service public class DeviceManagerLogic implements DeviceManager { @@ -46,6 +47,9 @@ public class DeviceManagerLogic implements DeviceManager { @Autowired private DeviceControlProxy deviceControlProxy; + @Autowired + private DeviceSubscriptionStore deviceSubscriptionStore; + @Autowired ContextAddress contextAddress; @@ -133,13 +137,25 @@ public String deviceExecute(String deviceId,String deviceCommand, String session * Device 제어 후 제어 결과가 Success면 Device Subscription 요청 */ if(resultMessage.getCode().equals(ResultMessage.RESPONSE_SUCCESS_ONEM2MCODE)) { - String response = deviceSubscription(device.getDeviceUri()); + String subscriptionUri = device.getDeviceUri() + (ClientProfile.actionDeviceCommand(device.getDeviceUri()) ? ClientProfile.SI_CONTAINER_ACTION : ClientProfile.SI_CONTAINER_POWER) + ClientProfile.SI_CONTAINER_STATUS; + String response = deviceSubscription(subscriptionUri, deviceControlMessage.get_commandId()); logger.debug(LogPrint.LogMethodNamePrint() + " | Device Subscription : " + " , Device Uri = " + device.getDeviceUri() + " , Result : " + response + " , Session ID = " + sessionId); + + /** + * Device Subscription 데이터 저장 + */ + if(response.equals(ResultMessage.RESPONSE_SUCCESS_ONEM2MCODE)){ + saveDeviceSubscriptionData(deviceControlMessage.get_commandId(), deviceControlMessage.getCon()); + } + + /* + 디바이스 해제는 Controller에서 상태 업데이트 후 해제. if(response.equals(ResultMessage.RESPONSE_SUCCESS_ONEM2MCODE)){ - /** + *//** * Device Subscription이 성공이면 30초 후 Subscription 해지 요청. * 시간은 정책으로 수정 가능. - */ + *//* + Thread thread = new Thread(new Runnable() { @Override public void run() { @@ -156,6 +172,8 @@ public void run() { }); thread.start(); } + */ + } @@ -229,18 +247,27 @@ public List searchDeviceList() { public void deviceUpdate(DeviceStatusData deviceStatusData) { // if(!deviceStatusData.get_uri().isEmpty()){ - Device device = deviceSearchById(deviceStatusData.get_uri()); - if(!deviceStatusData.getDeviceStatus().isEmpty() && !deviceStatusData.checkDeviceStatus(device.getDeviceStatus())) { + String deviceUri = getOnem2mDeviceUri(deviceStatusData.get_uri()); + Device device = deviceSearchById(deviceUri); + DeviceSubscriptionObject deviceSubscriptionObject = deviceSubscriptionStore.retrieve(deviceStatusData.get_commandId()); + + if(deviceSubscriptionObject != null && deviceSubscriptionObject.get_commandId().equals(deviceStatusData.get_commandId()) && deviceSubscriptionObject.getDeviceStatus().equals(deviceStatusData.getDeviceStatus())){ device.setDeviceStatus(deviceStatusData.getDeviceStatus()); deviceStore.update(device); + deviceSubscriptionRelease(deviceUri + (ClientProfile.actionDeviceCommand(device.getDeviceUri()) ? ClientProfile.SI_CONTAINER_ACTION : ClientProfile.SI_CONTAINER_POWER) + ClientProfile.SI_CONTAINER_STATUS); + deviceSubscriptionStore.delete(deviceSubscriptionObject.get_id()); + } + + if(!deviceStatusData.getDeviceStatus().isEmpty() && !deviceStatusData.checkDeviceStatus(device.getDeviceStatus())) { + } } } @Override - public String deviceSubscription(String uri) { + public String deviceSubscription(String uri, String commandId) { // - return deviceControlProxy.deviceSubscriptionRequest(uri); + return deviceControlProxy.deviceSubscriptionRequest(uri, commandId); } @Override @@ -249,13 +276,12 @@ public String deviceSubscriptionRelease(String uri) { return deviceControlProxy.deviceSubscriptionReleaseRequest(uri); } - private DeviceControlMessage deviceDataConversion(String deviceId, String commandId, String deviceCommand){ DeviceControlMessage deviceControlMessage = new DeviceControlMessage(); deviceControlMessage.set_uri(deviceId); deviceControlMessage.set_commandId(commandId); - if(deviceId != null && (deviceId.contains("Blind") || deviceId.contains("BeamScreen"))){ + if(deviceId != null && ClientProfile.actionDeviceCommand(deviceId)){ deviceControlMessage.set_command(ClientProfile.SI_CONTROL_ACTION); }else { deviceControlMessage.set_command(ClientProfile.SI_CONTROL_POWER); @@ -322,4 +348,19 @@ private void sessionDataUpdate(SessionStore sessionStore, Session session, Strin sessionStore.updateSession(session); } + public String getOnem2mDeviceUri(String uri){ + // + int stringlength = 3; + String[] strings = uri.split("/"); + + for(int i =1; i<4 ; i++){ + stringlength += strings[i].length(); + } + return uri.substring(0, stringlength); + } + + public void saveDeviceSubscriptionData(String deviceUri, String commandId){ + deviceSubscriptionStore.create(new DeviceSubscriptionObject(deviceUri, commandId)); + } + } diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/proxy/DeviceControlProxy.java b/so-device/src/main/java/com/pineone/icbms/so/device/proxy/DeviceControlProxy.java index 85c5101d..f4d54757 100644 --- a/so-device/src/main/java/com/pineone/icbms/so/device/proxy/DeviceControlProxy.java +++ b/so-device/src/main/java/com/pineone/icbms/so/device/proxy/DeviceControlProxy.java @@ -22,7 +22,7 @@ public interface DeviceControlProxy { * @param deviceUri * @return */ - String deviceSubscriptionRequest(String deviceUri); + String deviceSubscriptionRequest(String deviceUri, String commandId); /** * Device 구독 해지 요청 diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/proxy/DeviceSIProxy.java b/so-device/src/main/java/com/pineone/icbms/so/device/proxy/DeviceSIProxy.java index 6b7bfa2e..0c8e0207 100644 --- a/so-device/src/main/java/com/pineone/icbms/so/device/proxy/DeviceSIProxy.java +++ b/so-device/src/main/java/com/pineone/icbms/so/device/proxy/DeviceSIProxy.java @@ -57,7 +57,7 @@ public ResultMessage deviceControlRequest(String requestUrl, DeviceControlMessag } @Override - public String deviceSubscriptionRequest(String deviceUri) { + public String deviceSubscriptionRequest(String deviceUri, String commandId) { // logger.info("<================ Device Subscription Request Start ================>"); logger.debug(LogPrint.LogMethodNamePrint() + " | DeviceUri = " + deviceUri); @@ -65,10 +65,9 @@ public String deviceSubscriptionRequest(String deviceUri) { DeviceSubscriptionData deviceSubscriptionData = new DeviceSubscriptionData(); deviceSubscriptionData.set_notificationUri(contextAddress.getServerAddress(ContextAddress.SO_SERVER) + AddressStore.SO_DEVICE_STATUS); deviceSubscriptionData.set_uri(deviceUri); + deviceSubscriptionData.set_commandId(commandId); String requestBody = new Gson().toJson(deviceSubscriptionData); - // DeviceLogic에 생성되거나 제어되면 서브스크립트 걸어야 겠군. - // 현제 정책이 안되어 있어서. 등록되면 걸지.. 제어시 걸지는 고려 필요. String responseData = clientService.requestPostServiceReceiveString(contextAddress.getServerAddress(ContextAddress.SI_SERVER) + AddressStore.SI_SUBSCRIPTION_URI, requestBody); // ResponseData{ "code" : "2000", "message" : "", "content" : "" } diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/store/DeviceSubscriptionStore.java b/so-device/src/main/java/com/pineone/icbms/so/device/store/DeviceSubscriptionStore.java new file mode 100644 index 00000000..54707a26 --- /dev/null +++ b/so-device/src/main/java/com/pineone/icbms/so/device/store/DeviceSubscriptionStore.java @@ -0,0 +1,10 @@ +package com.pineone.icbms.so.device.store; + +import com.pineone.icbms.so.device.store.mongo.DeviceSubscriptionObject; + +public interface DeviceSubscriptionStore { + void create(DeviceSubscriptionObject deviceSubscriptionObject); + DeviceSubscriptionObject retrieve(String commandId); + void delete(String commandId); + +} diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionMongoStore.java b/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionMongoStore.java new file mode 100644 index 00000000..490198f7 --- /dev/null +++ b/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionMongoStore.java @@ -0,0 +1,37 @@ +package com.pineone.icbms.so.device.store.mongo; + +import com.pineone.icbms.so.device.store.DeviceSubscriptionStore; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +/** + * MongoDB와 DeviceSubscrption 연결 + */ +@Repository +public class DeviceSubscriptionMongoStore implements DeviceSubscriptionStore { + + public static final Logger logger = LoggerFactory.getLogger(DeviceSubscriptionMongoStore.class); + + @Autowired + DeviceSubscriptionRepository deviceSubscriptionRepository; + + @Override + public void create(DeviceSubscriptionObject deviceSubscriptionObject) { + logger.debug("Device = " + deviceSubscriptionObject.toString()); + deviceSubscriptionRepository.save(deviceSubscriptionObject); + } + + @Override + public DeviceSubscriptionObject retrieve(String commandId) { + logger.debug("Command ID = " + commandId); + return deviceSubscriptionRepository.findBy_commandId(commandId); + } + + @Override + public void delete(String commandId) { + logger.debug("Command ID = " + commandId); + deviceSubscriptionRepository.delete(commandId); + } +} diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionObject.java b/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionObject.java new file mode 100644 index 00000000..cb1f29b9 --- /dev/null +++ b/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionObject.java @@ -0,0 +1,64 @@ +package com.pineone.icbms.so.device.store.mongo; + +import org.springframework.data.mongodb.core.mapping.Document; + +/** + * Device Subscription에 대한 데이터 + */ +@Document(collection = "DeviceSubscription") +public class DeviceSubscriptionObject { + // + + private String _id; + + private String _commandId; + + private String deviceStatus; + + public DeviceSubscriptionObject() { + } + + public DeviceSubscriptionObject(String _commandId, String deviceStatus) { + this._commandId = _commandId; + this.deviceStatus = deviceStatus; + } + + public DeviceSubscriptionObject(String _id, String _commandId, String deviceStatus) { + this._id = _id; + this._commandId = _commandId; + this.deviceStatus = deviceStatus; + } + + public String get_commandId() { + return _commandId; + } + + public void set_commandId(String _commandId) { + this._commandId = _commandId; + } + + public String getDeviceStatus() { + return deviceStatus; + } + + public void setDeviceStatus(String deviceStatus) { + this.deviceStatus = deviceStatus; + } + + public String get_id() { + return _id; + } + + public void set_id(String _id) { + this._id = _id; + } + + @Override + public String toString() { + return "DeviceSubscriptionObject{" + + "_id='" + _id + '\'' + + ", _commandId='" + _commandId + '\'' + + ", deviceStatus='" + deviceStatus + '\'' + + '}'; + } +} diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionRepository.java b/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionRepository.java new file mode 100644 index 00000000..555d1e05 --- /dev/null +++ b/so-device/src/main/java/com/pineone/icbms/so/device/store/mongo/DeviceSubscriptionRepository.java @@ -0,0 +1,9 @@ +package com.pineone.icbms.so.device.store.mongo; + +import org.springframework.data.mongodb.repository.MongoRepository; + +public interface DeviceSubscriptionRepository extends MongoRepository { + + DeviceSubscriptionObject findBy_commandId(String commandId); + +} diff --git a/so-device/src/main/java/com/pineone/icbms/so/device/util/ClientProfile.java b/so-device/src/main/java/com/pineone/icbms/so/device/util/ClientProfile.java index c999a0f4..091226e9 100644 --- a/so-device/src/main/java/com/pineone/icbms/so/device/util/ClientProfile.java +++ b/so-device/src/main/java/com/pineone/icbms/so/device/util/ClientProfile.java @@ -8,6 +8,14 @@ public class ClientProfile { public static final String SI_COMMAND_ID = "cmd_"; + public static final String SI_DEVICE_BEAMSCREEN = "BeamScreen"; + public static final String SI_DEVICE_BLIND = "Blind"; + + public static final String SI_CONTAINER_STATUS = "/status"; + public static final String SI_CONTAINER_POWER = "/Power"; + public static final String SI_CONTAINER_ACTION = "/Action"; + + // Presentation Data public static final String RESPONSE_SUCCESS = "success"; public static final String RESPONSE_FAILURE = "failure"; @@ -16,4 +24,16 @@ public class ClientProfile { public static final String RESPONSE_SUCCESS_ONEM2MCODE = "2000"; + private ClientProfile() { + throw new IllegalAccessError("Utility class"); + } + + public static boolean actionDeviceCommand(String deviceUri){ + if(deviceUri.contains(SI_DEVICE_BEAMSCREEN) || deviceUri.contains(SI_DEVICE_BLIND)){ + return true; + } else { + return false; + } + } + } diff --git a/so-device/src/test/java/com/pineone/icbms/so/device/logic/DeviceManagerTest.java b/so-device/src/test/java/com/pineone/icbms/so/device/logic/DeviceManagerTest.java index 3c3c88fa..f158de55 100644 --- a/so-device/src/test/java/com/pineone/icbms/so/device/logic/DeviceManagerTest.java +++ b/so-device/src/test/java/com/pineone/icbms/so/device/logic/DeviceManagerTest.java @@ -1,5 +1,6 @@ package com.pineone.icbms.so.device.logic; +import com.pineone.icbms.so.device.store.mongo.DeviceSubscriptionRepository; import org.junit.Before; import org.junit.Test; @@ -7,6 +8,8 @@ public class DeviceManagerTest { private DeviceManager deviceManager; + private DeviceSubscriptionRepository deviceSubscriptionRepository; + @Before public void setUp(){ deviceManager = new DeviceManagerLogic(); @@ -30,5 +33,22 @@ public void deviceControlResultTest(){ } + @Test + public void getOnem2mDeviceUri(){ + // + String uri ="/herit-in/herit-cse/ONDB_SmartLight08_001/Power/status/CONTENT_INST_427988"; + String oneM2Muri = ""; + int stringlength = 3; + String[] strings = uri.split("/"); + for(String s : strings){ + System.out.println(s); + } + + for(int i =1; i<4 ; i++){ + stringlength += strings[i].length(); + } + + + } } diff --git a/so-device/src/test/java/com/pineone/icbms/so/device/proxy/DeviceSDAProxyTest.java b/so-device/src/test/java/com/pineone/icbms/so/device/proxy/DeviceSDAProxyTest.java index d93cc78e..2676116e 100644 --- a/so-device/src/test/java/com/pineone/icbms/so/device/proxy/DeviceSDAProxyTest.java +++ b/so-device/src/test/java/com/pineone/icbms/so/device/proxy/DeviceSDAProxyTest.java @@ -1,16 +1,8 @@ package com.pineone.icbms.so.device.proxy; -import com.pineone.icbms.so.device.entity.Device; -import com.pineone.icbms.so.device.util.ClientProfile; -import org.junit.Assert; import org.junit.Before; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; public class DeviceSDAProxyTest { @@ -21,56 +13,4 @@ public void setUp(){ deviceSDAProxy = mock(DeviceSDAProxy.class); } - - @Test - public void findDomainTest(){ - List domainlist = new ArrayList<>(); - - List domainTestList = new ArrayList<>(); - domainTestList.add("classroom"); - - when(deviceSDAProxy.findDomain(ClientProfile.SDA_DATAREQUEST_URI)).thenReturn(domainTestList); - domainlist = deviceSDAProxy.findDomain(ClientProfile.SDA_DATAREQUEST_URI); - Assert.assertEquals(domainlist.get(0),"classroom"); - - } - - @Test - public void findDeviceByIDTest(){ - Device device = new Device(); - Device deviceTest = new Device(); - deviceTest.setDeviceName("JunitTestDevice"); - deviceTest.setId("deviceT001"); - - when(deviceSDAProxy.findDeviceByID(ClientProfile.SDA_DATAREQUEST_URI + "device/deviceT001")).thenReturn(deviceTest); - device = deviceSDAProxy.findDeviceByID(ClientProfile.SDA_DATAREQUEST_URI + "device/deviceT001"); - Assert.assertEquals(device,deviceTest); - } - - @Test - public void findDeviceByDomainTest(){ - List devices = new ArrayList<>(); - List deviceTestList = new ArrayList<>(); - Device deviceTemp = new Device(); - deviceTemp.setDeviceName("JunitTestDevice"); - deviceTemp.setId("deviceT001"); - deviceTestList.add(deviceTemp); - - when(deviceSDAProxy.findDeviceByDomain(ClientProfile.SDA_DATAREQUEST_URI + "device/")).thenReturn(deviceTestList); - devices = deviceSDAProxy.findDeviceByDomain(ClientProfile.SDA_DATAREQUEST_URI + "device/"); - Assert.assertEquals(devices,deviceTestList); - - } - - @Test - public void findDeivceFunctionalityTest(){ - List deviceFunctionalityList = new ArrayList<>(); - List deviceFunctionalityListTest = new ArrayList<>(); - deviceFunctionalityListTest.add("TempControl"); - - when(deviceSDAProxy.findDeviceServiceList(ClientProfile.SDA_DATAREQUEST_URI +"devices/functionality/deviceT001")).thenReturn(deviceFunctionalityListTest); - deviceFunctionalityList = deviceSDAProxy.findDeviceServiceList(ClientProfile.SDA_DATAREQUEST_URI + "devices/functionality/deviceT001"); - Assert.assertEquals(deviceFunctionalityList,deviceFunctionalityListTest); - } - }