Document response structure for retrieving a logger group

Closes gh-17909
This commit is contained in:
Andy Wilkinson 2019-08-19 14:17:50 +01:00
parent 3bc65f4fec
commit f916e1a1ce
2 changed files with 18 additions and 3 deletions

View File

@ -72,6 +72,17 @@ include::{snippets}loggers/group/http-response.adoc[]
[[loggers-group-response-structure]]
=== Response Structure
The response contains details of the requested group. The following table describes the
structure of the response:
[cols="3,1,3"]
include::{snippets}loggers/group/response-fields.adoc[]
[[loggers-setting-level]]
== Setting a Log Level

View File

@ -37,6 +37,7 @@ import org.springframework.context.annotation.Import;
import org.springframework.http.MediaType;
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
import org.springframework.restdocs.payload.FieldDescriptor;
import org.springframework.restdocs.payload.JsonFieldType;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.verify;
@ -62,9 +63,9 @@ class LoggersEndpointDocumentationTests extends MockMvcEndpointDocumentationTest
static {
groupLevelFields = Arrays.asList(
fieldWithPath("configuredLevel").description("Configured level of the logger group")
.type(LogLevel.class).optional(),
fieldWithPath("members").description("Loggers that are part of this group").optional());
fieldWithPath("configuredLevel").description("Configured level of the logger group, if any.")
.type(JsonFieldType.STRING).optional(),
fieldWithPath("members").description("Loggers that are part of this group"));
}
@MockBean
@ -98,8 +99,11 @@ class LoggersEndpointDocumentationTests extends MockMvcEndpointDocumentationTest
@Test
void loggerGroups() throws Exception {
this.loggerGroups.get("test").configureLogLevel(LogLevel.INFO, (member, level) -> {
});
this.mockMvc.perform(get("/actuator/loggers/test")).andExpect(status().isOk())
.andDo(MockMvcRestDocumentation.document("loggers/group", responseFields(groupLevelFields)));
resetLogger();
}
@Test