@@ -0,0 +1,2648 @@
+/**%0A * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies%0A *%0A * Please see distribution for license.%0A */%0Apackage com.opengamma.master.marketdatasnapshot.impl;%0A%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.times;%0Aimport static org.mockito.Mockito.verify;%0Aimport static org.mockito.Mockito.when;%0Aimport static org.testng.AssertJUnit.assertEquals;%0A%0Aimport org.testng.annotations.Test;%0A%0Aimport com.opengamma.DataNotFoundException;%0Aimport com.opengamma.core.marketdatasnapshot.StructuredMarketDataSnapshot;%0Aimport com.opengamma.id.UniqueIdentifier;%0Aimport com.opengamma.master.marketdatasnapshot.ManageableMarketDataSnapshot;%0Aimport com.opengamma.master.marketdatasnapshot.MarketDataSnapshotDocument;%0Aimport com.opengamma.master.marketdatasnapshot.MarketDataSnapshotMaster;%0A%0A/**%0A * Test MasterSnapshotSource.%0A */%0A@Test%0Apublic class MasterSnapshotSourceTest %7B%0A%0A  private static final UniqueIdentifier UID = UniqueIdentifier.of(%22A%22, %22B%22);%0A%0A  @Test(expectedExceptions = IllegalArgumentException.class)%0A  public void test_constructor_1arg_nullMaster() throws Exception %7B%0A    new MasterSnapshotSource(null);%0A  %7D%0A%0A  //-------------------------------------------------------------------------%0A  public void test_getSnapshot_noOverride_found() throws Exception %7B%0A    MarketDataSnapshotMaster mock = mock(MarketDataSnapshotMaster.class);%0A%0A    MarketDataSnapshotDocument doc = new MarketDataSnapshotDocument(example());%0A    when(mock.get(UID)).thenReturn(doc);%0A    MasterSnapshotSource test = new MasterSnapshotSource(mock);%0A    StructuredMarketDataSnapshot testResult = test.getSnapshot(UID);%0A    verify(mock, times(1)).get(UID);%0A%0A    assertEquals(example(), testResult);%0A  %7D%0A%0A  //-------------------------------------------------------------------------%0A  @Test(expectedExceptions = DataNotFoundException.class, expectedExceptionsMessageRegExp = %22Some message%22)%0A  public void test_getSnapshot_noOverride_notFound() throws Exception %7B%0A    MarketDataSnapshotMaster mock = mock(MarketDataSnapshotMaster.class);%0A%0A    MarketDataSnapshotDocument doc = new MarketDataSnapshotDocument(example());%0A    when(mock.get(UID)).thenThrow(new DataNotFoundException(%22Some message%22));%0A    MasterSnapshotSource test = new MasterSnapshotSource(mock);%0A    StructuredMarketDataSnapshot testResult = test.getSnapshot(UID);%0A  %7D%0A%0A  //-------------------------------------------------------------------------%0A  protected ManageableMarketDataSnapshot example() %7B%0A    ManageableMarketDataSnapshot snapshotDocument = new ManageableMarketDataSnapshot();%0A    snapshotDocument.setUniqueId(UID);%0A    return snapshotDocument;%0A  %7D%0A%0A%7D%0A

Test the MasterSnapshotSource