### Question:
StigmaExtractingFilter extends MetadataFilter { @Override protected void apply(final HttpServletRequest request) { final RawStigmaToken rawStigmaToken = stigmaCookieService.readStigmaToken(request); final StigmaDetails stigmaDetails = stigmaService.findStigmaDetails(rawStigmaToken); if (stigmaDetails != null) { request.setAttribute(STIGMA_METADATA_ATTRIBUTE, stigmaDetails); } } StigmaExtractingFilter(final StigmaCookieService stigmaCookieService, final StigmaService stigmaService);   }### Answer:
@Test void should_write_stigma_details_as_attribute() { given(stigmaCookieService.readStigmaToken(request)).willReturn(STIGMA_TOKEN); given(stigmaService.findStigmaDetails(STIGMA_TOKEN)).willReturn(STIGMA_DETAILS); filter.apply(request); assertThat(request.getAttribute(StigmaConstants.STIGMA_METADATA_ATTRIBUTE)).isEqualTo(STIGMA_DETAILS); }
@Test void should_not_write_stigma_details_attribute_when_stigma_not_available() { given(stigmaCookieService.readStigmaToken(request)).willReturn(STIGMA_TOKEN); given(stigmaService.findStigmaDetails(STIGMA_TOKEN)).willReturn(null); filter.apply(request); assertThat(request.getAttribute(StigmaConstants.STIGMA_METADATA_ATTRIBUTE)).isNull(); }