### Question:
SystemService { public void replaceAnchor(byte[] anchorBytes) throws InvalidAnchorInstanceException, AnchorUploadException, MalformedAnchorException, ConfigurationDownloadException, ConfigurationVerifier.ConfigurationVerificationException { uploadAnchor(anchorBytes, true); } @Autowired  SystemService(GlobalConfService globalConfService, ServerConfService serverConfService,
            AnchorRepository anchorRepository, ConfigurationVerifier configurationVerifier,
            CurrentSecurityServerId currentSecurityServerId,
            AuditDataHelper auditDataHelper); List<TspType> getConfiguredTimestampingServices(); void addConfiguredTimestampingService(TspType tspTypeToAdd); void deleteConfiguredTimestampingService(TspType tspTypeToDelete); byte[] generateInternalCsr(String distinguishedName); AnchorFile getAnchorFile(); AnchorFile getAnchorFileFromBytes(byte[] anchorBytes, boolean shouldVerifyAnchorInstance); void uploadInitialAnchor(byte[] anchorBytes); void replaceAnchor(byte[] anchorBytes); boolean isAnchorImported(); byte[] readAnchorFile(); String getAnchorFilenameForDownload();  }### Answer:
@Test public void replaceAnchor() throws Exception { byte[] anchorBytes = FileUtils.readFileToByteArray(ANCHOR_FILE); try { systemService.replaceAnchor(anchorBytes); } catch (Exception e) { fail("Should not fail"); } }
@Test public void replaceAnchorFailVerification() throws Exception { doThrow(new ConfigurationVerifier.ConfigurationVerificationException(MISSING_PRIVATE_PARAMS)) .when(configurationVerifier).verifyInternalConfiguration(any()); byte[] anchorBytes = FileUtils.readFileToByteArray(ANCHOR_FILE); try { systemService.replaceAnchor(anchorBytes); fail("Should have failed"); } catch (Exception e) { assertErrorWithoutMetadata(MISSING_PRIVATE_PARAMS, (ConfigurationVerifier.ConfigurationVerificationException) e); } }
@Test(expected = SystemService.MalformedAnchorException.class) public void replaceAnchorWithBadData() throws Exception { byte[] anchorBytes = new byte[8]; systemService.replaceAnchor(anchorBytes); }