-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Log stack trace for Exceptions (#12)
- Loading branch information
1 parent
807eff8
commit 6cc1c44
Showing
6 changed files
with
107 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
ejmask-core/src/test/java/com/ebay/ejmask/core/util/CommonUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.ebay.ejmask.core.util; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
class CommonUtilsTest { | ||
|
||
@Test | ||
void isEmpty_whenCollectionNullOrEmpty_returnTrue() { | ||
boolean result = CommonUtils.isEmpty(null); | ||
Assertions.assertTrue(result); | ||
|
||
boolean result2 = CommonUtils.isEmpty(new ArrayList<>()); | ||
Assertions.assertTrue(result2); | ||
|
||
} | ||
|
||
@Test | ||
void isNotEmpty_whenCollectionIsNotEmpty_returnTrue() { | ||
List<String> list = new ArrayList<>(); | ||
list.add("content"); | ||
|
||
boolean result = CommonUtils.isNotEmpty(list); | ||
Assertions.assertTrue(result); | ||
|
||
} | ||
|
||
@Test | ||
void emptyIfNull_ifNullCollection_returnEmptyCollection() { | ||
Collection<String> collection = CommonUtils.emptyIfNull(null); | ||
Assertions.assertNotNull(collection); | ||
Assertions.assertEquals(0, collection.size()); | ||
|
||
} | ||
|
||
@Test | ||
void isNotAnEmptyArray_ifEmptyArray_returnsFalse() { | ||
boolean result = CommonUtils.isNotAnEmptyArray(new String[0]); | ||
Assertions.assertFalse(result); | ||
|
||
} | ||
|
||
@Test | ||
void isAnEmptyArray_ifEmptyArray_returnsFalse() { | ||
boolean result = CommonUtils.isAnEmptyArray(new String[0]); | ||
Assertions.assertTrue(result); | ||
|
||
} | ||
|
||
@Test | ||
void isNotBlank_ifBlankString_returnsFalse() { | ||
boolean result = CommonUtils.isNotBlank(" "); | ||
Assertions.assertFalse(result); | ||
|
||
} | ||
|
||
@Test | ||
void isBlank_ifBlankString_returnsTrue() { | ||
boolean result = CommonUtils.isBlank(" "); | ||
Assertions.assertTrue(result); | ||
} | ||
|
||
@Test | ||
void getStackTrace_whenExceptionThrown_shouldPrintStackTrace() { | ||
Exception e = new Exception("some exception"); | ||
String result = CommonUtils.getStackTrace(e); | ||
Assertions.assertNotNull(result); | ||
Assertions.assertEquals("java.lang.Exception: some exception", result.split("\n")[0]); | ||
} | ||
} |