use of io.gravitee.rest.api.idp.api.authentication.UserDetails in project gravitee-management-rest-api by gravitee-io.
the class RatingServiceTest method init.
@Before
public void init() {
final Authentication authentication = mock(Authentication.class);
when(authentication.getPrincipal()).thenReturn(new UserDetails(USER, "", emptyList()));
final SecurityContext securityContext = mock(SecurityContext.class);
when(securityContext.getAuthentication()).thenReturn(authentication);
SecurityContextHolder.setContext(securityContext);
when(rating.getId()).thenReturn(RATING_ID);
when(rating.getReferenceId()).thenReturn(API_ID);
when(rating.getTitle()).thenReturn(TITLE);
when(rating.getComment()).thenReturn(COMMENT);
when(rating.getRate()).thenReturn(RATE);
when(rating.getUser()).thenReturn(USER);
when(userService.findById(USER)).thenReturn(user);
when(user.getId()).thenReturn(USER);
when(mockParameterService.findAsBoolean(Key.PORTAL_RATING_ENABLED, ParameterReferenceType.ENVIRONMENT)).thenReturn(Boolean.TRUE);
}
Aggregations