text:
package fr.imie.util;

import fr.imie.business.Circle;
import fr.imie.business.IShape;
import fr.imie.business.Polygon;
import fr.imie.business.Rectangle;
import fr.imie.business.ShapeType;
import fr.imie.business.Square;
import fr.imie.business.Triangle;

public class ConcreteFActory implements AbstractFactory {

	@Override
	public IShape buildShape(ShapeType shapeType) {
		IShape out = null;
		switch (shapeType) {
		case Square:
			out = new Square();
			break;
		case Rectangle:
			out = new Rectangle();
			break;
		case Circle:
			out = new Circle();
			break;
		case Polygon:
			out = new Polygon();
			break;
		case Triangle:
			out = new Triangle();
			break;
		default:
			break;
		}

		return out;
	}

}


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using MArchive.BL;

namespace MArchive.Web {
	// Note: For instructions on enabling IIS6 or IIS7 classic mode,
	// visit http://go.microsoft.com/?LinkId=9394801

	public class MvcApplication : System.Web.HttpApplication {
		protected void Application_Start( ) {
			AreaRegistration.RegisterAllAreas( );

			WebApiConfig.Register( GlobalConfiguration.Configuration );
			FilterConfig.RegisterGlobalFilters( GlobalFilters.Filters );
			RouteConfig.RegisterRoutes( RouteTable.Routes );
			BundleConfig.RegisterBundles( BundleTable.Bundles );
			BLInitializer.Initialize( );
		}
	}
}

redpajama_set_name: RedPajamaGithub


text:
package org.apache.commons.lang3;

import java.io.IOException;
import java.io.Writer;

import org.apache.commons.lang3.text.translate.AggregateTranslator;
import org.apache.commons.lang3.text.translate.CharSequenceTranslator;
import org.apache.commons.lang3.text.translate.EntityArrays;
import org.apache.commons.lang3.text.translate.JavaUnicodeEscaper;
import org.apache.commons.lang3.text.translate.LookupTranslator;
import org.apache.commons.lang3.text.translate.NumericEntityUnescaper;
import org.apache.commons.lang3.text.translate.OctalUnescaper;
import org.apache.commons.lang3.text.translate.UnicodeUnescaper;

/**
 *
Escapes and unescapes {@code String}s for
 * Java, Java Script, HTML and XML.

 *
 *
#ThreadSafe#

 * @since 2.0
 * @version $Id: StringEscapeUtils.java 1467206 2013-04-12 08:39:02Z bayard $
 */
public class StringEscapeUtils {

    /* ESCAPE TRANSLATORS */

    /**
     * Translator object for escaping Java.
     *
     * While {@link #escapeJava(String)} is the expected method of use, this
     * object allows the Java escaping functionality to be used
     * as the foundation for a custom translator.
     *
     * @since 3.0
     */
    public static final CharSequenceTranslator ESCAPE_JAVA =
          new LookupTranslator(
            new String[][] {
              {"\"", "\\\""},
              {"\\", "\\\\"},
          }).with(
            new LookupTranslator(EntityArrays.JAVA_CTRL_CHARS_ESCAPE())
          ).with(
            JavaUnicodeEscaper.outsideOf(32, 0x7f)
        );

    /**
     * Translator object for escaping EcmaScript/JavaScript.
     *
     * While {@link #escapeEcmaScript(String)} is the expected method of use, this
     * object allows the EcmaScript escaping functionality to be used
     * as the foundation for a custom translator.
     *
     * @since 3.0
     */
    public static final CharSequenceTranslator ESCAPE_ECMASCRIPT =
        new AggregateTranslator(
            new LookupTranslator(
                      new String[][] {
                            {"'", "\\'"},
                            {"\"", "\\\""},
                            {"\\", "\\\\"},
                            {"/", "\\/"}
                      }),
            new LookupTranslator(EntityArrays.JAVA_CTRL_CHARS_ESCAPE()),
            JavaUnicodeEscaper.outsideOf(32, 0x7f)
        );

    /**
     * Translator object for escaping Json.
     *
     * While {@link #escapeJson(String)} is the expected method of use, this
     * object allows the Json escaping functionality to be used
     * as the foundation for a custom translator.
     *
     * @since 3.2
     */
    public static final CharSequenceTranslator ESCAPE_JSON =
        new AggregateTranslator(
            new LookupTranslator(
                      new String[][] {
                            {"\"", "\\\""},
                            {"\\", "\\\\"},
                            {"/", "\\/"}
                      }),
            new LookupTranslator(EntityArrays.JAVA_CTRL_CHARS_ESCAPE()),
            JavaUnicodeEscaper.outsideOf(32, 0x7f)
        );

    /**
     * Translator object for escaping XML.
     *
     * While {@link #escapeXml(String)} is the expected method of use, this
     * object allows the XML escaping functionality to be used
     * as the foundation for a custom translator.
     *
     * @since 3.0
     */
    public static final CharSequenceTranslator ESCAPE_XML =
        new AggregateTranslator(
            new LookupTranslator(EntityArrays.BASIC_ESCAPE()),
            new LookupTranslator(EntityArrays.APOS_ESCAPE())
        );

    /**
     * Translator object for escaping HTML version 3.0.
     *
     * While {@link #escapeHtml3(String)} is the expected method of use, this
     * object allows the HTML escaping functionality to be used
     * as the foundation for a custom translator.
     *
     * @since 3.0
     */
    public static final CharSequenceTranslator ESCAPE_HTML3 =
        new AggregateTranslator(
            new LookupTranslator(EntityArrays.BASIC_ESCAPE()),
            new LookupTranslator(EntityArrays.ISO8859_1_ESCAPE())
        );

    /**
     * Translator object for escaping HTML version 4.0.
     *
     * While {@link #escapeHtml4(String)} is the expected method of use, this
     * object allows the HTML escaping functionality to be used
     * as the foundation for a custom translator.
     *
     * @since 3.0
     */
    public static final CharSequenceTranslator ESCAPE_HTML4 =
        new AggregateTranslator(
            new LookupTranslator(EntityArrays.BASIC_ESCAPE()),
            new LookupTranslator(EntityArrays.ISO8859_1_ESCAPE()),
            new LookupTranslator(EntityArrays.HTML40_EXTENDED_ESCAPE())
        );

    /**
     * Translator object for escaping individual Comma Separated Values.
     *
     * While {@link #escapeCsv(String)} is the expected method of use, this
     * object allows the CSV escaping functionality to be used
     * as the foundation for a custom translator.
     *
     * @since 3.0
     */
    public static final CharSequenceTranslator ESCAPE_CSV = new CsvEscaper();

    // TODO: Create a parent class - 'SinglePassTranslator' ?
    //       It would handle the index checking + length returning,
    //       and could also have an optimization check method.
    static class CsvEscaper extends CharSequenceTranslator {

        private static final char CSV_DELIMITER = ',';
        private static final char CSV_QUOTE = '"';
        private static final String CSV_QUOTE_STR = String.valueOf(CSV_QUOTE);
        private static final char[] CSV_SEARCH_CHARS =
            new char[] {CSV_DELIMITER, CSV_QUOTE, CharUtils.CR, CharUtils.LF};

        @Override
        public int translate(final CharSequence input, final int index, final Writer out) throws IOException {

            if(index != 0) {
                throw new IllegalStateException("CsvEscaper should never reach the [1] index");
            }

            if (StringUtils.containsNone(input.toString(), CSV_SEARCH_CHARS)) {
                out.write(input.toString());
            } else {
                out.write(CSV_QUOTE);
                out.write(StringUtils.replace(input.toString(), CSV_QUOTE_STR, CSV_QUOTE_STR + CSV_QUOTE_STR));
                out.write(CSV_QUOTE);
            }
            return input.length();
        }
    }

    /* UNESCAPE TRANSLATORS */

    /**
     * Translator object for unescaping escaped Java.
     *
     * While {@link #unescapeJava(String)} is the expected method of use, this
     * object allows the Java unescaping functionality to be used
     * as the foundation for a custom translator.
     *
     * @since 3.0
     */
    // TODO: throw "illegal character: \92" as an Exception if a \ on the end of the Java (as per the compiler)?
    public static final CharSequenceTranslator UNESCAPE_JAVA =
        new AggregateTranslator(
            new OctalUnescaper(),     // .between('\1', '\377'),
            new UnicodeUnescaper(),
            new LookupTranslator(EntityArrays.JAVA_CTRL_CHARS_UNESCAPE()),
            new LookupTranslator(
                      new String[][] {
                            {"\\\\", "\\"},
                            {"\\\"", "\""},
                            {"\\'", "'"},
                            {"\\", ""}
                      })
        );

    /**
     * Translator object for unescaping escaped EcmaScript.
     *
     * While {@link #unescapeEcmaScript(String)} is the expected method of use, this
     * object allows the EcmaScript unescaping functionality to be used
     * as the foundation for a custom translator.
     *
     * @since 3.0
     */
    public static final CharSequenceTranslator UNESCAPE_ECMASCRIPT = UNESCAPE_JAVA;

    /**
     * Translator object for unescaping escaped Json.
     *
     * While {@link #unescapeJson(String)} is the expected method of use, this
     * object allows the Json unescaping functionality to be used
     * as the foundation for a custom translator.
     *
     * @since 3.2
     */
    public static final CharSequenceTranslator UNESCAPE_JSON = UNESCAPE_JAVA;

    /**
     * Translator object for unescaping escaped HTML 3.0.
     *
     * While {@link #unescapeHtml3(String)} is the expected method of use, this
     * object allows the HTML unescaping functionality to be used
     * as the foundation for a custom translator.
     *
     * @since 3.0
     */
    public static final CharSequenceTranslator UNESCAPE_HTML3 =
        new AggregateTranslator(
            new LookupTranslator(EntityArrays.BASIC_UNESCAPE()),
            new LookupTranslator(EntityArrays.ISO8859_1_UNESCAPE()),
            new NumericEntityUnescaper()
        );

    /**
     * Translator object for unescaping escaped HTML 4.0.
     *
     * While {@link #unescapeHtml4(String)} is the expected method of use, this
     * object allows the HTML unescaping functionality to be used
     * as the foundation for a custom translator.
     *
     * @since 3.0
     */
    public static final CharSequenceTranslator UNESCAPE_HTML4 =
        new AggregateTranslator(
            new LookupTranslator(EntityArrays.BASIC_UNESCAPE()),
            new LookupTranslator(EntityArrays.ISO8859_1_UNESCAPE()),
            new LookupTranslator(EntityArrays.HTML40_EXTENDED_UNESCAPE()),
            new NumericEntityUnescaper()
        );

    /**
     * Translator object for unescaping escaped XML.
     *
     * While {@link #unescapeXml(String)} is the expected method of use, this
     * object allows the XML unescaping functionality to be used
     * as the foundation for a custom translator.
     *
     * @since 3.0
     */
    public static final CharSequenceTranslator UNESCAPE_XML =
        new AggregateTranslator(
            new LookupTranslator(EntityArrays.BASIC_UNESCAPE()),
            new LookupTranslator(EntityArrays.APOS_UNESCAPE()),
            new NumericEntityUnescaper()
        );

    /**
     * Translator object for unescaping escaped Comma Separated Value entries.
     *
     * While {@link #unescapeCsv(String)} is the expected method of use, this
     * object allows the CSV unescaping functionality to be used
     * as the foundation for a custom translator.
     *
     * @since 3.0
     */
    public static final CharSequenceTranslator UNESCAPE_CSV = new CsvUnescaper();

    static class CsvUnescaper extends CharSequenceTranslator {

        private static final char CSV_DELIMITER = ',';
        private static final char CSV_QUOTE = '"';
        private static final String CSV_QUOTE_STR = String.valueOf(CSV_QUOTE);
        private static final char[] CSV_SEARCH_CHARS =
            new char[] {CSV_DELIMITER, CSV_QUOTE, CharUtils.CR, CharUtils.LF};

        @Override
        public int translate(final CharSequence input, final int index, final Writer out) throws IOException {

            if(index != 0) {
                throw new IllegalStateException("CsvUnescaper should never reach the [1] index");
            }

            if ( input.charAt(0) != CSV_QUOTE || input.charAt(input.length() - 1) != CSV_QUOTE ) {
                out.write(input.toString());
                return input.length();
            }

            // strip quotes
            final String quoteless = input.subSequence(1, input.length() - 1).toString();

            if ( StringUtils.containsAny(quoteless, CSV_SEARCH_CHARS) ) {
                // deal with escaped quotes; ie) ""
                out.write(StringUtils.replace(quoteless, CSV_QUOTE_STR + CSV_QUOTE_STR, CSV_QUOTE_STR));
            } else {
                out.write(input.toString());
            }
            return input.length();
        }
    }

    /* Helper functions */

    /**
     *
{@code StringEscapeUtils} instances should NOT be constructed in
     * standard programming.

     *
     *
Instead, the class should be used as:
     *
StringEscapeUtils.escapeJava("foo");

     *
     *
This constructor is public to permit tools that require a JavaBean
     * instance to operate.

     */
    public StringEscapeUtils() {
      super();
    }

    // Java and JavaScript
    //--------------------------------------------------------------------------
    /**
     *
Escapes the characters in a {@code String} using Java String rules.

     *
     *
Deals correctly with quotes and control-chars (tab, backslash, cr, ff, etc.)

     *
     *
So a tab becomes the characters {@code '\\'} and
     * {@code 't'}.

     *
     *
The only difference between Java strings and JavaScript strings
     * is that in JavaScript, a single quote and forward-slash (/) are escaped.

     *
     *
Example:
     *

     * input string: He didn't say, "Stop!"
     * output string: He didn't say, \"Stop!\"
     *

     *

     *
     * @param input  String to escape values in, may be null
     * @return String with escaped values, {@code null} if null string input
     */
    public static final String escapeJava(final String input) {
        return ESCAPE_JAVA.translate(input);
    }

    /**
     *
Escapes the characters in a {@code String} using EcmaScript String rules.

     *
Escapes any values it finds into their EcmaScript String form.
     * Deals correctly with quotes and control-chars (tab, backslash, cr, ff, etc.)

     *
     *
So a tab becomes the characters {@code '\\'} and
     * {@code 't'}.

     *
     *
The only difference between Java strings and EcmaScript strings
     * is that in EcmaScript, a single quote and forward-slash (/) are escaped.

     *
     *
Note that EcmaScript is best known by the JavaScript and ActionScript dialects.

     *
     *
Example:
     *

     * input string: He didn't say, "Stop!"
     * output string: He didn\'t say, \"Stop!\"
     *

     *

     *
     * @param input  String to escape values in, may be null
     * @return String with escaped values, {@code null} if null string input
     *
     * @since 3.0
     */
    public static final String escapeEcmaScript(final String input) {
        return ESCAPE_ECMASCRIPT.translate(input);
    }

    /**
     *
Escapes the characters in a {@code String} using Json String rules.

     *
Escapes any values it finds into their Json String form.
     * Deals correctly with quotes and control-chars (tab, backslash, cr, ff, etc.)

     *
     *
So a tab becomes the characters {@code '\\'} and
     * {@code 't'}.

     *
     *
The only difference between Java strings and Json strings
     * is that in Json, forward-slash (/) is escaped.

     *
     *
See http://www.ietf.org/rfc/rfc4627.txt for further details.

     *
     *
Example:
     *

     * input string: He didn't say, "Stop!"
     * output string: He didn't say, \"Stop!\"
     *

     *

     *
     * @param input  String to escape values in, may be null
     * @return String with escaped values, {@code null} if null string input
     *
     * @since 3.2
     */
    public static final String escapeJson(final String input) {
        return ESCAPE_JSON.translate(input);
    }

    /**
     *
Unescapes any Java literals found in the {@code String}.
     * For example, it will turn a sequence of {@code '\'} and
     * {@code 'n'} into a newline character, unless the {@code '\'}
     * is preceded by another {@code '\'}.

     *
     * @param input  the {@code String} to unescape, may be null
     * @return a new unescaped {@code String}, {@code null} if null string input
     */
    public static final String unescapeJava(final String input) {
        return UNESCAPE_JAVA.translate(input);
    }

    /**
     *
Unescapes any EcmaScript literals found in the {@code String}.

     *
     *
For example, it will turn a sequence of {@code '\'} and {@code 'n'}
     * into a newline character, unless the {@code '\'} is preceded by another
     * {@code '\'}.

     *
     * @see #unescapeJava(String)
     * @param input  the {@code String} to unescape, may be null
     * @return A new unescaped {@code String}, {@code null} if null string input
     *
     * @since 3.0
     */
    public static final String unescapeEcmaScript(final String input) {
        return UNESCAPE_ECMASCRIPT.translate(input);
    }

    /**
     *
Unescapes any Json literals found in the {@code String}.

     *
     *
For example, it will turn a sequence of {@code '\'} and {@code 'n'}
     * into a newline character, unless the {@code '\'} is preceded by another
     * {@code '\'}.

     *
     * @see #unescapeJava(String)
     * @param input  the {@code String} to unescape, may be null
     * @return A new unescaped {@code String}, {@code null} if null string input
     *
     * @since 3.2
     */
    public static final String unescapeJson(final String input) {
        return UNESCAPE_JSON.translate(input);
    }

    // HTML and XML
    //--------------------------------------------------------------------------
    /**
     *
Escapes the characters in a {@code String} using HTML entities.

     *
     *

     * For example:
     *

     *
"bread" & "butter"

     * becomes:
     *

     * &quot;bread&quot; &amp; &quot;butter&quot;.
     *

     *
     *
Supports all known HTML 4.0 entities, including funky accents.
     * Note that the commonly used apostrophe escape character (&apos;)
     * is not a legal entity and so is not supported).

     *
     * @param input  the {@code String} to escape, may be null
     * @return a new escaped {@code String}, {@code null} if null string input
     *
     * @see ISO Entities
     * @see HTML 3.2 Character Entities for ISO Latin-1
     * @see HTML 4.0 Character entity references
     * @see HTML 4.01 Character References
     * @see HTML 4.01 Code positions
     *
     * @since 3.0
     */
    public static final String escapeHtml4(final String input) {
        return ESCAPE_HTML4.translate(input);
    }

    /**
     *
Escapes the characters in a {@code String} using HTML entities.

     *
Supports only the HTML 3.0 entities.

     *
     * @param input  the {@code String} to escape, may be null
     * @return a new escaped {@code String}, {@code null} if null string input
     *
     * @since 3.0
     */
    public static final String escapeHtml3(final String input) {
        return ESCAPE_HTML3.translate(input);
    }

    //-----------------------------------------------------------------------
    /**
     *
Unescapes a string containing entity escapes to a string
     * containing the actual Unicode characters corresponding to the
     * escapes. Supports HTML 4.0 entities.

     *
     *
For example, the string "&lt;Fran&ccedil;ais&gt;"
     * will become "<Français>"

     *
     *
If an entity is unrecognized, it is left alone, and inserted
     * verbatim into the result string. e.g. "&gt;&zzzz;x" will
     * become ">&zzzz;x".

     *
     * @param input  the {@code String} to unescape, may be null
     * @return a new unescaped {@code String}, {@code null} if null string input
     *
     * @since 3.0
     */
    public static final String unescapeHtml4(final String input) {
        return UNESCAPE_HTML4.translate(input);
    }

    /**
     *
Unescapes a string containing entity escapes to a string
     * containing the actual Unicode characters corresponding to the
     * escapes. Supports only HTML 3.0 entities.

     *
     * @param input  the {@code String} to unescape, may be null
     * @return a new unescaped {@code String}, {@code null} if null string input
     *
     * @since 3.0
     */
    public static final String unescapeHtml3(final String input) {
        return UNESCAPE_HTML3.translate(input);
    }

    //-----------------------------------------------------------------------
    /**
     *
Escapes the characters in a {@code String} using XML entities.

     *
     *
For example: <tt>"bread" & "butter"</tt> =>
     * <tt>&quot;bread&quot; &amp; &quot;butter&quot;</tt>.
     *

     *
     *
Supports only the five basic XML entities (gt, lt, quot, amp, apos).
     * Does not support DTDs or external entities.

     *
     *
Note that Unicode characters greater than 0x7f are as of 3.0, no longer
     *    escaped. If you still wish this functionality, you can achieve it
     *    via the following:
     * {@code StringEscapeUtils.ESCAPE_XML.with( NumericEntityEscaper.between(0x7f, Integer.MAX_VALUE) );}

     *
     * @param input  the {@code String} to escape, may be null
     * @return a new escaped {@code String}, {@code null} if null string input
     * @see #unescapeXml(java.lang.String)
     */
    public static final String escapeXml(final String input) {
        return ESCAPE_XML.translate(input);
    }

    //-----------------------------------------------------------------------
    /**
     *
Unescapes a string containing XML entity escapes to a string
     * containing the actual Unicode characters corresponding to the
     * escapes.

     *
     *
Supports only the five basic XML entities (gt, lt, quot, amp, apos).
     * Does not support DTDs or external entities.

     *
     *
Note that numerical \\u Unicode codes are unescaped to their respective
     *    Unicode characters. This may change in future releases.

     *
     * @param input  the {@code String} to unescape, may be null
     * @return a new unescaped {@code String}, {@code null} if null string input
     * @see #escapeXml(String)
     */
    public static final String unescapeXml(final String input) {
        return UNESCAPE_XML.translate(input);
    }

    //-----------------------------------------------------------------------

    /**
     *
Returns a {@code String} value for a CSV column enclosed in double quotes,
     * if required.

     *
     *
If the value contains a comma, newline or double quote, then the
     *    String value is returned enclosed in double quotes.

     *

     *
     *
Any double quote characters in the value are escaped with another double quote.

     *
     *
If the value does not contain a comma, newline or double quote, then the
     *    String value is returned unchanged.

     *

     *
     * see Wikipedia and
     * RFC 4180.
     *
     * @param input the input CSV column String, may be null
     * @return the input String, enclosed in double quotes if the value contains a comma,
     * newline or double quote, {@code null} if null string input
     * @since 2.4
     */
    public static final String escapeCsv(final String input) {
        return ESCAPE_CSV.translate(input);
    }

    /**
     *
Returns a {@code String} value for an unescaped CSV column.

     *
     *
If the value is enclosed in double quotes, and contains a comma, newline
     *    or double quote, then quotes are removed.
     *

     *
     *
Any double quote escaped characters (a pair of double quotes) are unescaped
     *    to just one double quote.

     *
     *
If the value is not enclosed in double quotes, or is and does not contain a
     *    comma, newline or double quote, then the String value is returned unchanged.

     *

     *
     * see Wikipedia and
     * RFC 4180.
     *
     * @param input the input CSV column String, may be null
     * @return the input String, with enclosing double quotes removed and embedded double
     * quotes unescaped, {@code null} if null string input
     * @since 2.4
     */
    public static final String unescapeCsv(final String input) {
        return UNESCAPE_CSV.translate(input);
    }

}


text:
using System;
using System.Web;

using ASC.CRM.Core;
using ASC.Web.Core;
using ASC.Web.Core.Utility;
using ASC.Web.CRM.Configuration;
using ASC.Web.Studio.Controls.FileUploader;

namespace ASC.Web.CRM.Classes
{
    public class ImportFileHandler : IFileUploadHandler
    {
        public FileUploadResult ProcessUpload(HttpContext context)
        {
            if (!WebItemSecurity.IsAvailableForMe(ProductEntryPoint.ID))
                throw CRMSecurity.CreateSecurityException();

            var fileUploadResult = new FileUploadResult();

            if (!FileToUpload.HasFilesToUpload(context)) return fileUploadResult;

            var file = new FileToUpload(context);

            String assignedPath;

            Global.GetStore().SaveTemp("temp", out assignedPath, file.InputStream);

            file.InputStream.Position = 0;

            var jObject = ImportFromCSV.GetInfo(file.InputStream, context.Request["importSettings"]);

            jObject.Add("assignedPath", assignedPath);

            fileUploadResult.Success = true;
            fileUploadResult.Data = Global.EncodeTo64(jObject.ToString());

            return fileUploadResult;
        }
    }
}


text:
using BCBIStats
using StatsBase
using FreqTables
using ARules
using SparseArrays

mutable struct Stats
    pmid_count::Int

    mesh_names::Vector{String}

    topn_mesh_labels::Vector{String}
    topn_mesh_counts::Vector{Integer}

    pmi_sp::SparseMatrixCSC{Float64,Integer}
    top_coo_sp::SparseMatrixCSC{Int64, Int64}
    corrcoef::Array{Float64}

    mh_rules_pmid_count::Int
    mh_rules_df::DataFrame

end

Stats() = Stats(0, [], [], [], Array{Any,2}(undef, 0, 0), Array{Any,2}(undef, 0, 0), [], 0, DataFrame(lhs = [], rhs = [], supp = [], conf = [], lift = []))

"""
    get_plotting_inputs(mesh_df, topn)

Given a dataframe with PMIDs and Mesh Terms, returns various statistics for plotting
"""
function mesh_stats(mesh_df::DataFrame, topn::Int=50)

    # convert dataframe to frequency table
    mesh_frequencies = freqtable(string.(mesh_df[:pmid]), mesh_df[:descriptor])

    # total number of articles
    pmid_count = length(unique(mesh_df[:pmid]))

    # find the counts by mesh term, find the top mesh headings, and names
    mesh_counts = vec(sum(mesh_frequencies, 1))
    count_perm = sortperm(mesh_counts, rev=true)
    mesh_names = collect(keys(mesh_frequencies.dicts[2]))

    # check if there are topn frequencies, if not use length
    topn = min(topn, length(mesh_names))

    #RETURN LABELS FOR ALL CHARTS
    top_mesh_labels = mesh_names[count_perm[1:topn]]

    #RETURN FOR BAR CHART
    topn_mesh = mesh_counts[count_perm[1:topn]]

    #co-occurrance matrix - only for top MeSH
    top_occ = mesh_frequencies.array[:, count_perm[1:topn]]
    top_occ_sp = sparse(top_occ)
    top_coo_sp = top_occ_sp' * top_occ_sp

    # RETURN FOR PLOT MATRICES
    #Point Mutual Information
    pmi_sp = BCBIStats.COOccur.pmi_mat(top_coo_sp, pmid_count)
    #chi2
    # top_chi2= BCBIStats.COOccur.chi2_mat(top_occ, min_freq=0) NOT USED RIGHT NOW
    #correlation
    corrcoef = BCBIStats.COOccur.corrcoef(top_occ);

    # convert to BitArray
    mh_occ = convert(BitArray{2}, mesh_frequencies.array)

    # ARules

    top_mesh_df = filter(row -> row[:descriptor] in top_mesh_labels, mesh_df)

    fsets = Array{Array{String,1},1}()
    idx = Dict{Int32,Int}()

    for i = 1:size(top_mesh_df)[1]
      if haskey(idx, top_mesh_df[i,:pmid])
        push!(fsets[idx[top_mesh_df[i,:pmid]]], top_mesh_df[i,:descriptor])
      else
        push!(fsets, [top_mesh_df[i,:descriptor]])
        idx[top_mesh_df[i,:pmid]] = length(fsets)
      end
    end

    mh_rules_pmid_count = idx.count

    # find ARules - not actually used in plots?
    mh_rules = apriori(fsets, supp = 0.001, conf = 0, maxlen = 9)

    return PubMedMiner.Stats(
        pmid_count,
        mesh_names,
        top_mesh_labels,
        topn_mesh,
        pmi_sp,
        top_coo_sp,
        corrcoef,
        # mh_rules,
        # rules_df,
        # root,
        mh_rules_pmid_count,
        mh_rules
        # s,
        # t,
        # v
    )

end


text:
#include "UEPySImage.h"

#include "Engine/Texture2D.h"

static PyObject *py_ue_simage_set_brush(ue_PySImage *self, PyObject * args)
{
	ue_py_slate_cast(SImage);
	PyObject *py_brush;
	if (!PyArg_ParseTuple(args, "O:set_brush", &py_brush))
	{
		return nullptr;
	}

	FSlateBrush *brush = ue_py_check_struct<FSlateBrush>(py_brush);
	if (!brush)
		return PyErr_Format(PyExc_Exception, "argument is not a FSlateBrush");

	self->brush = *brush;

	py_SImage->SetImage(&self->brush);

	Py_RETURN_SLATE_SELF;
}

static PyObject *py_ue_simage_set_texture(ue_PySImage *self, PyObject * args)
{
	ue_py_slate_cast(SImage);
	PyObject *py_texture;
	PyObject *py_linear_color = nullptr;
	if (!PyArg_ParseTuple(args, "O|O:set_texture", &py_texture, &py_linear_color))
	{
		return nullptr;
	}

	UTexture2D *texture = ue_py_check_type<UTexture2D>(py_texture);
	if (!texture)
		return PyErr_Format(PyExc_Exception, "argument is not a Texture");

	FLinearColor tint(1, 1, 1, 1);

	if (py_linear_color)
	{
		ue_PyFLinearColor *py_color = py_ue_is_flinearcolor(py_linear_color);
		if (!py_color)
		{
			return PyErr_Format(PyExc_Exception, "argument is not a FLinearColor");
		}
		tint = py_color->color;
	}

#if ENGINE_MINOR_VERSION > 15
	self->brush = FSlateImageBrush(texture, FVector2D(texture->GetSurfaceWidth(), texture->GetSurfaceHeight()), tint);
#else
	self->brush = FSlateBrush();
	self->brush.ImageSize = FVector2D(texture->GetSurfaceWidth(), texture->GetSurfaceHeight());
	self->brush.SetResourceObject(texture);
	self->brush.TintColor = tint;
#endif

	py_SImage->SetImage(&self->brush);

	Py_RETURN_SLATE_SELF;
}

static PyMethodDef ue_PySImage_methods[] = {
	{ "set_brush", (PyCFunction)py_ue_simage_set_brush, METH_VARARGS, "" },
	{ "set_image", (PyCFunction)py_ue_simage_set_brush, METH_VARARGS, "" },
	{ "set_texture", (PyCFunction)py_ue_simage_set_texture, METH_VARARGS, "" },
	{ NULL }  /* Sentinel */
};

PyTypeObject ue_PySImageType = {
	PyVarObject_HEAD_INIT(NULL, 0)
	"unreal_engine.SImage", /* tp_name */
	sizeof(ue_PySImage), /* tp_basicsize */
	0,                         /* tp_itemsize */
	0,       /* tp_dealloc */
	0,                         /* tp_print */
	0,                         /* tp_getattr */
	0,                         /* tp_setattr */
	0,                         /* tp_reserved */
	0,                         /* tp_repr */
	0,                         /* tp_as_number */
	0,                         /* tp_as_sequence */
	0,                         /* tp_as_mapping */
	0,                         /* tp_hash  */
	0,                         /* tp_call */
	0,                         /* tp_str */
	0,                         /* tp_getattro */
	0,                         /* tp_setattro */
	0,                         /* tp_as_buffer */
	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,        /* tp_flags */
	"Unreal Engine SImage",           /* tp_doc */
	0,                         /* tp_traverse */
	0,                         /* tp_clear */
	0,                         /* tp_richcompare */
	0,                         /* tp_weaklistoffset */
	0,                         /* tp_iter */
	0,                         /* tp_iternext */
	ue_PySImage_methods,             /* tp_methods */
};

static int ue_py_simage_init(ue_PySImage *self, PyObject *args, PyObject *kwargs)
{
	ue_py_slate_setup_farguments(SImage);

	ue_py_slate_farguments_struct("color_and_opacity", ColorAndOpacity, FSlateColor);
	ue_py_slate_farguments_optional_struct_ptr("image", Image, FSlateBrush);
	ue_py_slate_farguments_event("on_mouse_button_down", OnMouseButtonDown, FPointerEventHandler, OnMouseEvent);

	ue_py_snew(SImage);
	return 0;
}

void ue_python_init_simage(PyObject *ue_module)
{

	ue_PySImageType.tp_init = (initproc)ue_py_simage_init;

	ue_PySImageType.tp_base = &ue_PySLeafWidgetType;

	if (PyType_Ready(&ue_PySImageType) < 0)
		return;

	Py_INCREF(&ue_PySImageType);
	PyModule_AddObject(ue_module, "SImage", (PyObject *)&ue_PySImageType);
}


text:
package Scarif;

import battlecode.common.*;

import java.util.ArrayList;
import java.util.HashSet;

public class GardenerPlayer extends BasePlayer {

    //Gardener specific variables
    private int treeTimer = 0;
    private int lumberjackTimer = 0;
    private int soldierTimer = 0;
    private int scoutTimer = 0;
    private int tankTimer = 0;
    static float FARMER_CLEARANCE_RADIUS = 8f;      //How far apart should farmers be
    static final float TREE_RADIUS = 1f;            //Radius of player trees
    private RobotType[] build_order;
    private boolean build_queue_empty = true;
    private boolean has_built_robot = false;
    private boolean enemyEngaged = false;

    private boolean CHEESE_SCOUT = true;

    //Farming stuff
    private MapLocation SPAWNING_ARCHON_LOCATION = null;
    private MapLocation LAST_KNOWN_GARDENER_LOCATION = null;
    private boolean settledDown = false;
    static HashSet<MapLocation> localBlacklist = new HashSet<>();
    static final int LOCATION_TIMEOUT = 50;                     //Timeout to get to a new location
    static int settleTimer;
    static final int MAX_READ_SETTLE_PTS = 50;                  //Maximum number of settle pts read
    static int MAX_INIT_TREES = 2;                              //Max number of early game trees

    static int number_gardeners = 0;
    static int number_lumberjacks = 0;
    private int surrounding_lumberjacks = 0;
    static int number_scouts = 0;
    static int number_soldiers = 0;
    static int number_tanks = 0;

    //Spawning constants (Macro control)
    private Direction SPAWN_DIR = null;                         //Reserved spawning slot once in position
    private float BULLET_OVERFLOW = 347;                        //Overflowing bullets, build something!
    static final int SOLDIER_DELAY = 30;          				//Number of turns to spawn a new soldier
    private float SPAWN_SOLDIER_CHANCE = 0.75f;
    private float SOLDIER_TO_TREE_RATIO = 1.23f;                //Max number of soldiers per tree
    static int MIN_SOLDIER = 5;                                //Minimum number of soldiers
    static int MAX_SOLDIER = 10;                               //Early game max soldiers
    static final int SCOUT_DELAY = 100;   						//Number of turns to spawn a new scout
    private float SPAWN_SCOUT_CHANCE = 0.0f;
    private float SCOUT_TO_TREE_RATIO = 0.25f;                  //Max number of scouts per tree
    static final int TANK_DELAY = 17; 							//Number of turns to spawn a new tank
    private float SPAWN_TANK_CHANCE = 1f;
    private float TANK_TO_TREE_RATIO = 0.25f;                   //Max number of tanks per tree
    private float TANK_DENSITY_THRESHOLD = 0.15f;               //Surrounding density < this before tanks can be spawned
    private float LUMBERJACK_TO_NEUTRAL_RATIO = 0.43f;          //Number of lumbers per tree surrounding gardener
    private final int LUMBERJACK_DELAY = 30;                    //Number of turns to spawn a new lumberjack
    private float NEUTRAL_TREE_HEALTH_THRESHOLD = 750f;         //Total accumulative health of surrounding trees | above which will spawn lumberjacks

    private ArrayList<Direction> current_available_slots = new ArrayList<>();
    private int timeToTarget = 0;
    private int targetTimer = THE_FINAL_PROBLEM;

    //Movement stuff
    static MapLocation prevLocation = null;                     //Previous location
    static int staying_conut = 0;                               //How many turns spent around there
    //static float movement_stuck_radius = RobotType.SOLDIER.strideRadius - EPSILON;
    //todo n*(0.95/4)*0.5 = movement stuck radius
    static int stuckRounds = 11;                                //How many rounds before I'm stuck
    static int cooldownRounds = 17;
    static int cooldownTimer = 0;                               //Turns to run slug path before reverting to direct pathing
    static float movement_stuck_radius = RobotType.GARDENER.strideRadius/8*stuckRounds;       //Stuck distance for 17 rounds
    static boolean am_stuck = false;                            //I am stuck where I am...
    static boolean cooldown_active = false;                     //Cooldown period where direct pathing is disabled
    static boolean search_dir = true;                           //Right/Left bot, true == Right bot

    private int SLUG = 3;                                       //How many levels of slugging

    private Direction cooldownDir = null;                       //Try to escape local minimum

    public GardenerPlayer(RobotController rc) throws GameActionException {
        super(rc);
        try {
            initPlayer();
        } catch(Exception e){
            e.printStackTrace();
        }
        for (; ; Clock.yield()) {
            try {
                startRound();
                run();
                endRound();
            } catch(Exception e){
                e.printStackTrace();
            }
        }
    }

    private void initPlayer() throws GameActionException {
        MOVEMENT_SCANNING_DISTANCE = 3.1f;
        MOVEMENT_SCANNING_RADIUS = 2.1f;

        SURROUNDING_ROBOTS_OWN = rc.senseNearbyRobots(3f, rc.getTeam());
        for (RobotInfo r:SURROUNDING_ROBOTS_OWN){
            if (r.type == RobotType.ARCHON){
                SPAWNING_ARCHON_LOCATION = r.location;
                break;
            }
        }
        //todo I'm debugging this...
        debug = false;
    }

    public void startRound() throws GameActionException {
        super.startRound();
        SURROUNDING_TREES_OWN = rc.senseNearbyTrees(3f, rc.getTeam());
        SURROUNDING_ROBOTS_OWN = rc.senseNearbyRobots(-1, rc.getTeam());
        if (settledDown){
            rc.broadcast(SUM_SETTLED,rc.readBroadcast(SUM_SETTLED)+1);
        }
        else{
            rc.broadcast(SUM_GARDENERS,rc.readBroadcast(SUM_GARDENERS)+1);
        }
        build_order = getBuildOrder();
        build_queue_empty = true;
        has_built_robot = false;

        if (SURROUNDING_ROBOTS_ENEMY.length > 0){
            contactRep();
        }

        //Reset farmer settling counter
        if (rc.readBroadcast(CONTROL_FARMER_HEARTBEAT) <= Math.max(0, rc.getRoundNum() - 3)){
            rc.broadcast(CONTROL_FARMER, rc.getID());
            rc.broadcast(AVAILABLE_FARMING_LOCATIONS, 0);
        }
        if (rc.readBroadcast(CONTROL_FARMER) == rc.getID()) {
            rc.setIndicatorLine(MY_LOCATION, MY_LOCATION.add(new Direction(0f),2f), 0, 0, 0);
            rc.broadcast(AVAILABLE_FARMING_LOCATIONS, 0);
            rc.broadcast(CONTROL_FARMER_HEARTBEAT, rc.getRoundNum());
            if (rc.readBroadcast(BLACKLISTED_FARMING_LOCATIONS) > MAX_BLACKLISTED_LOCATIONS){
                rc.broadcast(BLACKLISTED_FARMING_LOCATIONS, 0);
            }
        }

        number_gardeners = rc.readBroadcast(COUNT_GARDENERS);
        number_lumberjacks = rc.readBroadcast(COUNT_LUMBERJACKS);
        number_scouts = rc.readBroadcast(COUNT_SCOUTS);
        number_soldiers = rc.readBroadcast(COUNT_SOLDIERS);
        number_tanks = rc.readBroadcast(COUNT_TANKS);

        surrounding_lumberjacks = 0;
        for (RobotInfo r:SURROUNDING_ROBOTS_OWN){
            if (r.type == RobotType.LUMBERJACK) surrounding_lumberjacks++;
        }

        //todo check for last known gardener position (sticks close together :D)
        for (RobotInfo r:SURROUNDING_ROBOTS_OWN){
            if (r.type == RobotType.GARDENER){
                LAST_KNOWN_GARDENER_LOCATION = r.location;
                break;
            }
        }

        if (LAST_KNOWN_GARDENER_LOCATION != null) if (debug) rc.setIndicatorLine(MY_LOCATION, LAST_KNOWN_GARDENER_LOCATION, 0, 255, 0);

        //todo check whether enemy has been engaged!
        if (!enemyEngaged) enemyEngaged = (rc.readBroadcast(ENEMY_ENGAGED) == 1);

    }

    private void run() throws GameActionException {

        //Follow build order
        for (int i=0;i<MAX_BUILD_ORDER;i++){
            if (build_order[i]!=null){
                build_queue_empty = false;
                if (forceBuilding(build_order[i])){
                    rc.broadcast(BUILD_ORDER_QUEUE+i, 0);
                }
                break;
            }
        }

        //todo cheese dat scout out
        if (CHEESE_SCOUT && build_order[0] == null && build_order[1] == null){
            if (shouldCheeseScout() || rc.readBroadcast(FORCE_SCOUT_CHEESE) > 80) {
                CHEESE_SCOUT = (rc.readBroadcast(SCOUT_CHEESE_SIGNAL) == 0);
                if (CHEESE_SCOUT){
                    if(forceBuilding(RobotType.SCOUT)){
                        System.out.println("Scout cheeser sent!");
                        rc.broadcast(SCOUT_CHEESE_SIGNAL, 1);
                    }
                }
            }
            else CHEESE_SCOUT = false;
        }

        //Plant trees
        if (!settledDown){
            if (!rc.isCircleOccupiedExceptByThisRobot(MY_LOCATION, 3.01f) && rc.onTheMap(MY_LOCATION, 3f)) current_available_slots = HEXAGONAL_PATTERN;
            //todo Gardener starts to farm early
            else if (rc.getTreeCount() == 0) current_available_slots = getBuildSlots(MY_LOCATION, 2);
            else current_available_slots = getBuildSlots(MY_LOCATION, FARMER_MIN_SLOTS);
            if (current_available_slots.size() > 0) {
                //Get most spacious direction
                float density = 999999f;
                int spawn_direction = -1;
                System.out.println("Total build slots: " + Integer.toString(current_available_slots.size()));
                for (int i = 0; i < current_available_slots.size(); i++) {
                    System.out.println("Available build slot at: " + Float.toString(current_available_slots.get(i).radians));
                    float eval = getDensity(MY_LOCATION.add(current_available_slots.get(i), MOVEMENT_SCANNING_DISTANCE), MOVEMENT_SCANNING_RADIUS, OBJECTS);
                    if (eval < density) {
                        density = eval;
                        spawn_direction = i;
                    }
                }
                if (spawn_direction != -1) {
                    SPAWN_DIR = current_available_slots.get(spawn_direction);
                    current_available_slots.remove(spawn_direction);
                }
            }
        }
        else if (current_available_slots.size() < 1){
            if (SPAWN_DIR != null){
                current_available_slots.clear();
                for (int i=1;i<6;i++){
                    current_available_slots.add(SPAWN_DIR.rotateRightRads(DEG_60*i));
                }
            }
            else {
                current_available_slots = getBuildSlots(MY_LOCATION, 2);
                if (current_available_slots.size() > 0){
                    SPAWN_DIR = current_available_slots.get(0);
                    current_available_slots.remove(0);
                }
            }
        }

        //Debug bytecode costs
        System.out.println("Bytes used to compute build locations: "+Integer.toString(Clock.getBytecodeNum()));

        //Debug for spawn direction
        if (SPAWN_DIR != null) System.out.println("SPAWN_DIR: "+Float.toString(SPAWN_DIR.radians));

        //todo since got new movement mechanism, ignore spreading out, should be emergent?
        //todo don't settledown if entire grove of trees won't be on the map
        // && rc.onTheMap(MY_LOCATION, 3f)
        if (rc.getTreeCount() == 0){
            if (current_available_slots.size() > 0 && isSpreadOut(MY_LOCATION, FARMER_CLEARANCE_RADIUS, false)) settledDown = true;
        }
        else if (current_available_slots.size() > 0 && isSpreadOut(MY_LOCATION, FARMER_CLEARANCE_RADIUS, true)) settledDown = true;

        //Debug settling down
        System.out.println("Have I settled? "+Boolean.toString(settledDown));
        System.out.println("Max slots around me: "+Integer.toString(Math.max(FARMER_MIN_SLOTS-SURROUNDING_TREES_OWN.length,1)));

        if (!settledDown){
            //Try to spawn a lumberjack
            //Check if there are trees around
            if (rc.getRoundNum() > lumberjackTimer) {
                forceBuilding(RobotType.LUMBERJACK);
                lumberjackTimer = rc.getRoundNum() + LUMBERJACK_DELAY;
            }

            //Look for a space with a circle of radius 3
            //todo new gardener move algo
            //Vet target location
            if (target != null){
                if (!isSettleLocationValid(target)) target = null;
            }
            //Acquire new target if none currently
            if (target == null){
                target = acquireSettleLocation();
            }
            //Move to target location
            if (target == null){
                if (debug) rc.setIndicatorDot(MY_LOCATION, 255, 0, 0);
                gardenerDensityMove(GARDENER_MOVE_GRANULARITY);
            }
            else{
                if (debug) rc.setIndicatorDot(MY_LOCATION, 0, 255, 0);
                moveToSettleLocation();
            }
        }
        else{
            //Announce locations around itself
            broadcastAvailableSettleLocations();

            //Should I plant trees?
            boolean should_plant_trees = true;

            //Maintain a basic army before planting too many trees
            if (build_order[0] != null && build_order[1] != null && rc.getRoundNum() < EARLY_GAME){
                //Skip building trees till first 2 soldiers are out :)
                should_plant_trees = false;
            }
            if (spawnSoldierControl()){
                //If I should spawn a lumberjack or soldier or if I've tons of bullets, go build these units first :)
                should_plant_trees = false;
            }
            if (rc.getRoundNum() < EARLY_GAME && SURROUNDING_TREES_OWN.length >= MAX_INIT_TREES && enemyEngaged){
                //Stop planting too many trees early game
                should_plant_trees = false;
            }
            //I have tons of bullets, might as well...
            if (rc.getTeamBullets() > BULLET_OVERFLOW) should_plant_trees = true;

            //Plant trees
            if (should_plant_trees) {
                //Plant trees
                for (Direction dir : current_available_slots) {
                    System.out.println("Build slot at: "+dir);
                    if (rc.canPlantTree(dir) && rc.getRoundNum() > treeTimer && rand.nextFloat() < PLANT_TREE_CHANCE) {
                        rc.plantTree(dir);
                        treeTimer = rc.getRoundNum() + TREE_DELAY;
                    }
                }
                //Try forcing 5 trees around gardener
                if (SURROUNDING_TREES_OWN.length < 5 && SURROUNDING_TREES_OWN.length > 0) {
                    if (debug && SPAWN_DIR != null)
                        rc.setIndicatorLine(MY_LOCATION, MY_LOCATION.add(SPAWN_DIR, 3f), 0, 255, 255);
                    Direction cDir = MY_LOCATION.directionTo(SURROUNDING_TREES_OWN[0].location);
                    for (int i = 0; i < 5; i++) {
                        cDir = cDir.rotateRightRads(DEG_60);
                        if (rc.canPlantTree(cDir) && rc.getRoundNum() > treeTimer && rand.nextFloat() < PLANT_TREE_CHANCE) {
                            System.out.println("Forcing planting of tree at: " + Float.toString(cDir.radians));
                            System.out.println("Radians between spawn_dir and cDir: "+Float.toString(SPAWN_DIR.radiansBetween(cDir)));
                            if (absRad(SPAWN_DIR.radiansBetween(cDir)) >= DEG_60){
                                rc.plantTree(cDir);
                                treeTimer = rc.getRoundNum() + TREE_DELAY;
                            }
                        }
                    }
                }
            }

            //Water
            TreeInfo lowestHealthTree = null;
            float lowestHealth = 1000000f;
            for (TreeInfo tree : SURROUNDING_TREES_OWN) {
                if (tree.getHealth() < lowestHealth) {
                    lowestHealth = tree.getHealth();
                    lowestHealthTree = tree;
                }
            }
            if (lowestHealthTree != null) {
                if (rc.canWater(lowestHealthTree.getID())) {
                    try {
                        rc.water(lowestHealthTree.getID());
                    } catch (GameActionException e) {
                        e.printStackTrace();
                    }
                }
            }
        }

        //Build robots
        if (build_queue_empty){
            if (SURROUNDING_ROBOTS_ENEMY.length > 0){
                if (!has_built_robot) {
                    switch (SURROUNDING_ROBOTS_ENEMY[0].type) {
                        case ARCHON:
                            has_built_robot = forceBuilding(RobotType.SOLDIER);
                            break;
                        case LUMBERJACK:
                            has_built_robot = forceBuilding(RobotType.SOLDIER);
                            break;
                        case SCOUT:
                            has_built_robot = forceBuilding(RobotType.LUMBERJACK);
                            break;
                        case SOLDIER:
                            has_built_robot = forceBuilding(RobotType.SOLDIER);
                            break;
                        case GARDENER:
                            has_built_robot = forceBuilding(RobotType.LUMBERJACK);
                            break;
                        case TANK:
                            has_built_robot = forceBuilding(RobotType.TANK);
                            break;
                    }
                }
            }
            if (spawnLumberjackControl() && !has_built_robot) {
                has_built_robot = forceBuilding(RobotType.LUMBERJACK);
                if (has_built_robot) lumberjackTimer = rc.getRoundNum() + LUMBERJACK_DELAY;
            }
            if (spawnTankControl() && !has_built_robot) {
                has_built_robot = forceBuilding(RobotType.TANK);
                if (has_built_robot) tankTimer = rc.getRoundNum() + TANK_DELAY;
            }
            if (spawnSoldierControl() && !has_built_robot) {
                has_built_robot = forceBuilding(RobotType.SOLDIER);
                if (has_built_robot) soldierTimer = rc.getRoundNum() + SOLDIER_DELAY;
            }
            if (spawnScoutControl() && !has_built_robot) {
                has_built_robot = forceBuilding(RobotType.SCOUT);
                if (has_built_robot) scoutTimer = rc.getRoundNum() + SCOUT_DELAY;
            }
        }

        return;
    }

    public void endRound() throws GameActionException {
        super.endRound();
        System.out.println("Before computing stuck: "+Integer.toString(Clock.getBytecodeNum()));

        if (prevLocation == null){
            prevLocation = MY_LOCATION;
        }
        else{
            if (rc.getRoundNum() % stuckRounds == 0){
                //Check every stuckRounds rounds
                if (prevLocation.distanceTo(MY_LOCATION) < movement_stuck_radius){
                    //Oops, I'm stuck
                    System.out.println("Oh oops, I'm STUCK!!!");
                    am_stuck = true;
                    cooldown_active = true;
                    cooldownTimer = rc.getRoundNum() + cooldownRounds;
                }
                else{
                    am_stuck = false;
                    if (rc.getRoundNum() > cooldownTimer) cooldown_active = false;
                }
                prevLocation = MY_LOCATION;
            }
        }

        System.out.println("After computing stuck: "+Integer.toString(Clock.getBytecodeNum()));

        if (target != null){
            if (debug) rc.setIndicatorDot(target, 255, 255, 255);
            System.out.println(broadcaster.location_to_channel(target));
        }
    }

    //=========================================================================
    //<---------------------------- GARDENER MICRO --------------------------->
    //=========================================================================
    //<--------------------------- SPAWNING METRICS -------------------------->
    private boolean shouldCheeseScout(){
        SURROUNDING_TREES_NEUTRAL = rc.senseNearbyTrees(-1, Team.NEUTRAL);
        float tot_bullets = 0;
        for (TreeInfo t:SURROUNDING_TREES_NEUTRAL){
            tot_bullets += t.containedBullets;
        }
        if (tot_bullets > 40f) return true;
        return false;
    }

    private boolean spawnLumberjackControl(){
        if (rc.getTeamBullets() < RobotType.LUMBERJACK.bulletCost) return false;
        if (SURROUNDING_TREES_NEUTRAL.length == 0) return false;
        else {
            float cur_ratio = (float) surrounding_lumberjacks / SURROUNDING_TREES_NEUTRAL.length;
            if (cur_ratio > LUMBERJACK_TO_NEUTRAL_RATIO){
                float tot_health_trees = 0f;
                for (TreeInfo t:SURROUNDING_TREES_NEUTRAL){
                    tot_health_trees += t.getHealth();
                }
                if (tot_health_trees > 2*NEUTRAL_TREE_HEALTH_THRESHOLD) return true;
                else if (tot_health_trees > NEUTRAL_TREE_HEALTH_THRESHOLD && rc.getRoundNum() > lumberjackTimer) return true;
            }
            else return true;
        }
        return false;
    }

    private boolean spawnSoldierControl(){
        if (rc.getTeamBullets() < RobotType.SOLDIER.bulletCost) return false;
        if (rc.getRoundNum() < MID_GAME &&  !enemyEngaged) return false;
        if (rc.getRoundNum() < soldierTimer){
            if (rc.getTeamBullets() > BULLET_OVERFLOW) return true;
            else return false;
        }
        else{
            float cur_ratio = (float)number_soldiers/Math.max(1,rc.getTreeCount());
            if (cur_ratio > SOLDIER_TO_TREE_RATIO){
                if (number_soldiers < MIN_SOLDIER) return true;
                else return false;
            }
            else{
                if (rc.getRoundNum() < MID_GAME){
                    System.out.println("I'm in mid game with: "+Integer.toString(number_soldiers)+" soldiers");
                    if (rc.getTreeCount() > 13){    //todo magic numbers :O
                        if (rand.nextFloat() < SPAWN_SOLDIER_CHANCE) return true;
                    }
                    if (number_soldiers >= MAX_SOLDIER) return false;
                }
                if (rand.nextFloat() > SPAWN_SOLDIER_CHANCE) return false;
            }
        }
        return true;
    }

    private boolean spawnTankControl(){
        if (rc.getTeamBullets() < RobotType.TANK.bulletCost) return false;
        if (rc.getRoundNum() < MID_GAME*2 &&  !enemyEngaged) return false;
        if (rc.getTreeCount() < SUSTAINABLE_ECONOMY) return false;
        if (rc.getRoundNum() < tankTimer){
            if (rc.getTeamBullets() > BULLET_OVERFLOW) return true;
            else return false;
        }
        else{
            float cur_ratio = (float)number_tanks/Math.max(1,rc.getTreeCount());
            if (cur_ratio > TANK_TO_TREE_RATIO){
                if (rc.getTeamBullets() > 450) return true;
                else return false;
            }
            else{
                if (rand.nextFloat() > SPAWN_TANK_CHANCE) return false;
            }
        }
        return true;
    }

    private boolean spawnScoutControl(){
        if (rc.getTeamBullets() < RobotType.SCOUT.bulletCost) return false;
        if (rc.getRoundNum() < scoutTimer) return false;
        else{
            float cur_ratio = (float)number_scouts/Math.max(1,rc.getTreeCount());
            if (cur_ratio > SCOUT_TO_TREE_RATIO || rand.nextFloat() > SPAWN_SCOUT_CHANCE) return false;
        }
        return true;
    }

    //<-------------------------- BUILDING/PLANTING -------------------------->
    private RobotType[] getBuildOrder() throws GameActionException {
        boolean build_order_empty = true;
        RobotType[] build_order = new RobotType[MAX_BUILD_ORDER];
        for (int i=0;i<MAX_BUILD_ORDER;i++){
            build_order[i] = robotType(rc.readBroadcast(BUILD_ORDER_QUEUE+i));
            if (build_order[i] != null) build_order_empty = false;
        }

        if (build_order_empty) return build_order;

        //todo Vets build order
        float est_size = ENEMY_ARCHON_LOCATION.distanceTo(MY_LOCATION);

        if (getDensity(MY_LOCATION, 5f, TREES) > FOREST_DENSITY_THRESHOLD){
            System.out.println("DENSE MAP DETECTED");
            //todo stable: lum_sol_sol
            if (est_size < MAP_SMALL){
                if (build_order[0] != null){
                    build_order[0] = RobotType.LUMBERJACK;
                }
                if (build_order[1] != null){
                    build_order[1] = RobotType.SOLDIER;
                }
            }
            else if (est_size < MAP_LARGE){
                if (build_order[0] != null){
                    build_order[0] = RobotType.LUMBERJACK;
                }
                if (build_order[1] != null){
                    build_order[1] = RobotType.SOLDIER;
                }
            }
            else {
                if (build_order[0] != null){
                    build_order[0] = RobotType.LUMBERJACK;
                }
                if (build_order[1] != null){
                    build_order[1] = RobotType.SOLDIER;
                }
            }
        }
        else {
            System.out.println("Clear Map detected");
            if (build_order[0] != null){
                build_order[0] = RobotType.SOLDIER;
            }
            if (build_order[1] != null){
                build_order[1] = RobotType.SOLDIER;
            }
        }
        return build_order;
    }

    private boolean forceBuilding(RobotType robot) throws GameActionException {
        if (!rc.isBuildReady()) return false;
        if (imminentEconomicWin) return false;
        Direction initDir = MY_LOCATION.directionTo(ENEMY_ARCHON_LOCATION);
        if (debug) rc.setIndicatorLine(MY_LOCATION, ENEMY_ARCHON_LOCATION, 255, 255, 0);
        Direction tryDir = null;
        for (int i=0;i<SEARCH_GRANULARITY/2;i++){
            if (i%2==0){
                tryDir = initDir.rotateRightRads(i*DEG_180/SEARCH_GRANULARITY);
                if (rc.canBuildRobot(robot,tryDir)){
                    if (debug) rc.setIndicatorDot(MY_LOCATION.add(tryDir, 2f), 0, 255, 0);
                    rc.buildRobot(robot,tryDir);
                    return true;
                }
                else{
                    if (debug) rc.setIndicatorDot(MY_LOCATION.add(tryDir, 2f), 255, 0, 0);
                }
            }
            else{
                tryDir = initDir.rotateLeftRads(i*DEG_180/SEARCH_GRANULARITY);
                if (rc.canBuildRobot(robot,tryDir)){
                    if (debug) rc.setIndicatorDot(MY_LOCATION.add(tryDir, 2f), 0, 255, 0);
                    rc.buildRobot(robot,tryDir);
                    return true;
                }
                else{
                    if (debug) rc.setIndicatorDot(MY_LOCATION.add(tryDir, 2f), 255, 0, 0);
                }
            }
        }
        if (SPAWN_DIR != null){
            if (rc.canBuildRobot(robot, SPAWN_DIR)){
                rc.buildRobot(robot, SPAWN_DIR);
                return true;
            }
        }
        return false;
    }

    //<------------------------- TARGET ACQUISITION -------------------------->
    private boolean isSettleLocationValid(MapLocation loc) throws GameActionException {
        if (loc == null) return false;
        if (debug) rc.setIndicatorDot(loc, 0, 0, 255);
        if (localBlacklist.contains(loc)) return false;
        if (Clock.getBytecodeNum() > BYTE_THRESHOLD) return true;

        //Fetch blacklist
        HashSet<MapLocation> blacklist = new HashSet<MapLocation>(1000);
        int blacklist_size = rc.readBroadcast(BLACKLISTED_FARMING_LOCATIONS);
        System.out.println("Total Blacklisted locations: " + Integer.toString(blacklist_size));
        for (int i = 0; i < blacklist_size; i++){
            float locX = intToFloatPrecise(rc.readBroadcast(BLACKLISTED_LOCATIONS_X + i * 2));
            float locY = intToFloatPrecise(rc.readBroadcast(BLACKLISTED_LOCATIONS_Y + i * 2));
            blacklist.add(new MapLocation(locX, locY));
            if (debug) rc.setIndicatorDot(new MapLocation(locX, locY), 255, 255, 0);
        }
        if (blacklist.contains(loc)) return false;

        //If unable to get to target in 20 turns => local blacklist then choose new location
        if (rc.getRoundNum() >= settleTimer) {
            settleTimer = 1000000;
            localBlacklist.add(loc);
            return false;
        }
        if (rc.canSenseAllOfCircle(loc, rc.getType().bodyRadius)) {
            //If target is not on the map
            if (!rc.onTheMap(loc, rc.getType().bodyRadius)) {
                //Add this location to blacklist
                int num_blacklisted = rc.readBroadcast(BLACKLISTED_FARMING_LOCATIONS);
                rc.broadcast(BLACKLISTED_LOCATIONS_X + num_blacklisted * 2, floatToIntPrecise(loc.x));
                rc.broadcast(BLACKLISTED_LOCATIONS_Y + num_blacklisted * 2, floatToIntPrecise(loc.y));
                num_blacklisted += 1;
                rc.broadcast(BLACKLISTED_FARMING_LOCATIONS, num_blacklisted);
                if (debug) rc.setIndicatorLine(MY_LOCATION, loc, 255, 0, 0);
                localBlacklist.add(loc);
                return false;
            }
            //Occupied by gardener
            else if (rc.isLocationOccupiedByRobot(loc)) {
                RobotInfo robot = rc.senseRobotAtLocation(loc);
                if (robot.getType() == RobotType.GARDENER && robot.getID() != rc.getID()) {
                    //Add this location to blacklist
                    int num_blacklisted = rc.readBroadcast(BLACKLISTED_FARMING_LOCATIONS);
                    rc.broadcast(BLACKLISTED_LOCATIONS_X + num_blacklisted * 2, floatToIntPrecise(loc.x));
                    rc.broadcast(BLACKLISTED_LOCATIONS_Y + num_blacklisted * 2, floatToIntPrecise(loc.y));
                    num_blacklisted += 1;
                    rc.broadcast(BLACKLISTED_FARMING_LOCATIONS, num_blacklisted);
                    localBlacklist.add(loc);
                    return false;
                }
            }
            //Occupied by local tree
            else if (rc.isLocationOccupiedByTree(loc)) {
                //Add this location to local blacklist
                localBlacklist.add(loc);
                return false;
            }
            //Otherwise occupied but not by robot
            else if (rc.isCircleOccupiedExceptByThisRobot(loc, rc.getType().bodyRadius)) {
                boolean canSkip = false;
                if (rc.isLocationOccupiedByRobot(loc) && rc.senseRobotAtLocation(loc).getType() != RobotType.GARDENER && rc.senseRobotAtLocation(loc).getType() != RobotType.ARCHON) {
                    canSkip = true;
                }
                if (!canSkip) {
                    //Add this location to blacklist
                    int num_blacklisted = rc.readBroadcast(BLACKLISTED_FARMING_LOCATIONS);
                    rc.broadcast(BLACKLISTED_LOCATIONS_X + num_blacklisted * 2, floatToIntPrecise(loc.x));
                    rc.broadcast(BLACKLISTED_LOCATIONS_Y + num_blacklisted * 2, floatToIntPrecise(loc.y));
                    num_blacklisted += 1;
                    rc.broadcast(BLACKLISTED_FARMING_LOCATIONS, num_blacklisted);
                    localBlacklist.add(loc);
                    return false;
                }
            }
        }
        return true;
    }

    private MapLocation acquireSettleLocation() throws GameActionException {
        MapLocation targetLoc = null;
        //Fetch blacklist
        HashSet<MapLocation> blacklist = new HashSet<MapLocation>(1000);
        int blacklist_size = rc.readBroadcast(BLACKLISTED_FARMING_LOCATIONS);
        System.out.println("Total Blacklisted locations: " + Integer.toString(blacklist_size));
        for (int i = 0; i < blacklist_size; i++){
            float locX = intToFloatPrecise(rc.readBroadcast(BLACKLISTED_LOCATIONS_X + i * 2));
            float locY = intToFloatPrecise(rc.readBroadcast(BLACKLISTED_LOCATIONS_Y + i * 2));
            blacklist.add(new MapLocation(locX, locY));
            if (debug) rc.setIndicatorDot(new MapLocation(locX, locY), 255, 255, 0);
        }

        int num_settle_pts = Math.min(rc.readBroadcast(AVAILABLE_FARMING_LOCATIONS), MAX_READ_SETTLE_PTS);
        float mindist = 10000000f;
        for (int i = 0; i < num_settle_pts; i++){
            //todo bytecode escape
            //if (Clock.getBytecodeNum() > BYTE_THRESHOLD) continue;
            float locX = intToFloatPrecise(rc.readBroadcast(FARMING_LOCATIONS_X + i * 2));
            float locY = intToFloatPrecise(rc.readBroadcast(FARMING_LOCATIONS_Y + i * 2));
            MapLocation newPt = new MapLocation(locX, locY);
            boolean isValid = true;
            //ignore locations on blacklist or local blacklist
            if (blacklist.contains(newPt) || localBlacklist.contains(newPt)){
                isValid = false;
            }
            if (!isValid){
                continue;
            }
            float dist = newPt.distanceTo(MY_LOCATION);
            if (debug) rc.setIndicatorDot(newPt, 0, 255, 255);
            if (dist < mindist){
                mindist = dist;
                targetLoc = newPt;
            }
        }
        if (targetLoc != null) settleTimer = rc.getRoundNum() + Math.max(LOCATION_TIMEOUT, Math.round(MY_LOCATION.distanceTo(targetLoc)/(rc.getType().strideRadius)/4));
        else settleTimer = rc.getRoundNum() + LOCATION_TIMEOUT;
        return targetLoc;
    }

    private void moveToSettleLocation() throws GameActionException {
        if (target == null) return;     //Error, target not set beforehand
        if (MY_LOCATION.isWithinDistance(target, rc.getType().strideRadius)) {
            if (debug) rc.setIndicatorLine(MY_LOCATION, target, 0, 255, 0);
            rc.move(target);
            MY_LOCATION = rc.getLocation();

            //Force settle
            System.out.println("Forced Settle");
            int validCnt = 0;
            float density = 999999f;
            int spawn_direction = -1;
            for (int i = 0; i < 6; i++) {
                if (!rc.isCircleOccupied(MY_LOCATION.add(HEX_DIR[i], rc.getType().bodyRadius + TREE_RADIUS), TREE_RADIUS) && rc.onTheMap(MY_LOCATION.add(HEX_DIR[i], rc.getType().bodyRadius + TREE_RADIUS), TREE_RADIUS)) {
                    validCnt += 1;
                    System.out.println("Available build slot at: " + Float.toString(HEX_DIR[i].radians));
                    float eval = getDensity(MY_LOCATION.add(HEX_DIR[i], MOVEMENT_SCANNING_DISTANCE), MOVEMENT_SCANNING_RADIUS, TREES);
                    if (eval < density) {
                        density = eval;
                        spawn_direction = i;
                    }
                }
            }
            System.out.println("validCnt: " + validCnt);
            if (spawn_direction == -1) {
                spawn_direction = 0;
            }
            SPAWN_DIR = HEX_DIR[spawn_direction];
            settledDown = true;
            if (debug) rc.setIndicatorLine(MY_LOCATION, target, 255, 0, 0);
        }
        else {
            if (debug) rc.setIndicatorLine(MY_LOCATION, target, 255, 255, 0);
            if (am_stuck) {
                search_dir = !search_dir;
                am_stuck = false;
                staying_conut = 0;
            }
            moveToTargetExperimental(MY_LOCATION, SENSOR_GRANULARITY, search_dir, cooldown_active, SLUG);
        }
    }

    private void broadcastAvailableSettleLocations() throws  GameActionException {
        int num_settle_pts = rc.readBroadcast(AVAILABLE_FARMING_LOCATIONS);
        for (int i = 0; i < 6; i++){
            MapLocation newGardenerLoc = rc.getLocation().add(HEX_DIR[i], FARMER_CLEARANCE_RADIUS + EPSILON);
            if (broadcaster.isValidGrid(newGardenerLoc)){ //Imprecise but I doubt it matters
                if (debug) rc.setIndicatorDot(newGardenerLoc, 0, 255, 0); //For testing
                rc.broadcast(FARMING_LOCATIONS_X + 2 * num_settle_pts, floatToIntPrecise(newGardenerLoc.x));
                rc.broadcast(FARMING_LOCATIONS_Y + 2 * num_settle_pts, floatToIntPrecise(newGardenerLoc.y));
                num_settle_pts += 1;
            }
        }
        rc.broadcast(AVAILABLE_FARMING_LOCATIONS, num_settle_pts);
    }

    //<------------------------- MOVEMENT ALGORITHMS ------------------------->
    private float gardenerSurroundingDensity(MapLocation travelLoc) throws GameActionException {
        //todo bytecode saving metric
        //return getDensity(travelLoc, 3f, OBJECTS);
        float curDensity = 0;
        for (int i=0;i<6;i++){
            //Scan in a hexagonal pattern around the gardener
            MapLocation testLoc = travelLoc.add(new Direction(DEG_60*i), rc.getType().bodyRadius + 1f + EPSILON);
            if (!rc.onTheMap(testLoc.add(new Direction(DEG_60*i), 0.5f), 0.25f)){
                curDensity += 1f;
            }
            else curDensity += getDensity(testLoc, 1f, TREES);
        }
        return curDensity;
    }

    private float gardenerDensity(MapLocation travelLoc) throws GameActionException {
        //todo bytecode saving metric
        return getDensity(travelLoc, 3f, OBJECTS);
    }

    private boolean gardenerDensityMove(int GRANULARITY) throws GameActionException {
        if (cooldown_active) {
            if (cooldownDir == null) {
                //Look further away (long-range density) --> should escape local minimum
                Direction initDir = MY_LOCATION.directionTo(ENEMY_ARCHON_LOCATION);
                float curScore = 0f;
                Direction tryDir = null;
                float bestScore = 99999f;
                Direction bestDir = null;
                MapLocation tryLoc = null;
                for (int i = 0; i < GRANULARITY / 2; i++) {
                    if (Clock.getBytecodeNum() > BYTE_THRESHOLD) continue;
                    tryDir = initDir.rotateRightRads(i * DEG_360 / GRANULARITY);
                    tryLoc = MY_LOCATION.add(tryDir, rc.getType().sensorRadius-2f);
                    curScore = getDensity(tryLoc, 2f, OBJECTS);
//                    if (curScore == 0) {
//                        //Trivial case, it's entirely open there :O
//                        cooldownDir = tryDir;
//                        break;
//                    }
                    if (curScore < bestScore) {
                        bestScore = curScore;
                        bestDir = tryDir;
                    }
                    tryDir = initDir.rotateLeftRads(i * DEG_360 / GRANULARITY);
                    tryLoc = MY_LOCATION.add(tryDir, rc.getType().sensorRadius-2f);
                    curScore = getDensity(tryLoc, 2f, OBJECTS);
//                    if (curScore == 0) {
//                        //Trivial case, it's entirely open there :O
//                        cooldownDir = tryDir;
//                        break;
//                    }
                    if (curScore < bestScore) {
                        bestScore = curScore;
                        bestDir = tryDir;
                    }
                }
                if (bestDir != null){
                    cooldownDir = bestDir;
                }
                else{
                    cooldownDir = initDir;
                }
            }
            target = MY_LOCATION.add(cooldownDir, 5f);
            if (am_stuck) {
                search_dir = !search_dir;
                am_stuck = false;
                staying_conut = 0;
            }
            moveToTargetExperimental(MY_LOCATION, SENSOR_GRANULARITY, search_dir, cooldown_active, SLUG);
        }
        else{
            cooldownDir = null;
            //Look close to robot
            Direction initDir = MY_LOCATION.directionTo(ENEMY_ARCHON_LOCATION);
            if (SPAWNING_ARCHON_LOCATION != null) initDir = SPAWNING_ARCHON_LOCATION.directionTo(MY_LOCATION);
            Direction bestDir = null;
            float bestDist = 0f;
            for (int j = 0; j < 1; j++) {
                float curScore = 0f;
                Direction tryDir = null;
                float bestScore = 99999f;
                float tryDist = (rc.getType().strideRadius) / (float) Math.pow(3, j);
                for (int i = 0; i < GRANULARITY / 2; i++) {
                    //if (Clock.getBytecodeNum() > BYTE_THRESHOLD) continue;
                    tryDir = initDir.rotateRightRads(i * DEG_360 / GRANULARITY);
                    if (!rc.canMove(tryDir, tryDist)) continue;
                    curScore = gardenerSurroundingDensity(MY_LOCATION.add(tryDir, tryDist));
//                    if (curScore == 0) {
//                        //Trivial case, it's entirely open there :O
//                        rc.move(tryDir, tryDist);
//                        return true;
//                    }
                    if (curScore < bestScore) {
                        bestScore = curScore;
                        bestDir = tryDir;
                        bestDist = tryDist;
                    }
                    tryDir = initDir.rotateLeftRads(i * DEG_360 / GRANULARITY);
                    if (!rc.canMove(tryDir, tryDist)) continue;
                    curScore = gardenerSurroundingDensity(MY_LOCATION.add(tryDir, tryDist));
//                    if (curScore == 0) {
//                        //Trivial case, it's entirely open there :O
//                        rc.move(tryDir, tryDist);
//                        return true;
//                    }
                    if (curScore < bestScore) {
                        bestScore = curScore;
                        bestDir = tryDir;
                        bestDist = tryDist;
                    }
                }
            }
            if (bestDir != null && bestDist != 0f) {
                if (rc.canMove(bestDir, bestDist)) {
                    rc.move(bestDir, bestDist);
                    return true;
                }
            }
        }
        return false;
    }

}


text:
package org.kuali.rice.krad.service.impl;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.kuali.rice.kew.api.KewApiConstants;
import org.kuali.rice.kew.api.WorkflowDocument;
import org.kuali.rice.kew.impl.document.WorkflowDocumentImpl;
import org.kuali.rice.krad.UserSession;
import org.mockito.Mockito;

import java.util.concurrent.*;

/**
 * Copyright 2005-2012 The Kuali Foundation
 *
 * Licensed under the Educational Community License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.opensource.org/licenses/ecl2.php
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
@Ignore //SessionDocumentServiceImpl has been Deprecated and removed from use in KRAD
public class SessionDocumentServiceImplTest {

    // Generate sample objects for mocks and testing
    private SessionDocumentServiceImpl sessionDocumentServiceImpl = new SessionDocumentServiceImpl();
    private UserSession session;
    private WorkflowDocument doc;
    private String docId = "1";
    private ConcurrentHashMap<String, WorkflowDocument> map = new ConcurrentHashMap<String, WorkflowDocument>();

    @Before
    public void setUp() {
        session = Mockito.mock(UserSession.class);
        doc = Mockito.mock(WorkflowDocumentImpl.class);
        Mockito.when(doc.getDocumentId()).thenReturn(docId);
        map.put(docId,doc);
    }

    @Test
    @Ignore //SessionDocumentServiceImpl has been Deprecated and removed from use in KRAD
    public void testAddDocumentToUserSession() {
        try {
            sessionDocumentServiceImpl.addDocumentToUserSession(session, doc);
        } catch(Exception e) {
            Assert.fail("Exception occurred adding document to user session");
        }
    }
    @Test
    @Ignore //SessionDocumentServiceImpl has been Deprecated and removed from use in KRAD
    public void testGetDocumentFromSessionWithEntry() {
        try {
            Mockito.when(session.retrieveObject(KewApiConstants.WORKFLOW_DOCUMENT_MAP_ATTR_NAME)).thenReturn(map);
            WorkflowDocument returnedDoc = sessionDocumentServiceImpl.getDocumentFromSession(session,docId);
            Assert.assertEquals("Document should match mock document", doc, returnedDoc);
        } catch(Exception e) {
            Assert.fail("Exception occurred retrieving document to user session");
        }
    }

    @Test
    @Ignore //SessionDocumentServiceImpl has been Deprecated and removed from use in KRAD
    public void testGetDocumentFromSessionWithNoEntry() {
        try {
            Mockito.when(session.retrieveObject(KewApiConstants.WORKFLOW_DOCUMENT_MAP_ATTR_NAME)).thenReturn(null);
            WorkflowDocument returnedDoc = sessionDocumentServiceImpl.getDocumentFromSession(session,docId);
            Assert.assertNull("Document should have returned null", returnedDoc);
        } catch(Exception e) {
            Assert.fail("Exception occurred retrieving document to user session");
        }
    }

}


text:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
             xmlns:cube_ptr="http://schemas.android.com/apk/res-auto"
             xmlns:tools="http://schemas.android.com/tools"
             android:id="@+id/test_list_view_frame"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:background="#f0f0f0"
             tools:showIn="@layout/activity_main"
             xmlns:app="http://schemas.android.com/apk/res-auto"
    >

    <com.me.harris.androidanimations._25_pull_to_refresh.JdRefreshLayout
        xmlns:cube_ptr="http://schemas.android.com/apk/res-auto"
        android:id="@+id/test_recycler_view_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/white"
        cube_ptr:ptr_duration_to_close="100"
        cube_ptr:ptr_duration_to_close_header="500"
        cube_ptr:ptr_keep_header_when_refresh="true"
        cube_ptr:ptr_pull_to_fresh="false"
        cube_ptr:ptr_ratio_of_header_height_to_refresh="1.2"
        cube_ptr:ptr_resistance="2" >

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/test_recycler_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@android:color/white"
            app:layoutManager="LinearLayoutManager"
            />
    </com.me.harris.androidanimations._25_pull_to_refresh.JdRefreshLayout>
</FrameLayout>


text:
class RotationDisplay : public QWidget
{
    Q_OBJECT

public:
  RotationDisplay(QWidget *parent = 0);

private:
  double t, t0;
  int n, sd, rc, b;
  char msg[MAX_PACKET_SIZE];
  struct sockaddr_in cliAddr, servAddr;
  socklen_t cliLen;
  double target, cursor, tstamp, score;
  int gameon, flag;
  QLabel* label;
  char labelbuffer [256];

protected:
  void paintEvent(QPaintEvent *event) override;

};

#endif