|
1 | 1 | /*
|
2 |
| - * Copyright 2015-2023 the original author or authors. |
| 2 | + * Copyright 2015-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -77,24 +77,24 @@ static void setUp() throws Exception {
|
77 | 77 | }
|
78 | 78 |
|
79 | 79 | @Test
|
80 |
| - void testReferDatabaseIdInTemplate() { |
| 80 | + void testReferDatabaseIdInTemplate() throws Exception { |
81 | 81 | try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
|
82 | 82 | PreparedDatabaseIdParamsMapper mapper = sqlSession.getMapper(PreparedDatabaseIdParamsMapper.class);
|
83 | 83 | Optional<Name> nameList = mapper.getDatabaseIdTest();
|
84 | 84 | 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()); |
87 | 87 | }
|
88 | 88 | }
|
89 | 89 |
|
90 | 90 | @Test
|
91 |
| - void testReferDatabaseIdInTemplateWithParam() { |
| 91 | + void testReferDatabaseIdInTemplateWithParam() throws Exception { |
92 | 92 | try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
|
93 | 93 | PreparedDatabaseIdParamsMapper mapper = sqlSession.getMapper(PreparedDatabaseIdParamsMapper.class);
|
94 | 94 | Optional<Name> nameList = mapper.getDatabaseIdTestWithParam(new PreparedParam());
|
95 | 95 | 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()); |
98 | 98 | }
|
99 | 99 | }
|
100 | 100 |
|
|
0 commit comments