Skip to content

Commit 40f1144

Browse files
Merge pull request #77 from testomatio/fixes
Fixes
2 parents e809783 + b768d4c commit 40f1144

File tree

4 files changed

+55
-38
lines changed

4 files changed

+55
-38
lines changed

java-reporter-core/src/main/java/io/testomat/core/client/request/NativeRequestBodyBuilder.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class NativeRequestBodyBuilder implements RequestBodyBuilder {
3939

4040
public NativeRequestBodyBuilder() {
4141
this.publishParam = getPropertySafely(PUBLISH_PROPERTY_NAME);
42-
this.sharedRun = getPropertySafely(SHARED_RUN_PROPERTY_NAME);
42+
this.sharedRun = getSharedRun();
4343
this.sharedRunTimeout = getPropertySafely(SHARED_TIMEOUT_PROPERTY_NAME);
4444
this.objectMapper = new ObjectMapper();
4545
this.createParam = getCreateParam();
@@ -163,9 +163,26 @@ private String getPropertySafely(String propertyName) {
163163

164164
private boolean getCreateParam() {
165165
try {
166-
return provider.getProperty(CREATE_TEST_PROPERTY_NAME).equalsIgnoreCase(TRUE);
166+
String property = provider.getProperty(CREATE_TEST_PROPERTY_NAME);
167+
return property != null && !property.equalsIgnoreCase("0");
167168
} catch (Exception e) {
168169
return false;
169170
}
170171
}
172+
173+
private String getSharedRun() {
174+
String property;
175+
try {
176+
property = provider.getProperty(SHARED_RUN_PROPERTY_NAME);
177+
if (property != null
178+
&& !property.trim().isEmpty()
179+
&& !property.equalsIgnoreCase("0")
180+
) {
181+
return property;
182+
}
183+
} catch (Exception e) {
184+
return null;
185+
}
186+
return property;
187+
}
171188
}

java-reporter-core/src/main/java/io/testomat/core/constants/PropertyValuesConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.testomat.core.constants;
22

33
public class PropertyValuesConstants {
4-
public static final int DEFAULT_BATCH_SIZE = 100000;
4+
public static final int DEFAULT_BATCH_SIZE = 10;
55
public static final int DEFAULT_FLUSH_INTERVAL_SECONDS = 60000;
66
public static final String DEFAULT_URL = "https://app.testomat.io/";
77
public static final String DEFAULT_RUN_TITLE = "Default Run Title";

java-reporter-junit/src/main/java/io/testomat/junit/listener/JunitListener.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static io.testomat.core.constants.CommonConstants.FAILED;
44
import static io.testomat.core.constants.CommonConstants.PASSED;
55
import static io.testomat.core.constants.CommonConstants.SKIPPED;
6+
import static io.testomat.core.constants.PropertyNameConstants.API_KEY_PROPERTY_NAME;
67

78
import io.testomat.core.propertyconfig.impl.PropertyProviderFactoryImpl;
89
import io.testomat.core.propertyconfig.interf.PropertyProvider;
@@ -28,7 +29,6 @@ public class JunitListener implements BeforeEachCallback, BeforeAllCallback,
2829
AfterAllCallback, TestWatcher {
2930

3031
private static final Logger log = LoggerFactory.getLogger(JunitListener.class);
31-
private static final String LISTENING_REQUIRED_PROPERTY_NAME = "testomatio.listening";
3232

3333
private final MethodExportManager methodExportManager;
3434
private final GlobalRunManager runManager;
@@ -50,9 +50,9 @@ public JunitListener() {
5050
* Constructor for testing
5151
*
5252
* @param methodExportManager the method export manager
53-
* @param runManager the global run manager
54-
* @param reporter the JUnit test reporter
55-
* @param provider the property provider
53+
* @param runManager the global run manager
54+
* @param reporter the JUnit test reporter
55+
* @param provider the property provider
5656
*/
5757
public JunitListener(MethodExportManager methodExportManager,
5858
GlobalRunManager runManager,
@@ -147,7 +147,7 @@ private void exportTestClassIfNotProcessed(ExtensionContext context) {
147147

148148
private boolean isListeningRequired() {
149149
try {
150-
return provider.getProperty(LISTENING_REQUIRED_PROPERTY_NAME) != null;
150+
return provider.getProperty(API_KEY_PROPERTY_NAME) != null;
151151
} catch (Exception e) {
152152
return false;
153153
}

java-reporter-junit/src/test/java/io/testomat/junit/listener/JunitListenerTest.java

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class ListeningRequiredLogicTests {
106106
@DisplayName("Should return false when property throws PropertyNotFoundException")
107107
void shouldReturnFalseWhenPropertyThrowsPropertyNotFoundException() {
108108
// Given
109-
when(mockPropertyProvider.getProperty("testomatio.listening"))
109+
when(mockPropertyProvider.getProperty("testomatio"))
110110
.thenThrow(new PropertyNotFoundException("Property not found"));
111111

112112
// When
@@ -120,7 +120,7 @@ void shouldReturnFalseWhenPropertyThrowsPropertyNotFoundException() {
120120
@DisplayName("Should return false when property throws RuntimeException")
121121
void shouldReturnFalseWhenPropertyThrowsRuntimeException() {
122122
// Given
123-
when(mockPropertyProvider.getProperty("testomatio.listening"))
123+
when(mockPropertyProvider.getProperty("testomatio"))
124124
.thenThrow(new RuntimeException("Unexpected error"));
125125

126126
// When
@@ -134,7 +134,7 @@ void shouldReturnFalseWhenPropertyThrowsRuntimeException() {
134134
@DisplayName("Should return false when property returns null")
135135
void shouldReturnFalseWhenPropertyReturnsNull() {
136136
// Given
137-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn(null);
137+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn(null);
138138

139139
// When
140140
junitListener.beforeAll(mockExtensionContext);
@@ -152,7 +152,7 @@ class BeforeAllTests {
152152
@DisplayName("Should increment suite counter when listening is required")
153153
void shouldIncrementSuiteCounterWhenListeningIsRequired() {
154154
// Given
155-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn("true");
155+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn("true");
156156

157157
// When
158158
junitListener.beforeAll(mockExtensionContext);
@@ -165,7 +165,7 @@ void shouldIncrementSuiteCounterWhenListeningIsRequired() {
165165
@DisplayName("Should not increment suite counter when listening is not required")
166166
void shouldNotIncrementSuiteCounterWhenListeningIsNotRequired() {
167167
// Given
168-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn(null);
168+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn(null);
169169

170170
// When
171171
junitListener.beforeAll(mockExtensionContext);
@@ -178,7 +178,7 @@ void shouldNotIncrementSuiteCounterWhenListeningIsNotRequired() {
178178
@DisplayName("Should handle multiple beforeAll calls when listening is required")
179179
void shouldHandleMultipleBeforeAllCallsWhenListeningIsRequired() {
180180
// Given
181-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn("enabled");
181+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn("enabled");
182182

183183
// When
184184
junitListener.beforeAll(mockExtensionContext);
@@ -198,7 +198,7 @@ class AfterAllTests {
198198
@DisplayName("Should export test class and decrement suite counter when listening is required")
199199
void shouldExportTestClassAndDecrementSuiteCounterWhenListeningIsRequired() {
200200
// Given
201-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn("true");
201+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn("true");
202202
when(mockExtensionContext.getTestClass()).thenReturn(Optional.of(TestClassA.class));
203203

204204
// When
@@ -213,7 +213,7 @@ void shouldExportTestClassAndDecrementSuiteCounterWhenListeningIsRequired() {
213213
@DisplayName("Should not export or decrement when listening is not required")
214214
void shouldNotExportOrDecrementWhenListeningIsNotRequired() {
215215
// Given
216-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn(null);
216+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn(null);
217217

218218
// When
219219
junitListener.afterAll(mockExtensionContext);
@@ -227,7 +227,7 @@ void shouldNotExportOrDecrementWhenListeningIsNotRequired() {
227227
@DisplayName("Should only decrement suite counter when no test class present")
228228
void shouldOnlyDecrementSuiteCounterWhenNoTestClassPresent() {
229229
// Given
230-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn("true");
230+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn("true");
231231
when(mockExtensionContext.getTestClass()).thenReturn(Optional.empty());
232232

233233
// When
@@ -247,7 +247,7 @@ class BeforeEachTests {
247247
@DisplayName("Should not perform any operations in beforeEach regardless of listening status")
248248
void shouldNotPerformAnyOperationsInBeforeEach() {
249249
// Given
250-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn("true");
250+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn("true");
251251

252252
// When
253253
junitListener.beforeEach(mockExtensionContext);
@@ -269,7 +269,7 @@ class TestDisabledTests {
269269
void shouldReportTestAsDisabledWhenListeningIsRequired() {
270270
// Given
271271
String reason = "Test disabled for maintenance";
272-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn("true");
272+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn("true");
273273
when(mockExtensionContext.getTestClass()).thenReturn(Optional.of(TestClassA.class));
274274

275275
// When
@@ -285,7 +285,7 @@ void shouldReportTestAsDisabledWhenListeningIsRequired() {
285285
void shouldNotReportWhenListeningIsNotRequired() {
286286
// Given
287287
String reason = "Test disabled";
288-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn(null);
288+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn(null);
289289

290290
// When
291291
junitListener.testDisabled(mockExtensionContext, Optional.of(reason));
@@ -299,7 +299,7 @@ void shouldNotReportWhenListeningIsNotRequired() {
299299
@DisplayName("Should use default message when no reason provided")
300300
void shouldUseDefaultMessageWhenNoReasonProvided() {
301301
// Given
302-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn("true");
302+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn("true");
303303
when(mockExtensionContext.getTestClass()).thenReturn(Optional.of(TestClassA.class));
304304

305305
// When
@@ -319,7 +319,7 @@ class TestSuccessfulTests {
319319
@DisplayName("Should report test as successful when listening is required")
320320
void shouldReportTestAsSuccessfulWhenListeningIsRequired() {
321321
// Given
322-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn("true");
322+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn("true");
323323
when(mockExtensionContext.getTestClass()).thenReturn(Optional.of(TestClassA.class));
324324

325325
// When
@@ -334,7 +334,7 @@ void shouldReportTestAsSuccessfulWhenListeningIsRequired() {
334334
@DisplayName("Should not report when listening is not required")
335335
void shouldNotReportWhenListeningIsNotRequired() {
336336
// Given
337-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn(null);
337+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn(null);
338338

339339
// When
340340
junitListener.testSuccessful(mockExtensionContext);
@@ -354,7 +354,7 @@ class TestAbortedTests {
354354
void shouldReportTestAsAbortedWhenListeningIsRequired() {
355355
// Given
356356
Throwable cause = new RuntimeException("Test was aborted");
357-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn("true");
357+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn("true");
358358
when(mockExtensionContext.getTestClass()).thenReturn(Optional.of(TestClassA.class));
359359

360360
// When
@@ -370,7 +370,7 @@ void shouldReportTestAsAbortedWhenListeningIsRequired() {
370370
void shouldNotReportWhenListeningIsNotRequired() {
371371
// Given
372372
Throwable cause = new RuntimeException("Test was aborted");
373-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn(null);
373+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn(null);
374374

375375
// When
376376
junitListener.testAborted(mockExtensionContext, cause);
@@ -385,7 +385,7 @@ void shouldNotReportWhenListeningIsNotRequired() {
385385
void shouldHandleNullCauseMessage() {
386386
// Given
387387
Throwable cause = new RuntimeException(); // No message
388-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn("true");
388+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn("true");
389389
when(mockExtensionContext.getTestClass()).thenReturn(Optional.of(TestClassA.class));
390390

391391
// When
@@ -406,7 +406,7 @@ class TestFailedTests {
406406
void shouldReportTestAsFailedWhenListeningIsRequired() {
407407
// Given
408408
Throwable cause = new AssertionError("Expected <5> but was <3>");
409-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn("true");
409+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn("true");
410410
when(mockExtensionContext.getTestClass()).thenReturn(Optional.of(TestClassA.class));
411411

412412
// When
@@ -422,7 +422,7 @@ void shouldReportTestAsFailedWhenListeningIsRequired() {
422422
void shouldNotReportWhenListeningIsNotRequired() {
423423
// Given
424424
Throwable cause = new AssertionError("Test failed");
425-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn(null);
425+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn(null);
426426

427427
// When
428428
junitListener.testFailed(mockExtensionContext, cause);
@@ -437,7 +437,7 @@ void shouldNotReportWhenListeningIsNotRequired() {
437437
void shouldHandleNullCauseMessage() {
438438
// Given
439439
Throwable cause = new AssertionError(); // No message
440-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn("true");
440+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn("true");
441441
when(mockExtensionContext.getTestClass()).thenReturn(Optional.of(TestClassA.class));
442442

443443
// When
@@ -460,7 +460,7 @@ void shouldExportDifferentTestClassesSeparately() {
460460
ExtensionContext contextA = org.mockito.Mockito.mock(ExtensionContext.class);
461461
ExtensionContext contextB = org.mockito.Mockito.mock(ExtensionContext.class);
462462

463-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn("true");
463+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn("true");
464464
when(contextA.getTestClass()).thenReturn(Optional.of(TestClassA.class));
465465
when(contextA.getUniqueId()).thenReturn("test-context-A");
466466
when(contextB.getTestClass()).thenReturn(Optional.of(TestClassB.class));
@@ -480,7 +480,7 @@ void shouldExportDifferentTestClassesSeparately() {
480480
@DisplayName("Should not export when listening is not required")
481481
void shouldNotExportWhenListeningIsNotRequired() {
482482
// Given
483-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn(null);
483+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn(null);
484484
when(mockExtensionContext.getTestClass()).thenReturn(Optional.of(TestClassA.class));
485485

486486
// When
@@ -495,7 +495,7 @@ void shouldNotExportWhenListeningIsNotRequired() {
495495
@DisplayName("Should not export when test class is not present")
496496
void shouldNotExportWhenTestClassIsNotPresent() {
497497
// Given
498-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn("true");
498+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn("true");
499499
when(mockExtensionContext.getTestClass()).thenReturn(Optional.empty());
500500

501501
// When
@@ -514,7 +514,7 @@ class PropertyProviderExceptionHandlingTests {
514514
@DisplayName("Should handle PropertyNotFoundException gracefully in all callbacks")
515515
void shouldHandlePropertyNotFoundExceptionGracefullyInAllCallbacks() {
516516
// Given
517-
when(mockPropertyProvider.getProperty("testomatio.listening"))
517+
when(mockPropertyProvider.getProperty("testomatio"))
518518
.thenThrow(new PropertyNotFoundException("Property not found"));
519519

520520
// When & Then - all callbacks should handle exception gracefully
@@ -542,7 +542,7 @@ void shouldHandlePropertyNotFoundExceptionGracefullyInAllCallbacks() {
542542
@DisplayName("Should handle unexpected RuntimeException in property access")
543543
void shouldHandleUnexpectedRuntimeExceptionInPropertyAccess() {
544544
// Given
545-
when(mockPropertyProvider.getProperty("testomatio.listening"))
545+
when(mockPropertyProvider.getProperty("testomatio"))
546546
.thenThrow(new RuntimeException("Unexpected property access error"));
547547

548548
// When & Then - should not propagate exception
@@ -557,7 +557,7 @@ void shouldHandleUnexpectedRuntimeExceptionInPropertyAccess() {
557557
@DisplayName("Should handle intermittent property provider failures")
558558
void shouldHandleIntermittentPropertyProviderFailures() {
559559
// Given - first call fails, second succeeds
560-
when(mockPropertyProvider.getProperty("testomatio.listening"))
560+
when(mockPropertyProvider.getProperty("testomatio"))
561561
.thenThrow(new RuntimeException("Temporary failure"))
562562
.thenReturn("true");
563563
when(mockExtensionContext.getTestClass()).thenReturn(Optional.of(TestClassA.class));
@@ -580,7 +580,7 @@ class IntegrationTests {
580580
@DisplayName("Should handle complete test lifecycle when listening is required")
581581
void shouldHandleCompleteTestLifecycleWhenListeningIsRequired() {
582582
// Given
583-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn("enabled");
583+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn("enabled");
584584
when(mockExtensionContext.getTestClass()).thenReturn(Optional.of(TestClassA.class));
585585

586586
// When - simulate complete test lifecycle
@@ -603,7 +603,7 @@ void shouldHandleCompleteTestLifecycleWhenListeningIsRequired() {
603603
@DisplayName("Should handle complete test lifecycle when listening is not required")
604604
void shouldHandleCompleteTestLifecycleWhenListeningIsNotRequired() {
605605
// Given
606-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn(null);
606+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn(null);
607607

608608
// When - simulate complete test lifecycle
609609
junitListener.beforeAll(mockExtensionContext);
@@ -623,7 +623,7 @@ void shouldHandleCompleteTestLifecycleWhenListeningIsNotRequired() {
623623
@DisplayName("Should be thread-safe for concurrent test execution")
624624
void shouldBeThreadSafeForConcurrentTestExecution() {
625625
// Given
626-
when(mockPropertyProvider.getProperty("testomatio.listening")).thenReturn("true");
626+
when(mockPropertyProvider.getProperty("testomatio")).thenReturn("true");
627627
when(mockExtensionContext.getTestClass()).thenReturn(Optional.of(TestClassA.class));
628628

629629
// When - simulate concurrent test execution

0 commit comments

Comments
 (0)