package de.taimos.dao.mongo;

/*
 * #%L
 * Spring DAO Mongo
 * %%
 * Copyright (C) 2013 Taimos GmbH
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;

import org.bson.types.ObjectId;

import de.taimos.dao.AEntity;
import de.taimos.dao.ICrudDAO;

public abstract class AbstractMongoMockDAO<T extends AEntity> implements ICrudDAO<T> {
	
	protected ConcurrentHashMap<String, T> objects = new ConcurrentHashMap<>();
	
	
	@Override
	public List<T> findList() {
		System.out.println("Find by mock");
		List<T> res = new ArrayList<>();
		for (T mp : this.objects.values()) {
			res.add(mp);
		}
		return res;
	}
	
	@Override
	public T findById(String id) {
		return this.objects.get(id);
	}
	
	@Override
	public T save(T object) {
		if (object.getId() == null) {
			object.setId(ObjectId.get().toString());
		}
		this.objects.put(object.getId(), object);
		this.customSave(object);
		return object;
	}
	
	@SuppressWarnings("unused")
	protected void customSave(T object) {
		//
	}
	
	@SuppressWarnings("unused")
	protected void customDelete(String id) {
		//
	}
	
	@Override
	public void delete(T object) {
		this.delete(object.getId());
	}
	
	@Override
	public void delete(String id) {
		this.customDelete(null);
		this.objects.remove(id);
	}
}
@@ -1421,16 +1421,43 @@
 ));%0A%09%09%7D%0A
+%09%09this.customSave(object);%0A
 %09%09this.o
@@ -1496,35 +1496,8 @@
 t);%0A
-%09%09this.customSave(object);%0A
 %09%09re
@@ -1816,20 +1816,18 @@
 mDelete(
-null
+id
 );%0A%09%09thi
@@ -1852,8 +1852,9 @@
 d);%0A%09%7D%0A%7D
+%0A

Update AbstractMongoMockDAO.java