### Question:
SystemApiController implements SystemApi { @Override @PreAuthorize("hasAuthority('VIEW_PROXY_INTERNAL_CERT')") public ResponseEntity<CertificateDetails> getSystemCertificate() { X509Certificate x509Certificate = internalTlsCertificateService.getInternalTlsCertificate(); CertificateDetails certificate = certificateDetailsConverter.convert(x509Certificate); return new ResponseEntity<>(certificate, HttpStatus.OK); } @Autowired  SystemApiController(NativeWebRequest request); @Override Optional<NativeWebRequest> getRequest(); @Override @PreAuthorize("hasAuthority('EXPORT_PROXY_INTERNAL_CERT')") ResponseEntity<Resource> downloadSystemCertificate(); @Override @PreAuthorize("hasAuthority('VIEW_PROXY_INTERNAL_CERT')") ResponseEntity<CertificateDetails> getSystemCertificate();  }### Answer:
@Test @WithMockUser(authorities = { "VIEW_PROXY_INTERNAL_CERT" }) public void getSystemCertificate() throws Exception { X509Certificate x509Certificate = null; try (InputStream stream = getClass().getClassLoader().getResourceAsStream("internal.crt")) { x509Certificate = CryptoUtils.readCertificate(stream); } given(mockRepository.getInternalTlsCertificate()).willReturn(x509Certificate); CertificateDetails certificate = systemApiController.getSystemCertificate().getBody(); assertEquals("xroad2-lxd-ss1", certificate.getIssuerCommonName()); }