Skip to content

Commit 307cbfc

Browse files
authored
Merge pull request #618 from iExecBlockchainComputing/bugfix/clean-version-service
Remove `VersionService#isSnapshot`
2 parents 51af7f6 + b900a1f commit 307cbfc

File tree

6 files changed

+72
-21
lines changed

6 files changed

+72
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file.
1919
- Events are now immutable with `@Value` lombok annotation. (#608)
2020
- Fix several code smells. (#609)
2121
- Upgrade to Gradle 8.2.1 with up-to-date plugins. (#612)
22+
- Remove `VersionService#isSnapshot`. (#618)
2223
### Dependency Upgrades
2324
- Remove `logstash-gelf` dependency. (#607)
2425
- Upgrade to `eclipse-temurin` 11.0.20. (#610)

src/main/java/com/iexec/core/config/OpenApiConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 IEXEC BLOCKCHAIN TECH
2+
* Copyright 2020-2023 IEXEC BLOCKCHAIN TECH
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.
@@ -16,7 +16,7 @@
1616

1717
package com.iexec.core.config;
1818

19-
import com.iexec.core.utils.version.VersionService;
19+
import com.iexec.core.version.VersionService;
2020
import io.swagger.v3.oas.models.OpenAPI;
2121
import io.swagger.v3.oas.models.info.Info;
2222
import org.springframework.context.annotation.Bean;

src/main/java/com/iexec/core/utils/version/VersionController.java renamed to src/main/java/com/iexec/core/version/VersionController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.iexec.core.utils.version;
17+
package com.iexec.core.version;
1818

1919
import org.springframework.http.ResponseEntity;
2020
import org.springframework.web.bind.annotation.GetMapping;

src/main/java/com/iexec/core/utils/version/VersionService.java renamed to src/main/java/com/iexec/core/version/VersionService.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 IEXEC BLOCKCHAIN TECH
2+
* Copyright 2020-2023 IEXEC BLOCKCHAIN TECH
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.
@@ -14,9 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.iexec.core.utils.version;
17+
package com.iexec.core.version;
1818

19-
import com.iexec.common.utils.VersionUtils;
2019
import org.springframework.boot.info.BuildProperties;
2120
import org.springframework.stereotype.Service;
2221

@@ -33,8 +32,4 @@ public String getVersion() {
3332
return buildProperties.getVersion();
3433
}
3534

36-
public boolean isSnapshot() {
37-
return VersionUtils.isSnapshot(buildProperties.getVersion());
38-
}
39-
4035
}
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+
}

src/test/java/com/iexec/core/utils/version/VersionServiceTests.java renamed to src/test/java/com/iexec/core/version/VersionServiceTests.java

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
1-
package com.iexec.core.utils.version;
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;
218

319
import org.junit.jupiter.api.Assertions;
420
import org.junit.jupiter.api.BeforeEach;
@@ -25,18 +41,10 @@ public void preflight() {
2541
}
2642

2743
@ParameterizedTest
28-
@ValueSource(strings={"x.y.z", "x.y.z-rc"})
29-
void testNonSnapshotVersion(String version) {
44+
@ValueSource(strings={"x.y.z", "x.y.z-rc", "x.y.z-NEXT-SNAPSHOT"})
45+
void testVersions(String version) {
3046
Mockito.when(buildProperties.getVersion()).thenReturn(version);
3147
Assertions.assertEquals(version, versionService.getVersion());
32-
Assertions.assertFalse(versionService.isSnapshot());
33-
}
34-
35-
@Test
36-
void testSnapshotVersion() {
37-
Mockito.when(buildProperties.getVersion()).thenReturn("x.y.z-NEXT-SNAPSHOT");
38-
Assertions.assertEquals("x.y.z-NEXT-SNAPSHOT", versionService.getVersion());
39-
Assertions.assertTrue(versionService.isSnapshot());
4048
}
4149

4250
}

0 commit comments

Comments
 (0)