use of org.codenergic.theskeleton.core.web.UserArgumentResolver in project theskeleton by codenergic.
the class UserPostRestControllerTest method init.
@Before
public void init() {
mockMvc = MockMvcBuilders.standaloneSetup(new UserPostRestController(postService)).setCustomArgumentResolvers(new UserArgumentResolver(username -> new UserEntity().setUsername(username)), new AuthenticationPrincipalArgumentResolver(), new PageableHandlerMethodArgumentResolver()).apply(documentationConfiguration(restDocumentation)).build();
Authentication authentication = new TestingAuthenticationToken(new UserEntity().setId(USER_ID).setUsername(USERNAME), "1234");
SecurityContextHolder.getContext().setAuthentication(authentication);
}
use of org.codenergic.theskeleton.core.web.UserArgumentResolver in project theskeleton by codenergic.
the class UserFollowerRestControllerTest method init.
@Before
public void init() {
when(userDetailsService.loadUserByUsername(USERNAME)).thenReturn(new UserEntity().setId(USER_ID).setUsername(USERNAME));
mockMvc = MockMvcBuilders.standaloneSetup(new UserFollowerRestController(userFollowerService)).setCustomArgumentResolvers(new UserArgumentResolver(userDetailsService), new AuthenticationPrincipalArgumentResolver(), new PageableHandlerMethodArgumentResolver()).apply(documentationConfiguration(restDocumentation)).build();
Authentication authentication = new UsernamePasswordAuthenticationToken(new UserEntity().setId(USER_ID).setUsername(USERNAME), "1234");
SecurityContextHolder.getContext().setAuthentication(authentication);
}
use of org.codenergic.theskeleton.core.web.UserArgumentResolver in project theskeleton by codenergic.
the class PostRestControllerTest method init.
@Before
public void init() {
when(userDetailsService.loadUserByUsername(USERNAME)).thenReturn(new UserEntity().setId(USER_ID).setUsername(USERNAME));
mockMvc = MockMvcBuilders.standaloneSetup(new PostRestController(postService, postReactionService)).setCustomArgumentResolvers(new UserArgumentResolver(userDetailsService), new AuthenticationPrincipalArgumentResolver(), new PageableHandlerMethodArgumentResolver()).apply(documentationConfiguration(restDocumentation)).build();
Authentication authentication = new UsernamePasswordAuthenticationToken(new UserEntity().setId(USER_ID).setUsername(USERNAME), "1234");
SecurityContextHolder.getContext().setAuthentication(authentication);
PostServiceTest.DUMMY_POST.setCreatedDate(new Date());
PostServiceTest.DUMMY_POST.setLastModifiedDate(new Date());
PostServiceTest.DUMMY_POST2.setCreatedDate(new Date());
PostServiceTest.DUMMY_POST2.setLastModifiedDate(new Date());
}
Aggregations