// Path: moneta-core/src/main/java/org/moneta/config/MonetaEnvironment.java
// public class MonetaEnvironment extends BaseType {
// 	
// 	private static MonetaConfiguration configuration;
// 
// 	public static MonetaConfiguration getConfiguration() {
// 		return configuration;
// 	}
// 
// 	public static void setConfiguration(MonetaConfiguration configuration) {
// 		MonetaEnvironment.configuration = configuration;
// 	}
// 
// }
// 
// Path: moneta-core/src/main/java/org/moneta/types/search/CompositeCriteria.java
// public class CompositeCriteria extends BaseType implements Criteria {
// 	
// 	public static enum Operator {AND, OR};
// 	
// 	private Operator operator;
// 	private Criteria[] searchCriteria;
// 	
// 	public Operator getOperator() {
// 		return operator;
// 	}
// 	
// 	public void setOperator(Operator operator) {
// 		this.operator = operator;
// 	}
// 	
// 	public Criteria[] getSearchCriteria() {
// 		return searchCriteria;
// 	}
// 	
// 	public void setSearchCriteria(Criteria[] searchCriteria) {
// 		this.searchCriteria = searchCriteria;
// 	}
// 
// }
// 
// Path: moneta-core/src/main/java/org/moneta/types/search/Criteria.java
// public interface Criteria {
// 
// }
// 
// Path: moneta-core/src/main/java/org/moneta/types/search/FilterCriteria.java
// public class FilterCriteria extends BaseType implements Criteria {
// 	
// 	public static enum Operation {EQUAL, NOT_EQUAL, GREATER_THAN, LESS_THAN, IS_NULL, IS_NOT_NULL, LIKE};
// 	
// 	private String fieldName;
// 	private Operation operation;
// 	private Object value;
// 	
// 	public String getFieldName() {
// 		return fieldName;
// 	}
// 	
// 	public void setFieldName(String fieldName) {
// 		this.fieldName = fieldName;
// 	}
// 	
// 	public Operation getOperation() {
// 		return operation;
// 	}
// 	
// 	public void setOperation(Operation operation) {
// 		this.operation = operation;
// 	}
// 	
// 	public Object getValue() {
// 		return value;
// 	}
// 	
// 	public void setValue(Object value) {
// 		this.value = value;
// 	}
// 	
// 
// }
// 
// Path: moneta-core/src/main/java/org/moneta/types/search/SearchRequest.java
// public class SearchRequest extends BaseType {
// 	
// 	private String topic;
// 	private String[] fieldNames;
// 	private CompositeCriteria searchCriteria;
// 	private Long maxRows;
// 	private Long startRow;
// 	
// 	public String[] getFieldNames() {
// 		return fieldNames;
// 	}
// 	
// 	public void setFieldNames(String[] fieldNames) {
// 		this.fieldNames = fieldNames;
// 	}
// 	
// 	public CompositeCriteria getSearchCriteria() {
// 		return searchCriteria;
// 	}
// 	
// 	public void setSearchCriteria(CompositeCriteria searchCriteria) {
// 		this.searchCriteria = searchCriteria;
// 	}
// 
// 	public Long getMaxRows() {
// 		return maxRows;
// 	}
// 
// 	public void setMaxRows(Long maxRows) {
// 		this.maxRows = maxRows;
// 	}
// 
// 	public String getTopic() {
// 		return topic;
// 	}
// 
// 	public void setTopic(String topic) {
// 		this.topic = topic;
// 	}
// 
// 	public Long getStartRow() {
// 		return startRow;
// 	}
// 
// 	public void setStartRow(Long startRow) {
// 		this.startRow = startRow;
// 	}
// 
// 
// }


import java.util.Arrays;
import org.apache.commons.lang3.StringUtils;
import org.force66.mock.servletapi.MockRequest;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.moneta.config.MonetaEnvironment;
import org.moneta.types.search.CompositeCriteria;
import org.moneta.types.search.Criteria;
import org.moneta.types.search.FilterCriteria;
import org.moneta.types.search.SearchRequest;

	private void testCriteria(Criteria criteria, String fieldName, FilterCriteria.Operation operator, Object value) {
		Assert.assertTrue(criteria instanceof FilterCriteria);
		FilterCriteria filterCriteria = (FilterCriteria)criteria;
		
		Assert.assertTrue(fieldName.equals(filterCriteria.getFieldName()));
		Assert.assertTrue(operator.equals(filterCriteria.getOperation()));
		Assert.assertTrue(value.equals(filterCriteria.getValue()));
	}

	private void testException(String testMessage) {
		Throwable exceptionThrown=null;
		try {factory.deriveSearchRequest(request);}
		catch (Exception e) {
			exceptionThrown=e;
		}
		Assert.assertTrue(exceptionThrown != null);
		Assert.assertTrue(exceptionThrown.getMessage() != null);
		Assert.assertTrue(exceptionThrown.getMessage().contains(testMessage));
	}
	
	@Test
	public void testDeriveSearachNodes() throws Exception {
		request.setUri("/myapp", "/Environment/one/two/three");
		Assert.assertTrue(Arrays.deepEquals(factory.deriveSearchNodes(request), 
				StringUtils.split("/Environment/one/two/three", '/')));
		
		request.setUri("", "/moneta/Environment");
		Assert.assertTrue(Arrays.deepEquals(factory.deriveSearchNodes(request), 
				StringUtils.split("/moneta/Environment", '/')));
		

// Path: moneta-core/src/main/java/org/moneta/config/MonetaEnvironment.java
// public class MonetaEnvironment extends BaseType {
// 	
// 	private static MonetaConfiguration configuration;
// 
// 	public static MonetaConfiguration getConfiguration() {
// 		return configuration;
// 	}
// 
// 	public static void setConfiguration(MonetaConfiguration configuration) {
// 		MonetaEnvironment.configuration = configuration;
// 	}
// 
// }
// 
// Path: moneta-core/src/main/java/org/moneta/types/search/CompositeCriteria.java
// public class CompositeCriteria extends BaseType implements Criteria {
// 	
// 	public static enum Operator {AND, OR};
// 	
// 	private Operator operator;
// 	private Criteria[] searchCriteria;
// 	
// 	public Operator getOperator() {
// 		return operator;
// 	}
// 	
// 	public void setOperator(Operator operator) {
// 		this.operator = operator;
// 	}
// 	
// 	public Criteria[] getSearchCriteria() {
// 		return searchCriteria;
// 	}
// 	
// 	public void setSearchCriteria(Criteria[] searchCriteria) {
// 		this.searchCriteria = searchCriteria;
// 	}
// 
// }
// 
// Path: moneta-core/src/main/java/org/moneta/types/search/Criteria.java
// public interface Criteria {
// 
// }
// 
// Path: moneta-core/src/main/java/org/moneta/types/search/FilterCriteria.java
// public class FilterCriteria extends BaseType implements Criteria {
// 	
// 	public static enum Operation {EQUAL, NOT_EQUAL, GREATER_THAN, LESS_THAN, IS_NULL, IS_NOT_NULL, LIKE};
// 	
// 	private String fieldName;
// 	private Operation operation;
// 	private Object value;
// 	
// 	public String getFieldName() {
// 		return fieldName;
// 	}
// 	
// 	public void setFieldName(String fieldName) {
// 		this.fieldName = fieldName;
// 	}
// 	
// 	public Operation getOperation() {
// 		return operation;
// 	}
// 	
// 	public void setOperation(Operation operation) {
// 		this.operation = operation;
// 	}
// 	
// 	public Object getValue() {
// 		return value;
// 	}
// 	
// 	public void setValue(Object value) {
// 		this.value = value;
// 	}
// 	
// 
// }
// 
// Path: moneta-core/src/main/java/org/moneta/types/search/SearchRequest.java
// public class SearchRequest extends BaseType {
// 	
// 	private String topic;
// 	private String[] fieldNames;
// 	private CompositeCriteria searchCriteria;
// 	private Long maxRows;
// 	private Long startRow;
// 	
// 	public String[] getFieldNames() {
// 		return fieldNames;
// 	}
// 	
// 	public void setFieldNames(String[] fieldNames) {
// 		this.fieldNames = fieldNames;
// 	}
// 	
// 	public CompositeCriteria getSearchCriteria() {
// 		return searchCriteria;
// 	}
// 	
// 	public void setSearchCriteria(CompositeCriteria searchCriteria) {
// 		this.searchCriteria = searchCriteria;
// 	}
// 
// 	public Long getMaxRows() {
// 		return maxRows;
// 	}
// 
// 	public void setMaxRows(Long maxRows) {
// 		this.maxRows = maxRows;
// 	}
// 
// 	public String getTopic() {
// 		return topic;
// 	}
// 
// 	public void setTopic(String topic) {
// 		this.topic = topic;
// 	}
// 
// 	public Long getStartRow() {
// 		return startRow;
// 	}
// 
// 	public void setStartRow(Long startRow) {
// 		this.startRow = startRow;
// 	}
// 
// 
// }


// Path: moneta-core/src/test/java/org/moneta/SearchRequestFactoryTest.java
import java.util.Arrays;
import org.apache.commons.lang3.StringUtils;
import org.force66.mock.servletapi.MockRequest;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.moneta.config.MonetaEnvironment;
import org.moneta.types.search.CompositeCriteria;
import org.moneta.types.search.Criteria;
import org.moneta.types.search.FilterCriteria;
import org.moneta.types.search.SearchRequest;

	private void testCriteria(Criteria criteria, String fieldName, FilterCriteria.Operation operator, Object value) {
		Assert.assertTrue(criteria instanceof FilterCriteria);
		FilterCriteria filterCriteria = (FilterCriteria)criteria;
		
		Assert.assertTrue(fieldName.equals(filterCriteria.getFieldName()));
		Assert.assertTrue(operator.equals(filterCriteria.getOperation()));
		Assert.assertTrue(value.equals(filterCriteria.getValue()));
	}

	private void testException(String testMessage) {
		Throwable exceptionThrown=null;
		try {factory.deriveSearchRequest(request);}
		catch (Exception e) {
			exceptionThrown=e;
		}
		Assert.assertTrue(exceptionThrown != null);
		Assert.assertTrue(exceptionThrown.getMessage() != null);
		Assert.assertTrue(exceptionThrown.getMessage().contains(testMessage));
	}
	
	@Test
	public void testDeriveSearachNodes() throws Exception {
		request.setUri("/myapp", "/Environment/one/two/three");
		Assert.assertTrue(Arrays.deepEquals(factory.deriveSearchNodes(request), 
				StringUtils.split("/Environment/one/two/three", '/')));
		
		request.setUri("", "/moneta/Environment");
		Assert.assertTrue(Arrays.deepEquals(factory.deriveSearchNodes(request), 
				StringUtils.split("/moneta/Environment", '/')));
		

		MonetaEnvironment.getConfiguration().setIgnoredContextPathNodes(new String[]{"moneta"});
