Skip to content

Commit

Permalink
#1021: Add comments and test for Last Will config
Browse files Browse the repository at this point in the history
Signed-off-by: Vadim Guenther <vadim.guenther@bosch.io>
  • Loading branch information
VadimGue committed Apr 8, 2021
1 parent 5fc8763 commit 0822075
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Expand Up @@ -125,28 +125,28 @@ public Optional<String> getMqttPublisherId() {


/**
* @return the optional publisherId which should be used as the client ID of the publisher actor.
* @return the optional topic which should be used on Last Will message.
*/
public Optional<String> getMqttWillTopic() {
return getStringOptional(LAST_WILL_TOPIC);
}

/**
* @return the optional publisherId which should be used as the client ID of the publisher actor.
* @return the Qos which should be used on Last Will message.
*/
public String getMqttWillQos() {
return getSafely(() -> specificConfig.getString(LAST_WILL_QOS), DEFAULT_LAST_WILL_QOS);
}

/**
* @return the optional publisherId which should be used as the client ID of the publisher actor.
* @return the optional message which should be used on Last Will message.
*/
public Optional<String> getMqttWillMessage() {
return getStringOptional(LAST_WILL_MESSAGE);
}

/**
* @return the optional publisherId which should be used as the client ID of the publisher actor.
* @return the retain flag which should be used on Last Will message.
*/
public boolean getMqttWillRetain() {
return getSafely(() -> specificConfig.getBoolean(LAST_WILL_RETAIN), DEFAULT_LAST_WILL_RETAIN);
Expand Down
Expand Up @@ -34,6 +34,10 @@ public void parseMqttSpecificConfig() {
configuredSpecificConfig.put("clientId", "consumer-client-id");
configuredSpecificConfig.put("publisherId", "publisher-client-id");
configuredSpecificConfig.put("reconnectForRedeliveryDelay", "4m");
configuredSpecificConfig.put("lastWillTopic", "lastWillTopic");
configuredSpecificConfig.put("lastWillQos", "EXACTLY_ONCE");
configuredSpecificConfig.put("lastWillMessage", "last will message");
configuredSpecificConfig.put("lastWillRetain", "true");
final MqttSpecificConfig specificConfig = new MqttSpecificConfig(configuredSpecificConfig);
assertThat(specificConfig.reconnectForRedelivery()).isFalse();
assertThat(specificConfig.separatePublisherClient()).isFalse();
Expand All @@ -50,5 +54,9 @@ public void defaultConfig() {
assertThat(specificConfig.getMqttClientId()).isEmpty();
assertThat(specificConfig.getMqttPublisherId()).isEmpty();
assertThat(specificConfig.getReconnectForDeliveryDelay()).isEqualTo(Duration.ofSeconds(2L));
assertThat(specificConfig.getMqttWillTopic()).isEmpty();
assertThat(specificConfig.getMqttWillQos()).isEqualTo("AT_MOST_ONCE");
assertThat(specificConfig.getMqttWillMessage()).isEmpty();
assertThat(specificConfig.getMqttWillRetain()).isFalse();
}
}
}

0 comments on commit 0822075

Please sign in to comment.