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

import static org.testng.AssertJUnit.assertEquals;

import org.testng.annotations.Test;

import com.opengamma.id.ExternalId;
import com.opengamma.util.test.TestGroup;

/**
 * Test {@link ExternalSchemes}.
 */
@Test(groups = TestGroup.UNIT)
public class ExternalSchemesTest {

  public void test_constants() {
    assertEquals("ISIN", ExternalSchemes.ISIN.getName());
    assertEquals("CUSIP", ExternalSchemes.CUSIP.getName());
    assertEquals("SEDOL1", ExternalSchemes.SEDOL1.getName());
    assertEquals("BLOOMBERG_BUID", ExternalSchemes.BLOOMBERG_BUID.getName());
    assertEquals("BLOOMBERG_TICKER", ExternalSchemes.BLOOMBERG_TICKER.getName());
    assertEquals("BLOOMBERG_TCM", ExternalSchemes.BLOOMBERG_TCM.getName());
    assertEquals("RIC", ExternalSchemes.RIC.getName());
  }

  public void test_identifiers() {
    assertEquals(ExternalId.of("ISIN", "A"), ExternalSchemes.isinSecurityId("A"));
    assertEquals(ExternalId.of("CUSIP", "A"), ExternalSchemes.cusipSecurityId("A"));
    assertEquals(ExternalId.of("SEDOL1", "A"), ExternalSchemes.sedol1SecurityId("A"));
    assertEquals(ExternalId.of("BLOOMBERG_BUID", "A"), ExternalSchemes.bloombergBuidSecurityId("A"));
    assertEquals(ExternalId.of("BLOOMBERG_TICKER", "A"), ExternalSchemes.bloombergTickerSecurityId("A"));
    assertEquals(ExternalId.of("BLOOMBERG_TCM", "T 4.75 15/08/43 Govt"), ExternalSchemes.bloombergTCMSecurityId("T", "4.75", "15/08/43", "Govt"));
    assertEquals(ExternalId.of("RIC", "A"), ExternalSchemes.ricSecurityId("A"));
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_isin_null() {
    ExternalSchemes.isinSecurityId(null);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_cusip_null() {
    ExternalSchemes.cusipSecurityId(null);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_sedol1_null() {
    ExternalSchemes.sedol1SecurityId(null);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_bloombergBuid_null() {
    ExternalSchemes.bloombergBuidSecurityId(null);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_bloombergTicker_null() {
    ExternalSchemes.bloombergTickerSecurityId(null);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_bloombergTCM_null() {
    ExternalSchemes.bloombergTCMSecurityId(null, null, null, null);
  }

  @Test(expectedExceptions = IllegalArgumentException.class)
  public void test_ric_null() {
    ExternalSchemes.ricSecurityId(null);
  }

}

@@ -940,24 +940,104 @@
 getName());%0A
+    assertEquals(%22MARKIT_RED_CODE%22, ExternalSchemes.MARKIT_RED_CODE.getName());%0A
   %7D%0A%0A  publi
@@ -1751,24 +1751,117 @@
 tyId(%22A%22));%0A
+    assertEquals(ExternalId.of(%22MARKIT_RED_CODE%22, %22A%22), ExternalSchemes.markItRedCode(%22A%22));%0A
   %7D%0A%0A  @Test
@@ -2917,11 +2917,161 @@
 l);%0A  %7D%0A
+  %0A  @Test(expectedExceptions = IllegalArgumentException.class)%0A  public void test_markitRedCode_null() %7B%0A    ExternalSchemes.markItRedCode(null);%0A  %7D
 %0A%7D%0A

Add unit test for MarkItRedcode creation in ExternalSchemes