Skip to content

Commit db723fa

Browse files
committed
[java11] Use orElseThrow instead of get
1 parent c14fd45 commit db723fa

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/test/java/org/mybatis/scripting/freemarker/PreparedDatabaseIdParamsTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2023 the original author or authors.
2+
* Copyright 2015-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -77,24 +77,24 @@ static void setUp() throws Exception {
7777
}
7878

7979
@Test
80-
void testReferDatabaseIdInTemplate() {
80+
void testReferDatabaseIdInTemplate() throws Exception {
8181
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
8282
PreparedDatabaseIdParamsMapper mapper = sqlSession.getMapper(PreparedDatabaseIdParamsMapper.class);
8383
Optional<Name> nameList = mapper.getDatabaseIdTest();
8484
Assertions.assertTrue(nameList.isPresent());
85-
Assertions.assertEquals("Fred", nameList.get().getFirstName());
86-
Assertions.assertEquals("Flintstone", nameList.get().getLastName());
85+
Assertions.assertEquals("Fred", nameList.orElseThrow(() -> new Exception()).getFirstName());
86+
Assertions.assertEquals("Flintstone", nameList.orElseThrow(() -> new Exception()).getLastName());
8787
}
8888
}
8989

9090
@Test
91-
void testReferDatabaseIdInTemplateWithParam() {
91+
void testReferDatabaseIdInTemplateWithParam() throws Exception {
9292
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
9393
PreparedDatabaseIdParamsMapper mapper = sqlSession.getMapper(PreparedDatabaseIdParamsMapper.class);
9494
Optional<Name> nameList = mapper.getDatabaseIdTestWithParam(new PreparedParam());
9595
Assertions.assertTrue(nameList.isPresent());
96-
Assertions.assertEquals("Fred", nameList.get().getFirstName());
97-
Assertions.assertEquals("Flintstone", nameList.get().getLastName());
96+
Assertions.assertEquals("Fred", nameList.orElseThrow(() -> new Exception()).getFirstName());
97+
Assertions.assertEquals("Flintstone", nameList.orElseThrow(() -> new Exception()).getLastName());
9898
}
9999
}
100100

0 commit comments

Comments
 (0)