// Path: core/src/main/java/com/ccoe/build/core/filter/FilterMatcher.java
// public class FilterMatcher {
// 
// 	public boolean isMatch(HashMap<String, String> source, Filter filter) {
// 		for (Cause cause : filter.getCause()) {
// 			String sourceName = cause.getSource();
// 			//whether sourceName is null or not, there should be a key with value sourceName in source
// 			//or the record can't match, that means returning false;
// 			if(source.containsKey(sourceName)) {
// 				String value = source.get(sourceName);   //wouldn't cause error when sourceName is null;
// 				if(!isMatchCause(value, cause)) {
// 					return false;
// 				}
// 			} else {
// 				return false;
// 			}
// 		}
// 		return true;
// 	}
// 
// 	public boolean isMatch(String fullstack, Filter filter) {
// 		for (Cause cause : filter.getCause()) {
// 			if (!isMatchCause(fullstack, cause)) {
// 				return false;
// 			}
// 		}
// 		return true;
// 	}
// 	
// 	protected boolean isMatchCause(String content, Cause cause) {
// 		if (isMatchContent(content, cause)
// 				|| isMatchKeyword(content, cause)
// 				|| isMatchPattern(content, cause)) {
// 			return true;
// 		}
// 		return false;
// 	}
// 	
// 	protected boolean isMatchContent(String content, Cause cause) {
// 		if (!StringUtils.isEmpty(cause.getValue()) && content.equals(cause.getValue())) {
// 			return true;
// 		}
// 		return false;
// 	}
// 	
// 	protected boolean isMatchKeyword(String content, Cause cause) {
// 		if (!StringUtils.isEmpty(cause.getKeyword()) && content.contains(cause.getKeyword())) {
// 			return true;
// 		}
// 		return false;
// 	}
// 	
// 	protected boolean isMatchPattern(String content, Cause cause) {
// 		if (!StringUtils.isEmpty(cause.getPattern())) {
// 			if (Pattern.compile(cause.getPattern(), Pattern.DOTALL).matcher(content).matches()) {
// 			//if (StringUtils.isEmpty(StringUtils.getFirstFound(fullstack, cause.getPattern(), true))) {
// 				return true;
// 			}
// 		}
// 		return false;
// 	}
// }
// 
// Path: core/src/main/java/com/ccoe/build/core/filter/model/Cause.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class Cause {
// 	
// 	@XmlAttribute
// 	private String source;
// 	
// 	@XmlAttribute
// 	private String keyword;
// 	
// 	@XmlAttribute
// 	private String pattern;
// 
// 	@XmlAttribute
// 	private String value;
// 
// 	public String getSource() {
// 		return source;
// 	}
// 
// 	public void setSource(String source) {
// 		this.source = source;
// 	}
// 	
// 	public String getKeyword() {
// 		return keyword;
// 	}
// 
// 	public void setKeyword(String keyword) {
// 		this.keyword = keyword;
// 	}
// 	
// 	public String getPattern() {
// 		return this.pattern;
// 	}
// 	
// 	public void setPattern(String p) {
// 		this.pattern = p;
// 	}
// 	
// 	public String getValue() {
// 		return value;
// 	}
// 
// 	public void setValue(String value) {
// 		this.value = value;
// 	}
// }
// 
// Path: core/src/main/java/com/ccoe/build/core/filter/model/Filter.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class Filter {
// 	@XmlAttribute
// 	private String name;
// 	
// 	@XmlAttribute
// 	private String description;
// 	
// 	private String category;
// 
// 	@XmlElement(name="cause")
// 	private List<Cause> cause = new ArrayList<Cause>();
// 	
// 	public List<Cause> getCause() {
// 		return this.cause;
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 	
// 	public String getDescription() {
// 		return description;
// 	}
// 
// 	public void setDescription(String description) {
// 		this.description= description;
// 	}
// 
// 	public String getCategory() {
// 		return category;
// 	}
// 
// 	public void setCategory(String category) {
// 		this.category = category;
// 	}
// 	
// 	public void setCauses(List<Cause> lsCause){
// 		this.cause = lsCause;
// 	}
// }


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import com.ccoe.build.core.filter.FilterMatcher;
import com.ccoe.build.core.filter.model.Cause;
import com.ccoe.build.core.filter.model.Filter;
/*
Copyright [2013-2014] eBay Software Foundation

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.

*/

package com.ccoe.build.core.filter;





public class FilterMatcherTest {
	static FilterMatcher matcher;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		matcher = new FilterMatcher();
	}

	@Test
	public void testIsMatchHashMapOfStringStringFilter() {
// Path: core/src/main/java/com/ccoe/build/core/filter/FilterMatcher.java
// public class FilterMatcher {
// 
// 	public boolean isMatch(HashMap<String, String> source, Filter filter) {
// 		for (Cause cause : filter.getCause()) {
// 			String sourceName = cause.getSource();
// 			//whether sourceName is null or not, there should be a key with value sourceName in source
// 			//or the record can't match, that means returning false;
// 			if(source.containsKey(sourceName)) {
// 				String value = source.get(sourceName);   //wouldn't cause error when sourceName is null;
// 				if(!isMatchCause(value, cause)) {
// 					return false;
// 				}
// 			} else {
// 				return false;
// 			}
// 		}
// 		return true;
// 	}
// 
// 	public boolean isMatch(String fullstack, Filter filter) {
// 		for (Cause cause : filter.getCause()) {
// 			if (!isMatchCause(fullstack, cause)) {
// 				return false;
// 			}
// 		}
// 		return true;
// 	}
// 	
// 	protected boolean isMatchCause(String content, Cause cause) {
// 		if (isMatchContent(content, cause)
// 				|| isMatchKeyword(content, cause)
// 				|| isMatchPattern(content, cause)) {
// 			return true;
// 		}
// 		return false;
// 	}
// 	
// 	protected boolean isMatchContent(String content, Cause cause) {
// 		if (!StringUtils.isEmpty(cause.getValue()) && content.equals(cause.getValue())) {
// 			return true;
// 		}
// 		return false;
// 	}
// 	
// 	protected boolean isMatchKeyword(String content, Cause cause) {
// 		if (!StringUtils.isEmpty(cause.getKeyword()) && content.contains(cause.getKeyword())) {
// 			return true;
// 		}
// 		return false;
// 	}
// 	
// 	protected boolean isMatchPattern(String content, Cause cause) {
// 		if (!StringUtils.isEmpty(cause.getPattern())) {
// 			if (Pattern.compile(cause.getPattern(), Pattern.DOTALL).matcher(content).matches()) {
// 			//if (StringUtils.isEmpty(StringUtils.getFirstFound(fullstack, cause.getPattern(), true))) {
// 				return true;
// 			}
// 		}
// 		return false;
// 	}
// }
// 
// Path: core/src/main/java/com/ccoe/build/core/filter/model/Cause.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class Cause {
// 	
// 	@XmlAttribute
// 	private String source;
// 	
// 	@XmlAttribute
// 	private String keyword;
// 	
// 	@XmlAttribute
// 	private String pattern;
// 
// 	@XmlAttribute
// 	private String value;
// 
// 	public String getSource() {
// 		return source;
// 	}
// 
// 	public void setSource(String source) {
// 		this.source = source;
// 	}
// 	
// 	public String getKeyword() {
// 		return keyword;
// 	}
// 
// 	public void setKeyword(String keyword) {
// 		this.keyword = keyword;
// 	}
// 	
// 	public String getPattern() {
// 		return this.pattern;
// 	}
// 	
// 	public void setPattern(String p) {
// 		this.pattern = p;
// 	}
// 	
// 	public String getValue() {
// 		return value;
// 	}
// 
// 	public void setValue(String value) {
// 		this.value = value;
// 	}
// }
// 
// Path: core/src/main/java/com/ccoe/build/core/filter/model/Filter.java
// @XmlAccessorType(XmlAccessType.FIELD)
// public class Filter {
// 	@XmlAttribute
// 	private String name;
// 	
// 	@XmlAttribute
// 	private String description;
// 	
// 	private String category;
// 
// 	@XmlElement(name="cause")
// 	private List<Cause> cause = new ArrayList<Cause>();
// 	
// 	public List<Cause> getCause() {
// 		return this.cause;
// 	}
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public void setName(String name) {
// 		this.name = name;
// 	}
// 	
// 	public String getDescription() {
// 		return description;
// 	}
// 
// 	public void setDescription(String description) {
// 		this.description= description;
// 	}
// 
// 	public String getCategory() {
// 		return category;
// 	}
// 
// 	public void setCategory(String category) {
// 		this.category = category;
// 	}
// 	
// 	public void setCauses(List<Cause> lsCause){
// 		this.cause = lsCause;
// 	}
// }


// Path: core/src/test/java/com/ccoe/build/core/filter/FilterMatcherTest.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import junit.framework.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import com.ccoe.build.core.filter.FilterMatcher;
import com.ccoe.build.core.filter.model.Cause;
import com.ccoe.build.core.filter.model.Filter;

/*
Copyright [2013-2014] eBay Software Foundation

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.

*/

package com.ccoe.build.core.filter;





public class FilterMatcherTest {
	static FilterMatcher matcher;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		matcher = new FilterMatcher();
	}

	@Test
	public void testIsMatchHashMapOfStringStringFilter() {
		List<Cause> lsCause = new ArrayList<Cause>();