### Question:
OverAnnotatedService { @RolesAllowed("USER") public String sec1a() { return "@RolesAllowed(\"USER\")"; }  @PreFilter("filterObject.content.length() < 240 or hasRole('ADMIN')") @PostFilter("filterObject.author.name == authentication.name") List<ShortMessage> saveAndReturnAll(List<ShortMessage> posts); @RolesAllowed("USER") String sec1a(); @RolesAllowed("ROLE_USER") String sec1b(); @Secured("USER") String sec2a(); @Secured("ROLE_USER") String sec2b(); @PreAuthorize("hasRole('USER')") String sec3a(); @PreAuthorize("hasRole('ROLE_USER')") String sec3b(); @PreAuthorize("hasAuthority('USER')") String sec3c(); @PreAuthorize("hasAuthority('ROLE_USER')") String sec3d();  }### Answer:
@Test @WithMockUser public void getMessageWithMockUserCustomAuthorities() { overAnnotatedService.sec1a(); }
@Test @WithAnonymousUser public void getMessage() { try { overAnnotatedService.sec1a(); fail(); } catch (AccessDeniedException e) { } }