// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
// 
//     /**
//      *
//      */
//     private static final long serialVersionUID = 8231671973667011469L;
// 
//     public enum Status {
//         OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
//     }
// 
//     private final Status status;
//     private final transient T obj;
// 
//     public ServiceResponse(Status status, T obj) {
//         this.status = status;
//         this.obj = obj;
//     }
// 
//     public Status getStatus() {
//         return status;
//     }
// 
//     public T getObj() {
//         return obj;
//     }
// }
// 
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
// 
//     private int total;
// 
//     private String firstPageNumber;
//     private String lastPageNumber;
//     private String nextPageNumber;
//     private int nextPage = 0;
//     private int lastPage = 0;
//     private String previousPageNumber;
//     private String startIndexString;
// 
//     private int startIndex;
// 
//     public int getTotal() {
// 	return total;
//     }
//     public void setTotal(int total) {
// 	this.total = total;
//     }
// 
//     public String getFirstPageNumber() {
// 	return firstPageNumber;
//     }
//     public void setFirstPageNumber(String firstPageNumber) {
// 	this.firstPageNumber = firstPageNumber;
//     }
//     public String getLastPageNumber() {
// 	return lastPageNumber;
//     }
//     public void setLastPageNumber(String lastPageNumber) {
// 	this.lastPageNumber = lastPageNumber;
//     }
//     public String getNextPageNumber() {
// 	return nextPageNumber;
//     }
//     public void setNextPageNumber(String nextPageNumber) {
// 	this.nextPageNumber = nextPageNumber;
//     }
//     public String getPreviousPageNumber() {
// 	return previousPageNumber;
//     }
//     public void setPreviousPageNumber(String previousPageNumber) {
// 	this.previousPageNumber = previousPageNumber;
//     }
//     public int getStartIndex() {
// 	return startIndex;
//     }
//     public void setStartIndex(int startIndex) {
// 	this.startIndex = startIndex;
//     }
//     public int getNextPage() {
// 	return nextPage;
//     }
//     public void setNextPage(int nextPage) {
// 	this.nextPage = nextPage;
//     }
//     public int getLastPage() {
// 	return lastPage;
//     }
//     public void setLastPage(int lastPage) {
// 	this.lastPage = lastPage;
//     }
//     public String getStartIndexString() {
// 	return startIndexString;
//     }
//     public void setStartIndexString(String startIndexString) {
// 	this.startIndexString = startIndexString;
//     }
// 
// 
//     @Override
//     public String toString(){
// 	return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
//     }
// 
// }
// 
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/TextSearchService.java
// public interface TextSearchService {
// 
// 
// 
//    public ServiceResponse<Map<String, Object>> getTextPositions(String query, String queryString, boolean isW3c, String page, boolean isMixedSearch, String within, String widthHeight);
// 
// 
//     public long getTotalHits();
// 
//     public PageParameters getPageParameters();
// 
//     public TextUtils getTextUtils();
// 
// }


import static org.junit.Assert.*;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.cache.Cache;
import org.springframework.cache.Cache.ValueWrapper;
import org.springframework.cache.CacheManager;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.service.TextSearchService;
import com.google.common.collect.Iterators;
	String widthHeight=null;

	long totalHits = 10;
	when(template.getClient()).thenReturn(client);

	SearchHits searchHits = mock(SearchHits.class);
	when(searchHits.getTotalHits()).thenReturn(totalHits);

	SearchHit[] hits = new SearchHit[1];
	SearchHit hit = mock(SearchHit.class);
	hits[0] = hit;
	when(searchHits.iterator()).thenReturn(Iterators.forArray(hits));

	when(hit.getSourceAsString()).thenReturn(null);

	SearchResponse response = mock(SearchResponse.class);
	when(response.getHits()).thenReturn(searchHits);

	ListenableActionFuture<SearchResponse> action = mock(ListenableActionFuture.class);
	when(action.actionGet()).thenReturn(response);

	SearchRequestBuilder builder = mock(SearchRequestBuilder.class);
	when(builder.setQuery(anyObject())).thenReturn(builder);
	when(builder.setPostFilter(anyObject())).thenReturn(builder);
	when(builder.setFrom(anyInt())).thenReturn(builder);
	when(builder.setSize(anyInt())).thenReturn(builder);
	when(builder.execute()).thenReturn(action);

	when(client.prepareSearch("w3cannotation")).thenReturn(builder);

// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/ServiceResponse.java
// public class ServiceResponse<T> implements Serializable{
// 
//     /**
//      *
//      */
//     private static final long serialVersionUID = 8231671973667011469L;
// 
//     public enum Status {
//         OK, NOT_FOUND, CACHE_KEY_MISS, ILLEGAL_MODIFICATION, NON_CONFORMANT
//     }
// 
//     private final Status status;
//     private final transient T obj;
// 
//     public ServiceResponse(Status status, T obj) {
//         this.status = status;
//         this.obj = obj;
//     }
// 
//     public Status getStatus() {
//         return status;
//     }
// 
//     public T getObj() {
//         return obj;
//     }
// }
// 
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/model/annotation/page/PageParameters.java
// public class PageParameters {
// 
//     private int total;
// 
//     private String firstPageNumber;
//     private String lastPageNumber;
//     private String nextPageNumber;
//     private int nextPage = 0;
//     private int lastPage = 0;
//     private String previousPageNumber;
//     private String startIndexString;
// 
//     private int startIndex;
// 
//     public int getTotal() {
// 	return total;
//     }
//     public void setTotal(int total) {
// 	this.total = total;
//     }
// 
//     public String getFirstPageNumber() {
// 	return firstPageNumber;
//     }
//     public void setFirstPageNumber(String firstPageNumber) {
// 	this.firstPageNumber = firstPageNumber;
//     }
//     public String getLastPageNumber() {
// 	return lastPageNumber;
//     }
//     public void setLastPageNumber(String lastPageNumber) {
// 	this.lastPageNumber = lastPageNumber;
//     }
//     public String getNextPageNumber() {
// 	return nextPageNumber;
//     }
//     public void setNextPageNumber(String nextPageNumber) {
// 	this.nextPageNumber = nextPageNumber;
//     }
//     public String getPreviousPageNumber() {
// 	return previousPageNumber;
//     }
//     public void setPreviousPageNumber(String previousPageNumber) {
// 	this.previousPageNumber = previousPageNumber;
//     }
//     public int getStartIndex() {
// 	return startIndex;
//     }
//     public void setStartIndex(int startIndex) {
// 	this.startIndex = startIndex;
//     }
//     public int getNextPage() {
// 	return nextPage;
//     }
//     public void setNextPage(int nextPage) {
// 	this.nextPage = nextPage;
//     }
//     public int getLastPage() {
// 	return lastPage;
//     }
//     public void setLastPage(int lastPage) {
// 	this.lastPage = lastPage;
//     }
//     public String getStartIndexString() {
// 	return startIndexString;
//     }
//     public void setStartIndexString(String startIndexString) {
// 	this.startIndexString = startIndexString;
//     }
// 
// 
//     @Override
//     public String toString(){
// 	return "total:" +this.getTotal() + " startIndex:" +this.getStartIndex() + " nextPage:" + this.getNextPage() ;
//     }
// 
// }
// 
// Path: the-mathmos-server/src/main/java/com/digirati/themathmos/service/TextSearchService.java
// public interface TextSearchService {
// 
// 
// 
//    public ServiceResponse<Map<String, Object>> getTextPositions(String query, String queryString, boolean isW3c, String page, boolean isMixedSearch, String within, String widthHeight);
// 
// 
//     public long getTotalHits();
// 
//     public PageParameters getPageParameters();
// 
//     public TextUtils getTextUtils();
// 
// }


// Path: the-mathmos-server/src/test/java/com/digirati/themathmos/service/impl/W3CSearchServiceImpTest.java
import static org.junit.Assert.*;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import org.elasticsearch.action.ListenableActionFuture;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.cache.Cache;
import org.springframework.cache.Cache.ValueWrapper;
import org.springframework.cache.CacheManager;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import com.digirati.themathmos.model.ServiceResponse;
import com.digirati.themathmos.model.annotation.page.PageParameters;
import com.digirati.themathmos.service.TextSearchService;
import com.google.common.collect.Iterators;

	String widthHeight=null;

	long totalHits = 10;
	when(template.getClient()).thenReturn(client);

	SearchHits searchHits = mock(SearchHits.class);
	when(searchHits.getTotalHits()).thenReturn(totalHits);

	SearchHit[] hits = new SearchHit[1];
	SearchHit hit = mock(SearchHit.class);
	hits[0] = hit;
	when(searchHits.iterator()).thenReturn(Iterators.forArray(hits));

	when(hit.getSourceAsString()).thenReturn(null);

	SearchResponse response = mock(SearchResponse.class);
	when(response.getHits()).thenReturn(searchHits);

	ListenableActionFuture<SearchResponse> action = mock(ListenableActionFuture.class);
	when(action.actionGet()).thenReturn(response);

	SearchRequestBuilder builder = mock(SearchRequestBuilder.class);
	when(builder.setQuery(anyObject())).thenReturn(builder);
	when(builder.setPostFilter(anyObject())).thenReturn(builder);
	when(builder.setFrom(anyInt())).thenReturn(builder);
	when(builder.setSize(anyInt())).thenReturn(builder);
	when(builder.execute()).thenReturn(action);

	when(client.prepareSearch("w3cannotation")).thenReturn(builder);

	PageParameters textPagingParamters = new PageParameters();