forked from eclipse-jkube/jkube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MicroprofileHealthUtilTest.java
116 lines (91 loc) · 3.45 KB
/
MicroprofileHealthUtilTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**
* Copyright (c) 2019 Red Hat, Inc.
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at:
*
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
*/
package org.eclipse.jkube.kit.common.util;
import org.eclipse.jkube.kit.common.Dependency;
import org.eclipse.jkube.kit.common.JavaProject;
import org.junit.jupiter.api.Test;
import java.util.Collections;
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
class MicroprofileHealthUtilTest {
@Test
void hasMicroProfileHealthDependency_withMicroProfileInInvalidGroup_shouldReturnTrue() {
// Given
JavaProject javaProject = createNewJavaProjectDependency("org.wildfly.swarm", "microprofile", "2018.5.0");
// When
boolean result = MicroprofileHealthUtil.hasMicroProfileHealthDependency(javaProject);
// Then
assertThat(result).isFalse();
}
@Test
void hasMicroProfileDependency_withMicroProfile_shouldReturnTrue() {
// Given
JavaProject javaProject = createNewJavaProjectDependency("org.eclipse.microprofile", "microprofile", "5.0");
// When
boolean result = MicroprofileHealthUtil.hasMicroProfileDependency(javaProject);
// Then
assertThat(result).isTrue();
}
@Test
void hasMicroProfileHealthDependency_withMicroProfileHealth_shouldReturnTrue() {
// Given
JavaProject javaProject = createNewJavaProjectDependency("org.eclipse.microprofile.health", "microprofile-health-api", "5.0");
// When
boolean result = MicroprofileHealthUtil.hasMicroProfileHealthDependency(javaProject);
// Then
assertThat(result).isTrue();
}
@Test
void isStartupEndpointSupported_withNoDependency_shouldReturnFalse() {
// Given
JavaProject javaProject = JavaProject.builder().build();
// When
boolean result = MicroprofileHealthUtil.isStartupEndpointSupported(javaProject);
// Then
assertThat(result).isFalse();
}
@Test
void isStartupEndpointSupported_withMicroprofileBefore3_1_shouldReturnFalse() {
// Given
JavaProject javaProject = createNewJavaProjectDependency("org.eclipse.microprofile", "microprofile", "2.2");
// When
boolean result = MicroprofileHealthUtil.isStartupEndpointSupported(javaProject);
// Then
assertThat(result).isFalse();
}
@Test
void isStartupEndpointSupported_withMicroprofileAfter3_1_shouldReturnTrue() {
// Given
JavaProject javaProject = createNewJavaProjectDependency("org.eclipse.microprofile", "microprofile", "5.0");
// When
boolean result = MicroprofileHealthUtil.isStartupEndpointSupported(javaProject);
// Then
assertThat(result).isTrue();
}
@Test
void isStartupEndpointSupported_withMicroprofileHealthAfter3_1_shouldReturnTrue() {
// Given
JavaProject javaProject = createNewJavaProjectDependency("org.eclipse.microprofile.health", "microprofile-health-api", "5.0");
// When
boolean result = MicroprofileHealthUtil.isStartupEndpointSupported(javaProject);
// Then
assertThat(result).isTrue();
}
private JavaProject createNewJavaProjectDependency(String groupId, String artifactId, String version) {
return JavaProject.builder().dependenciesWithTransitive(Collections.singletonList(Dependency.builder()
.groupId(groupId)
.artifactId(artifactId)
.version(version)
.build())).build();
}
}