Skip to content

Commit 0656e20

Browse files
authored
Merge 0e54cf4 into d280e98
2 parents d280e98 + 0e54cf4 commit 0656e20

File tree

6 files changed

+72
-10
lines changed

6 files changed

+72
-10
lines changed

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ jobs:
2424
strategy:
2525
matrix:
2626
os: [ubuntu-latest, macOS-latest, windows-latest]
27-
java: [11, 17, 20, 21-ea]
27+
java: [11, 17, 21]
2828
distribution: ['zulu']
2929
fail-fast: false
3030
max-parallel: 5
3131
name: Test JDK ${{ matrix.java }}, ${{ matrix.os }}
3232

3333
steps:
34-
- uses: actions/checkout@v3
34+
- uses: actions/checkout@v4
3535
- name: Set up JDK
3636
uses: actions/setup-java@v3
3737
with:

.github/workflows/coveralls.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2015-2020 the original author or authors.
2+
# Copyright 2015-2023 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.
@@ -23,7 +23,7 @@ jobs:
2323
if: github.repository_owner == 'mybatis'
2424
runs-on: ubuntu-latest
2525
steps:
26-
- uses: actions/checkout@v3
26+
- uses: actions/checkout@v4
2727
- name: Set up JDK
2828
uses: actions/setup-java@v3
2929
with:

.github/workflows/sonar.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2015-2020 the original author or authors.
2+
# Copyright 2015-2023 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.
@@ -26,7 +26,7 @@ jobs:
2626
if: github.repository_owner == 'mybatis'
2727
runs-on: ubuntu-latest
2828
steps:
29-
- uses: actions/checkout@v3
29+
- uses: actions/checkout@v4
3030
with:
3131
# Disabling shallow clone is recommended for improving relevancy of reporting
3232
fetch-depth: 0

.github/workflows/sonatype.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2015-2020 the original author or authors.
2+
# Copyright 2015-2023 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.
@@ -26,7 +26,7 @@ jobs:
2626
if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]')
2727
runs-on: ubuntu-latest
2828
steps:
29-
- uses: actions/checkout@v3
29+
- uses: actions/checkout@v4
3030
- name: Set up JDK
3131
uses: actions/setup-java@v3
3232
with:

.github/workflows/support.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ jobs:
2424
strategy:
2525
matrix:
2626
os: [ubuntu-latest, macOS-latest]
27-
java: [11, 17, 20, 21-ea]
27+
java: [11, 17, 21]
2828
distribution: ['zulu']
2929
fail-fast: false
3030
max-parallel: 5
3131
name: Test JDK ${{ matrix.java }}, ${{ matrix.os }}
3232

3333
steps:
34-
- uses: actions/checkout@v3
34+
- uses: actions/checkout@v4
3535
- name: Set up JDK
3636
uses: actions/setup-java@v3
3737
with:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright 2015-2023 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package sample.mybatis.web;
17+
18+
import static org.assertj.core.api.Assertions.assertThat;
19+
20+
import java.util.Map;
21+
22+
import org.junit.jupiter.api.BeforeEach;
23+
import org.junit.jupiter.api.Test;
24+
import org.mockito.Mockito;
25+
import org.springframework.beans.factory.annotation.Autowired;
26+
import org.springframework.boot.test.context.SpringBootTest;
27+
import org.springframework.boot.test.mock.mockito.MockBean;
28+
import org.springframework.boot.test.web.client.TestRestTemplate;
29+
30+
import sample.mybatis.web.domain.City;
31+
import sample.mybatis.web.mapper.CityMapper;
32+
33+
/**
34+
* @author Kazuki Shimizu
35+
*/
36+
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
37+
class SampleMybatisWithMockBeanApplicationTest {
38+
39+
@Autowired
40+
private TestRestTemplate restTemplate;
41+
42+
@MockBean
43+
CityMapper cityMapper;
44+
45+
@BeforeEach
46+
void setup() {
47+
City city = new City();
48+
city.setId(10L);
49+
city.setCountry("US");
50+
city.setState("NV");
51+
city.setName("Las Vegas");
52+
Mockito.when(cityMapper.findByState("NV")).thenReturn(city);
53+
}
54+
55+
@Test
56+
void test() {
57+
@SuppressWarnings("unchecked")
58+
Map<String, Object> body = this.restTemplate.getForObject("/cities/{state}", Map.class, "NV");
59+
assertThat(body).hasSize(4).containsEntry("id", 10).containsEntry("name", "Las Vegas").containsEntry("state", "NV")
60+
.containsEntry("country", "US");
61+
}
62+
}

0 commit comments

Comments
 (0)