Action { protected List<String> getKeysOnMemoryMatchingDynamicKey(String providerKey, String dynamicKey) { List<String> keysMatchingDynamicKey = new ArrayList<>(); String composedProviderKeyAndDynamicKey = providerKey + PREFIX_DYNAMIC_KEY + dynamicKey; for (String composedKeyMemory : memory.keySet()) { final String keyPartProviderAndDynamicKeyMemory = composedKeyMemory.substring(0, composedKeyMemory.lastIndexOf(PREFIX_DYNAMIC_KEY_GROUP)); if (composedProviderKeyAndDynamicKey.equals(keyPartProviderAndDynamicKeyMemory)) { keysMatchingDynamicKey.add(composedKeyMemory); } } return keysMatchingDynamicKey; } Action(Memory memory, Persistence persistence);   }
@Test public void Check_Keys_Matching_Dynamic_Key() { List<String> keysMatchingDynamicKey1 = actionUT.getKeysOnMemoryMatchingDynamicKey(PROVIDER_KEY, DYNAMIC_KEY_1); assertThat(keysMatchingDynamicKey1.get(0), is(filter1Page1)); assertThat(keysMatchingDynamicKey1.get(1), is(filter1Page2)); assertThat(keysMatchingDynamicKey1.size(), is(2)); List<String> keysMatchingDynamicKey2 = actionUT.getKeysOnMemoryMatchingDynamicKey(PROVIDER_KEY, DYNAMIC_KEY_2); assertThat(keysMatchingDynamicKey2.get(0), is(filter2Page1)); assertThat(keysMatchingDynamicKey2.get(1), is(filter2Page2)); assertThat(keysMatchingDynamicKey2.size(), is(2)); }