// Path: src/main/java/org/mockenize/model/MockBean.java
// @Data
// public class MockBean implements Cacheable {
// 
// 	private static final String UNDERLINE = "_";
// 
// 	private static final String SLASH = "/";
// 
// 	@NotNull
// 	private String key;
// 
// 	@NotNull
// 	private String path;
// 
// 	@NotNull
// 	private String method;
// 
// 	private Map<String, String> headers = Collections.emptyMap();
// 
// 	private JsonNode body;
// 
// 	@NotNull
// 	private Integer status = 200;
// 
// 	private int timeout = 0;
// 
// 	private int minTimeout = 0;
// 
// 	private int maxTimeout = 0;
// 
// 	private String scriptName;
// 
// 	@Override
// 	public String getKey() {
// 		return method.concat(path.replaceAll(SLASH, UNDERLINE));
// 	}
// 
// 	public void setPath(String path) {
// 		if (path != null && !path.startsWith(SLASH)) {
// 			this.path = SLASH + path;
// 		} else {
// 			this.path = path;
// 		}
// 	}
// 
// }
// 
// Path: src/main/java/org/mockenize/model/MultipleMockBean.java
// @Data
// @EqualsAndHashCode(callSuper = true)
// public class MultipleMockBean extends MockBean {
// 
// 	private List<MockBean> values = Collections.emptyList();
// 
// 	private boolean random;
// 
// 	private int lastIndexResponse = -1;
// 
// 	public int nextIndex() {
// 		if (++lastIndexResponse >= values.size()) {
// 			lastIndexResponse = 0;
// 		}
// 		return lastIndexResponse;
// 	}
// 
// 	public List<MockBean> getValues() {
// 		if (!values.isEmpty()) {
// 			for (MockBean mockBean : values) {
// 				mockBean.setMethod(getMethod());
// 				mockBean.setPath(getPath());
// 			}
// 		}
// 		return this.values;
// 	}
// }
// 
// Path: src/main/java/org/mockenize/model/ScriptBean.java
// @Data
// public class ScriptBean implements Serializable, Cacheable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	private String name;
// 
// 	private String value;
// 
// 	public ScriptBean(String name, String value) {
// 		this.name = name;
// 		this.value = value;
// 	}
// 
// 	@Override
// 	public String getKey() {
// 		return this.name;
// 	}
// }
// 
// Path: src/main/java/org/mockenize/repository/MockRepository.java
// @Repository
// public class MockRepository extends AbstractRepository<MockBean> {
// 
// 	public static final String MAP_KEY = "mocks";
// 
// 	@Autowired
// 	public MockRepository(HazelcastInstance hazelcastInstance) {
// 		super(hazelcastInstance, MAP_KEY);
// 	}
// 
// 	public MockBean findByMethodAndPath(String method, String path) {
// 		Collection<MockBean> values = map.values(new PathPredicate(method, path));
// 		Iterator<MockBean> iterator = values.iterator();
// 		return iterator.hasNext() ? iterator.next() : null;
// 	}
// 
// }


import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
import org.mockenize.model.MockBean;
import org.mockenize.model.MultipleMockBean;
import org.mockenize.model.ScriptBean;
import org.mockenize.repository.MockRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.base.Strings;
package org.mockenize.service;





@Service
public class MockService implements ResponseService {
	
	private static final Logger LOGGER = LoggerFactory.getLogger(MockService.class);

	private static final int FIRST = 0;

	@Autowired
	private MockRepository mockRepository;

	@Autowired
	private ScriptService scriptService;

	private Random random = new Random();

	public MockBean getByKey(String key) {
		return mockRepository.findByKey(key);
	}

	public MockBean getByMethodAndPath(String method, String path) {
		MockBean mockBean = mockRepository.findByMethodAndPath(method, path);

		if (mockBean instanceof MultipleMockBean) {
			MultipleMockBean multipleMockBean = (MultipleMockBean) mockBean;
// Path: src/main/java/org/mockenize/model/MockBean.java
// @Data
// public class MockBean implements Cacheable {
// 
// 	private static final String UNDERLINE = "_";
// 
// 	private static final String SLASH = "/";
// 
// 	@NotNull
// 	private String key;
// 
// 	@NotNull
// 	private String path;
// 
// 	@NotNull
// 	private String method;
// 
// 	private Map<String, String> headers = Collections.emptyMap();
// 
// 	private JsonNode body;
// 
// 	@NotNull
// 	private Integer status = 200;
// 
// 	private int timeout = 0;
// 
// 	private int minTimeout = 0;
// 
// 	private int maxTimeout = 0;
// 
// 	private String scriptName;
// 
// 	@Override
// 	public String getKey() {
// 		return method.concat(path.replaceAll(SLASH, UNDERLINE));
// 	}
// 
// 	public void setPath(String path) {
// 		if (path != null && !path.startsWith(SLASH)) {
// 			this.path = SLASH + path;
// 		} else {
// 			this.path = path;
// 		}
// 	}
// 
// }
// 
// Path: src/main/java/org/mockenize/model/MultipleMockBean.java
// @Data
// @EqualsAndHashCode(callSuper = true)
// public class MultipleMockBean extends MockBean {
// 
// 	private List<MockBean> values = Collections.emptyList();
// 
// 	private boolean random;
// 
// 	private int lastIndexResponse = -1;
// 
// 	public int nextIndex() {
// 		if (++lastIndexResponse >= values.size()) {
// 			lastIndexResponse = 0;
// 		}
// 		return lastIndexResponse;
// 	}
// 
// 	public List<MockBean> getValues() {
// 		if (!values.isEmpty()) {
// 			for (MockBean mockBean : values) {
// 				mockBean.setMethod(getMethod());
// 				mockBean.setPath(getPath());
// 			}
// 		}
// 		return this.values;
// 	}
// }
// 
// Path: src/main/java/org/mockenize/model/ScriptBean.java
// @Data
// public class ScriptBean implements Serializable, Cacheable {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	private String name;
// 
// 	private String value;
// 
// 	public ScriptBean(String name, String value) {
// 		this.name = name;
// 		this.value = value;
// 	}
// 
// 	@Override
// 	public String getKey() {
// 		return this.name;
// 	}
// }
// 
// Path: src/main/java/org/mockenize/repository/MockRepository.java
// @Repository
// public class MockRepository extends AbstractRepository<MockBean> {
// 
// 	public static final String MAP_KEY = "mocks";
// 
// 	@Autowired
// 	public MockRepository(HazelcastInstance hazelcastInstance) {
// 		super(hazelcastInstance, MAP_KEY);
// 	}
// 
// 	public MockBean findByMethodAndPath(String method, String path) {
// 		Collection<MockBean> values = map.values(new PathPredicate(method, path));
// 		Iterator<MockBean> iterator = values.iterator();
// 		return iterator.hasNext() ? iterator.next() : null;
// 	}
// 
// }


// Path: src/main/java/org/mockenize/service/MockService.java
import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
import org.mockenize.model.MockBean;
import org.mockenize.model.MultipleMockBean;
import org.mockenize.model.ScriptBean;
import org.mockenize.repository.MockRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.base.Strings;

package org.mockenize.service;





@Service
public class MockService implements ResponseService {
	
	private static final Logger LOGGER = LoggerFactory.getLogger(MockService.class);

	private static final int FIRST = 0;

	@Autowired
	private MockRepository mockRepository;

	@Autowired
	private ScriptService scriptService;

	private Random random = new Random();

	public MockBean getByKey(String key) {
		return mockRepository.findByKey(key);
	}

	public MockBean getByMethodAndPath(String method, String path) {
		MockBean mockBean = mockRepository.findByMethodAndPath(method, path);

		if (mockBean instanceof MultipleMockBean) {
			MultipleMockBean multipleMockBean = (MultipleMockBean) mockBean;
			int size = multipleMockBean.getValues().size();