/**
 * Copyright (C) 2009 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.financial;

import org.testng.annotations.Test;
import org.testng.AssertJUnit;
import com.opengamma.core.security.SecurityUtils;
import com.opengamma.financial.convention.ConventionBundle;
import com.opengamma.financial.convention.ConventionBundleMaster;
import com.opengamma.financial.convention.ConventionBundleSource;
import com.opengamma.financial.convention.DefaultConventionBundleSource;
import com.opengamma.financial.convention.InMemoryConventionBundleMaster;
import com.opengamma.financial.convention.businessday.BusinessDayConvention;
import com.opengamma.financial.convention.businessday.BusinessDayConventionFactory;
import com.opengamma.financial.convention.daycount.DayCount;
import com.opengamma.financial.convention.daycount.DayCountFactory;
import com.opengamma.id.Identifier;
import com.opengamma.id.IdentifierBundle;
import com.opengamma.id.UniqueIdentifier;

/**
 * Unit test for InMemoryReferenceRateRepository
 */
public class InMemoryReferenceRateRepositoryTest {

  @Test
  public void testRepostiory() {
    final ConventionBundleMaster repo = new InMemoryConventionBundleMaster();
    final ConventionBundleSource source = new DefaultConventionBundleSource(repo);
    final ConventionBundle conventions = source.getConventionBundle(Identifier.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "USD LIBOR O/N"));
    final BusinessDayConvention modified = BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Modified Following");
    final BusinessDayConvention following = BusinessDayConventionFactory.INSTANCE.getBusinessDayConvention("Following");
    final DayCount actact = DayCountFactory.INSTANCE.getDayCount("Actual/360");
    AssertJUnit.assertEquals("USD LIBOR O/N", conventions.getName());
    AssertJUnit.assertEquals(IdentifierBundle.of(SecurityUtils.bloombergTickerSecurityId("US00O/N Index"), Identifier.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "USD LIBOR O/N")), conventions
        .getIdentifiers());
    AssertJUnit.assertEquals(UniqueIdentifier.of(InMemoryConventionBundleMaster.IN_MEMORY_UNIQUE_SCHEME.getName(), "1"), conventions.getUniqueId());
    AssertJUnit.assertEquals(actact, conventions.getDayCount());
    AssertJUnit.assertEquals(following, conventions.getBusinessDayConvention());
    AssertJUnit.assertEquals(0, conventions.getSettlementDays());

    final ConventionBundle conventions2 = source.getConventionBundle(Identifier.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "USD LIBOR 3m"));
    AssertJUnit.assertEquals("USD LIBOR 3m", conventions2.getName());
    AssertJUnit.assertEquals(IdentifierBundle.of(SecurityUtils.bloombergTickerSecurityId("US0003M Index"), Identifier.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "USD LIBOR 3m")), conventions2
        .getIdentifiers());
    AssertJUnit.assertEquals(UniqueIdentifier.of(InMemoryConventionBundleMaster.IN_MEMORY_UNIQUE_SCHEME.getName(), "7"), conventions2.getUniqueId());
    AssertJUnit.assertEquals(actact, conventions2.getDayCount());
    AssertJUnit.assertEquals(modified, conventions2.getBusinessDayConvention());
    AssertJUnit.assertEquals(2, conventions2.getSettlementDays());
  }
}

@@ -187,23 +187,18 @@
 tng.
-annotations.Tes
+AssertJUni
 t;%0Ai
@@ -210,37 +210,43 @@
  org.testng.
-AssertJUni
+annotations.Tes
 t;%0A
+%0A
 import com.o
@@ -952,50 +952,8 @@
 er;%0A
-import com.opengamma.id.IdentifierBundle;%0A
 impo
@@ -1306,160 +1306,8 @@
 o);%0A
-    final ConventionBundle conventions = source.getConventionBundle(Identifier.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, %22USD LIBOR O/N%22));%0A
     
@@ -1640,301 +1640,502 @@
     
-AssertJUnit.assertEquals(%22USD LIBOR O/N%22, conventions.getName());%0A    AssertJUnit.assertEquals(IdentifierBundle.of(SecurityUtils.bloombergTickerSecurityId(%22US00O/N Index%22), Identifier.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, %22USD LIBOR O/N%22)), conventions%0A        .getIdentifiers(
+%0A    final ConventionBundle conventions = source.getConventionBundle(Identifier.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, %22USD LIBOR O/N%22));%0A    AssertJUnit.assertEquals(%22USD LIBOR O/N%22, conventions.getName());%0A    AssertJUnit.assertEquals(%22US00O/N Index%22, conventions.getIdentifiers().getIdentifierValue(SecurityUtils.BLOOMBERG_TICKER));%0A    AssertJUnit.assertEquals(%22USD LIBOR O/N%22, conventions.getIdentifiers().getIdentifierValue(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME
 ));%0A
@@ -2495,16 +2495,20 @@
 ays());%0A
+    
 %0A    fin
@@ -2755,206 +2755,251 @@
 als(
-IdentifierBundle.of(SecurityUtils.bloombergTickerSecurityId(%22US0003M Index%22), Identifier.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, %22USD LIBOR 3m%22)), conventions2%0A        .getIdentifiers(
+%22US0003M Index%22, conventions2.getIdentifiers().getIdentifierValue(SecurityUtils.BLOOMBERG_TICKER));%0A    AssertJUnit.assertEquals(%22USD LIBOR 3m%22, conventions2.getIdentifiers().getIdentifierValue(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME
 ));%0A
@@ -3366,10 +3366,11 @@
 ));%0A  %7D%0A
+%0A
 %7D%0A

Fix and harden test