text:
using namespace mtconnect;
using namespace mtconnect::source::adapter;
using namespace mtconnect::pipeline;
using namespace mtconnect::observation;
using namespace mtconnect::entity;
using namespace std;
using namespace std::literals;
using namespace std::chrono_literals;
using namespace mtconnect::sink::rest_sink;

using TransformFun = std::function<const EntityPtr(const EntityPtr entity)>;
class TestTransform : public Transform
{
public:
  TestTransform(const std::string &name, TransformFun fun, Guard guard)
    : Transform(name), m_function(fun)
  {
    m_guard = guard;
  }
  TestTransform(const std::string &name, Guard guard) : Transform(name) { m_guard = guard; }
  TestTransform(const std::string &name) : Transform(name) {}

  const EntityPtr operator()(const EntityPtr ptr) override { return m_function(ptr); }

  void setGuard(Guard &guard) { m_guard = guard; }
  TransformFun m_function;
};
using TestTransformPtr = shared_ptr<TestTransform>;

class TestPipeline : public Pipeline
{
public:
  using Pipeline::Pipeline;

  void build(const ConfigOptions &options) override {}

  TransformPtr getStart() { return m_start; }
};

class PipelineEditTest : public testing::Test
{
protected:
  void SetUp() override
  {
    boost::asio::io_context::strand strand(m_ioContext);
    m_pipeline = make_unique<TestPipeline>(m_context, strand);

    TestTransformPtr ta = make_shared<TestTransform>("A"s, EntityNameGuard("X", RUN));
    ta->m_function = [ta](const EntityPtr entity) {
      EntityPtr ret = shared_ptr<Entity>(new Entity(*entity));
      ret->setValue(ret->getValue<string>() + "A"s);
      return ta->next(ret);
    };

    TestTransformPtr tb = make_shared<TestTransform>("B"s, EntityNameGuard("X", RUN));
    tb->m_function = [tb](const EntityPtr entity) {
      EntityPtr ret = shared_ptr<Entity>(new Entity(*entity));
      ret->setValue(ret->getValue<string>() + "B"s);
      return tb->next(ret);
    };

    TestTransformPtr tc = make_shared<TestTransform>("C"s, EntityNameGuard("X", RUN));
    tc->m_function = [](const EntityPtr entity) {
      EntityPtr ret = shared_ptr<Entity>(new Entity(*entity));
      ret->setValue(ret->getValue<string>() + "C"s);
      return ret;
    };

    m_pipeline->getStart()->bind(ta);
    ta->bind(tb);
    tb->bind(tc);
  }

  void TearDown() override
  {
    m_pipeline.reset();
    m_context.reset();
  }

  boost::asio::io_context m_ioContext;
  PipelineContextPtr m_context;
  std::unique_ptr<TestPipeline> m_pipeline;
};

TEST_F(PipelineEditTest, run_three_transforms)
{
  auto entity = shared_ptr<Entity>(new Entity("X", Properties {{"VALUE", "S"s}}));
  auto result = m_pipeline->run(entity);

  ASSERT_EQ("SABC", result->getValue<string>());
}

TEST_F(PipelineEditTest, insert_R_before_B)
{
  TestTransformPtr tr = make_shared<TestTransform>("R"s, EntityNameGuard("X", RUN));
  tr->m_function = [&tr](const EntityPtr entity) {
    EntityPtr ret = shared_ptr<Entity>(new Entity(*entity));
    ret->setValue(ret->getValue<string>() + "R"s);
    return tr->next(ret);
  };

  ASSERT_TRUE(m_pipeline->spliceBefore("B", tr));

  auto entity = shared_ptr<Entity>(new Entity("X", Properties {{"VALUE", "S"s}}));
  auto result = m_pipeline->run(entity);

  ASSERT_EQ("SARBC", result->getValue<string>());
}

TEST_F(PipelineEditTest, insert_R_after_B)
{
  TestTransformPtr tr = make_shared<TestTransform>("R"s, EntityNameGuard("X", RUN));
  tr->m_function = [&tr](const EntityPtr entity) {
    EntityPtr ret = shared_ptr<Entity>(new Entity(*entity));
    ret->setValue(ret->getValue<string>() + "R"s);
    return tr->next(ret);
  };

  ASSERT_TRUE(m_pipeline->spliceAfter("B", tr));

  auto entity = shared_ptr<Entity>(new Entity("X", Properties {{"VALUE", "S"s}}));
  auto result = m_pipeline->run(entity);

  ASSERT_EQ("SABRC", result->getValue<string>());
}

TEST_F(PipelineEditTest, append_R_first_after_B)
{
  TestTransformPtr tr = make_shared<TestTransform>("R"s, EntityNameGuard("X", RUN));
  tr->m_function = [](const EntityPtr entity) {
    EntityPtr ret = shared_ptr<Entity>(new Entity(*entity));
    ret->setValue(ret->getValue<string>() + "R"s);
    return ret;
  };

  ASSERT_TRUE(m_pipeline->firstAfter("B", tr));

  auto entity = shared_ptr<Entity>(new Entity("X", Properties {{"VALUE", "S"s}}));
  auto result = m_pipeline->run(entity);

  ASSERT_EQ("SABR", result->getValue<string>());
}

TEST_F(PipelineEditTest, append_R_last_after_B)
{
  TestTransformPtr tr = make_shared<TestTransform>("R"s, EntityNameGuard("X", RUN));
  tr->m_function = [](const EntityPtr entity) {
    EntityPtr ret = shared_ptr<Entity>(new Entity(*entity));
    ret->setValue(ret->getValue<string>() + "R"s);
    return ret;
  };

  ASSERT_TRUE(m_pipeline->lastAfter("B"s, tr));

  auto entity = shared_ptr<Entity>(new Entity("X", Properties {{"VALUE", "S"s}}));
  auto result = m_pipeline->run(entity);

  ASSERT_EQ("SABC", result->getValue<string>());
}


text:
typedef int (*Func) (const void*);
#define CALL(p, m) (((Func)((*p)->m))(p))
// Check if the function return an expected number.
#define CHECK(n, p, m) check(n, CALL(p, m), #m)

typedef void (*CheckFunc) (int, int, const char*);

void CheckEncoderInterface (ISVCEncoder* p, CheckFunc check) {
  CHECK (1, p, Initialize);
  CHECK (2, p, InitializeExt);
  CHECK (3, p, GetDefaultParams);
  CHECK (4, p, Uninitialize);
  CHECK (5, p, EncodeFrame);
  CHECK (6, p, EncodeParameterSets);
  CHECK (7, p, ForceIntraFrame);
  CHECK (8, p, SetOption);
  CHECK (9, p, GetOption);
}

void CheckDecoderInterface (ISVCDecoder* p, CheckFunc check) {
  CHECK (1, p, Initialize);
  CHECK (2, p, Uninitialize);
  CHECK (3, p, DecodeFrame);
  CHECK (4, p, DecodeFrameNoDelay);
  CHECK (5, p, DecodeFrame2);
  CHECK (6, p, DecodeFrameEx);
  CHECK (7, p, DecodeParser);
  CHECK (8, p, SetOption);
  CHECK (9, p, GetOption);
  CHECK (10, p, FlushFrame);
}

struct bool_test_struct {
  char c;
  bool b;
};

size_t GetBoolSize (void) {
  return sizeof (bool);
}

size_t GetBoolOffset (void) {
  return offsetof (struct bool_test_struct, b);
}

size_t GetBoolStructSize (void) {
  return sizeof (struct bool_test_struct);
}

redpajama_set_name: RedPajamaGithub


text:
source $HOME/.rvm/scripts/rvm && source .rvmrc

# install bundler if necessary
gem list --local bundler | grep bundler || gem install bundler || exit 1

# debugging info
echo USER=$USER && ruby --version && which ruby && which bundle

# conditionally install project gems from Gemfile
bundle check || bundle install || exit 1

test -e config/database.yml || (test -e config/database.yml.example && cp config/database.yml.example config/database.yml)
test -e config/database.yml || (test -e config/database.example.yml && cp config/database.example.yml config/database.yml)

RAILS_ENV=development rake db:version > /dev/null || rake db:create
RAILS_ENV=test rake db:version  > /dev/null || rake db:create

RAILS_ENV=development rake db:migrate test:prepare

rake default


text:
window.require = function (file, cwd) {
    var resolved = require.resolve(file, cwd || '/');
    var mod = require.modules[resolved];
    if (!mod) throw new Error(
        'Failed to resolve module ' + file + ', tried ' + resolved
    );
    var res = mod._cached ? mod._cached : mod();
    return res;
}

require.paths = [];
require.modules = {};

require._core = {
    'assert': true,
    'events': true,
    'fs': true,
    'path': true,
    'vm': true
};

require.resolve = (function () {
    return function (x, cwd) {
        if (!cwd) cwd = '/';

        if (require._core[x]) return x;
        var path = require.modules.path();
        cwd = path.resolve('/', cwd);
        var y = cwd || '/';

        if (x.match(/^(?:\.\.?\/|\/)/)) {
            var m = loadAsFileSync(path.resolve(y, x))
                || loadAsDirectorySync(path.resolve(y, x));
            if (m) return m;
        }

        var n = loadNodeModulesSync(x, y);
        if (n) return n;

        throw new Error("Cannot find module '" + x + "'");

        function matchWithModules (x) {
            var moduleNames = Object.keys(require.modules);
            for (var i = 0; i < moduleNames.length; i++) {
                if (moduleNames[i].indexOf(x) === 0) {
                    return moduleNames[i];
                }
            }
            return false;
        }

        function loadAsFileSync (x) {
            if (require.modules[x] || (x = matchWithModules(x))) {
                return x;
            }
        }

        function loadAsDirectorySync (x) {
            x = x.replace(/\/+$/, '');
            return loadAsFileSync(x + '/index');
        }

        function loadNodeModulesSync (x, start) {
            var dirs = nodeModulesPathsSync(start);
            for (var i = 0; i < dirs.length; i++) {
                var dir = dirs[i];
                var m = loadAsFileSync(dir + '/' + x);
                if (m) return m;
                var n = loadAsDirectorySync(dir + '/' + x);
                if (n) return n;
            }

            var m = loadAsFileSync(x);
            if (m) return m;
        }

        function nodeModulesPathsSync (start) {
            var parts;
            if (start === '/') parts = [ '' ];
            else parts = path.normalize(start).split('/');

            var dirs = [];
            for (var i = parts.length - 1; i >= 0; i--) {
                if (parts[i] === 'node_modules') continue;
                var dir = parts.slice(0, i + 1).join('/') + '/node_modules';
                dirs.push(dir);
            }

            return dirs;
        }
    };
})();

require.alias = function (from, to) {
    var path = require.modules.path();
    var res = null;
    try {
        res = require.resolve(from + '/package.json', '/');
    }
    catch (err) {
        res = require.resolve(from, '/');
    }
    var basedir = path.dirname(res);

    var keys = (Object.keys || function (obj) {
        var res = [];
        for (var key in obj) res.push(key)
        return res;
    })(require.modules);

    for (var i = 0; i < keys.length; i++) {
        var key = keys[i];
        if (key.slice(0, basedir.length + 1) === basedir + '/') {
            var f = key.slice(basedir.length);
            require.modules[to + f] = require.modules[basedir + f];
        }
        else if (key === basedir) {
            require.modules[to] = require.modules[basedir];
        }
    }
};

require.define = function (filename, fn) {
    var dirname = require._core[filename]
        ? ''
        : require.modules.path().dirname(filename)
    ;

    var require_ = function (file) {
        return require(file, dirname)
    };
    require_.resolve = function (name) {
        return require.resolve(name, dirname);
    };
    require_.modules = require.modules;
    require_.define = require.define;
    var module_ = { exports : {} };

    require.modules[filename] = function () {
        require.modules[filename]._cached = module_.exports;
        fn.call(
            module_.exports,
            require_,
            module_,
            module_.exports,
            dirname,
            filename
        );
        require.modules[filename]._cached = module_.exports;
        return module_.exports;
    };
};

if (typeof process === 'undefined') process = {};

if (!process.nextTick) process.nextTick = (function () {
    var queue = [];
    var canPost = typeof window !== 'undefined'
        && window.postMessage && window.addEventListener
    ;

    if (canPost) {
        window.addEventListener('message', function (ev) {
            if (ev.source === window && ev.data === 'browserify-tick') {
                ev.stopPropagation();
                if (queue.length > 0) {
                    var fn = queue.shift();
                    fn();
                }
            }
        }, true);
    }

    return function (fn) {
        if (canPost) {
            queue.push(fn);
            window.postMessage('browserify-tick', '*');
        }
        else setTimeout(fn, 0);
    };
})();

if (!process.title) process.title = 'browser';

if (!process.binding) process.binding = function (name) {
    if (name === 'evals') return require('vm')
    else throw new Error('No such module')
};

if (!process.cwd) process.cwd = function () { return '.' };

require.define("path", function (require, module, exports, __dirname, __filename) {
function filter (xs, fn) {
    var res = [];
    for (var i = 0; i < xs.length; i++) {
        if (fn(xs[i], i, xs)) res.push(xs[i]);
    }
    return res;
}

// resolves . and .. elements in a path array with directory names there
// must be no slashes, empty elements, or device names (c:\) in the array
// (so also no leading and trailing slashes - it does not distinguish
// relative and absolute paths)
function normalizeArray(parts, allowAboveRoot) {
  // if the path tries to go above the root, `up` ends up > 0
  var up = 0;
  for (var i = parts.length; i >= 0; i--) {
    var last = parts[i];
    if (last == '.') {
      parts.splice(i, 1);
    } else if (last === '..') {
      parts.splice(i, 1);
      up++;
    } else if (up) {
      parts.splice(i, 1);
      up--;
    }
  }

  // if the path is allowed to go above the root, restore leading ..s
  if (allowAboveRoot) {
    for (; up--; up) {
      parts.unshift('..');
    }
  }

  return parts;
}

// Regex to split a filename into [*, dir, basename, ext]
// posix version
var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/;

// path.resolve([from ...], to)
// posix version
exports.resolve = function() {
var resolvedPath = '',
    resolvedAbsolute = false;

for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {
  var path = (i >= 0)
      ? arguments[i]
      : process.cwd();

  // Skip empty and invalid entries
  if (typeof path !== 'string' || !path) {
    continue;
  }

  resolvedPath = path + '/' + resolvedPath;
  resolvedAbsolute = path.charAt(0) === '/';
}

// At this point the path should be resolved to a full absolute path, but
// handle relative paths to be safe (might happen when process.cwd() fails)

// Normalize the path
resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
    return !!p;
  }), !resolvedAbsolute).join('/');

  return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
};

// path.normalize(path)
// posix version
exports.normalize = function(path) {
var isAbsolute = path.charAt(0) === '/',
    trailingSlash = path.slice(-1) === '/';

// Normalize the path
path = normalizeArray(filter(path.split('/'), function(p) {
    return !!p;
  }), !isAbsolute).join('/');

  if (!path && !isAbsolute) {
    path = '.';
  }
  if (path && trailingSlash) {
    path += '/';
  }

  return (isAbsolute ? '/' : '') + path;
};

// posix version
exports.join = function() {
  var paths = Array.prototype.slice.call(arguments, 0);
  return exports.normalize(filter(paths, function(p, index) {
    return p && typeof p === 'string';
  }).join('/'));
};

exports.dirname = function(path) {
  var dir = splitPathRe.exec(path)[1] || '';
  var isWindows = false;
  if (!dir) {
    // No dirname
    return '.';
  } else if (dir.length === 1 ||
      (isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {
    // It is just a slash or a drive letter with a slash
    return dir;
  } else {
    // It is a full dirname, strip trailing slash
    return dir.substring(0, dir.length - 1);
  }
};

exports.basename = function(path, ext) {
  var f = splitPathRe.exec(path)[2] || '';
  // TODO: make this comparison case-insensitive on windows?
  if (ext && f.substr(-1 * ext.length) === ext) {
    f = f.substr(0, f.length - ext.length);
  }
  return f;
};

exports.extname = function(path) {
  return splitPathRe.exec(path)[3] || '';
};

});


text:
package com.datatorrent.stram.debug;

import java.io.*;
import java.util.ArrayList;
import org.junit.Assert;

import org.codehaus.jackson.map.ObjectMapper;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.LocalFileSystem;
import org.apache.hadoop.fs.Path;

import com.datatorrent.api.Context;
import com.datatorrent.common.util.AsyncFSStorageAgent;
import com.datatorrent.stram.engine.StreamingContainer;
import com.datatorrent.stram.StramLocalCluster;
import com.datatorrent.stram.debug.TupleRecorder.PortInfo;
import com.datatorrent.stram.engine.GenericTestOperator;
import com.datatorrent.stram.engine.TestGeneratorInputOperator;
import com.datatorrent.stram.plan.logical.LogicalPlan;
import com.datatorrent.stram.plan.physical.PTOperator;
import com.datatorrent.stram.support.StramTestSupport;
import com.datatorrent.stram.support.StramTestSupport.WaitCondition;
import com.datatorrent.stram.util.FSPartFileCollection;
import org.codehaus.jettison.json.JSONObject;

/**
 *
 */
public class TupleRecorderTest
{
  private final String classname;

  @Before
  public void setup() throws IOException
  {
    StreamingContainer.eventloop.start();
  }

  @After
  public void teardown()
  {
    StreamingContainer.eventloop.stop();
  }

  public TupleRecorderTest()
  {
    classname = "com.datatorrent.stram.debug.TupleRecorderCollection";
  }

  public TupleRecorder getTupleRecorder(final StramLocalCluster localCluster, final PTOperator op)
  {
    TupleRecorderCollection instance = (TupleRecorderCollection)localCluster.getContainer(op).getInstance(classname);
    return instance.getTupleRecorder(op.getId(), null);
  }

  public class Tuple
  {
    public String key;
    public String value;
  }

  @Test
  public void testRecorder() throws IOException
  {
    try (FileSystem fs = new LocalFileSystem()) {
      TupleRecorder recorder = new TupleRecorder(null, "application_test_id_1");
      recorder.getStorage().setBytesPerPartFile(4096);
      recorder.getStorage().setLocalMode(true);
      recorder.getStorage().setBasePath("file://" + testWorkDir.getAbsolutePath() + "/recordings");

      recorder.addInputPortInfo("ip1", "str1");
      recorder.addInputPortInfo("ip2", "str2");
      recorder.addInputPortInfo("ip3", "str3");
      recorder.addOutputPortInfo("op1", "str4");
      recorder.setup(null, null);

      recorder.beginWindow(1000);
      recorder.beginWindow(1000);
      recorder.beginWindow(1000);

      Tuple t1 = new Tuple();
      t1.key = "speed";
      t1.value = "5m/h";
      recorder.writeTuple(t1, "ip1");
      recorder.endWindow();
      Tuple t2 = new Tuple();
      t2.key = "speed";
      t2.value = "4m/h";
      recorder.writeTuple(t2, "ip3");
      recorder.endWindow();
      Tuple t3 = new Tuple();
      t3.key = "speed";
      t3.value = "6m/h";
      recorder.writeTuple(t3, "ip2");
      recorder.endWindow();

      recorder.beginWindow(1000);
      Tuple t4 = new Tuple();
      t4.key = "speed";
      t4.value = "2m/h";
      recorder.writeTuple(t4, "op1");
      recorder.endWindow();
      recorder.teardown();

      fs.initialize((new Path(recorder.getStorage().getBasePath()).toUri()), new Configuration());
      Path path;
      String line;

      path = new Path(recorder.getStorage().getBasePath(), FSPartFileCollection.INDEX_FILE);
      try (FSDataInputStream is = fs.open(path);
          BufferedReader br = new BufferedReader(new InputStreamReader(is))) {

        line = br.readLine();
        //    Assert.assertEquals("check index", "B:1000:T:0:part0.txt", line);
        Assert.assertTrue("check index", line
            .matches("F:part0.txt:\\d+-\\d+:4:T:1000-1000:33:\\{\"3\":\"1\",\"1\":\"1\",\"0\":\"1\",\"2\":\"1\"\\}"));
      }
      path = new Path(recorder.getStorage().getBasePath(), FSPartFileCollection.META_FILE);
      try (FSDataInputStream is = fs.open(path);
          BufferedReader br = new BufferedReader(new InputStreamReader(is))) {

        ObjectMapper mapper = new ObjectMapper();
        line = br.readLine();
        Assert.assertEquals("check version", "1.2", line);
        br.readLine(); // RecordInfo
        //RecordInfo ri = mapper.readValue(line, RecordInfo.class);
        line = br.readLine();
        PortInfo pi = mapper.readValue(line, PortInfo.class);
        Assert.assertEquals("port1", recorder.getPortInfoMap().get(pi.name).id, pi.id);
        Assert.assertEquals("port1", recorder.getPortInfoMap().get(pi.name).type, pi.type);
        line = br.readLine();
        pi = mapper.readValue(line, PortInfo.class);
        Assert.assertEquals("port2", recorder.getPortInfoMap().get(pi.name).id, pi.id);
        Assert.assertEquals("port2", recorder.getPortInfoMap().get(pi.name).type, pi.type);
        line = br.readLine();
        pi = mapper.readValue(line, PortInfo.class);
        Assert.assertEquals("port3", recorder.getPortInfoMap().get(pi.name).id, pi.id);
        Assert.assertEquals("port3", recorder.getPortInfoMap().get(pi.name).type, pi.type);
        line = br.readLine();
        pi = mapper.readValue(line, PortInfo.class);
        Assert.assertEquals("port4", recorder.getPortInfoMap().get(pi.name).id, pi.id);
        Assert.assertEquals("port4", recorder.getPortInfoMap().get(pi.name).type, pi.type);
        Assert.assertEquals("port size", 4, recorder.getPortInfoMap().size());
        //line = br.readLine();
      }
      path = new Path(recorder.getStorage().getBasePath(), "part0.txt");
      try (FSDataInputStream is = fs.open(path);
          BufferedReader br = new BufferedReader(new InputStreamReader(is))) {

        line = br.readLine();
        Assert.assertTrue("check part0", line.startsWith("B:"));
        Assert.assertTrue("check part0", line.endsWith(":1000"));

        line = br.readLine();
        Assert.assertTrue("check part0 1", line.startsWith("T:"));
        Assert.assertTrue("check part0 1", line.endsWith(":0:30:{\"key\":\"speed\",\"value\":\"5m/h\"}"));

        line = br.readLine();
        Assert.assertTrue("check part0 2", line.startsWith("T:"));
        Assert.assertTrue("check part0 2", line.endsWith(":2:30:{\"key\":\"speed\",\"value\":\"4m/h\"}"));

        line = br.readLine();
        Assert.assertTrue("check part0 3", line.startsWith("T:"));
        Assert.assertTrue("check part0 3", line.endsWith(":1:30:{\"key\":\"speed\",\"value\":\"6m/h\"}"));

        line = br.readLine();
        Assert.assertTrue("check part0 4", line.startsWith("T:"));
        Assert.assertTrue("check part0 4", line.endsWith(":3:30:{\"key\":\"speed\",\"value\":\"2m/h\"}"));

        line = br.readLine();
        Assert.assertTrue("check part0 5", line.startsWith("E:"));
        Assert.assertTrue("check part0 5", line.endsWith(":1000"));
      }
    } catch (IOException ex) {
      throw new RuntimeException(ex);
    }
  }

  private static final File testWorkDir = new File("target", TupleRecorderTest.class.getName());
  private static final int testTupleCount = 10;

  @Test
  public void testRecordingFlow() throws Exception
  {
    LogicalPlan dag = new LogicalPlan();
    dag.setAttribute(Context.OperatorContext.STORAGE_AGENT, new AsyncFSStorageAgent(testWorkDir.getAbsolutePath(), null));

    dag.getAttributes().put(LogicalPlan.APPLICATION_PATH, "file://" + testWorkDir.getAbsolutePath());
    dag.getAttributes().put(LogicalPlan.TUPLE_RECORDING_PART_FILE_SIZE, 1024);  // 1KB per part

    TestGeneratorInputOperator op1 = dag.addOperator("op1", TestGeneratorInputOperator.class);
    GenericTestOperator op2 = dag.addOperator("op2", GenericTestOperator.class);
    GenericTestOperator op3 = dag.addOperator("op3", GenericTestOperator.class);

    op1.setEmitInterval(100); // emit every 100 msec
    dag.addStream("stream1", op1.outport, op2.inport1);//.setInline(true);
    dag.addStream("stream2", op2.outport1, op3.inport1);//.setInline(true);

    final StramLocalCluster localCluster = new StramLocalCluster(dag);
    localCluster.runAsync();

    final PTOperator ptOp2 = localCluster.findByLogicalNode(dag.getMeta(op2));
    StramTestSupport.waitForActivation(localCluster, ptOp2);

    testRecordingOnOperator(localCluster, ptOp2);

    final PTOperator ptOp1 = localCluster.findByLogicalNode(dag.getMeta(op1));
    StramTestSupport.waitForActivation(localCluster, ptOp1);

    testRecordingOnOperator(localCluster, ptOp1);

    localCluster.shutdown();
  }

  private void testRecordingOnOperator(final StramLocalCluster localCluster, final PTOperator op) throws Exception
  {
    String id = "xyz";
    localCluster.getStreamingContainerManager().startRecording(id, op.getId(), null, 0);

    WaitCondition c = new WaitCondition()
    {
      @Override
      public boolean isComplete()
      {
        return null != getTupleRecorder(localCluster, op);
      }

    };
    Assert.assertTrue("Should get a tuple recorder within 10 seconds", StramTestSupport.awaitCompletion(c, 10000));
    final TupleRecorder tupleRecorder = getTupleRecorder(localCluster, op);
    long startTime = tupleRecorder.getStartTime();
    String line;
    File dir = new File(testWorkDir, "recordings/" + op.getId() + "/" + id);
    File file;

    file = new File(dir, FSPartFileCollection.META_FILE);
    Assert.assertTrue("meta file should exist", file.exists());
    int numPorts = tupleRecorder.getSinkMap().size();

    try (BufferedReader br = new BufferedReader(new FileReader(file))) {
      line = br.readLine();
      Assert.assertEquals("version should be 1.2", "1.2", line);
      line = br.readLine();
      JSONObject json = new JSONObject(line);
      Assert.assertEquals("Start time verification", startTime, json.getLong("startTime"));
      Assert.assertTrue(numPorts > 0);

      for (int i = 0; i < numPorts; i++) {
        line = br.readLine();
        Assert.assertTrue("should contain name, streamName, type and id", line != null && line
            .contains("\"name\"") && line.contains("\"streamName\"") && line.contains("\"type\"") && line
            .contains("\"id\""));
      }
    }

    c = new WaitCondition()
    {
      @Override
      public boolean isComplete()
      {
        return (tupleRecorder.getTotalTupleCount() >= testTupleCount);
      }

    };

    Assert.assertTrue("Should record more than " + testTupleCount + " tuples within 15 seconds", StramTestSupport.awaitCompletion(c, 15000));

    localCluster.getStreamingContainerManager().stopRecording(op.getId(), null);
    c = new WaitCondition()
    {
      @Override
      public boolean isComplete()
      {
        TupleRecorder tupleRecorder = getTupleRecorder(localCluster, op);
        return (tupleRecorder == null);
      }

    };
    Assert.assertTrue("Tuple recorder shouldn't exist any more after stopping", StramTestSupport.awaitCompletion(c, 5000));

    file = new File(dir, FSPartFileCollection.INDEX_FILE);
    Assert.assertTrue("index file should exist", file.exists());

    ArrayList<String> partFiles = new ArrayList<>();
    int indexCount = 0;
    try (BufferedReader br = new BufferedReader(new FileReader(file))) {
      while ((line = br.readLine()) != null) {
        String partFile = "part" + indexCount + ".txt";
        if (line.startsWith("F:" + partFile + ":")) {
          partFiles.add(partFile);
          indexCount++;
        } else if (line.startsWith("E")) {
          Assert.assertEquals("index file should end after E line", br.readLine(), null);
          break;
        } else {
          Assert.fail("index file line is not starting with F or E");
        }
      }
    }

    int tupleCount[] = new int[numPorts];
    boolean beginWindowExists = false;
    boolean endWindowExists = false;

    for (String partFile : partFiles) {
      file = new File(dir, partFile);
      if (!partFile.equals(partFiles.get(partFiles.size() - 1))) {
        Assert.assertTrue(partFile + " should be greater than 1KB", file.length() >= 1024);
      }
      Assert.assertTrue(partFile + " should exist", file.exists());
      try (BufferedReader br = new BufferedReader(new FileReader(file))) {
        while ((line = br.readLine()) != null) {
          if (line.startsWith("B:")) {
            beginWindowExists = true;
          } else if (line.startsWith("E:")) {
            endWindowExists = true;
          } else if (line.startsWith("T:")) {
            String[] parts = line.split(":");
            tupleCount[Integer.valueOf(parts[2])]++;
          }
        }
      }
    }
    Assert.assertTrue("begin window should exist", beginWindowExists);
    Assert.assertTrue("end window should exist", endWindowExists);
    int sum = 0;
    for (int i = 0; i < numPorts; i++) {
      Assert.assertTrue("tuple exists for port " + i, tupleCount[i] > 0);
      sum += tupleCount[i];
    }
    Assert.assertTrue("total tuple count >= " + testTupleCount, sum >= testTupleCount);
  }

  private static final Logger logger = LoggerFactory.getLogger(TupleRecorderTest.class);
}


text:
import string

def split_embiggen_sort(sentence):
    '''
    takes a string and removes punctuation
    splits it into a list of individual words,
    converts them to uppercase and
    sorts them in descending order
    '''
    all_converted = embiggen(sentence)
    all_converted = stripper3(all_converted)
    all_converted = divide_at_spaces(all_converted)
    all_converted = big_to_little(all_converted)

    return all_converted

def stripper3(sentence):
    '''
    takes a string as input and removes punctuation using list comprehension
    returns a string
    '''
    res = "".join([x for x in sentence if x not in string.punctuation])
    return res

def embiggen(sentence):
    '''
    convert a string to uppercase and
    returns a string
    '''
    assert(type(sentence) is str)
    converted = sentence.upper()
    return converted

def divide_at_spaces(sentence):
    '''
    takes a string as input
    splits the string at space characters and
    returns a list of strings
    '''
    assert(type(sentence) is str)
    chopped = sentence.split()
    return chopped

def big_to_little(bits):
    '''
    sorts a list of words from longest to shortest and return a list
    '''
    assert(type(bits) is list)
    bits.sort(key=len)
    return bits


text:
package com.amazonaws.services.codebuild.model.transform;

import java.math.*;

import javax.annotation.Generated;

import com.amazonaws.services.codebuild.model.*;
import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*;
import com.amazonaws.transform.*;

import com.fasterxml.jackson.core.JsonToken;
import static com.fasterxml.jackson.core.JsonToken.*;

/**
 * BuildBatchPhase JSON Unmarshaller
 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class BuildBatchPhaseJsonUnmarshaller implements Unmarshaller<BuildBatchPhase, JsonUnmarshallerContext> {

    public BuildBatchPhase unmarshall(JsonUnmarshallerContext context) throws Exception {
        BuildBatchPhase buildBatchPhase = new BuildBatchPhase();

        int originalDepth = context.getCurrentDepth();
        String currentParentElement = context.getCurrentParentElement();
        int targetDepth = originalDepth + 1;

        JsonToken token = context.getCurrentToken();
        if (token == null)
            token = context.nextToken();
        if (token == VALUE_NULL) {
            return null;
        }

        while (true) {
            if (token == null)
                break;

            if (token == FIELD_NAME || token == START_OBJECT) {
                if (context.testExpression("phaseType", targetDepth)) {
                    context.nextToken();
                    buildBatchPhase.setPhaseType(context.getUnmarshaller(String.class).unmarshall(context));
                }
                if (context.testExpression("phaseStatus", targetDepth)) {
                    context.nextToken();
                    buildBatchPhase.setPhaseStatus(context.getUnmarshaller(String.class).unmarshall(context));
                }
                if (context.testExpression("startTime", targetDepth)) {
                    context.nextToken();
                    buildBatchPhase.setStartTime(DateJsonUnmarshallerFactory.getInstance("unixTimestamp").unmarshall(context));
                }
                if (context.testExpression("endTime", targetDepth)) {
                    context.nextToken();
                    buildBatchPhase.setEndTime(DateJsonUnmarshallerFactory.getInstance("unixTimestamp").unmarshall(context));
                }
                if (context.testExpression("durationInSeconds", targetDepth)) {
                    context.nextToken();
                    buildBatchPhase.setDurationInSeconds(context.getUnmarshaller(Long.class).unmarshall(context));
                }
                if (context.testExpression("contexts", targetDepth)) {
                    context.nextToken();
                    buildBatchPhase.setContexts(new ListUnmarshaller<PhaseContext>(PhaseContextJsonUnmarshaller.getInstance())

                    .unmarshall(context));
                }
            } else if (token == END_ARRAY || token == END_OBJECT) {
                if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) {
                    if (context.getCurrentDepth() <= originalDepth)
                        break;
                }
            }
            token = context.nextToken();
        }

        return buildBatchPhase;
    }

    private static BuildBatchPhaseJsonUnmarshaller instance;

    public static BuildBatchPhaseJsonUnmarshaller getInstance() {
        if (instance == null)
            instance = new BuildBatchPhaseJsonUnmarshaller();
        return instance;
    }
}


text:
package com.mb3364.twitch.api.models;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public class Ingests {

    private List<Ingest> ingests;

    @Override
    public String toString() {
        return "Ingests{" +
                "ingests=" + ingests +
                '}';
    }

    public List<Ingest> getIngests() {
        return ingests;
    }

    public void setIngests(List<Ingest> ingests) {
        this.ingests = ingests;
    }
}


text:
package org.mafagafogigante.dungeon.world;

import org.mafagafogigante.dungeon.entity.creatures.Observer;
import org.mafagafogigante.dungeon.io.Version;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;

/**
 * A collection of visibility criterion.
 */
public class VisibilityCriteria implements Serializable {

  private static final long serialVersionUID = Version.MAJOR;
  private final List<VisibilityCriterion> visibilityCriteria;

  public VisibilityCriteria(VisibilityCriterion... visibilityCriteria) {
    this.visibilityCriteria = Arrays.asList(visibilityCriteria);
  }

  /**
   * Evaluates whether or not these visibility criteria is met by an observer.
   */
  public boolean isMetBy(Observer observer) {
    for (VisibilityCriterion criterion : visibilityCriteria) {
      if (!criterion.isMetBy(observer)) {
        return false;
      }
    }
    return true;
  }

  @Override
  public String toString() {
    return "visibilityCriteria=VisibilityCriteria{" + visibilityCriteria + '}';
  }

}