<commit_before>package com.opengamma.web.server.push;

import com.opengamma.id.UniqueId;
import com.opengamma.web.server.WebGridCell;
import com.opengamma.web.server.push.rest.ViewportDefinitionReader;
import org.testng.annotations.Test;

import java.io.IOException;
import java.util.Set;
import java.util.SortedMap;

import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertTrue;

/**
 *
 */
public class ViewportDefinitionTest {

  // TODO this need to be moved
  @Test
  public void isReadable() {
    ViewportDefinitionReader reader = new ViewportDefinitionReader();
    assertTrue(reader.isReadable(ViewportDefinition.class, null, null, null));
    // a random other class that shouldn't be readable
    assertFalse(reader.isReadable(Viewport.class, null, null, null));
  }

  // TODO why does this take so long to run?
  @Test
  public void fromJSON() throws IOException {
    String json = "{" +
        "\"viewDefinitionName\": \"testViewDefName\", " +
        "\"marketDataType\": \"snapshot\", " +
        "\"snapshotId\": \"Tst~123\", " +
        "\"portfolioViewport\": {" +
        "\"rowIds\": [3, 4, 5], " +
        "\"lastTimestamps\": [12345678, 12345679, 12345680], " +
        "\"dependencyGraphCells\": [[3, 1], [3, 2], [4, 3]]" +
        "}, " +
        "\"primitiveViewport\": {" +
        "\"rowIds\": [5, 6, 7], " +
        "\"lastTimestamps\": [12345681, 12345682, 12345683], " +
        "\"dependencyGraphCells\": [[5, 1], [5, 2], [7, 3]]" +
        "}" +
        "}";
    ViewportDefinition viewportDefinition = ViewportDefinition.fromJSON(json);
<commit_msg>[PLAT-1515] Get analytics as CSV<commit_after>package com.opengamma.web.server.push;

import com.opengamma.id.UniqueId;
import com.opengamma.web.server.WebGridCell;
import com.opengamma.web.server.push.rest.ViewportDefinitionReader;
import org.testng.annotations.Test;

import java.io.IOException;
import java.util.Set;
import java.util.SortedMap;

import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertTrue;

/**
 *
 */
public class ViewportDefinitionTest {

  // TODO this need to be moved
  @Test
  public void isReadable() {
    ViewportDefinitionReader reader = new ViewportDefinitionReader();
    assertTrue(reader.isReadable(ViewportDefinition.class, null, null, null));
    // a random other class that shouldn't be readable
    assertFalse(reader.isReadable(Viewport.class, null, null, null));
  }

  @Test
  public void fromJSON() throws IOException {
    String json = "{" +
        "\"viewDefinitionName\": \"testViewDefName\", " +
        "\"marketDataType\": \"snapshot\", " +
        "\"snapshotId\": \"Tst~123\", " +
        "\"portfolioViewport\": {" +
        "\"rowIds\": [3, 4, 5], " +
        "\"lastTimestamps\": [12345678, 12345679, 12345680], " +
        "\"dependencyGraphCells\": [[3, 1], [3, 2], [4, 3]]" +
        "}, " +
        "\"primitiveViewport\": {" +
        "\"rowIds\": [5, 6, 7], " +
        "\"lastTimestamps\": [12345681, 12345682, 12345683], " +
        "\"dependencyGraphCells\": [[5, 1], [5, 2], [7, 3]]" +
        "}" +
        "}";
    ViewportDefinition viewportDefinition = ViewportDefinition.fromJSON(json);

{'fraction_non_alphanumeric': 0.16121495327102803, 'fraction_numerical': 0.04147196261682243, 'mean_word_length': 3.3575063613231553, 'pattern_counts': {'":': 22, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6651498', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1088, 'n_words': 233}