Merge pull request #48 from nagisa77/codex/fix-unsatisfieddependencyexception-in-tests

Fix controller tests
This commit is contained in:
Tim
2025-07-02 17:00:54 +08:00
committed by GitHub
2 changed files with 8 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ package com.openisle.controller;
import com.openisle.model.Category; import com.openisle.model.Category;
import com.openisle.service.CategoryService; import com.openisle.service.CategoryService;
import com.openisle.service.PostService;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -26,6 +27,9 @@ class CategoryControllerTest {
@MockBean @MockBean
private CategoryService categoryService; private CategoryService categoryService;
@MockBean
private PostService postService;
@Test @Test
void createAndGetCategory() throws Exception { void createAndGetCategory() throws Exception {
Category c = new Category(); Category c = new Category();

View File

@@ -2,6 +2,7 @@ package com.openisle.controller;
import com.openisle.model.Tag; import com.openisle.model.Tag;
import com.openisle.service.TagService; import com.openisle.service.TagService;
import com.openisle.service.PostService;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -26,6 +27,9 @@ class TagControllerTest {
@MockBean @MockBean
private TagService tagService; private TagService tagService;
@MockBean
private PostService postService;
@Test @Test
void createAndGetTag() throws Exception { void createAndGetTag() throws Exception {
Tag t = new Tag(); Tag t = new Tag();