<commit_before>package com.continuuity.gateway.tools;

import com.continuuity.common.conf.CConfiguration;
import com.continuuity.common.conf.Constants;
import com.continuuity.data2.OperationException;
import com.continuuity.gateway.GatewayTestBase;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;
import java.util.concurrent.TimeUnit;

/**
 * Tests the stream client.
 */
public class StreamClientTest extends GatewayTestBase {
  private static final String hostname = "127.0.0.1";
  private static final String AUTH_KEY = GatewayTestBase.getAuthHeader().getValue();

  private static final Logger LOG = LoggerFactory.getLogger(StreamClientTest.class);

  /**
   * This tests the StreamClient command line tool for various combinations of
   * command line arguments. Note that this tool is a command line tool,
   * and it prints stuff on the console. That is not testable with this
   * unit test. Therefore we only test whether it succeeds or fails for
   * certain command line argument.
   *
   * @throws Exception if anything goes wrong
   */
  @Test
  public void testUsage() throws Exception {
    CConfiguration configuration = CConfiguration.create();
    String port = Integer.toString(GatewayTestBase.getPort());

    // argument combinations that should return success
    String[][] goodArgsList = {
        { "--help" }, // print help
        { "create", "--stream", "teststream", "--host", hostname, "--port", port, "--apikey", AUTH_KEY }
    };

    // argument combinations that should lead to failure
    String[][] badArgsList = {
        { },
        { "create", "firststre@m", "--apikey", AUTH_KEY }, // create stream with illegal name
        { "fetch", "--key", "--apikey", AUTH_KEY }, // no key
    };

    // test each good combination
    for (String[] args : goodArgsList) {
      LOG.info("Testing: " + Arrays.toString(args));
      Assert.assertNotNull(new StreamClient().disallowSSL().execute(args, configuration));
    }
    // test each bad combination
    for (String[] args : badArgsList) {
      LOG.info("Testing: " + Arrays.toString(args));
      Assert.assertNull(new StreamClient().disallowSSL().execute(args, configuration));
    }
  }

  @Test
  public void testStreamFetch() throws OperationException {
    String streamId = "fetchstream";<commit_msg>Remove unnecessary unit test for usage message<commit_after>package com.continuuity.gateway.tools;

import com.continuuity.common.conf.CConfiguration;
import com.continuuity.common.conf.Constants;
import com.continuuity.data2.OperationException;
import com.continuuity.gateway.GatewayTestBase;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;
import java.util.concurrent.TimeUnit;

/**
 * Tests the stream client.
 */
public class StreamClientTest extends GatewayTestBase {
  private static final String hostname = "127.0.0.1";
  private static final String AUTH_KEY = GatewayTestBase.getAuthHeader().getValue();

  private static final Logger LOG = LoggerFactory.getLogger(StreamClientTest.class);

  /**
   * This tests the StreamClient command line tool for various combinations of
   * command line arguments. Note that this tool is a command line tool,
   * and it prints stuff on the console. That is not testable with this
   * unit test. Therefore we only test whether it succeeds or fails for
   * certain command line argument.
   *
   * @throws Exception if anything goes wrong
   */
  @Test
  public void testUsage() throws Exception {
    CConfiguration configuration = CConfiguration.create();
    String port = Integer.toString(GatewayTestBase.getPort());

    // argument combinations that should return success
    String[][] goodArgsList = {
        { "create", "--stream", "teststream", "--host", hostname, "--port", port, "--apikey", AUTH_KEY }
    };

    // argument combinations that should lead to failure
    String[][] badArgsList = {
        { },
        { "create", "firststre@m", "--apikey", AUTH_KEY }, // create stream with illegal name
        { "fetch", "--key", "--apikey", AUTH_KEY }, // no key
    };

    // test each good combination
    for (String[] args : goodArgsList) {
      LOG.info("Testing: " + Arrays.toString(args));
      Assert.assertNotNull(new StreamClient().disallowSSL().execute(args, configuration));
    }
    // test each bad combination
    for (String[] args : badArgsList) {
      LOG.info("Testing: " + Arrays.toString(args));
      Assert.assertNull(new StreamClient().disallowSSL().execute(args, configuration));
    }
  }

  @Test
  public void testStreamFetch() throws OperationException {
    String streamId = "fetchstream";
{'fraction_non_alphanumeric': 0.11597558408756051, 'fraction_numerical': 0.003788676068196169, 'mean_word_length': 3.63609756097561, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6891198', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1284, 'n_words': 398}