### Question:
Indexer { protected void handleFailure(String reason, Boolean disablePermanently, IndexerApiAccessType accessType, Long responseTime, IndexerAccessResult accessResult) { if (disablePermanently) { getLogger().warn("Because an unrecoverable error occurred {} will be permanently disabled until reenabled by the user", indexer.getName()); getConfig().setState(IndexerConfig.State.DISABLED_SYSTEM); } else if (!configProvider.getBaseConfig().getSearching().isIgnoreTemporarilyDisabled()) { getConfig().setState(IndexerConfig.State.DISABLED_SYSTEM_TEMPORARY); getConfig().setDisabledLevel(getConfig().getDisabledLevel() + 1); long minutesToAdd = DISABLE_PERIODS.get(Math.min(DISABLE_PERIODS.size() - 1, getConfig().getDisabledLevel())); Instant disabledUntil = Instant.now().plus(minutesToAdd, ChronoUnit.MINUTES); getConfig().setDisabledUntil(disabledUntil.toEpochMilli()); getLogger().warn("Because an error occurred {} will be temporarily disabled until {}. This is error number {} in a row", indexer.getName(), disabledUntil, getConfig().getDisabledLevel()); } getConfig().setLastError(reason); configProvider.getBaseConfig().save(false); saveApiAccess(accessType, responseTime, accessResult, false); }  void initialize(IndexerConfig config, IndexerEntity indexer); @EventListener void handleNewConfig(ConfigChangedEvent configChangedEvent); IndexerSearchResult search(SearchRequest searchRequest, int offset, Integer limit); abstract NfoResult getNfo(String guid); String getName(); IndexerConfig getConfig(); IndexerEntity getIndexerEntity(); String cleanUpTitle(String title); Optional<Instant> tryParseDate(String dateString); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }### Answer:
@Test public void handleFailure() throws Exception { indexerConfig.setState(IndexerConfig.State.ENABLED); indexerConfig.setDisabledLevel(0); indexerConfig.setDisabledUntil(null); testee.handleFailure("reason", false, null, null, null); assertThat(indexerConfig.getState(), is(IndexerConfig.State.DISABLED_SYSTEM_TEMPORARY)); assertThat(indexerConfig.getDisabledLevel(), is(1)); long disabledPeriod = Math.abs(Instant.ofEpochMilli(indexerConfig.getDisabledUntil()).getEpochSecond() - Instant.now().getEpochSecond()); long delta = Math.abs(Indexer.DISABLE_PERIODS.get(1) * 60 - disabledPeriod); org.assertj.core.api.Assertions.assertThat(delta).isLessThan(5); indexerConfig.setState(IndexerConfig.State.ENABLED); indexerConfig.setDisabledLevel(0); indexerConfig.setDisabledUntil(null); testee.handleFailure("reason", true, null, null, null); assertThat(indexerConfig.getState(), is(IndexerConfig.State.DISABLED_SYSTEM)); }