@Override public void execute(IotHubConnectionStatus status, IotHubConnectionStatusChangeReason statusChangeReason, Throwable throwable, Object callbackContext) { actualStatusUpdates.add(new Pair<>(status, throwable)); } }, new Object());
@Override public void execute(IotHubConnectionStatus status, IotHubConnectionStatusChangeReason statusChangeReason, Throwable throwable, Object callbackContext) { actualStatusUpdates.add(new Pair<>(status, throwable)); } };
@Override public void execute(IotHubConnectionStatus status, IotHubConnectionStatusChangeReason statusChangeReason, Throwable throwable, Object callbackContext) { actualStatusUpdates.add(new com.microsoft.azure.sdk.iot.device.DeviceTwin.Pair<>(status, throwable)); } };
@Override public void execute(IotHubConnectionStatus status, IotHubConnectionStatusChangeReason statusChangeReason, Throwable throwable, Object callbackContext) { statusUpdates.add(new Pair<>(status, throwable)); } }, new Object());
@Override public void execute(IotHubConnectionStatus status, IotHubConnectionStatusChangeReason statusChangeReason, Throwable throwable, Object callbackContext) { connectionStatusUpdates.add(new Pair<>(status, throwable)); } }, null);
public void setDesiredPropertyCallback(Property desiredProp, PropertyCallBack<String, Object> desiredPropCallBack, Object desiredPropCallBackContext) { if (desiredProp == null) { /* **Codes_SRS_DEVICE_25_007: [**If the parameter desiredProp is null then this method shall throw IllegalArgumentException**]** */ throw new IllegalArgumentException("desired property cannot be null"); } /* **Codes_SRS_DEVICE_25_006: [**The function shall add the property and its callback and context pair to the user map of desired properties.**]** **Codes_SRS_DEVICE_25_008: [**This method shall add the parameters to the map even if callback and object pair are null**]** */ this.desiredProp.put(desiredProp, new Pair<>(desiredPropCallBack, desiredPropCallBackContext)); }
public void setMessageCallback(String inputName, MessageCallback callback, Object context) { if (this.inputChannelMessageCallbacks.containsKey(inputName) && callback == null) { // Codes_SRS_DEVICECLIENTCONFIG_34_058: [If the provided inputName is already saved in the message callbacks map, and the provided callback is null, this function // shall remove the inputName from the message callbacks map.] this.inputChannelMessageCallbacks.remove(inputName); } else { // Codes_SRS_DEVICECLIENTCONFIG_34_044: [The function shall map the provided inputName to the callback and context in the saved inputChannelMessageCallbacks map.] this.inputChannelMessageCallbacks.put(inputName, new Pair<>(callback, context)); } }
public Property(String key, Object value) { if (key == null || key.isEmpty()) { /* **Codes_SRS_Property_25_002: [**If the key is null or empty, the constructor shall throw an IllegalArgumentException.**] */ throw new IllegalArgumentException("Key cannot be null or empty"); } if (key.contains(" ") || key.contains("$") || key.contains(".")) { /* **Codes_SRS_Property_25_006: [**If the key contains illegal unicode control characters i.e ' ', '.', '$', the constructor shall throw an IllegalArgumentException.**]** */ throw new IllegalArgumentException("Key cannot contain illegal unicode control characters '.', '$', ' '"); } /* **Codes_SRS_Property_25_001: [**The constructor shall save the key and value representing this property.**]** */ this.property = new Pair<>(key, value); }
@Test public void testSubscribeToDesiredPropertiesWithVersion() throws IOException, InterruptedException, IotHubException { // arrange deviceUnderTest.sCDeviceForTwin.clearTwin(); deviceUnderTest.dCDeviceForTwin.getDesiredProp().clear(); Map<Property, Pair<TwinPropertyCallBack, Object>> desiredPropertiesCB = new HashMap<>(); for (int i = 0; i < MAX_PROPERTIES_TO_TEST; i++) { PropertyState propertyState = new PropertyState(); propertyState.callBackTriggered = false; propertyState.propertyNewVersion = -1; propertyState.property = new Property(PROPERTY_KEY + i, PROPERTY_VALUE); deviceUnderTest.dCDeviceForTwin.propertyStateList[i] = propertyState; desiredPropertiesCB.put(propertyState.property, new com.microsoft.azure.sdk.iot.device.DeviceTwin.Pair<TwinPropertyCallBack, Object>(deviceUnderTest.dCOnProperty, propertyState)); } // act internalClient.subscribeToTwinDesiredProperties(desiredPropertiesCB); Thread.sleep(DELAY_BETWEEN_OPERATIONS); Set<com.microsoft.azure.sdk.iot.service.devicetwin.Pair> desiredProperties = new HashSet<>(); for (int i = 0; i < MAX_PROPERTIES_TO_TEST; i++) { desiredProperties.add(new com.microsoft.azure.sdk.iot.service.devicetwin.Pair(PROPERTY_KEY + i, PROPERTY_VALUE_UPDATE + UUID.randomUUID())); } deviceUnderTest.sCDeviceForTwin.setDesiredProperties(desiredProperties); sCDeviceTwin.updateTwin(deviceUnderTest.sCDeviceForTwin); // assert waitAndVerifyTwinStatusBecomesSuccess(); waitAndVerifyDesiredPropertyCallback(PROPERTY_VALUE_UPDATE, true); }
propertyState.property = new Property(PROPERTY_KEY + i, PROPERTY_VALUE); deviceUnderTest.dCDeviceForTwin.propertyStateList[i] = propertyState; desiredPropertiesCB.put(propertyState.property, new com.microsoft.azure.sdk.iot.device.DeviceTwin.Pair<TwinPropertyCallBack, Object>(deviceUnderTest.dCOnProperty, propertyState));
put(new Property("HomeTemp(F)", null), new Pair<TwinPropertyCallBack, Object>(new onHomeTempChange(), null)); put(new Property("LivingRoomLights", null), new Pair<TwinPropertyCallBack, Object>(new onProperty(), null)); put(new Property("BedroomRoomLights", null), new Pair<TwinPropertyCallBack, Object>(new onProperty(), null)); put(new Property("HomeSecurityCamera", null), new Pair<TwinPropertyCallBack, Object>(new onCameraActivity(), null));
put(new Property("HomeTemp(F)", null), new Pair<TwinPropertyCallBack, Object>(new onHomeTempChange(), null)); put(new Property("LivingRoomLights", null), new Pair<TwinPropertyCallBack, Object>(new onProperty(), null)); put(new Property("BedroomRoomLights", null), new Pair<TwinPropertyCallBack, Object>(new onProperty(), null)); put(new Property("HomeSecurityCamera", null), new Pair<TwinPropertyCallBack, Object>(new onCameraActivity(), null));