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

import org.junit.Test;

import com.opengamma.engine.value.ValueProperties;
import com.opengamma.engine.value.ValuePropertyNames;
import com.opengamma.engine.value.ValueRequirement;
import com.opengamma.engine.view.ResultModelDefinition;
import com.opengamma.engine.view.ViewCalculationConfiguration;
import com.opengamma.engine.view.ViewDefinition;
import com.opengamma.id.UniqueIdentifier;
import com.opengamma.livedata.UserPrincipal;
import com.opengamma.util.money.Currency;


/**
 * Tests ViewDefinitionBuilder
 */
public class ViewDefinitionBuilderTest extends AbstractBuilderTestCase {
  
  private static final UserPrincipal TEST_USER = UserPrincipal.getLocalUser();
  
  private static final String TEST_VIEW_DEFINITION_NAME = "Test View";
  
  private static final UniqueIdentifier TEST_PORTFOLIO_ID = UniqueIdentifier.of("A", "B");
  
  private static final UniqueIdentifier FUNCTION_ID = UniqueIdentifier.of("AFunc", "B");
  
  @Test
  public void testEncoding() {
    assertEncodeDecodeCycle(ViewDefinition.class, getTestViewDefinition());
  }

  private ViewDefinition getTestViewDefinition() {
    
    ValueProperties constraints = ValueProperties.with(ValuePropertyNames.FUNCTION, FUNCTION_ID.toString()).withAny(ValuePropertyNames.CURVE).get();
    ValueProperties allConstraints = ValueProperties.all();
    ValueProperties noConstraints = ValueProperties.none();
    //TODO ValueProperties nearlyAllConstraints = ValueProperties.all().withoutAny("SomePropName");
    
    final ViewDefinition viewDefinition = new ViewDefinition(TEST_VIEW_DEFINITION_NAME, TEST_PORTFOLIO_ID, TEST_USER, new ResultModelDefinition());
    final ViewCalculationConfiguration calcConfig1 = new ViewCalculationConfiguration (viewDefinition, "1");
    calcConfig1.addSpecificRequirement(new ValueRequirement ("Value1", UniqueIdentifier.of ("Test", "Foo")));
    calcConfig1.addSpecificRequirement(new ValueRequirement ("Value1", UniqueIdentifier.of ("Test", "Bar"), constraints));
    calcConfig1.setDefaultProperties (ValueProperties.with(ValuePropertyNames.CURRENCY, "GBP").get ());
    
    calcConfig1.addPortfolioRequirement("SomeSecType", "SomeOutput", constraints);
    
    calcConfig1.addPortfolioRequirement("SomeSecType", "SomeOtherOutput", allConstraints);
    calcConfig1.addPortfolioRequirement("SomeSecType", "SomeOtherOutput", allConstraints);
    calcConfig1.addPortfolioRequirement("SomeSecType", "YetAnotherOutput", noConstraints);
  //TODO calcConfig1.addPortfolioRequirement("SomeOtherSecType", "YetAnotherOutput", nearlyAllConstraints);
        
    final ViewCalculationConfiguration calcConfig2 = new ViewCalculationConfiguration (viewDefinition, "2");
    calcConfig2.addSpecificRequirement(new ValueRequirement ("Value2", UniqueIdentifier.of ("Test", "Foo")));
    calcConfig2.addSpecificRequirement(new ValueRequirement ("Value2", UniqueIdentifier.of ("Test", "Bar")));
    viewDefinition.setDefaultCurrency(Currency.USD);
    viewDefinition.addViewCalculationConfiguration(calcConfig1);
    viewDefinition.addViewCalculationConfiguration(calcConfig2);
    return viewDefinition;
  }

}

@@ -1564,16 +1564,26 @@
  //TODO 
+PLAT-1126 
 ValuePro
@@ -2628,16 +2628,18 @@
 aints);%0A
+  
   //TODO
@@ -2639,16 +2639,26 @@
  //TODO 
+PLAT-1126 
 calcConf

Mark PLAT-1126