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

import static com.opengamma.web.WebResourceTestUtils.assertJSONObjectEquals;
import static com.opengamma.web.WebResourceTestUtils.loadJson;
import static org.testng.AssertJUnit.assertNotNull;

import java.util.Collections;

import javax.ws.rs.core.MultivaluedMap;

import org.apache.commons.lang.StringUtils;
import org.json.JSONObject;
import org.testng.annotations.Test;

import com.opengamma.util.test.TestGroup;

/**
 * Test {@link WebSecuritiesResource}.
 */
@Test(groups = TestGroup.UNIT)
public class WebSecuritiesResourceTest extends AbstractWebSecurityResourceTestCase {

  public void testGetMetaDataJSON() throws Exception {
    String metaDataJSON = _webSecuritiesResource.getMetaDataJSON(null);
    assertNotNull(metaDataJSON);
    JSONObject actualJson = new JSONObject(metaDataJSON); 
    assertJSONObjectEquals(loadJson("com/opengamma/web/security/securitiesMetaDataJson.txt"), actualJson);
  }

  public void testGetAllSecurities() throws Exception {
    MultivaluedMap<String, String> queryParameters = _uriInfo.getQueryParameters();
    queryParameters.putSingle("name", StringUtils.EMPTY);
    queryParameters.putSingle("identifier", StringUtils.EMPTY);
    queryParameters.putSingle("type", StringUtils.EMPTY);
    queryParameters.put("securityId", Collections.<String>emptyList());
    
    String resultJson = _webSecuritiesResource.getJSON(null, null, null, null, null, 
        queryParameters.getFirst("name"), queryParameters.getFirst("identifier"), 
        queryParameters.getFirst("type"), queryParameters.get("securityId"), _uriInfo);
    assertNotNull(resultJson);
    assertJSONObjectEquals(loadJson("com/opengamma/web/security/allSecuritiesJson.txt"), new JSONObject(resultJson));
  }

}

@@ -391,16 +391,64 @@
 ections;
+%0Aimport java.util.HashMap;%0Aimport java.util.Map;
 %0A%0Aimport
@@ -1048,85 +1048,440 @@
 als(
-loadJson(%22com/opengamma/web/security/secu
+expectedSecurityTypes(), actualJson);%0A  %7D%0A%0A  private JSONObject expectedSecurityTypes() %7B%0A    SecurityTypesDescriptionProvider s_secTypesProvider = SecurityTypesDesc
 ri
+p
 ti
-esMetaDataJson.txt%22), actualJson
+onProvider.getInstance();%0A    Map%3CString, Object%3E result = new HashMap%3C%3E();%0A    result.put(%22description2type%22, s_secTypesProvider.getDescription2Type());%0A    result.put(%22types%22, s_secTypesProvider.getDescription2Type().values());%0A    return new JSONObject(result
 );%0A 

Fix test as security types now based on anotated classes rather than securities in security master