-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ test : add errorcode duplication test
- Loading branch information
1 parent
a0c4d0c
commit 3e718d2
Showing
3 changed files
with
36 additions
and
2 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
34 changes: 34 additions & 0 deletions
34
backend/streetdrop-api/src/test/java/unit/common/error/StreetDropErrorCodeTest.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,34 @@ | ||
package unit.common.error; | ||
|
||
import com.depromeet.common.error.dto.StreetDropErrorCode; | ||
import com.depromeet.common.error.dto.StreetDropErrorCodeList; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
|
||
@DisplayName("에러 코드 테스트") | ||
public class StreetDropErrorCodeTest { | ||
@Test | ||
@DisplayName("다른 도메인의 에러 코드가 중복되지 않는지 테스트") | ||
public void testNoDuplicateErrorResponseCodes() { | ||
|
||
StreetDropErrorCodeList streetDropErrorCodeList = StreetDropErrorCodeList.getInstance(); | ||
List<StreetDropErrorCode> errorCodes = streetDropErrorCodeList.getStreetDropErrorCodeList(); | ||
|
||
List<String> errorResponseCodes = errorCodes.stream() | ||
.map(StreetDropErrorCode::getErrorResponseCode) | ||
.toList(); | ||
|
||
var duplicatedList = errorResponseCodes.stream() | ||
.filter(i -> errorResponseCodes.stream().filter(i::equals).count() > 1) | ||
.distinct() | ||
.toList(); | ||
|
||
assertTrue(duplicatedList.isEmpty(), "There are duplicated error response codes: " + duplicatedList); | ||
} | ||
|
||
} |