Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing issue: QOS not set for incoming messages from $iothub/twin/PAT… #1747

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(mqttMessage.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;
timtay-microsoft marked this conversation as resolved.
Show resolved Hide resolved
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
Loading