Skip to content

Commit 43e7ca5

Browse files
samuelpsouzaohbus
andauthored
refactor: iluwatar#1012 - Resolve Sonar report: missing assertions in several AppTest classes (iluwatar#1784)
Co-authored-by: Subhrodip Mohanta <hello@subho.xyz>
1 parent f6d4397 commit 43e7ca5

File tree

7 files changed

+34
-21
lines changed

7 files changed

+34
-21
lines changed

filterer/src/test/java/com/iluwatar/filterer/AppTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@
2323

2424
package com.iluwatar.filterer;
2525

26+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
27+
2628
import org.junit.jupiter.api.Test;
2729

2830
class AppTest {
31+
2932
@Test
3033
void shouldLaunchApp() {
31-
App.main(new String[]{});
34+
assertDoesNotThrow(() -> App.main(new String[]{}));
3235
}
3336
}

monad/src/test/java/com/iluwatar/monad/AppTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,19 @@
2323

2424
package com.iluwatar.monad;
2525

26+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
27+
2628
import org.junit.jupiter.api.Test;
2729

2830
/**
2931
* Application Test
3032
*/
31-
public class AppTest {
33+
34+
class AppTest {
3235

3336
@Test
34-
void testMain() {
35-
App.main(new String[]{});
37+
void shouldExecuteApplicationWithoutException() {
38+
assertDoesNotThrow(() -> App.main(new String[]{}));
3639
}
3740

3841
}

monostate/src/test/java/com/iluwatar/monostate/AppTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,19 @@
2323

2424
package com.iluwatar.monostate;
2525

26+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
27+
2628
import org.junit.jupiter.api.Test;
2729

2830
/**
2931
* Application Test Entry
3032
*/
31-
public class AppTest {
33+
34+
class AppTest {
3235

3336
@Test
34-
void testMain() {
35-
App.main(new String[]{});
37+
void shouldExecuteApplicationWithoutException() {
38+
assertDoesNotThrow(() -> App.main(new String[]{}));
3639
}
3740

3841
}

multiton/src/test/java/com/iluwatar/multiton/AppTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,18 @@
2323

2424
package com.iluwatar.multiton;
2525

26+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
27+
2628
import org.junit.jupiter.api.Test;
2729

2830
/**
29-
* Application test
31+
* Test if the application starts without throwing an exception.
3032
*/
31-
public class AppTest {
33+
34+
class AppTest {
3235

3336
@Test
34-
void test() {
35-
App.main(new String[]{});
37+
void shouldExecuteApplicationWithoutException() {
38+
assertDoesNotThrow(() -> App.main(new String[]{}));
3639
}
3740
}

object-pool/src/test/java/com/iluwatar/object/pool/AppTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
package com.iluwatar.object.pool;
2525

26+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
27+
2628
import org.junit.jupiter.api.Test;
2729

2830
/**
@@ -34,6 +36,6 @@ class AppTest {
3436

3537
@Test
3638
void shouldExecuteApplicationWithoutException() {
37-
App.main(new String[]{});
39+
assertDoesNotThrow(() -> App.main(new String[]{}));
3840
}
3941
}

parameter-object/src/test/java/com/iluwatar/parameter/object/AppTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,16 @@
2323

2424
package com.iluwatar.parameter.object;
2525

26+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
27+
2628
import org.junit.jupiter.api.Test;
27-
import org.slf4j.Logger;
28-
import org.slf4j.LoggerFactory;
2929

3030
/**
3131
* Application test
3232
*/
3333
class AppTest {
34-
private static final Logger LOGGER = LoggerFactory.getLogger(AppTest.class);
35-
3634
@Test
3735
void shouldExecuteApplicationWithoutException() {
38-
App.main(new String[]{});
39-
LOGGER.info("Executed successfully without exception.");
36+
assertDoesNotThrow(() -> App.main(new String[]{}));
4037
}
4138
}

saga/src/test/java/com/iluwatar/saga/orchestration/SagaApplicationTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@
2323

2424
package com.iluwatar.saga.orchestration;
2525

26+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
27+
2628
import org.junit.jupiter.api.Test;
2729

2830
/**
29-
* empty test
31+
* Test if the application starts without throwing an exception.
3032
*/
3133
class SagaApplicationTest {
3234

3335
@Test
34-
void mainTest() {
35-
SagaApplication.main(new String[]{});
36+
void shouldExecuteApplicationWithoutException() {
37+
assertDoesNotThrow(() -> SagaApplication.main(new String[]{}));
3638
}
3739
}

0 commit comments

Comments
 (0)