use of com.aws.greengrass.mqttclient.MqttClient.MAX_NUMBER_OF_FORWARD_SLASHES in project aws-greengrass-nucleus by aws-greengrass.
the class MqttClientTest method GIVEN_reserved_topic_have_9_forward_slashes_WHEN_publish_THEN_future_complete.
@Test
void GIVEN_reserved_topic_have_9_forward_slashes_WHEN_publish_THEN_future_complete() throws SpoolerStoreException, InterruptedException, ExecutionException {
MqttClient client = spy(new MqttClient(deviceConfiguration, spool, false, (c) -> builder, executorService));
String topic = reservedTopicPrefix + String.join("/", Collections.nCopies(MAX_NUMBER_OF_FORWARD_SLASHES, "a"));
assertEquals(9, topic.chars().filter(num -> num == '/').count());
PublishRequest request = PublishRequest.builder().topic(topic).payload(new byte[1]).qos(QualityOfService.AT_LEAST_ONCE).build();
SpoolMessage message = SpoolMessage.builder().id(0L).request(request).build();
when(spool.addMessage(request)).thenReturn(message);
CompletableFuture<Integer> future = client.publish(request);
assertEquals(0, future.get());
verify(spool, times(1)).addMessage(request);
verify(spool, never()).getSpoolConfig();
}
Aggregations