@@ -23,8 +23,11 @@ static void initToolkit() {
2323 }
2424
2525
26+ /**
27+ * Verifies that a valid message is sent successfully and captured by the connection spy.
28+ */
2629 @ Test
27- @ DisplayName ("Should send message successfully when message is valid" )
30+ @ DisplayName ("Should send message successfully when message is valid. " )
2831 void shouldSendValidMessageSuccessfully () throws InterruptedException {
2932 // Arrange
3033 var spy = new NtfyConnectionSpy ();
@@ -43,8 +46,11 @@ void shouldSendValidMessageSuccessfully() throws InterruptedException {
4346 assertThat (spy .message ).isEqualTo ("Hello World" );
4447 }
4548
49+ /**
50+ * Ensures the message input field is cleared after a successful send operation.
51+ */
4652 @ Test
47- @ DisplayName ("Should clear message field after successful send" )
53+ @ DisplayName ("Should clear message field after successful send. " )
4854 void shouldClearMessageFieldAfterSuccessfulSend () throws InterruptedException {
4955 // Arrange
5056 var spy = new NtfyConnectionSpy ();
@@ -63,6 +69,9 @@ void shouldClearMessageFieldAfterSuccessfulSend() throws InterruptedException {
6369 assertThat (model .getMessageToSend ()).isEmpty ();
6470 }
6571
72+ /**
73+ * Confirms that sending an empty string returns false and does not trigger a send.
74+ */
6675 @ Test
6776 @ DisplayName ("Should return false when sending empty string" )
6877 void shouldReturnFalseForEmptyMessage () throws InterruptedException {
@@ -88,6 +97,9 @@ void shouldReturnFalseForEmptyMessage() throws InterruptedException {
8897 assertThat (spy .message ).isNull ();
8998 }
9099
100+ /**
101+ * Confirms that sending a null message returns false and does not trigger a send.
102+ */
91103 @ Test
92104 @ DisplayName ("Should return false when sending null message" )
93105 void shouldReturnFalseForNullMessage () throws InterruptedException {
@@ -113,6 +125,9 @@ void shouldReturnFalseForNullMessage() throws InterruptedException {
113125 assertThat (spy .message ).isNull ();
114126 }
115127
128+ /**
129+ * Ensures failed sends are handled gracefully: callback receives false, message is retained.
130+ */
116131 @ Test
117132 @ DisplayName ("Should handle failed send and keep message" )
118133 void shouldHandleFailedSendGracefully () throws InterruptedException {
@@ -145,6 +160,9 @@ public void receive(Consumer<NtfyMessageDto> messageHandler) { }
145160 assertThat (model .getMessageToSend ()).isEqualTo ("Fail this message" );
146161 }
147162
163+ /**
164+ * Verifies multiple sequential sends are processed correctly in order.
165+ */
148166 @ Test
149167 @ DisplayName ("Should handle multiple sequential sends correctly" )
150168 void shouldHandleMultipleSequentialSends () throws InterruptedException {
@@ -177,6 +195,9 @@ void shouldHandleMultipleSequentialSends() throws InterruptedException {
177195 assertThat (spy .message ).isEqualTo ("Second" );
178196 }
179197
198+ /**
199+ * Ensures exceptions during send are caught and result in a failed callback (false).
200+ */
180201 @ Test
181202 @ DisplayName ("Should handle exceptions during send gracefully" )
182203 void shouldHandleExceptionsDuringSend () throws InterruptedException {
@@ -219,8 +240,9 @@ public void receive(Consumer<NtfyMessageDto> messageHandler) { }
219240 }
220241 }
221242
222- // ========== RECEIVE MESSAGE TESTS ==========
223-
243+ /**
244+ * Verifies that a valid incoming message is added to the observable message list.
245+ */
224246 @ Test
225247 @ DisplayName ("Should add received message to message list" )
226248 void shouldAddReceivedMessageToList () throws InterruptedException {
@@ -249,6 +271,9 @@ void shouldAddReceivedMessageToList() throws InterruptedException {
249271 assertThat (model .getMessages ()).contains (message );
250272 }
251273
274+ /**
275+ * Ensures null messages received from the connection are ignored and not added.
276+ */
252277 @ Test
253278 @ DisplayName ("Should ignore null received messages" )
254279 void shouldIgnoreNullReceivedMessages () throws InterruptedException {
@@ -273,6 +298,9 @@ void shouldIgnoreNullReceivedMessages() throws InterruptedException {
273298 assertThat (model .getMessages ()).isEmpty ();
274299 }
275300
301+ /**
302+ * Confirms messages with blank or empty content are filtered out and not added.
303+ */
276304 @ Test
277305 @ DisplayName ("Should ignore messages with blank or empty content" )
278306 void shouldIgnoreBlankOrEmptyMessages () throws InterruptedException {
@@ -301,6 +329,9 @@ void shouldIgnoreBlankOrEmptyMessages() throws InterruptedException {
301329 assertThat (model .getMessages ()).isEmpty ();
302330 }
303331
332+ /**
333+ * Verifies multiple incoming messages are added in the correct arrival order.
334+ */
304335 @ Test
305336 @ DisplayName ("Should add multiple received messages in correct order" )
306337 void shouldAddMultipleMessagesInOrder () throws InterruptedException {
@@ -337,8 +368,10 @@ void shouldAddMultipleMessagesInOrder() throws InterruptedException {
337368 assertThat (model .getMessages ().get (2 )).isEqualTo (message3 );
338369 }
339370
340- // ========== INTEGRATION TESTS ==========
341371
372+ /**
373+ * Integration test: verifies message is successfully sent to a mocked Ntfy server via HTTP.
374+ */
342375 @ Test
343376 @ DisplayName ("Should send message to fake server successfully" )
344377 void shouldSendMessageToFakeServer (WireMockRuntimeInfo wmRuntimeInfo ) throws InterruptedException {
0 commit comments