### Question:
KeyStoreOperations implements IKeyStoreOperations { @Override public <T> List<T> getDTOListAndDeleteIt(String userID, String useCase, Class<T> forClass, JsonReader<T> jsonReader) { String collectionKey = new KeySet(forClass, userID, useCase).createKeyCollectionKey(); final String keysetAsJson = localStorage.getItem(collectionKey); localStorage.removeItem(collectionKey); if (keysetAsJson != null) { final KeySet keySet = keyset_reader.read(keysetAsJson); return getDTOListAndDeleteIt(keySet, jsonReader); } else { return new ArrayList<T>(); } } KeyStoreOperations(IStorage localStorage, JsonReader<KeySet> keyset_reader,
							  JsonWriter<KeySet> keyset_writer); @Override List<T> getDTOList(String userID, String useCase, Class<T> forClass, JsonReader<T> jsonReader); @Override List<T> getDTOListAndDeleteIt(String userID, String useCase, Class<T> forClass, JsonReader<T> jsonReader); @Override List<T> getDTOList(KeyCollection keyCollection, JsonReader<T> jsonReader); @Override void removeDTOList(KeyCollection keyCollection); @Override List<T> getDTOListAndDeleteIt(KeyCollection keyCollection, JsonReader<T> jsonReader); @Override void updateDTO(T toUpdate, KeySet keySet, String oid, JsonWriter<T> jsonWriter); @Override void deleteDTO(KeySet keySet, String oidToDelete, JsonWriter<T> jsonWriter); @Override void updateOrCreateDTOList(List<T> toUpdate, KeySet keySet, JsonWriter<T> jsonWriter, List<Long> oids); @Override KeySet loadKeysetFormStoreOrCreateEmptyOne(Class<?> forClass, String uuid, String useCase); @Override void createList(List<T> toUpdate, KeySet keySet, JsonWriter<T> jsonWriter);  }### Answer:
@Test public void testGetDTOListAndDeleteIt() throws Exception { KeyStoreOperations ops = new KeyStoreOperations(storage, keySetJsonReader, keySetJsonWriter); List<TestDto> list = new ArrayList<TestDto>(); list.add(new TestDto(1, "Test1")); list.add(new TestDto(2, "Test2")); list.add(new TestDto(3, "Test3")); KeySet keySet = new KeySet(TestDto.class, "user", "UC_LIST"); ops.createList(list, keySet, testDtoJsonWriter); assertEquals(4, storage.getLength()); final List<TestDto> dtoListFromStore = ops.getDTOListAndDeleteIt(keySet, testDtoJsonReader); assertEquals(0, storage.getLength()); assertEquals(3, dtoListFromStore.size()); assertTrue(dtoListFromStore.contains(new TestDto(1, "Test1"))); assertTrue(dtoListFromStore.contains(new TestDto(2, "Test2"))); assertTrue(dtoListFromStore.contains(new TestDto(3, "Test3"))); }