Skip to content

Commit b900a1f

Browse files
committed
Add VersionControllerTests
1 parent 3431b60 commit b900a1f

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2020-2023 IEXEC BLOCKCHAIN TECH
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+
* http://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+
17+
package com.iexec.core.version;
18+
19+
import org.junit.jupiter.api.BeforeEach;
20+
import org.junit.jupiter.params.ParameterizedTest;
21+
import org.junit.jupiter.params.provider.ValueSource;
22+
import org.mockito.InjectMocks;
23+
import org.mockito.Mock;
24+
import org.mockito.MockitoAnnotations;
25+
import org.springframework.http.ResponseEntity;
26+
27+
import static org.junit.jupiter.api.Assertions.assertEquals;
28+
import static org.mockito.Mockito.when;
29+
30+
class VersionControllerTests {
31+
@Mock
32+
private VersionService versionService;
33+
@InjectMocks
34+
private VersionController versionController;
35+
36+
@BeforeEach
37+
void init() {
38+
MockitoAnnotations.openMocks(this);
39+
}
40+
41+
@ParameterizedTest
42+
@ValueSource(strings={"x.y.z", "x.y.z-rc", "x.y.z-NEXT-SNAPSHOT"})
43+
void testVersionController(String version) {
44+
when(versionService.getVersion()).thenReturn(version);
45+
assertEquals(ResponseEntity.ok(version), versionController.getVersion());
46+
}
47+
}

0 commit comments

Comments
 (0)