Skip to content

Commit 9320dcc

Browse files
committed
test(util): BCryptPasswordEncoderUtil 인스턴스화 테스트 추가
- private 생성자를 이용한 인스턴스화 불가능 여부 테스트 추가 - UnsupportedOperationException 예외 발생 확인
1 parent 5b3dd60 commit 9320dcc

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/test/java/com/somemore/global/util/encoder/BCryptPasswordEncoderUtilTest.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package com.somemore.global.util.encoder;
22

3-
import static org.assertj.core.api.Assertions.assertThat;
4-
5-
import org.junit.jupiter.api.Test;
63
import org.junit.jupiter.api.DisplayName;
4+
import org.junit.jupiter.api.Test;
5+
6+
import java.lang.reflect.InvocationTargetException;
7+
8+
import static org.assertj.core.api.Assertions.assertThat;
9+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
710

811
class BCryptPasswordEncoderUtilTest {
912

@@ -33,4 +36,18 @@ void testMatches() {
3336
// then
3437
assertThat(BCryptPasswordEncoderUtil.matches(rawPassword, encodedPassword)).isTrue();
3538
}
39+
40+
@Test
41+
@DisplayName("인스턴스화 할 수 없다.")
42+
void testConstruct() throws Exception {
43+
// given
44+
var constructor = BCryptPasswordEncoderUtil.class.getDeclaredConstructor();
45+
constructor.setAccessible(true);
46+
47+
// when & then
48+
assertThatThrownBy(constructor::newInstance)
49+
.isInstanceOf(InvocationTargetException.class)
50+
.extracting(Throwable::getCause)
51+
.isInstanceOf(UnsupportedOperationException.class);
52+
}
3653
}

0 commit comments

Comments
 (0)