<commit_before>/**
 * Copyright (C) 2012 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.master.cache;

import static org.testng.AssertJUnit.assertEquals;

import java.util.ArrayList;
import java.util.List;

import net.sf.ehcache.CacheManager;

import org.joda.beans.Bean;
import org.testng.annotations.Test;

import com.opengamma.id.UniqueId;
import com.opengamma.master.security.SecuritySearchRequest;
import com.opengamma.util.ehcache.EHCacheUtils;
import com.opengamma.util.paging.PagingRequest;
import com.opengamma.util.test.TestGroup;
import com.opengamma.util.tuple.ObjectsPair;

@Test(groups = TestGroup.UNIT)
public class EHCachingSearchCacheTest {

  private static final int TOTAL_SIZE = 100;
  private static final String TEST_SCHEME = "TEST";

  @Test
  public void testSearchCache() {
    for (int requestSize = 1; requestSize < TOTAL_SIZE; requestSize = requestSize + 17) {
      for (int requestStartStepSize = 1; requestStartStepSize < TOTAL_SIZE / 2; requestStartStepSize = requestStartStepSize + 71) {
        EHCachingSearchCache searchCache = getCleanSearchCache();
        for (int requestStartPos = 0; requestStartPos * requestStartStepSize < TOTAL_SIZE * 4; requestStartPos++) {
          PagingRequest pagingRequest = PagingRequest.ofIndex((requestStartPos * requestStartStepSize) % TOTAL_SIZE, requestSize);
          System.out.println(pagingRequest);
          assertEquals(searchCache.search(new SecuritySearchRequest(), pagingRequest, false).getSecond(),
                       buildResultIDs(
                         PagingRequest.ofIndex(
                           pagingRequest.getFirstItem(),
                           Math.min(pagingRequest.getLastItem() - pagingRequest.getFirstItem(),
                                    TOTAL_SIZE - pagingRequest.getFirstItem()
                           )
                         )
                       )
          );
        }
      }
    }
  }

  @Test
  public void testSearchCachePrefetching() {
    for (int requestSize = 1; requestSize < TOTAL_SIZE; requestSize = requestSize + 17) {
      for (int requestStartStepSize = 1; requestStartStepSize < TOTAL_SIZE / 2; requestStartStepSize = requestStartStepSize + 71) {
        EHCachingSearchCache searchCache = getCleanSearchCache();
        for (int requestStartPos = 0; requestStartPos * requestStartStepSize < TOTAL_SIZE * 4; requestStartPos++) {
          PagingRequest pagingRequest = PagingRequest.ofIndex((requestStartPos * requestStartStepSize) % TOTAL_SIZE, requestSize);
          System.out.println(pagingRequest);
          searchCache.prefetch(new SecuritySearchRequest(), pagingRequest);
          assertEquals(searchCache.search(new SecuritySearchRequest(), pagingRequest, false).getSecond(),
                       buildResultIDs(
                         PagingRequest.ofIndex(
                           pagingRequest.getFirstItem(),<commit_msg>Remove noisy testing system out<commit_after>/**
 * Copyright (C) 2012 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.master.cache;

import static org.testng.AssertJUnit.assertEquals;

import java.util.ArrayList;
import java.util.List;

import net.sf.ehcache.CacheManager;

import org.joda.beans.Bean;
import org.testng.annotations.Test;

import com.opengamma.id.UniqueId;
import com.opengamma.master.security.SecuritySearchRequest;
import com.opengamma.util.ehcache.EHCacheUtils;
import com.opengamma.util.paging.PagingRequest;
import com.opengamma.util.test.TestGroup;
import com.opengamma.util.tuple.ObjectsPair;

@Test(groups = TestGroup.UNIT)
public class EHCachingSearchCacheTest {

  private static final int TOTAL_SIZE = 100;
  private static final String TEST_SCHEME = "TEST";

  @Test
  public void testSearchCache() {
    for (int requestSize = 1; requestSize < TOTAL_SIZE; requestSize = requestSize + 17) {
      for (int requestStartStepSize = 1; requestStartStepSize < TOTAL_SIZE / 2; requestStartStepSize = requestStartStepSize + 71) {
        EHCachingSearchCache searchCache = getCleanSearchCache();
        for (int requestStartPos = 0; requestStartPos * requestStartStepSize < TOTAL_SIZE * 4; requestStartPos++) {
          PagingRequest pagingRequest = PagingRequest.ofIndex((requestStartPos * requestStartStepSize) % TOTAL_SIZE, requestSize);
          assertEquals(searchCache.search(new SecuritySearchRequest(), pagingRequest, false).getSecond(),
                       buildResultIDs(
                         PagingRequest.ofIndex(
                           pagingRequest.getFirstItem(),
                           Math.min(pagingRequest.getLastItem() - pagingRequest.getFirstItem(),
                                    TOTAL_SIZE - pagingRequest.getFirstItem()
                           )
                         )
                       )
          );
        }
      }
    }
  }

  @Test
  public void testSearchCachePrefetching() {
    for (int requestSize = 1; requestSize < TOTAL_SIZE; requestSize = requestSize + 17) {
      for (int requestStartStepSize = 1; requestStartStepSize < TOTAL_SIZE / 2; requestStartStepSize = requestStartStepSize + 71) {
        EHCachingSearchCache searchCache = getCleanSearchCache();
        for (int requestStartPos = 0; requestStartPos * requestStartStepSize < TOTAL_SIZE * 4; requestStartPos++) {
          PagingRequest pagingRequest = PagingRequest.ofIndex((requestStartPos * requestStartStepSize) % TOTAL_SIZE, requestSize);
          System.out.println(pagingRequest);
          searchCache.prefetch(new SecuritySearchRequest(), pagingRequest);
          assertEquals(searchCache.search(new SecuritySearchRequest(), pagingRequest, false).getSecond(),
                       buildResultIDs(
                         PagingRequest.ofIndex(
                           pagingRequest.getFirstItem(),
{'fraction_non_alphanumeric': 0.08570466408486277, 'fraction_numerical': 0.008418925745074928, 'mean_word_length': 2.9078947368421053, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7254369', 'n_tokens_mistral': 1664, 'n_tokens_neox': 1572, 'n_words': 338}