Skip to content

Commit

Permalink
Fixing issue: QOS not set for incoming messages from $iothub/twin/PAT…
Browse files Browse the repository at this point in the history
…CH/properties/desired/ topic Azure#1746
  • Loading branch information
dzakub committed Oct 12, 2023
1 parent 4ed458d commit 2f18b9c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ else if (topic.length() > PATCH.length() && topic.startsWith(PATCH))
{
message = new IotHubTransportMessage(data, MessageType.DEVICE_TWIN);
message.setDeviceOperationType(DeviceOperations.DEVICE_OPERATION_TWIN_SUBSCRIBE_DESIRED_PROPERTIES_RESPONSE);
message.setQualityOfService(messagePair.getValue().getQos());
}

// Case for $iothub/twin/PATCH/properties/desired/?$version={new version}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,33 @@ public void receiveDoesNotSetVersionForDesiredPropNotifRespIfNotFound() throws T
}
}

@Test
public void receiveSetQosForDesiredProp() throws TransportException
{
final byte[] actualPayload = "NotificationResponseDataContainingDesiredPropertiesDocument".getBytes(StandardCharsets.UTF_8);
final String expectedTopic = "$iothub/twin/PATCH/properties/desired/";
IotHubTransportMessage receivedMessage = null;
int expectedQualityOfService = 2;
try
{
//arrange
Queue<Pair<String, MqttMessage>> testreceivedMessages = new ConcurrentLinkedQueue<>();
MqttMessage mqttMessage = new MqttMessage(actualPayload);
mqttMessage.setQos(expectedQualityOfService);
testreceivedMessages.add(new MutablePair<>(expectedTopic, mqttMessage));
MqttTwin testTwin = new MqttTwin("", mockedConnectOptions, new HashMap<>(), testreceivedMessages);

//act
receivedMessage = testTwin.receive();
}
finally
{
//assert
assertNotNull(receivedMessage);
assertEquals(expectedQualityOfService, receivedMessage.getQualityOfService());
}
}

/*
**Tests_SRS_MQTTDEVICETWIN_25_042: [If the topic is of type patch for desired properties then this method shall parse further to look for version which if found is set by calling setVersion]
*/
Expand Down

0 comments on commit 2f18b9c

Please sign in to comment.