Package com.opengamma.master.holiday

Examples of com.opengamma.master.holiday.HolidaySearchResult


    List<HolidayDocument> documents = new ArrayList<>();
    for (UniqueId uniqueId : pair.getSecond()) {
      documents.add(get(uniqueId));
    }

    HolidaySearchResult result = new HolidaySearchResult(documents);
    result.setPaging(Paging.of(request.getPagingRequest(), pair.getFirst()));

    // Debug: check result against underlying
    if (EHCachingSearchCache.TEST_AGAINST_UNDERLYING) {
      HolidaySearchResult check = ((HolidayMaster) getUnderlying()).search(request);
      if (!result.getPaging().equals(check.getPaging())) {
        s_logger.error("_documentSearchCache.getCache().getName() + \" returned paging:\\n\"" + result.getPaging() +
                           "\nbut the underlying master returned paging:\n" + check.getPaging());
      }
      if (!result.getDocuments().equals(check.getDocuments())) {
        s_logger.error(_documentSearchCache.getCache().getName() + " returned documents:\n" + result.getDocuments() +
                           "\nbut the underlying master returned documents:\n" + check.getDocuments());
      }
    }

    return result;
  }
View Full Code Here


  }

  @POST
  @Path("holidaySearches")
  public Response search(HolidaySearchRequest request) {
    HolidaySearchResult result = getHolidayMaster().search(request);
    return responseOkFudge(result);
  }
View Full Code Here

        list.add(doc);
      }
    }
    Collections.sort(list, request.getSortOrder());
   
    final HolidaySearchResult result = new HolidaySearchResult();
    result.setPaging(Paging.of(request.getPagingRequest(), list));
    result.getDocuments().addAll(request.getPagingRequest().select(list));
    return result;
  }
View Full Code Here

  public void applyPaging() {
    HolidayDocument m1h1 = holidayDocWithId("m1", "1");
    HolidayDocument m1h2 = holidayDocWithId("m1", "2");
    HolidayDocument m1h3 = holidayDocWithId("m1", "3");
    HolidayDocument m1h4 = holidayDocWithId("m1", "4");
    HolidaySearchResult sr;
    sr = new HolidaySearchResult(ImmutableList.of(m1h1, m1h2, m1h3, m1h4));
   
    PagingRequest ofIndex ;
    ofIndex = PagingRequest.ofIndex(1, 3);
   
    cMaster.applyPaging(sr, ofIndex);
   
    assertEquals(Paging.of(ofIndex, 4), sr.getPaging());
    assertEquals(ImmutableList.of(m1h2, m1h3, m1h4), sr.getDocuments());

    sr = new HolidaySearchResult(ImmutableList.of(m1h1, m1h2, m1h3, m1h4));
   
    ofIndex = PagingRequest.ofIndex(100, 103);
   
    cMaster.applyPaging(sr, ofIndex);
   
    assertEquals(Paging.of(ofIndex, 4), sr.getPaging());
    assertEquals(ImmutableList.of(), sr.getDocuments());

  }
View Full Code Here

    HolidayDocument m2h4 = holidayDocWithId("m2", "4");
    HolidayDocument m2h5 = holidayDocWithId("m2", "5");
    HolidayDocument m2h6 = holidayDocWithId("m2", "6");
    final HolidayDocument m2h7 = holidayDocWithId("m2", "7");

    HolidaySearchResult m1Result = new HolidaySearchResult(Lists.newArrayList(m1h1, m1h2, m1h2, m1h3, m1h4, m1h4));
    HolidaySearchResult m2Result = new HolidaySearchResult(Lists.newArrayList(m2h3, m2h4, m2h5, m2h6, m2h7));
   
    final List<HolidayDocument> resultList = Lists.newArrayList();
   
    @SuppressWarnings("unchecked")
    final SearchCallback<HolidayDocument, HolidayMaster> cbDelegate = mock(SearchCallback.class);
View Full Code Here

    verifyNoMoreInteractions(m2);
   
  }
 
  private List<HolidayDocument> runPagedSearch(PagingRequest pr, List<HolidayDocument> m1Result, int m1Total, List<HolidayDocument> m2Result, int m2Total) {
    HolidaySearchResult result = new HolidaySearchResult();
    HolidaySearchRequest searchRequest = new HolidaySearchRequest();
    searchRequest.setPagingRequest(pr);
    HolidaySearchResult m1SearchResult = new HolidaySearchResult();
    m1SearchResult.setDocuments(m1Result);
    m1SearchResult.setPaging(Paging.of(PagingRequest.ofIndex(0, m1Result.size()), m1Total));
    HolidaySearchResult m2SearchResult = new HolidaySearchResult();
    m2SearchResult.setPaging(Paging.of(PagingRequest.ofIndex(0, m2Result.size()), m2Total));
    m2SearchResult.setDocuments(m2Result);
   
    when(m1.search(Mockito.<HolidaySearchRequest>any())).thenReturn(m1SearchResult);
    when(m2.search(Mockito.<HolidaySearchRequest>any())).thenReturn(m2SearchResult);
   
    cMaster.pagedSearch(new SearchStrategy<HolidayDocument, HolidayMaster, HolidaySearchRequest>() {
View Full Code Here

    HolidayMaster mock = mock(HolidayMaster.class);
    HolidaySearchRequest request = new HolidaySearchRequest(GBP);
    request.setDateToCheck(DATE_MONDAY);
    request.setVersionCorrection(VC);
    ManageableHoliday holiday = new ManageableHoliday(GBP, Collections.singletonList(DATE_MONDAY));
    HolidaySearchResult result = new HolidaySearchResult();
    result.getDocuments().add(new HolidayDocument(holiday));
   
    when(mock.search(request)).thenReturn(result);
    MasterHolidaySource test = new MasterHolidaySource(mock, VC);
    boolean testResult = test.isHoliday(DATE_MONDAY, GBP);
    verify(mock, times(1)).search(request);
View Full Code Here

  public void test_isHoliday_LocalDateCurrency_workday() throws Exception {
    HolidayMaster mock = mock(HolidayMaster.class);
    HolidaySearchRequest request = new HolidaySearchRequest(GBP);
    request.setDateToCheck(DATE_MONDAY);
    request.setVersionCorrection(VC);
    HolidaySearchResult result = new HolidaySearchResult();
   
    when(mock.search(request)).thenReturn(result);
    MasterHolidaySource test = new MasterHolidaySource(mock, VC);
    boolean testResult = test.isHoliday(DATE_MONDAY, GBP);
    verify(mock, times(1)).search(request);
View Full Code Here

  public void test_isHoliday_LocalDateCurrency_sunday() throws Exception {
    HolidayMaster mock = mock(HolidayMaster.class);
    HolidaySearchRequest request = new HolidaySearchRequest(GBP);
    request.setDateToCheck(DATE_SUNDAY);
    request.setVersionCorrection(VC);
    HolidaySearchResult result = new HolidaySearchResult();
   
    when(mock.search(request)).thenReturn(result);
    MasterHolidaySource test = new MasterHolidaySource(mock, VC);
    boolean testResult = test.isHoliday(DATE_SUNDAY, GBP);
    verify(mock, times(0)).search(request);
View Full Code Here

    HolidayMaster mock = mock(HolidayMaster.class);
    HolidaySearchRequest request = new HolidaySearchRequest(HolidayType.BANK, ExternalIdBundle.of(ID));
    request.setDateToCheck(DATE_MONDAY);
    request.setVersionCorrection(VC);
    ManageableHoliday holiday = new ManageableHoliday(GBP, Collections.singletonList(DATE_MONDAY));
    HolidaySearchResult result = new HolidaySearchResult();
    result.getDocuments().add(new HolidayDocument(holiday));
   
    when(mock.search(request)).thenReturn(result);
    MasterHolidaySource test = new MasterHolidaySource(mock, VC);
    boolean testResult = test.isHoliday(DATE_MONDAY, HolidayType.BANK, ID);
    verify(mock, times(1)).search(request);
View Full Code Here

TOP

Related Classes of com.opengamma.master.holiday.HolidaySearchResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.