### Question:
OfflineConfigurationCacheRepo { public boolean persistMappingRulesConfig(final String serviceId, final String mappingRulesConfig) { return persist(ConfigType.MAPPING_RULES, new String[]{serviceId}, mappingRulesConfig, "json"); } OfflineConfigurationCacheRepo(final String apimAdapterCacheLocation); static OfflineConfigurationCacheRepo disabled(); boolean persistMetricConfig(final String serviceId, final String metricConfig); boolean persistProxyConfig(final String serviceId, final String proxyConfig); boolean persistPlanConfig(final String serviceId, final String clientId, final String planConfig); boolean persistMappingRulesConfig(final String serviceId, final String mappingRulesConfig); boolean persistOidc(String tokenIssuerUrl, String oidc); boolean persistJwks(String jwksUrl, String jwks); String findMetricConfig(final String serviceId); String findProxyConfig(final String serviceId); String findPlanConfig(final String serviceId, final String clientId); String findMappingRulesConfig(final String serviceId); String findOidc(String tokenIssuerUrl); String findJwks(String jwksUrl); boolean deletePlanConfig(final String serviceId, final String clientId); OfflineConfigurationState getState();  }### Answer:
@Test public void testPersistWithRotation() { OfflineConfigurationCacheRepo repo = createRepo(); final String serviceId1 = "serviceId1"; final List<String> writtenConfigs = new ArrayList<>(); int filesWritten = 10; for (int i = 0; i < filesWritten; i++) { final String config = createDummyConfig(); if (writtenConfigs.contains(config)) { fail("Config has to change in every loop. Only this way it is possible to verify newest config was loaded"); } writtenConfigs.add(config); repo.persistMappingRulesConfig(serviceId1, config); } final Path configDirPath = dir.resolve(OfflineConfigurationCacheRepo.CONFIG_DIR_NAME).resolve(ConfigType.MAPPING_RULES.getId()); final String[] files = configDirPath.toFile().list(); assertNotNull(files); assertEquals(NUMBER_ROTATING_FILES, files.length); final String[] configsFromFiles = Arrays.stream(files).map(filename -> { try { return new String(Files.readAllBytes(configDirPath.resolve(filename)), StandardCharsets.UTF_8); } catch (IOException e) { return ""; } }).toArray(String[]::new); final List<String> lastWrittenConfigs = writtenConfigs.subList(NUMBER_ROTATING_FILES, writtenConfigs.size()); assertEquals(filesWritten - NUMBER_ROTATING_FILES, lastWrittenConfigs.size()); assertTrue(lastWrittenConfigs.containsAll(Arrays.asList(configsFromFiles))); }