토비의 스프링 4장 에러

2022. 5. 10. 15:45Spring/에러

assertThat(set.translate(null, null, sqlEx), is(DuplicateKeyException.class)); 가 에러가 났다.

잘못된 값이 들어왔다는 뜻인데 

The method assertThat(T, Matcher<? super T>) in the type MatcherAssert is not applicable for the arguments (DataAccessException, Matcher<DuplicateKeyException>)  라고 에러가 난다.

대충 구글에서 번역해서 보자면 DuplicateKeyException.class가 인수로써 맞지 않는덴다

구글에서 찾아보니 다른분도 똑같이 에러가 났었고, is에서 요구하는 인수가 아니기때문에

assertThat(set.translate(null, null, sqlEx), instanceOf(DuplicateKeyException.class));로 고치면 됐다.

junit5를 쓰고있어서 지양하는 코드도 많은데 그래도 잘 되서 다행이다.