### Question:
BbsArticleApiService { public void preModifyArticle(BbsArticleEntity dbParam) { Optional<BbsArticleEntity> optDbInfo = this.get(dbParam.getArticleId()); if (optDbInfo.isPresent() == false) { throw new BaseException("데이터를 찾을 수 없습니다.", HttpStatus.BAD_REQUEST); } BbsArticleEntity dbInfo = optDbInfo.get(); if (StringUtils.equals(dbInfo.getCreatedUserId(), dbParam.getUpdatedUserId()) == false) { throw new BaseException("작성자만 글을 수정할 수 있습니다.", HttpStatus.BAD_REQUEST); } }  Page<BbsArticleEntity> page(Pageable pageable); Optional<BbsArticleEntity> get(Long articleId); void preAddArticle(BbsArticleEntity dbParam); @Transactional void addArticle(BbsArticleEntity dbParam); void preModifyArticle(BbsArticleEntity dbParam); @Transactional void modifyArticle(BbsArticleEntity dbParam);  }### Answer:
@Test(expected = BaseException.class) public void preModifyArticle1() { final Long articleId = 1L; GIVEN: { given(bbsArticleRepository.findByArticleId(articleId)).willReturn(null); } WHEN: { bbsArticleApiService.preModifyArticle(new BbsArticleEntity()); } }
@Test(expected = BaseException.class) public void preModifyArticle2() { final Long articleId = 1L; BbsArticleEntity param = BbsArticleEntity.builder() .articleId(articleId) .updatedUserId("test") .build(); GIVEN: { given(bbsArticleRepository.findByArticleId(articleId)).willReturn( BbsArticleEntity.builder() .updatedUserId("test2") .build() ); } WHEN: { bbsArticleApiService.preModifyArticle(param); } }