Failed to instantiate [org.springframework.mobile.device.Device]: The specified class is an interface

The addFreePostTest () method failed. I could not inject device bean. How can I solve this problem?

org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.mobile.device.Device]: Specified class is an interface

      

BoardRestController.class

@RestController
@RequestMapping("/api/board/free")
public class BoardRestController {

    @PostMapping("")
    public FreePostWriteResponse addFreePost(
            @Valid @RequestBody FreePostForm form,
            Device device) {

    }

      

BoardRestControllerTests.class

@RunWith(SpringRunner.class)
@WebMvcTest(BoardRestController.class)
public class BoardRestControllerTests {

    @Autowired
    private MockMvc mvc;

    @MockBean private BoardFreeService boardFreeService;

    @Test
    @WithMockUser
    public void addFreePostTest() throws Exception {

        FreePostForm form = FreePostForm.builder()
                .subject("Subject.")
                .content("Content.")
                .categoryCode(JakdukConst.BOARD_CATEGORY_TYPE.FOOTBALL)
                .build();

        mvc.perform(post("/api/board/free")
                .contentType(MediaType.APPLICATION_JSON)
                .content(ObjectMapperUtils.writeValueAsString(form)))
                .andExpect(status().isOk());
    }

      

+3


source to share





All Articles