### Question:
AdvertisementController { @GetMapping("/confidentiality/{confidentialityLevel}") @PreAuthorize("hasAuthority('Display') and @webSecurity.hasAttributeValue('confidentiality_level', #confidentialityLevel)") public ResponseEntity<AdvertisementListDto> readByConfidentiality( @PathVariable("confidentialityLevel") String confidentialityLevel) { Page<Advertisement> page = adsRepo .findAllByConfidentialityLevel(ConfidentialityLevel.valueOf(confidentialityLevel), PageRequest.of(FIRST_PAGE_ID, DEFAULT_PAGE_SIZE)); return new ResponseEntity<>(new AdvertisementListDto(page.getContent()), PageHeaderBuilder.createLinkHeader(page, PATH_PAGES), HttpStatus.OK); } AdvertisementController(AdvertisementRepository adsRepo); @PostMapping ResponseEntity<AdvertisementDto> create(@RequestBody @Valid AdvertisementDto advertisement,
            UriComponentsBuilder uriComponentsBuilder); @GetMapping ResponseEntity<AdvertisementListDto> readAll(@AuthenticationPrincipal Token token); @GetMapping("/confidentiality/{confidentialityLevel}") @PreAuthorize("hasAuthority('Display') and @webSecurity.hasAttributeValue('confidentiality_level', #confidentialityLevel)") ResponseEntity<AdvertisementListDto> readByConfidentiality(
            @PathVariable("confidentialityLevel") String confidentialityLevel); @GetMapping("/pages/{pageId}") ResponseEntity<AdvertisementListDto> readPage(@PathVariable("pageId") int pageId); @GetMapping("/{id}") AdvertisementDto readById(@PathVariable("id") @Min(0) Long id); @PutMapping("/{id}") @PreAuthorize("@webSecurity.isCreatedBy(#id)") AdvertisementDto update(@RequestBody AdvertisementDto updatedAdvertisement, @PathVariable("id") Long id); @DeleteMapping("{id}") @ResponseStatus(NO_CONTENT) @PreAuthorize("hasAuthority('Update') and @webSecurity.isCreatedBy(#id)") void deleteById(@PathVariable("id") Long id); static final String PATH_PAGES; static final int FIRST_PAGE_ID; static final int DEFAULT_PAGE_SIZE; }### Answer:
@Test public void readByConfidentiality() throws Exception { mockMvc.perform(buildPostRequest(SOME_TITLE, ConfidentialityLevel.STRICTLY_CONFIDENTIAL) .with(bearerToken(jwt_advertiser))).andExpect(status().isCreated()); mockMvc.perform(buildPostRequest(SOME_TITLE, ConfidentialityLevel.CONFIDENTIAL) .with(bearerToken(jwt_advertiser))).andExpect(status().isCreated()); mockMvc.perform(buildPostRequest(SOME_TITLE, ConfidentialityLevel.INTERNAL) .with(bearerToken(jwt_advertiser))).andExpect(status().isCreated()); mockMvc.perform(buildPostRequest(SOME_TITLE, ConfidentialityLevel.PUBLIC) .with(bearerToken(jwt_advertiser))).andExpect(status().isCreated()); mockMvc.perform(get(AdvertisementController.PATH + "/confidentiality/" + ConfidentialityLevel.PUBLIC.name()) .with(bearerToken(jwt_adsViewer_public))) .andExpect(status().isOk()) .andExpect(content().contentType(APPLICATION_JSON_UTF8)) .andExpect(jsonPath("$.value.length()", is(1))) .andExpect(jsonPath("$.value[0].confidentialityLevel", is(ConfidentialityLevel.PUBLIC.name()))); mockMvc.perform(get(AdvertisementController.PATH + "/confidentiality/" + ConfidentialityLevel.INTERNAL.name()) .with(bearerToken(jwt_adsViewer_public))) .andExpect(status().isForbidden()); mockMvc.perform(get(AdvertisementController.PATH + "/confidentiality/" + ConfidentialityLevel.PUBLIC.name()) .with(bearerToken(jwt_advertiser))) .andExpect(status().isForbidden()); }