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

import static com.opengamma.sesame.config.ConfigBuilder.config;
import static com.opengamma.sesame.config.ConfigBuilder.implementations;
import static org.testng.AssertJUnit.assertEquals;

import org.testng.annotations.Test;

import com.opengamma.util.test.TestGroup;

@Test(groups = TestGroup.UNIT)
public class CompositeFunctionModelConfigTest {

  @Test
  public void compose2() {
    FunctionModelConfig config1 = config(implementations(Object.class, String.class,
                                                         Float.class, Character.class));
    FunctionModelConfig config2 = config(implementations(Object.class, Integer.class,
                                                         Long.class, Double.class));
    CompositeFunctionModelConfig config = new CompositeFunctionModelConfig(config1, config2);
    assertEquals(String.class, config.getFunctionImplementation(Object.class));
    assertEquals(Double.class, config.getFunctionImplementation(Long.class));
    assertEquals(Character.class, config.getFunctionImplementation(Float.class));
  }

  @Test
  public void composeMultiple() {
    FunctionModelConfig config1 = config(implementations(Object.class, String.class,
                                                         Float.class, Character.class));
    FunctionModelConfig config2 = config(implementations(Object.class, Integer.class,
                                                         Long.class, Double.class));
    FunctionModelConfig config3 = config(implementations(Number.class, Integer.class,
                                                         Long.class, Short.class));
    FunctionModelConfig config = CompositeFunctionModelConfig.compose(config1, config2, config3);
    assertEquals(String.class, config.getFunctionImplementation(Object.class));
    assertEquals(Double.class, config.getFunctionImplementation(Long.class));
    assertEquals(Character.class, config.getFunctionImplementation(Float.class));
    assertEquals(Integer.class, config.getFunctionImplementation(Number.class));
  }
}

@@ -358,16 +358,113 @@
 quals;%0A%0A
+import java.util.HashMap;%0Aimport java.util.HashSet;%0Aimport java.util.Map;%0Aimport java.util.Set;%0A%0A
 import o
@@ -788,37 +788,35 @@
             
-Float
+Map
 .class, 
 Character.cl
@@ -799,33 +799,31 @@
  Map.class, 
-Character
+HashMap
 .class));%0A  
@@ -955,36 +955,38 @@
                 
-Long
+Number
 .class, Double.c
@@ -1223,36 +1223,38 @@
 nImplementation(
-Long
+Number
 .class));%0A    as
@@ -1260,33 +1260,31 @@
 ssertEquals(
-Character
+HashMap
 .class, conf
@@ -1304,37 +1304,35 @@
 nImplementation(
-Float
+Map
 .class));%0A  %7D%0A%0A 
@@ -1518,21 +1518,19 @@
     
-Float
+Map
 .class, 
 Char
@@ -1525,25 +1525,23 @@
 .class, 
-Character
+HashMap
 .class))
@@ -1677,36 +1677,38 @@
                 
-Long
+Number
 .class, Double.c
@@ -1772,30 +1772,27 @@
 tations(
-Number
+Set
 .class, 
 Integer.
@@ -1775,39 +1775,39 @@
 ions(Set.class, 
-Integer
+HashSet
 .class,%0A        
@@ -1859,20 +1859,19 @@
     
-Long
+Set
 .class, 
 Shor
@@ -1870,12 +1870,14 @@
 ss, 
-Shor
+HashSe
 t.cl
@@ -2129,12 +2129,14 @@
 ion(
-Long
+Number
 .cla
@@ -2162,17 +2162,15 @@
 als(
-Character
+HashMap
 .cla
@@ -2210,13 +2210,11 @@
 ion(
-Float
+Map
 .cla
@@ -2236,23 +2236,23 @@
 tEquals(
-Integer
+HashSet
 .class, 
@@ -2276,38 +2276,35 @@
 nImplementation(
-Number
+Set
 .class));%0A  %7D%0A%7D%0A

Fix CompositeFunctionModelConfigTest