use of com.mercedesbenz.sechub.domain.administration.user.UserDetailInformation in project sechub by mercedes-benz.
the class UserAdministrationRestControllerRestDocTest method restdoc_show_user_details.
@Test
@UseCaseRestDoc(useCase = UseCaseAdminShowsUserDetails.class)
public void restdoc_show_user_details() throws Exception {
/* prepare */
String apiEndpoint = https(PORT_USED).buildAdminShowsUserDetailsUrl(USER_ID.pathElement());
Class<? extends Annotation> useCase = UseCaseAdminShowsUserDetails.class;
User user = mock(User.class);
when(user.getName()).thenReturn("user1");
when(user.getEmailAdress()).thenReturn("user1@example.org");
Set<Project> projects = new LinkedHashSet<>();
Project project1 = mock(Project.class);
when(project1.getId()).thenReturn("project1");
projects.add(project1);
when(user.getProjects()).thenReturn(projects);
UserDetailInformation info = new UserDetailInformation(user);
when(userDetailService.fetchDetails("user1")).thenReturn(info);
/* execute + test @formatter:off */
this.mockMvc.perform(get(apiEndpoint, "user1")).andExpect(status().isOk()).andDo(defineRestService().with().useCaseData(useCase).tag(RestDocFactory.extractTag(apiEndpoint)).responseSchema(OpenApiSchema.USER_DETAILS.getSchema()).and().document(pathParameters(parameterWithName(USER_ID.paramName()).description("The user id of user to show details for")), responseFields(fieldWithPath(UserDetailInformation.PROPERTY_USERNAME).description("The name of the user"), fieldWithPath(UserDetailInformation.PROPERTY_EMAIL).description("The mail adress of the user"), fieldWithPath(UserDetailInformation.PROPERTY_SUPERADMIN).description("True, when this user is a super administrator"), fieldWithPath(UserDetailInformation.PROPERTY_PROJECTS).description("The projects the user has access to"), fieldWithPath(UserDetailInformation.PROPERTY_OWNED_PROJECTS).description("The projects the user is owner of"))));
/* @formatter:on */
}
Aggregations