Package com.opengamma.master.holiday

Examples of com.opengamma.master.holiday.HolidayDocument


  protected boolean isHoliday(final HolidaySearchRequest request, final LocalDate dateToCheck) {
    if (isWeekend(dateToCheck)) {
      return true;
    }
    request.setDateToCheck(dateToCheck);
    HolidayDocument doc = getMaster().search(request).getFirstDocument();
    return isHoliday(doc, dateToCheck);
  }
View Full Code Here


  @BeforeMethod
  public void setUp() {
    master = new InMemoryHolidayMaster();
    ManageableHoliday inputHoliday = new ManageableHoliday(GBP, Collections.singletonList(DATE_MONDAY));
    HolidayDocument inputDoc = new HolidayDocument(inputHoliday);
    addedDoc = master.add(inputDoc);
  }
View Full Code Here

  public void test_get_noMatch() {
    master.get(UniqueId.of("A", "B"));
  }

  public void test_get_match() {
    HolidayDocument result = master.get(addedDoc.getUniqueId());
    assertEquals(UniqueId.of("MemHol", "1"), result.getUniqueId());
    assertEquals(addedDoc, result);
  }
View Full Code Here

  //-------------------------------------------------------------------------
  @Test
  public void testGetHoliday() {
    final ManageableHoliday holiday = new ManageableHoliday(Currency.GBP, new ArrayList<LocalDate>());
    final HolidayDocument result = new HolidayDocument(holiday);
    when(_underlying.get(OID, VersionCorrection.LATEST)).thenReturn(result);
   
    Response test = _resource.get(null, null);
    assertEquals(Status.OK.getStatusCode(), test.getStatus());
    assertSame(result, test.getEntity());
View Full Code Here

  }

  @Test
  public void testUpdateHoliday() {
    final ManageableHoliday holiday = new ManageableHoliday(Currency.GBP, new ArrayList<LocalDate>());
    final HolidayDocument request = new HolidayDocument(holiday);
    request.setUniqueId(OID.atLatestVersion());
   
    final HolidayDocument result = new HolidayDocument(holiday);
    result.setUniqueId(OID.atVersion("1"));
    when(_underlying.update(same(request))).thenReturn(result);
   
    Response test = _resource.update(_uriInfo, request);
    assertEquals(Status.CREATED.getStatusCode(), test.getStatus());
    assertSame(result, test.getEntity());
View Full Code Here

    cMaster.replaceVersions(o1, Collections.singletonList(d1));
  }

  @Test
  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);
View Full Code Here

  }

  @Test
  public void search() {
   
    HolidayDocument m1h1 = holidayDocWithId("m1", "1");
    HolidayDocument m1h2 = holidayDocWithId("m1", "2");
    HolidayDocument m1h3 = holidayDocWithId("m1", "3");
    HolidayDocument m1h4 = holidayDocWithId("m1", "4");

    HolidayDocument m2h3 = holidayDocWithId("m2", "3");
    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);
   
    cMaster.search(Lists.newArrayList(m1Result, m2Result, null), new SearchCallback<HolidayDocument, HolidayMaster>() {

      @Override
      public int compare(HolidayDocument arg0, HolidayDocument arg1) {
        return arg0.getUniqueId().getValue().compareTo(arg1.getUniqueId().getValue());
      }

      @Override
      public boolean include(HolidayDocument document) {
        return !m2h7.equals(document);
      }

      @Override
      public void accept(HolidayDocument document, HolidayMaster master, boolean masterUnique, boolean clientUnique) {
        cbDelegate.accept(document, master, masterUnique, clientUnique);
View Full Code Here

   
  }

  private HolidayDocument holidayDocWithId(String scheme, String id) {
    HolidayDocument holidayDocument = new HolidayDocument();
    holidayDocument.setUniqueId(UniqueId.of(scheme, id));
    return holidayDocument;
  }
View Full Code Here

  //-------------------------------------------------------------------------
  public void test_getHoliday_UniqueId_noOverride_found() throws Exception {
    HolidayMaster mock = mock(HolidayMaster.class);
   
    HolidayDocument doc = new HolidayDocument(example());
    when(mock.get(UID)).thenReturn(doc);
    MasterHolidaySource test = new MasterHolidaySource(mock);
    Holiday testResult = test.get(UID);
    verify(mock, times(1)).get(UID);
   
View Full Code Here

  }

  public void test_getHoliday_UniqueId_found() throws Exception {
    HolidayMaster mock = mock(HolidayMaster.class);
   
    HolidayDocument doc = new HolidayDocument(example());
    when(mock.get(OID, VC)).thenReturn(doc);
    MasterHolidaySource test = new MasterHolidaySource(mock, VC);
    Holiday testResult = test.get(UID);
    verify(mock, times(1)).get(OID, VC);
   
View Full Code Here

TOP

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

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.