Skip to content

Commit 64aefcb

Browse files
committed
Polish 'Document the os info contribution'
See gh-45565
1 parent 752135d commit 64aefcb

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/info/InfoEndpointDocumentationTests.java

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@
3838
import org.springframework.restdocs.payload.JsonFieldType;
3939
import org.springframework.restdocs.payload.ResponseFieldsSnippet;
4040

41+
import static org.assertj.core.api.Assertions.assertThat;
4142
import static org.springframework.restdocs.payload.PayloadDocumentation.beneathPath;
4243
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
4344
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
44-
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
45-
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
4645

4746
/**
4847
* Tests for generating documentation describing the {@link InfoEndpoint}.
@@ -52,10 +51,9 @@
5251
class InfoEndpointDocumentationTests extends MockMvcEndpointDocumentationTests {
5352

5453
@Test
55-
void info() throws Exception {
56-
this.mockMvc.perform(get("/actuator/info"))
57-
.andExpect(status().isOk())
58-
.andDo(MockMvcRestDocumentation.document("info", gitInfo(), buildInfo(), osInfo(), processInfo()));
54+
void info() {
55+
assertThat(this.mvc.get().uri("/actuator/info")).hasStatusOk()
56+
.apply(MockMvcRestDocumentation.document("info", gitInfo(), buildInfo(), osInfo(), processInfo()));
5957
}
6058

6159
private ResponseFieldsSnippet gitInfo() {
@@ -80,13 +78,13 @@ private ResponseFieldsSnippet buildInfo() {
8078
}
8179

8280
private ResponseFieldsSnippet osInfo() {
83-
return responseFields(beneathPath("os"), osInfoField("name", "Name"), osInfoField("version", "Version"),
84-
osInfoField("arch", "Architecture"));
81+
return responseFields(beneathPath("os"), osInfoField("name", "Name of the operating system"),
82+
osInfoField("version", "Version of the operating system"),
83+
osInfoField("arch", "Architecture of the operating system"));
8584
}
8685

8786
private FieldDescriptor osInfoField(String field, String desc) {
88-
return fieldWithPath(field)
89-
.description("Operating System " + desc + " (as obtained from the 'os." + field + "' system property).")
87+
return fieldWithPath(field).description(desc + " (as obtained from the 'os." + field + "' system property).")
9088
.type(JsonFieldType.STRING)
9189
.optional();
9290
}
@@ -97,7 +95,20 @@ private ResponseFieldsSnippet processInfo() {
9795
fieldWithPath("parentPid").description("Parent Process ID (or -1).").type(JsonFieldType.NUMBER),
9896
fieldWithPath("owner").description("Process owner.").type(JsonFieldType.STRING),
9997
fieldWithPath("cpus").description("Number of CPUs available to the process.")
100-
.type(JsonFieldType.NUMBER));
98+
.type(JsonFieldType.NUMBER),
99+
fieldWithPath("memory").description("Memory information."),
100+
fieldWithPath("memory.heap").description("Heap memory."),
101+
fieldWithPath("memory.heap.init").description("The number of bytes initially requested by the JVM."),
102+
fieldWithPath("memory.heap.used").description("The number of bytes currently being used."),
103+
fieldWithPath("memory.heap.committed").description("The number of bytes committed for JVM use."),
104+
fieldWithPath("memory.heap.max")
105+
.description("The maximum number of bytes that can be used by the JVM (or -1)."),
106+
fieldWithPath("memory.nonHeap").description("Non-heap memory."),
107+
fieldWithPath("memory.nonHeap.init").description("The number of bytes initially requested by the JVM."),
108+
fieldWithPath("memory.nonHeap.used").description("The number of bytes currently being used."),
109+
fieldWithPath("memory.nonHeap.committed").description("The number of bytes committed for JVM use."),
110+
fieldWithPath("memory.nonHeap.max")
111+
.description("The maximum number of bytes that can be used by the JVM (or -1)."));
101112
}
102113

103114
@Configuration(proxyBeanMethods = false)

0 commit comments

Comments
 (0)