找不到()位置接口java.util.list的符号方法,unittests
我目前正在开发一个spring启动应用程序,我现在正在编写unittests。但是,当我运行命令“mvn test”时,我得到以下错误: 这是密码 BoardServiceTest.java找不到()位置接口java.util.list的符号方法,unittests,java,spring-boot,Java,Spring Boot,我目前正在开发一个spring启动应用程序,我现在正在编写unittests。但是,当我运行命令“mvn test”时,我得到以下错误: 这是密码 BoardServiceTest.java @Test public void testGetBoards() { Set<Lists> list = new HashSet<Lists>(); List<Board> expectedBoards = List.of(
@Test
public void testGetBoards() {
Set<Lists> list = new HashSet<Lists>();
List<Board> expectedBoards = List.of(
new Board(1, "Studie", list),
new Board(2, "Todo Applicatie", list)
);
when(this.boardRepo.findAll()).thenReturn(expectedBoards);
var receivedBoards = this.boardService.getBoards();
assertEquals(expectedBoards, receivedBoards);
verify(this.boardRepo, times(1)).findAll();
}
@Test
public void testGetLists() throws Exception {
int boardId = 1;
Set<Task> task = new HashSet<>();
List<Lists> expectedLists = List.of(
new Lists(1, "registered", new Board(), task),
new Lists(2, "open", new Board(), task)
);
when(this.listRepository.findAll()).thenReturn(expectedLists);
var receivedLists = this.listService.getLists(boardId);
assertEquals(expectedLists, receivedLists);
verify(this.listRepository, times(1)).findAll();
}
@测试
公共void testGetBoards(){
Set list=新的HashSet();
List expectedBoards=List.of(
新董事会(1,“研究”,名单),
新板(2,“待办事项申请”,列表)
);
当(this.boardRepo.findAll())。然后返回(expectedBoards);
var receivedBoards=this.boardService.getBoards();
资产质量(预期板、接收板);
验证(this.boardRepo,times(1)).findAll();
}
ListsServiceTest.java
@Test
public void testGetBoards() {
Set<Lists> list = new HashSet<Lists>();
List<Board> expectedBoards = List.of(
new Board(1, "Studie", list),
new Board(2, "Todo Applicatie", list)
);
when(this.boardRepo.findAll()).thenReturn(expectedBoards);
var receivedBoards = this.boardService.getBoards();
assertEquals(expectedBoards, receivedBoards);
verify(this.boardRepo, times(1)).findAll();
}
@Test
public void testGetLists() throws Exception {
int boardId = 1;
Set<Task> task = new HashSet<>();
List<Lists> expectedLists = List.of(
new Lists(1, "registered", new Board(), task),
new Lists(2, "open", new Board(), task)
);
when(this.listRepository.findAll()).thenReturn(expectedLists);
var receivedLists = this.listService.getLists(boardId);
assertEquals(expectedLists, receivedLists);
verify(this.listRepository, times(1)).findAll();
}
@测试
public void TestGetList()引发异常{
int boardId=1;
Set task=new HashSet();
List expectedLists=List.of(
新列表(1,“已注册”,新板(),任务),
新列表(2,“打开”,新板(),任务)
);
when(this.listRepository.findAll()).thenReturn(ExpectedList);
var receivedLists=this.listService.getLists(boardId);
资产质量(预期清单、接收清单);
验证(this.listRepository,times(1)).findAll();
}
列表。如果添加了
,您需要确保使用JDK 9+编译源代码,并且在mavenpom.xml
中设置了适当的java版本。以后请不要发布错误消息的屏幕截图,而是将错误消息本身作为文本发布。@JoachimSauer我现在没有这样做,但我无法复制完整的错误。这就是我拍截图的原因。但我不会在未来的几周内发表评论。我在pom.xml中看到我使用的是Java1.8。我会更新的