text:
using Xunit;

namespace System.Text.Tests
{
    public class DecoderConvert2Decoder : Decoder
    {
        private Decoder _decoder = null;

        public DecoderConvert2Decoder()
        {
            _decoder = Encoding.UTF8.GetDecoder();
        }

        public override int GetCharCount(byte[] bytes, int index, int count)
        {
            return _decoder.GetCharCount(bytes, index, count);
        }

        public override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
        {
            return _decoder.GetChars(bytes, byteIndex, byteCount, chars, charIndex);
        }

        public override void Reset()
        {
            _decoder.Reset();
        }
    }

    // Convert(System.Byte[],System.Int32,System.Int32,System.Char[],System.Int32,System.Int32,System.Boolean,System.Int32@,System.Int32@,System.Boolean@)
    public class DecoderConvert2
    {
        private const int c_SIZE_OF_ARRAY = 127;
        private readonly RandomDataGenerator _generator = new RandomDataGenerator();

        // PosTest1: Call Convert to convert a arbitrary byte array to character array by using ASCII decoder
        [Fact]
        public void PosTest1()
        {
            Decoder decoder = Encoding.UTF8.GetDecoder();
            char[] chars = new char[c_SIZE_OF_ARRAY];
            byte[] bytes = new byte[c_SIZE_OF_ARRAY];
            for (int i = 0; i < bytes.Length; ++i)
            {
                bytes[i] = _generator.GetByte(-55);
            }

            int bytesUsed;
            int charsUsed;
            bool completed;
            decoder.Convert(bytes, 0, bytes.Length, chars, 0, chars.Length, true, out bytesUsed, out charsUsed, out completed);
            decoder.Reset();

            decoder.Convert(bytes, 0, bytes.Length, chars, 0, chars.Length, false, out bytesUsed, out charsUsed, out completed);
            decoder.Reset();
        }

        // PosTest2: Call Convert to convert a arbitrary byte array to character array by using Unicode decoder"
        [Fact]
        public void PosTest2()
        {
            Decoder decoder = Encoding.Unicode.GetDecoder();
            char[] chars = new char[c_SIZE_OF_ARRAY];
            byte[] bytes = new byte[c_SIZE_OF_ARRAY * 2];
            for (int i = 0; i < bytes.Length; ++i)
            {
                bytes[i] = _generator.GetByte(-55);
            }

            int bytesUsed;
            int charsUsed;
            bool completed;
            decoder.Convert(bytes, 0, bytes.Length, chars, 0, chars.Length, true, out bytesUsed, out charsUsed, out completed);
            decoder.Reset();

            decoder.Convert(bytes, 0, bytes.Length, chars, 0, chars.Length, false, out bytesUsed, out charsUsed, out completed);
            decoder.Reset();
        }

        // PosTest3: Call Convert to convert a ASCII byte array to character array by using ASCII decoder
        [Fact]
        public void PosTest3()
        {
            Decoder decoder = Encoding.UTF8.GetDecoder();
            char[] chars = new char[c_SIZE_OF_ARRAY];
            byte[] bytes = new byte[c_SIZE_OF_ARRAY];
            char[] expected = new char[c_SIZE_OF_ARRAY];
            for (int i = 0; i < bytes.Length; ++i)
            {
                bytes[i] = (byte)i;
            }
            for (int i = 0; i < expected.Length; ++i)
            {
                expected[i] = (char)('\0' + i);
            }

            VerificationHelper(decoder, bytes, 0, bytes.Length, chars, 0, chars.Length, true, bytes.Length, chars.Length, true, expected, "003.1");
            decoder.Reset();
            VerificationHelper(decoder, bytes, 0, bytes.Length, chars, 0, chars.Length, false, bytes.Length, chars.Length, true, expected, "003.2");
            decoder.Reset();
        }

        // PosTest4: Call Convert to convert a ASCII byte array with user implemented decoder
        [Fact]
        public void PosTest4()
        {
            byte[] bytes = new byte[c_SIZE_OF_ARRAY];
            char[] chars = new char[bytes.Length];
            char[] expected = new char[bytes.Length];
            for (int i = 0; i < bytes.Length; ++i)
            {
                bytes[i] = (byte)i;
            }
            for (int i = 0; i < expected.Length; ++i)
            {
                expected[i] = (char)('\0' + i);
            }

            Decoder decoder = new DecoderConvert2Decoder();

            VerificationHelper(decoder, bytes, 0, bytes.Length, chars, 0, chars.Length, true, bytes.Length, chars.Length, true, expected, "004.1");
            decoder.Reset();
            VerificationHelper(decoder, bytes, 0, bytes.Length, chars, 0, chars.Length, false, bytes.Length, chars.Length, true, expected, "004.2");
            decoder.Reset();
        }

        // PosTest5: Call Convert to convert partial of a ASCII byte array with ASCII decoder
        [Fact]
        public void PosTest5()
        {
            byte[] bytes = new byte[c_SIZE_OF_ARRAY];
            char[] chars = new char[bytes.Length];
            Decoder decoder = Encoding.UTF8.GetDecoder();

            for (int i = 0; i < bytes.Length; ++i)
            {
                bytes[i] = (byte)i;
            }

            VerificationHelper(decoder, bytes, 0, 1, chars, 0, 1, false, 1, 1, true, "005.1");
            decoder.Reset();
            VerificationHelper(decoder, bytes, 0, 1, chars, 0, 1, true, 1, 1, true, "005.2");
            decoder.Reset();

            // Verify maxBytes is large than character count
            VerificationHelper(decoder, bytes, 0, bytes.Length, chars, 0, chars.Length - 1, false, bytes.Length - 1, chars.Length - 1, false, "005.3");
            decoder.Reset();
            VerificationHelper(decoder, bytes, 0, bytes.Length, chars, 0, chars.Length - 1, true, bytes.Length - 1, chars.Length - 1, false, "005.4");
            decoder.Reset();
        }

        // PosTest6: Call Convert to convert a ASCII character array with Unicode encoder
        [Fact]
        public void PosTest6()
        {
            byte[] bytes = new byte[c_SIZE_OF_ARRAY];
            char[] chars = new char[bytes.Length];
            for (int i = 0; i < bytes.Length; ++i)
            {
                bytes[i] = (byte)i;
            }

            Decoder decoder = Encoding.Unicode.GetDecoder();
            VerificationHelper(decoder, bytes, 0, bytes.Length, chars, 0, chars.Length, false, bytes.Length, chars.Length / 2, true, "006.1");
            decoder.Reset();
            // There will be 1 byte left unconverted after previous statement, and set flush = false should left this 1 byte in the buffer.
            VerificationHelper(decoder, bytes, 0, bytes.Length, chars, 0, chars.Length, true, bytes.Length, chars.Length / 2 + 1, true, "006.2");
            decoder.Reset();
        }

        // PosTest7: Call Convert to convert partial of a ASCII character array with Unicode encoder
        [Fact]
        public void PosTest7()
        {
            byte[] bytes = new byte[c_SIZE_OF_ARRAY];
            char[] chars = new char[bytes.Length];
            Decoder decoder = Encoding.Unicode.GetDecoder();
            for (int i = 0; i < bytes.Length; ++i)
            {
                bytes[i] = (byte)i;
            }

            VerificationHelper(decoder, bytes, 0, 2, chars, 0, 1, false, 2, 1, true, "007.1");
            decoder.Reset();
            VerificationHelper(decoder, bytes, 0, 2, chars, 0, 1, true, 2, 1, true, "007.2");
            decoder.Reset();

            VerificationHelper(decoder, bytes, 0, bytes.Length, chars, 0, 1, false, 2, 1, false, "007.3");
            decoder.Reset();
            VerificationHelper(decoder, bytes, 0, bytes.Length, chars, 0, 1, true, 2, 1, false, "007.4");
            decoder.Reset();
        }

        // PosTest8: Call Convert to convert a Unicode character array with Unicode encoder
        [Fact]
        public void PosTest8()
        {
            char[] expected = "\u8FD9\u4E2A\u4E00\u4E2A\u6D4B\u8BD5".ToCharArray();
            byte[] bytes = new byte[] {
                217,
                143,
                42,
                78,
                0,
                78,
                42,
                78,
                75,
                109,
                213,
                139
            };
            char[] chars = new char[expected.Length];
            Decoder decoder = Encoding.Unicode.GetDecoder();

            VerificationHelper(decoder, bytes, 0, bytes.Length, chars, 0, chars.Length, false, bytes.Length, chars.Length, true, expected, "008.1");
            decoder.Reset();
            VerificationHelper(decoder, bytes, 0, bytes.Length, chars, 0, chars.Length, true, bytes.Length, chars.Length, true, expected, "008.2");
            decoder.Reset();
        }

        // PosTest9: Call Convert to convert partial of a Unicode character array with Unicode encoder
        [Fact]
        public void PosTest9()
        {
            char[] expected = "\u8FD9".ToCharArray();
            char[] chars = new char[expected.Length];
            byte[] bytes = new byte[] {
                217,
                143,
                42,
                78,
                0,
                78,
                42,
                78,
                75,
                109,
                213,
                139
            };
            Decoder decoder = Encoding.Unicode.GetDecoder();

            VerificationHelper(decoder, bytes, 0, 2, chars, 0, 1, false, 2, 1, true, expected, "009.1");
            decoder.Reset();
            VerificationHelper(decoder, bytes, 0, 2, chars, 0, 1, true, 2, 1, true, expected, "009.2");
            decoder.Reset();

            VerificationHelper(decoder, bytes, 0, bytes.Length, chars, 0, 1, false, 2, 1, false, expected, "009.3");
            decoder.Reset();
            VerificationHelper(decoder, bytes, 0, bytes.Length, chars, 0, 1, true, 2, 1, false, expected, "009.4");
            decoder.Reset();
        }

        // PosTest10: Call Convert with ASCII decoder and convert nothing
        [Fact]
        public void PosTest10()
        {
            byte[] bytes = new byte[c_SIZE_OF_ARRAY];
            char[] chars = new char[bytes.Length];
            Decoder decoder = Encoding.Unicode.GetDecoder();
            for (int i = 0; i < bytes.Length; ++i)
            {
                bytes[i] = (byte)i;
            }

            VerificationHelper(decoder, bytes, 0, 0, chars, 0, 0, false, 0, 0, true, "010.1");
            decoder.Reset();
            VerificationHelper(decoder, bytes, 0, 0, chars, 0, chars.Length, true, 0, 0, true, "010.2");
            decoder.Reset();
        }

        // NegTest1: ArgumentNullException should be thrown when chars or bytes is a null reference
        [Fact]
        public void NegTest1()
        {
            Decoder decoder = Encoding.UTF8.GetDecoder();
            byte[] b = new byte[c_SIZE_OF_ARRAY];
            char[] c = new char[c_SIZE_OF_ARRAY];

            VerificationHelper<ArgumentNullException>(decoder, null, 0, 0, c, 0, 0, true, typeof(ArgumentNullException), "101.1");
            VerificationHelper<ArgumentNullException>(decoder, b, 0, 0, null, 0, 0, true, typeof(ArgumentNullException), "101.2");
            VerificationHelper<ArgumentNullException>(decoder, null, 0, 0, c, 0, 0, false, typeof(ArgumentNullException), "101.3");
            VerificationHelper<ArgumentNullException>(decoder, b, 0, 0, null, 0, 0, false, typeof(ArgumentNullException), "101.4");
        }

        // NegTest2: ArgumentOutOfRangeException should be thrown when charIndex, charCount, byteIndex, or byteCount is less than zero.
        [Fact]
        public void NegTest2()
        {
            Decoder decoder = Encoding.UTF8.GetDecoder();
            byte[] b = new byte[c_SIZE_OF_ARRAY];
            char[] c = new char[c_SIZE_OF_ARRAY];

            VerificationHelper<ArgumentOutOfRangeException>(decoder, b, -1, 0, c, 0, 0, true, typeof(ArgumentOutOfRangeException), "102.1");
            VerificationHelper<ArgumentOutOfRangeException>(decoder, b, 0, 0, c, -1, 0, true, typeof(ArgumentOutOfRangeException), "102.2");
            VerificationHelper<ArgumentOutOfRangeException>(decoder, b, -1, 0, c, 0, 0, false, typeof(ArgumentOutOfRangeException), "102.3");
            VerificationHelper<ArgumentOutOfRangeException>(decoder, b, 0, 0, c, -1, 0, false, typeof(ArgumentOutOfRangeException), "102.4");
            VerificationHelper<ArgumentOutOfRangeException>(decoder, b, 0, -1, c, 0, 0, true, typeof(ArgumentOutOfRangeException), "102.5");
            VerificationHelper<ArgumentOutOfRangeException>(decoder, b, 0, 0, c, 0, -1, true, typeof(ArgumentOutOfRangeException), "102.6");
            VerificationHelper<ArgumentOutOfRangeException>(decoder, b, 0, -1, c, 0, 0, false, typeof(ArgumentOutOfRangeException), "102.7");
            VerificationHelper<ArgumentOutOfRangeException>(decoder, b, 0, 0, c, 0, -1, false, typeof(ArgumentOutOfRangeException), "102.8");
        }

        // NegTest3: ArgumentException should be thrown when The output buffer is too small to contain any of the converted input
        [Fact]
        public void NegTest3()
        {
            Decoder decoder = Encoding.Unicode.GetDecoder();
            byte[] bytes = new byte[c_SIZE_OF_ARRAY];
            for (int i = 0; i < bytes.Length; ++i)
            {
                bytes[i] = _generator.GetByte(-55);
            }
            char[] chars = new char[0];

            VerificationHelper<ArgumentException>(decoder, bytes, 0, c_SIZE_OF_ARRAY, chars, 0, 0, true, typeof(ArgumentException), "103.1");
        }

        // NegTest4: ArgumentOutOfRangeException should be thrown when The length of chars - charIndex is less than charCount.
        [Fact]
        public void NegTest4()
        {
            Decoder decoder = Encoding.UTF8.GetDecoder();
            byte[] b = new byte[c_SIZE_OF_ARRAY];
            char[] c = new char[c_SIZE_OF_ARRAY];

            VerificationHelper<ArgumentOutOfRangeException>(decoder, b, 1, 1, c, 1, c.Length, true, typeof(ArgumentOutOfRangeException), "104.1");
            VerificationHelper<ArgumentOutOfRangeException>(decoder, b, 0, 1, c, c.Length, 1, true, typeof(ArgumentOutOfRangeException), "104.2");
            VerificationHelper<ArgumentOutOfRangeException>(decoder, b, 1, 1, c, 1, c.Length, false, typeof(ArgumentOutOfRangeException), "104.3");
            VerificationHelper<ArgumentOutOfRangeException>(decoder, b, 0, 1, c, c.Length, 1, true, typeof(ArgumentOutOfRangeException), "104.4");
        }

        // NegTest5: ArgumentOutOfRangeException should be thrown when The length of bytes - byteIndex is less than byteCount
        [Fact]
        public void NegTest5()
        {
            Decoder decoder = Encoding.UTF8.GetDecoder();
            byte[] b = new byte[c_SIZE_OF_ARRAY];
            char[] c = new char[c_SIZE_OF_ARRAY];

            VerificationHelper<ArgumentOutOfRangeException>(decoder, b, 1, b.Length, c, 1, 0, true, typeof(ArgumentOutOfRangeException), "105.1");
            VerificationHelper<ArgumentOutOfRangeException>(decoder, b, b.Length, 1, c, 0, 1, true, typeof(ArgumentOutOfRangeException), "105.2");
            VerificationHelper<ArgumentOutOfRangeException>(decoder, b, 1, b.Length, c, 1, 0, false, typeof(ArgumentOutOfRangeException), "105.3");
            VerificationHelper<ArgumentOutOfRangeException>(decoder, b, b.Length, 1, c, 0, 1, true, typeof(ArgumentOutOfRangeException), "105.4");
        }

        private void VerificationHelper(Decoder decoder, byte[] bytes,
            int byteIndex,
            int byteCount,
            char[] chars,
            int charIndex,
            int charCount,
            bool flush,
            int desiredBytesUsed,
            int desiredCharsUsed,
            bool desiredCompleted,
            string errorno)
        {
            int bytesUsed;
            int charsUsed;
            bool completed;

            decoder.Convert(bytes, byteIndex, byteCount, chars, charIndex, charCount, flush, out bytesUsed,
                out charsUsed, out completed);

            Assert.Equal(desiredBytesUsed, bytesUsed);
            Assert.Equal(desiredCharsUsed, charsUsed);
            Assert.Equal(desiredCompleted, completed);
        }

        private void VerificationHelper(Decoder decoder, byte[] bytes,
            int byteIndex,
            int byteCount,
            char[] chars,
            int charIndex,
            int charCount,
            bool flush,
            int desiredBytesUsed,
            int desiredCharsUsed,
            bool desiredCompleted,
            char[] desiredChars,
            string errorno)
        {
            VerificationHelper(decoder, bytes, byteIndex, byteCount, chars, charIndex, charCount, flush, desiredBytesUsed,
                desiredCharsUsed, desiredCompleted, errorno + ".1");

            Assert.Equal(desiredChars.Length, chars.Length);

            for (int i = 0; i < chars.Length; ++i)
            {
                Assert.Equal(desiredChars[i], chars[i]);
            }
        }

        private void VerificationHelper<T>(Decoder decoder, byte[] bytes,
            int byteIndex,
            int byteCount,
            char[] chars,
            int charIndex,
            int charCount,
            bool flush,
            Type expected,
            string errorno) where T : Exception
        {
            string str = null;
            int bytesUsed;
            int charsUsed;
            bool completed;

            str = new string(chars);
            Assert.Throws<T>(() =>
            {
                decoder.Convert(bytes, byteIndex, byteCount, chars, charIndex, charCount, flush, out bytesUsed,
                 out charsUsed, out completed);
            });
        }
    }
}


text:
package com.amazonaws.services.simplesystemsmanagement.model;

import java.io.Serializable;
import javax.annotation.Generated;

import com.amazonaws.AmazonWebServiceRequest;

/**
 *
 * @see AWS API
 *      Documentation
 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class CreateDocumentRequest extends com.amazonaws.AmazonWebServiceRequest implements Serializable, Cloneable {

    /**
     *

     * A valid JSON or YAML string.
     *

     */
    private String content;
    /**
     *

     * A list of key and value pairs that describe attachments to a version of a document.
     *

     */
    private com.amazonaws.internal.SdkInternalList<AttachmentsSource> attachments;
    /**
     *

     * A name for the Systems Manager document.
     *

     * <important>
     *

     * Do not use the following to begin the names of documents you create. They are reserved by AWS for use as document
     * prefixes:
     *

     *

     *

     *

     * aws
     *

     *

     *

     *

     * amazon
     *

     *

     *

     *

     * amzn
     *

     *

     *

     * </important>
     */
    private String name;
    /**
     *

     * An optional field specifying the version of the artifact you are creating with the document. For example,
     * "Release 12, Update 6". This value is unique across all versions of a document, and cannot be changed.
     *

     */
    private String versionName;
    /**
     *

     * The type of document to create. Valid document types include: Command, Policy,
     * Automation, Session, and Package.
     *

     */
    private String documentType;
    /**
     *

     * Specify the document format for the request. The document format can be either JSON or YAML. JSON is the default
     * format.
     *

     */
    private String documentFormat;
    /**
     *

     * Specify a target type to define the kinds of resources the document can run on. For example, to run a document on
     * EC2 instances, specify the following value: /AWS::EC2::Instance. If you specify a value of '/' the document can
     * run on all types of resources. If you don't specify a value, the document can't run on any resources. For a list
     * of valid resource types, see AWS
     * Resource Types Reference in the AWS CloudFormation User Guide.
     *

     */
    private String targetType;
    /**
     *

     * Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different ways, such
     * as by purpose, owner, or environment. For example, you might want to tag an SSM document to identify the types of
     * targets or the environment where it will run. In this case, you could specify the following key name/value pairs:
     *

     *

     *

     *

     * Key=OS,Value=Windows
     *

     *

     *

     *

     * Key=Environment,Value=Production
     *

     *

     *

     * <note>
     *

     * To add tags to an existing SSM document, use the AddTagsToResource action.
     *

     * </note>
     */
    private com.amazonaws.internal.SdkInternalList<Tag> tags;

    /**
     *

     * A valid JSON or YAML string.
     *

     *
     * @param content
     *        A valid JSON or YAML string.
     */

    public void setContent(String content) {
        this.content = content;
    }

    /**
     *

     * A valid JSON or YAML string.
     *

     *
     * @return A valid JSON or YAML string.
     */

    public String getContent() {
        return this.content;
    }

    /**
     *

     * A valid JSON or YAML string.
     *

     *
     * @param content
     *        A valid JSON or YAML string.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public CreateDocumentRequest withContent(String content) {
        setContent(content);
        return this;
    }

    /**
     *

     * A list of key and value pairs that describe attachments to a version of a document.
     *

     *
     * @return A list of key and value pairs that describe attachments to a version of a document.
     */

    public java.util.List<AttachmentsSource> getAttachments() {
        if (attachments == null) {
            attachments = new com.amazonaws.internal.SdkInternalList<AttachmentsSource>();
        }
        return attachments;
    }

    /**
     *

     * A list of key and value pairs that describe attachments to a version of a document.
     *

     *
     * @param attachments
     *        A list of key and value pairs that describe attachments to a version of a document.
     */

    public void setAttachments(java.util.Collection<AttachmentsSource> attachments) {
        if (attachments == null) {
            this.attachments = null;
            return;
        }

        this.attachments = new com.amazonaws.internal.SdkInternalList<AttachmentsSource>(attachments);
    }

    /**
     *

     * A list of key and value pairs that describe attachments to a version of a document.
     *

     *

     * NOTE: This method appends the values to the existing list (if any). Use
     * {@link #setAttachments(java.util.Collection)} or {@link #withAttachments(java.util.Collection)} if you want to
     * override the existing values.
     *

     *
     * @param attachments
     *        A list of key and value pairs that describe attachments to a version of a document.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public CreateDocumentRequest withAttachments(AttachmentsSource... attachments) {
        if (this.attachments == null) {
            setAttachments(new com.amazonaws.internal.SdkInternalList<AttachmentsSource>(attachments.length));
        }
        for (AttachmentsSource ele : attachments) {
            this.attachments.add(ele);
        }
        return this;
    }

    /**
     *

     * A list of key and value pairs that describe attachments to a version of a document.
     *

     *
     * @param attachments
     *        A list of key and value pairs that describe attachments to a version of a document.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public CreateDocumentRequest withAttachments(java.util.Collection<AttachmentsSource> attachments) {
        setAttachments(attachments);
        return this;
    }

    /**
     *

     * A name for the Systems Manager document.
     *

     * <important>
     *

     * Do not use the following to begin the names of documents you create. They are reserved by AWS for use as document
     * prefixes:
     *

     *

     *

     *

     * aws
     *

     *

     *

     *

     * amazon
     *

     *

     *

     *

     * amzn
     *

     *

     *

     * </important>
     *
     * @param name
     *        A name for the Systems Manager document.
 <important>
     *

     *        Do not use the following to begin the names of documents you create. They are reserved by AWS for use as
     *        document prefixes:
     *

     *

     *

     *

     *        aws
     *

     *

     *

     *

     *        amazon
     *

     *

     *

     *

     *        amzn
     *

     *

     *

     */

    public void setName(String name) {
        this.name = name;
    }

    /**
     *

     * A name for the Systems Manager document.
     *

     * <important>
     *

     * Do not use the following to begin the names of documents you create. They are reserved by AWS for use as document
     * prefixes:
     *

     *

     *

     *

     * aws
     *

     *

     *

     *

     * amazon
     *

     *

     *

     *

     * amzn
     *

     *

     *

     * </important>
     *
     * @return A name for the Systems Manager document.
 <important>
     *

     *         Do not use the following to begin the names of documents you create. They are reserved by AWS for use as
     *         document prefixes:
     *

     *

     *

     *

     *         aws
     *

     *

     *

     *

     *         amazon
     *

     *

     *

     *

     *         amzn
     *

     *

     *

     */

    public String getName() {
        return this.name;
    }

    /**
     *

     * A name for the Systems Manager document.
     *

     * <important>
     *

     * Do not use the following to begin the names of documents you create. They are reserved by AWS for use as document
     * prefixes:
     *

     *

     *

     *

     * aws
     *

     *

     *

     *

     * amazon
     *

     *

     *

     *

     * amzn
     *

     *

     *

     * </important>
     *
     * @param name
     *        A name for the Systems Manager document.
 <important>
     *

     *        Do not use the following to begin the names of documents you create. They are reserved by AWS for use as
     *        document prefixes:
     *

     *

     *

     *

     *        aws
     *

     *

     *

     *

     *        amazon
     *

     *

     *

     *

     *        amzn
     *

     *

     *

     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public CreateDocumentRequest withName(String name) {
        setName(name);
        return this;
    }

    /**
     *

     * An optional field specifying the version of the artifact you are creating with the document. For example,
     * "Release 12, Update 6". This value is unique across all versions of a document, and cannot be changed.
     *

     *
     * @param versionName
     *        An optional field specifying the version of the artifact you are creating with the document. For example,
     *        "Release 12, Update 6". This value is unique across all versions of a document, and cannot be changed.
     */

    public void setVersionName(String versionName) {
        this.versionName = versionName;
    }

    /**
     *

     * An optional field specifying the version of the artifact you are creating with the document. For example,
     * "Release 12, Update 6". This value is unique across all versions of a document, and cannot be changed.
     *

     *
     * @return An optional field specifying the version of the artifact you are creating with the document. For example,
     *         "Release 12, Update 6". This value is unique across all versions of a document, and cannot be changed.
     */

    public String getVersionName() {
        return this.versionName;
    }

    /**
     *

     * An optional field specifying the version of the artifact you are creating with the document. For example,
     * "Release 12, Update 6". This value is unique across all versions of a document, and cannot be changed.
     *

     *
     * @param versionName
     *        An optional field specifying the version of the artifact you are creating with the document. For example,
     *        "Release 12, Update 6". This value is unique across all versions of a document, and cannot be changed.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public CreateDocumentRequest withVersionName(String versionName) {
        setVersionName(versionName);
        return this;
    }

    /**
     *

     * The type of document to create. Valid document types include: Command, Policy,
     * Automation, Session, and Package.
     *

     *
     * @param documentType
     *        The type of document to create. Valid document types include: Command, Policy,
     *        Automation, Session, and Package.
     * @see DocumentType
     */

    public void setDocumentType(String documentType) {
        this.documentType = documentType;
    }

    /**
     *

     * The type of document to create. Valid document types include: Command, Policy,
     * Automation, Session, and Package.
     *

     *
     * @return The type of document to create. Valid document types include: Command, Policy,
     *         Automation, Session, and Package.
     * @see DocumentType
     */

    public String getDocumentType() {
        return this.documentType;
    }

    /**
     *

     * The type of document to create. Valid document types include: Command, Policy,
     * Automation, Session, and Package.
     *

     *
     * @param documentType
     *        The type of document to create. Valid document types include: Command, Policy,
     *        Automation, Session, and Package.
     * @return Returns a reference to this object so that method calls can be chained together.
     * @see DocumentType
     */

    public CreateDocumentRequest withDocumentType(String documentType) {
        setDocumentType(documentType);
        return this;
    }

    /**
     *

     * The type of document to create. Valid document types include: Command, Policy,
     * Automation, Session, and Package.
     *

     *
     * @param documentType
     *        The type of document to create. Valid document types include: Command, Policy,
     *        Automation, Session, and Package.
     * @see DocumentType
     */

    public void setDocumentType(DocumentType documentType) {
        withDocumentType(documentType);
    }

    /**
     *

     * The type of document to create. Valid document types include: Command, Policy,
     * Automation, Session, and Package.
     *

     *
     * @param documentType
     *        The type of document to create. Valid document types include: Command, Policy,
     *        Automation, Session, and Package.
     * @return Returns a reference to this object so that method calls can be chained together.
     * @see DocumentType
     */

    public CreateDocumentRequest withDocumentType(DocumentType documentType) {
        this.documentType = documentType.toString();
        return this;
    }

    /**
     *

     * Specify the document format for the request. The document format can be either JSON or YAML. JSON is the default
     * format.
     *

     *
     * @param documentFormat
     *        Specify the document format for the request. The document format can be either JSON or YAML. JSON is the
     *        default format.
     * @see DocumentFormat
     */

    public void setDocumentFormat(String documentFormat) {
        this.documentFormat = documentFormat;
    }

    /**
     *

     * Specify the document format for the request. The document format can be either JSON or YAML. JSON is the default
     * format.
     *

     *
     * @return Specify the document format for the request. The document format can be either JSON or YAML. JSON is the
     *         default format.
     * @see DocumentFormat
     */

    public String getDocumentFormat() {
        return this.documentFormat;
    }

    /**
     *

     * Specify the document format for the request. The document format can be either JSON or YAML. JSON is the default
     * format.
     *

     *
     * @param documentFormat
     *        Specify the document format for the request. The document format can be either JSON or YAML. JSON is the
     *        default format.
     * @return Returns a reference to this object so that method calls can be chained together.
     * @see DocumentFormat
     */

    public CreateDocumentRequest withDocumentFormat(String documentFormat) {
        setDocumentFormat(documentFormat);
        return this;
    }

    /**
     *

     * Specify the document format for the request. The document format can be either JSON or YAML. JSON is the default
     * format.
     *

     *
     * @param documentFormat
     *        Specify the document format for the request. The document format can be either JSON or YAML. JSON is the
     *        default format.
     * @see DocumentFormat
     */

    public void setDocumentFormat(DocumentFormat documentFormat) {
        withDocumentFormat(documentFormat);
    }

    /**
     *

     * Specify the document format for the request. The document format can be either JSON or YAML. JSON is the default
     * format.
     *

     *
     * @param documentFormat
     *        Specify the document format for the request. The document format can be either JSON or YAML. JSON is the
     *        default format.
     * @return Returns a reference to this object so that method calls can be chained together.
     * @see DocumentFormat
     */

    public CreateDocumentRequest withDocumentFormat(DocumentFormat documentFormat) {
        this.documentFormat = documentFormat.toString();
        return this;
    }

    /**
     *

     * Specify a target type to define the kinds of resources the document can run on. For example, to run a document on
     * EC2 instances, specify the following value: /AWS::EC2::Instance. If you specify a value of '/' the document can
     * run on all types of resources. If you don't specify a value, the document can't run on any resources. For a list
     * of valid resource types, see AWS
     * Resource Types Reference in the AWS CloudFormation User Guide.
     *

     *
     * @param targetType
     *        Specify a target type to define the kinds of resources the document can run on. For example, to run a
     *        document on EC2 instances, specify the following value: /AWS::EC2::Instance. If you specify a value of '/'
     *        the document can run on all types of resources. If you don't specify a value, the document can't run on
     *        any resources. For a list of valid resource types, see AWS Resource Types Reference in the AWS CloudFormation User Guide.
     */

    public void setTargetType(String targetType) {
        this.targetType = targetType;
    }

    /**
     *

     * Specify a target type to define the kinds of resources the document can run on. For example, to run a document on
     * EC2 instances, specify the following value: /AWS::EC2::Instance. If you specify a value of '/' the document can
     * run on all types of resources. If you don't specify a value, the document can't run on any resources. For a list
     * of valid resource types, see AWS
     * Resource Types Reference in the AWS CloudFormation User Guide.
     *

     *
     * @return Specify a target type to define the kinds of resources the document can run on. For example, to run a
     *         document on EC2 instances, specify the following value: /AWS::EC2::Instance. If you specify a value of
     *         '/' the document can run on all types of resources. If you don't specify a value, the document can't run
     *         on any resources. For a list of valid resource types, see AWS
     *         Resource Types Reference in the AWS CloudFormation User Guide.
     */

    public String getTargetType() {
        return this.targetType;
    }

    /**
     *

     * Specify a target type to define the kinds of resources the document can run on. For example, to run a document on
     * EC2 instances, specify the following value: /AWS::EC2::Instance. If you specify a value of '/' the document can
     * run on all types of resources. If you don't specify a value, the document can't run on any resources. For a list
     * of valid resource types, see AWS
     * Resource Types Reference in the AWS CloudFormation User Guide.
     *

     *
     * @param targetType
     *        Specify a target type to define the kinds of resources the document can run on. For example, to run a
     *        document on EC2 instances, specify the following value: /AWS::EC2::Instance. If you specify a value of '/'
     *        the document can run on all types of resources. If you don't specify a value, the document can't run on
     *        any resources. For a list of valid resource types, see AWS Resource Types Reference in the AWS CloudFormation User Guide.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public CreateDocumentRequest withTargetType(String targetType) {
        setTargetType(targetType);
        return this;
    }

    /**
     *

     * Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different ways, such
     * as by purpose, owner, or environment. For example, you might want to tag an SSM document to identify the types of
     * targets or the environment where it will run. In this case, you could specify the following key name/value pairs:
     *

     *

     *

     *

     * Key=OS,Value=Windows
     *

     *

     *

     *

     * Key=Environment,Value=Production
     *

     *

     *

     * <note>
     *

     * To add tags to an existing SSM document, use the AddTagsToResource action.
     *

     * </note>
     *
     * @return Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different
     *         ways, such as by purpose, owner, or environment. For example, you might want to tag an SSM document to
     *         identify the types of targets or the environment where it will run. In this case, you could specify the
     *         following key name/value pairs:

     *

     *

     *

     *         Key=OS,Value=Windows
     *

     *

     *

     *

     *         Key=Environment,Value=Production
     *

     *

     *

     *         <note>
     *

     *         To add tags to an existing SSM document, use the AddTagsToResource action.
     *

     */

    public java.util.List<Tag> getTags() {
        if (tags == null) {
            tags = new com.amazonaws.internal.SdkInternalList<Tag>();
        }
        return tags;
    }

    /**
     *

     * Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different ways, such
     * as by purpose, owner, or environment. For example, you might want to tag an SSM document to identify the types of
     * targets or the environment where it will run. In this case, you could specify the following key name/value pairs:
     *

     *

     *

     *

     * Key=OS,Value=Windows
     *

     *

     *

     *

     * Key=Environment,Value=Production
     *

     *

     *

     * <note>
     *

     * To add tags to an existing SSM document, use the AddTagsToResource action.
     *

     * </note>
     *
     * @param tags
     *        Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different
     *        ways, such as by purpose, owner, or environment. For example, you might want to tag an SSM document to
     *        identify the types of targets or the environment where it will run. In this case, you could specify the
     *        following key name/value pairs:

     *

     *

     *

     *        Key=OS,Value=Windows
     *

     *

     *

     *

     *        Key=Environment,Value=Production
     *

     *

     *

     *        <note>
     *

     *        To add tags to an existing SSM document, use the AddTagsToResource action.
     *

     */

    public void setTags(java.util.Collection<Tag> tags) {
        if (tags == null) {
            this.tags = null;
            return;
        }

        this.tags = new com.amazonaws.internal.SdkInternalList<Tag>(tags);
    }

    /**
     *

     * Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different ways, such
     * as by purpose, owner, or environment. For example, you might want to tag an SSM document to identify the types of
     * targets or the environment where it will run. In this case, you could specify the following key name/value pairs:
     *

     *

     *

     *

     * Key=OS,Value=Windows
     *

     *

     *

     *

     * Key=Environment,Value=Production
     *

     *

     *

     * <note>
     *

     * To add tags to an existing SSM document, use the AddTagsToResource action.
     *

     * </note>
     *

     * NOTE: This method appends the values to the existing list (if any). Use
     * {@link #setTags(java.util.Collection)} or {@link #withTags(java.util.Collection)} if you want to override the
     * existing values.
     *

     *
     * @param tags
     *        Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different
     *        ways, such as by purpose, owner, or environment. For example, you might want to tag an SSM document to
     *        identify the types of targets or the environment where it will run. In this case, you could specify the
     *        following key name/value pairs:

     *

     *

     *

     *        Key=OS,Value=Windows
     *

     *

     *

     *

     *        Key=Environment,Value=Production
     *

     *

     *

     *        <note>
     *

     *        To add tags to an existing SSM document, use the AddTagsToResource action.
     *

     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public CreateDocumentRequest withTags(Tag... tags) {
        if (this.tags == null) {
            setTags(new com.amazonaws.internal.SdkInternalList<Tag>(tags.length));
        }
        for (Tag ele : tags) {
            this.tags.add(ele);
        }
        return this;
    }

    /**
     *

     * Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different ways, such
     * as by purpose, owner, or environment. For example, you might want to tag an SSM document to identify the types of
     * targets or the environment where it will run. In this case, you could specify the following key name/value pairs:
     *

     *

     *

     *

     * Key=OS,Value=Windows
     *

     *

     *

     *

     * Key=Environment,Value=Production
     *

     *

     *

     * <note>
     *

     * To add tags to an existing SSM document, use the AddTagsToResource action.
     *

     * </note>
     *
     * @param tags
     *        Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different
     *        ways, such as by purpose, owner, or environment. For example, you might want to tag an SSM document to
     *        identify the types of targets or the environment where it will run. In this case, you could specify the
     *        following key name/value pairs:

     *

     *

     *

     *        Key=OS,Value=Windows
     *

     *

     *

     *

     *        Key=Environment,Value=Production
     *

     *

     *

     *        <note>
     *

     *        To add tags to an existing SSM document, use the AddTagsToResource action.
     *

     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public CreateDocumentRequest withTags(java.util.Collection<Tag> tags) {
        setTags(tags);
        return this;
    }

    /**
     * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
     * redacted from this string using a placeholder value.
     *
     * @return A string representation of this object.
     *
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getContent() != null)
            sb.append("Content: ").append(getContent()).append(",");
        if (getAttachments() != null)
            sb.append("Attachments: ").append(getAttachments()).append(",");
        if (getName() != null)
            sb.append("Name: ").append(getName()).append(",");
        if (getVersionName() != null)
            sb.append("VersionName: ").append(getVersionName()).append(",");
        if (getDocumentType() != null)
            sb.append("DocumentType: ").append(getDocumentType()).append(",");
        if (getDocumentFormat() != null)
            sb.append("DocumentFormat: ").append(getDocumentFormat()).append(",");
        if (getTargetType() != null)
            sb.append("TargetType: ").append(getTargetType()).append(",");
        if (getTags() != null)
            sb.append("Tags: ").append(getTags());
        sb.append("}");
        return sb.toString();
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;

        if (obj instanceof CreateDocumentRequest == false)
            return false;
        CreateDocumentRequest other = (CreateDocumentRequest) obj;
        if (other.getContent() == null ^ this.getContent() == null)
            return false;
        if (other.getContent() != null && other.getContent().equals(this.getContent()) == false)
            return false;
        if (other.getAttachments() == null ^ this.getAttachments() == null)
            return false;
        if (other.getAttachments() != null && other.getAttachments().equals(this.getAttachments()) == false)
            return false;
        if (other.getName() == null ^ this.getName() == null)
            return false;
        if (other.getName() != null && other.getName().equals(this.getName()) == false)
            return false;
        if (other.getVersionName() == null ^ this.getVersionName() == null)
            return false;
        if (other.getVersionName() != null && other.getVersionName().equals(this.getVersionName()) == false)
            return false;
        if (other.getDocumentType() == null ^ this.getDocumentType() == null)
            return false;
        if (other.getDocumentType() != null && other.getDocumentType().equals(this.getDocumentType()) == false)
            return false;
        if (other.getDocumentFormat() == null ^ this.getDocumentFormat() == null)
            return false;
        if (other.getDocumentFormat() != null && other.getDocumentFormat().equals(this.getDocumentFormat()) == false)
            return false;
        if (other.getTargetType() == null ^ this.getTargetType() == null)
            return false;
        if (other.getTargetType() != null && other.getTargetType().equals(this.getTargetType()) == false)
            return false;
        if (other.getTags() == null ^ this.getTags() == null)
            return false;
        if (other.getTags() != null && other.getTags().equals(this.getTags()) == false)
            return false;
        return true;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;

        hashCode = prime * hashCode + ((getContent() == null) ? 0 : getContent().hashCode());
        hashCode = prime * hashCode + ((getAttachments() == null) ? 0 : getAttachments().hashCode());
        hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode());
        hashCode = prime * hashCode + ((getVersionName() == null) ? 0 : getVersionName().hashCode());
        hashCode = prime * hashCode + ((getDocumentType() == null) ? 0 : getDocumentType().hashCode());
        hashCode = prime * hashCode + ((getDocumentFormat() == null) ? 0 : getDocumentFormat().hashCode());
        hashCode = prime * hashCode + ((getTargetType() == null) ? 0 : getTargetType().hashCode());
        hashCode = prime * hashCode + ((getTags() == null) ? 0 : getTags().hashCode());
        return hashCode;
    }

    @Override
    public CreateDocumentRequest clone() {
        return (CreateDocumentRequest) super.clone();
    }

}

redpajama_set_name: RedPajamaGithub


text:
# ▤ SideMenu
[![Version](https://img.shields.io/cocoapods/v/SideMenu.svg?style=flat)](http://cocoapods.org/pods/SideMenu)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![License](https://img.shields.io/cocoapods/l/SideMenu.svg?style=flat)](http://cocoapods.org/pods/SideMenu)
[![Platform](https://img.shields.io/cocoapods/p/SideMenu.svg?style=flat)](http://cocoapods.org/pods/SideMenu)

### If you like SideMenu, give it a ★ at the top right of its [GitHub](https://github.com/jonkykong/SideMenu) page.
#### Using SideMenu in your app? [Send](mailto:yo@massappeal.co?subject=SideMenu%20in%20action!) me a link to your app in the app store!

> Hi, I'm Jon Kent and I am an iOS designer, developer, and mobile strategist. I love coffee and play the drums.
> * [**Hire me**](mailto:yo@massappeal.co?subject=Let's%20build%20something%20amazing) to help you make cool stuff. *Note: If you're having a problem with SideMenu, please open an [issue](https://github.com/jonkykong/SideMenu/issues/new) and do not email me.*
> * Check out my [website](http://massappeal.co) to see some of my other projects.
> * Building and maintaining this free library takes time. Help keep me awake and buy me a coffee ☕ via [PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=contact%40jonkent%2eme&lc=US&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted).

## Overview

SideMenu is a simple and versatile side menu control written in Swift.
- [x] **It can be implemented in storyboard without a single line of [code](#code-less-storyboard-implementation).**
- [x] Four standard animation styles to choose from (there's even a parallax effect if you want to get weird).
- [x] Highly customizable without needing to write tons of custom code.
- [x] Supports continuous swiping between side menus on boths sides in a single gesture.
- [x] Global menu configuration. Set-up once and be done for all screens.
- [x] Menus can be presented and dismissed the same as any other view controller since this control uses [custom transitions](https://developer.apple.com/library/content/featuredarticles/ViewControllerPGforiPhoneOS/CustomizingtheTransitionAnimations.html).
- [x] Animations use your view controllers, not snapshots.
- [x] Properly handles screen rotation and in-call status bar height changes.

Check out the example project to see it in action!
### Preview Samples
| Slide Out | Slide In | Dissolve | Slide In + Out |
| --- | --- | --- | --- |
| ![](etc/SlideOut.gif) | ![](etc/SlideIn.gif) | ![](etc/Dissolve.gif) | ![](etc/InOut.gif) |

## Requirements
- [x] iOS 8 or higher.

## Installation
### CocoaPods

[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:

```bash
$ gem install cocoapods
```

To integrate SideMenu into your Xcode project using CocoaPods, specify it in your `Podfile`:

```ruby
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'SideMenu'

# For Swift 3 (no longer maintained), use:
# pod 'SideMenu', '~> 2.3.4'
```

Then, run the following command:

```bash
$ pod install
```

### Carthage

[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with [Homebrew](http://brew.sh/) using the following command:

```bash
$ brew update
$ brew install carthage
```

To integrate SideMenu into your Xcode project using Carthage, specify it in your `Cartfile`:

```ogdl
github "jonkykong/SideMenu" "master"
```

## Usage
### Code-less Storyboard Implementation
1. Create a Navigation Controller for a side menu. Set the `Custom Class` of the Navigation Controller to be `UISideMenuNavigationController` in the **Identity Inspector**. Set the `Module` to `SideMenu` (ignore this step if you've manually added SideMenu to your project). Create a Root View Controller for the Navigation Controller (shown as a UITableViewController below). Set up any Triggered Segues you want in that view controller.
![](etc/Screenshot1.png)

2. Set the `Left Side` property of the `UISideMenuNavigationController` to On if you want it to appear from the left side of the screen, or Off/Default if you want it to appear from the right side.
![](etc/Screenshot2.png)

3. Add a UIButton or UIBarButton to a view controller that you want to display the menu from. Set that button's Triggered Segues action to modally present the Navigation Controller from step 1.
![](etc/Screenshot3.png)

That's it. *Note: you can only enable gestures in code.*
### Code Implementation
First:
```swift
import SideMenu
```

In your view controller's `viewDidLoad` event, do something like this (**IMPORTANT: If you're seeing a black menu when you use gestures, read this section carefully!**):
``` swift
// Define the menus
let menuLeftNavigationController = UISideMenuNavigationController(rootViewController: YourViewController)
// UISideMenuNavigationController is a subclass of UINavigationController, so do any additional configuration
// of it here like setting its viewControllers. If you're using storyboards, you'll want to do something like:
// let menuLeftNavigationController = storyboard!.instantiateViewController(withIdentifier: "LeftMenuNavigationController") as! UISideMenuNavigationController
SideMenuManager.default.menuLeftNavigationController = menuLeftNavigationController

let menuRightNavigationController = UISideMenuNavigationController(rootViewController: YourViewController)
// UISideMenuNavigationController is a subclass of UINavigationController, so do any additional configuration
// of it here like setting its viewControllers. If you're using storyboards, you'll want to do something like:
// let menuRightNavigationController = storyboard!.instantiateViewController(withIdentifier: "RightMenuNavigationController") as! UISideMenuNavigationController
SideMenuManager.default.menuRightNavigationController = menuRightNavigationController

// Enable gestures. The left and/or right menus must be set up above for these to work.
// Note that these continue to work on the Navigation Controller independent of the view controller it displays!
SideMenuManager.default.menuAddPanGestureToPresent(toView: self.navigationController!.navigationBar)
SideMenuManager.default.menuAddScreenEdgePanGesturesToPresent(toView: self.navigationController!.view)
```
Then from a button, do something like this:
``` swift
present(SideMenuManager.default.menuLeftNavigationController!, animated: true, completion: nil)

// Similarly, to dismiss a menu programmatically, you would do this:
dismiss(animated: true, completion: nil)
```
That's it.
### Customization
#### SideMenuManager
Just type ` SideMenuManager.default.menu...` and code completion will show you everything you can customize (defaults are shown below for reference):
``` swift
/**
The push style of the menu.

There are six modes in MenuPushStyle:
- defaultBehavior: The view controller is pushed onto the stack.
- popWhenPossible: If a view controller already in the stack is of the same class as the pushed view controller, the stack is instead popped back to the existing view controller. This behavior can help users from getting lost in a deep navigation stack.
- preserve: If a view controller already in the stack is of the same class as the pushed view controller, the existing view controller is pushed to the end of the stack. This behavior is similar to a UITabBarController.
- preserveAndHideBackButton: Same as .preserve and back buttons are automatically hidden.
- replace: Any existing view controllers are released from the stack and replaced with the pushed view controller. Back buttons are automatically hidden. This behavior is ideal if view controllers require a lot of memory or their state doesn't need to be preserved..
- subMenu: Unlike all other behaviors that push using the menu's presentingViewController, this behavior pushes view controllers within the menu.  Use this behavior if you want to display a sub menu.
*/
open var menuPushStyle: MenuPushStyle = .defaultBehavior

/**
The presentation mode of the menu.

There are four modes in MenuPresentMode:
- menuSlideIn: Menu slides in over of the existing view.
- viewSlideOut: The existing view slides out to reveal the menu.
- viewSlideInOut: The existing view slides out while the menu slides in.
- menuDissolveIn: The menu dissolves in over the existing view controller.
*/
open var menuPresentMode: MenuPresentMode = .viewSlideOut

/// Prevents the same view controller (or a view controller of the same class) from being pushed more than once. Defaults to true.
open var menuAllowPushOfSameClassTwice = true

/**
Width of the menu when presented on screen, showing the existing view controller in the remaining space. Default is 75% of the screen width.

Note that each menu's width can be overridden using the `menuWidth` property on any `UISideMenuNavigationController` instance.
*/
open var menuWidth: CGFloat = max(round(min((appScreenRect.width), (appScreenRect.height)) * 0.75), 240)

/// Duration of the animation when the menu is presented without gestures. Default is 0.35 seconds.
open var menuAnimationPresentDuration: Double = 0.35

/// Duration of the animation when the menu is dismissed without gestures. Default is 0.35 seconds.
open var menuAnimationDismissDuration: Double = 0.35

/// Duration of the remaining animation when the menu is partially dismissed with gestures. Default is 0.35 seconds.
open var menuAnimationCompleteGestureDuration: Double = 0.35

/// Amount to fade the existing view controller when the menu is presented. Default is 0 for no fade. Set to 1 to fade completely.
open var menuAnimationFadeStrength: CGFloat = 0

/// The amount to scale the existing view controller or the menu view controller depending on the `menuPresentMode`. Default is 1 for no scaling. Less than 1 will shrink, greater than 1 will grow.
open var menuAnimationTransformScaleFactor: CGFloat = 1

/// The background color behind menu animations. Depending on the animation settings this may not be visible. If `menuFadeStatusBar` is true, this color is used to fade it. Default is black.
open var menuAnimationBackgroundColor: UIColor?

/// The shadow opacity around the menu view controller or existing view controller depending on the `menuPresentMode`. Default is 0.5 for 50% opacity.
open var menuShadowOpacity: Float = 0.5

/// The shadow color around the menu view controller or existing view controller depending on the `menuPresentMode`. Default is black.
open var menuShadowColor = UIColor.black

/// The radius of the shadow around the menu view controller or existing view controller depending on the `menuPresentMode`. Default is 5.
open var menuShadowRadius: CGFloat = 5

/// The left menu swipe to dismiss gesture.
open weak var menuLeftSwipeToDismissGesture: UIPanGestureRecognizer?

/// The right menu swipe to dismiss gesture.
open weak var menuRightSwipeToDismissGesture: UIPanGestureRecognizer?

/// Enable or disable gestures that would swipe to dismiss the menu. Default is true.
open var menuEnableSwipeGestures: Bool = true

/// Enable or disable interaction with the presenting view controller while the menu is displayed. Enabling may make it difficult to dismiss the menu or cause exceptions if the user tries to present and already presented menu. Default is false.
open var menuPresentingViewControllerUserInteractionEnabled: Bool = false

/// The strength of the parallax effect on the existing view controller. Does not apply to `menuPresentMode` when set to `ViewSlideOut`. Default is 0.
open var menuParallaxStrength: Int = 0

/// Draws the `menuAnimationBackgroundColor` behind the status bar. Default is true.
open var menuFadeStatusBar = true

/// The animation options when a menu is displayed. Ignored when displayed with a gesture.
open var menuAnimationOptions: UIViewAnimationOptions = .curveEaseInOut

/// The animation spring damping when a menu is displayed. Ignored when displayed with a gesture.
open var menuAnimationUsingSpringWithDamping: CGFloat = 1

/// The animation initial spring velocity when a menu is displayed. Ignored when displayed with a gesture.
open var menuAnimationInitialSpringVelocity: CGFloat = 1

/**
Automatically dismisses the menu when another view is pushed from it.

Note: to prevent the menu from dismissing when presenting, set modalPresentationStyle = .overFullScreen
of the view controller being presented in storyboard or during its initalization.
*/
open var menuDismissOnPush = true

/**
The blur effect style of the menu if the menu's root view controller is a UITableViewController or UICollectionViewController.

- Note: If you want cells in a UITableViewController menu to show vibrancy, make them a subclass of UITableViewVibrantCell and set the `blurEffectStyle` of each cell to SideMenuManager.default.menuBlurEffectStyle.
*/
open var menuBlurEffectStyle: UIBlurEffectStyle?

/// The left menu.
open var menuLeftNavigationController: UISideMenuNavigationController?

/// The right menu.
open var menuRightNavigationController: UISideMenuNavigationController?

/**
Adds screen edge gestures to a view to present a menu.

- Parameter toView: The view to add gestures to.
- Parameter forMenu: The menu (left or right) you want to add a gesture for. If unspecified, gestures will be added for both sides.

- Returns: The array of screen edge gestures added to `toView`.
*/
@discardableResult open func menuAddScreenEdgePanGesturesToPresent(toView: UIView, forMenu:UIRectEdge? = nil) -> [UIScreenEdgePanGestureRecognizer]

/**
Adds a pan edge gesture to a view to present menus.

- Parameter toView: The view to add a pan gesture to.

- Returns: The pan gesture added to `toView`.
*/
@discardableResult open func menuAddPanGestureToPresent(toView: UIView) -> UIPanGestureRecognizer
```
#### UISideMenuNavigationController
`UISideMenuNavigationController` supports the following customizations and properties:
``` swift
/// SideMenuManager instance associated with this menu. Default is `SideMenuManager.default`. This property cannot be changed after the menu has loaded.
open weak var sideMenuManager: SideMenuManager! = SideMenuManager.default

/// Width of the menu when presented on screen, showing the existing view controller in the remaining space. Default is zero. When zero, `sideMenuManager.menuWidth` is used. This property cannot be changed while the isHidden property is false.
@IBInspectable open var menuWidth: CGFloat = 0

/// Whether the menu appears on the right or left side of the screen. Right is the default. This property cannot be changed after the menu has loaded.
@IBInspectable open var leftSide: Bool = false

/// Indicates if the menu is anywhere in the view hierarchy, even if covered by another view controller.
open var isHidden: Bool
```
#### UISideMenuNavigationControllerDelegate
To receive notifications when a menu is displayed from a view controller, have it adhere to the  `UISideMenuNavigationControllerDelegate` protocol:
``` swift
extension MyViewController: UISideMenuNavigationControllerDelegate {

    func sideMenuWillAppear(menu: UISideMenuNavigationController, animated: Bool) {
        print("SideMenu Appearing! (animated: \(animated))")
    }

    func sideMenuDidAppear(menu: UISideMenuNavigationController, animated: Bool) {
        print("SideMenu Appeared! (animated: \(animated))")
    }

    func sideMenuWillDisappear(menu: UISideMenuNavigationController, animated: Bool) {
        print("SideMenu Disappearing! (animated: \(animated))")
    }

    func sideMenuDidDisappear(menu: UISideMenuNavigationController, animated: Bool) {
        print("SideMenu Disappeared! (animated: \(animated))")
    }

}
```
### Advanced
For simplicity, `SideMenuManager.default` serves as the primary instance as most projects will only need one menu across all screens. If you need to show a different SideMenu, such as from a modal view controller presented from a previous SideMenu, do the following:
1. Declare a variable containing your custom `SideMenuManager` instance. You may want it to define it globally and configure it in your app delegate if menus will be used on multiple screens.
``` swift
let customSideMenuManager = SideMenuManager()
```
2. Setup and display menus with your custom instance the same as you would with the  `SideMenuManager.default` instance.
3. If using Storyboards, subclass your instance of `UISideMenuNavigationController` and set its `sideMenuManager` property to your custom instance. This must be done before `viewDidLoad` is called:
``` swift
class MySideMenuNavigationController: UISideMenuNavigationController {

    let customSideMenuManager = SideMenuManager()

    override func awakeFromNib() {
        super.awakeFromNib()

        sideMenuManager = customSideMenuManager
    }

}
```
Alternatively, you can set  `sideMenuManager` from the view controller that segues to your UISideMenuNavigationController:
``` swift
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    if let sideMenuNavigationController = segue.destination as? UISideMenuNavigationController {
        sideMenuNavigationController.sideMenuManager = customSideMenuManager
    }
}
```
*Important: displaying SideMenu instances directly over each other is not supported. Use `menuPushStyle = .subMenu` instead.*
## Known Issues
Don't try to change the status bar appearance when presenting a menu. When used with quick gestures/animations, it causes the presentation animation to not complete properly and locks the UI. This was fixed in iOS 9.3. See [radar 21961293](http://www.openradar.me/21961293) for more information.

## Thank You
A special thank you to everyone that has [contributed](https://github.com/jonkykong/SideMenu/graphs/contributors) to this library to make it better. Your support is appreciated!

## License

SideMenu is available under the MIT license. See the LICENSE file for more info.


text:
try:
    from setuptools import setup, find_packages
    from setuptools.command.test import test
except ImportError:
    from ez_setup import use_setuptools

    use_setuptools()
    from setuptools import setup, find_packages
    from setuptools.command.test import test

import os

here = os.path.dirname(os.path.abspath(__file__))
f = open(os.path.join(here, "README.md"))
long_description = f.read().strip()
f.close()

setup(
    name="django_spam",
    version="2.0.1",
    author="Nick Kelly",
    author_email="nick.kelly@tivix.com",
    url="http://github.com/Tivix/django-spam",
    description="Redirecting bots to utilize their time better...",
    packages=find_packages(exclude=("tests*",)),
    long_description=long_description,
    long_description_content_type="text/markdown",
    keywords="django spam",
    zip_safe=False,
    include_package_data=True,
    py_modules=["django_spam"],
    test_suite="runtests.runtests",
    install_requires=[
        "Django>=2.0.0",
    ],
    classifiers=[
        "Framework :: Django",
        "Framework :: Django :: 2.0",
        "Framework :: Django :: 2.1",
        "Framework :: Django :: 2.2",
        "Framework :: Django :: 3.0",
        "Framework :: Django :: 3.1",
        "Intended Audience :: Developers",
        "Intended Audience :: System Administrators",
        "Operating System :: OS Independent",
        "Topic :: Software Development",
    ],
)


text:
package main

import (
	"encoding/json"
	"flag"
	"fmt"
	"log"
	"net"
)

var listenAddr = flag.String("listen", "localhost:8000", "host:port to listen on")

type Message struct {
	Body string
}

func main() {
	flag.Parse()

	// TODO: Create a net.Listener listening from the address in the "listen" flag.

	for {
		// TODO: Accept a new connection from the listener.
		go serve(c)
	}
}

func serve(c net.Conn) {
	// TODO: Use defer to Close the connection when this function returns.

	// TODO: Create a new json.Decoder reading from the connection.
	for {
		// TODO: Create an empty message.
		// TODO: Decode a new message into the variable you just created.
		// TODO: Print the message to the standard output.
	}
}


text:
import { Component, OnDestroy } from '@angular/core';
import { Location } from '@angular/common';
import { FormBuilder, Validators } from '@angular/forms';
import { Subject } from 'rxjs/Subject';
import { DialogService } from '../shared/index';
import { UserAuthService } from '../shared/global/user-auth.service';

@Component({
    moduleId: module.id,
    selector: 'sd-user-registration',
    templateUrl: 'user-registration.component.html',
})
export class UserRegistrationComponent implements OnDestroy {

    userRegistrationForm = this.formBuilder.group({
        firstName: ['', [Validators.required, Validators.maxLength(200)]],
        lastName: ['', [Validators.required, Validators.maxLength(200)]],
        organisation: ['', [Validators.required, Validators.maxLength(200)]],
        position: ['', [Validators.required, Validators.maxLength(200)]],
        email: ['', [Validators.required, Validators.maxLength(200)]],
        phone: ['', [Validators.required, Validators.maxLength(20)]],
        remarks: ['', [Validators.required, Validators.maxLength(10000)]]
    });

    private unsubscribe: Subject<void> = new Subject<void>();

    constructor(
        private location: Location,
        private formBuilder: FormBuilder,
        private userService: UserAuthService,
        private dialogs: DialogService,
    ) {}

    ngOnDestroy() {
        this.unsubscribe.next();
        this.unsubscribe.complete();
    }

    public cancel() {
        this.location.back();
    }

    public submit() {
        console.log(this.userRegistrationForm.getRawValue());
        this.userService.requestNewUser(this.userRegistrationForm.getRawValue())
            .takeUntil(this.unsubscribe)
            .subscribe(() =>
                this.dialogs.showNotificationDialog(
                    `Thank you for registering. You will be contacted by a member from the GNSS Operations
                    Team at Geoscience Australia regarding your login details.`,
                    () => window.location.assign('/')
                )
            );

    }

    public isFormInvalid(): boolean {
        return this.userRegistrationForm.invalid;
    }
}


text:
ACCEPTED

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Syll. fung. (Abellini) 1: 288 (1882)

#### Original name
Sphaeria scotina Durieu & Mont., 1846

### Remarks
null


text:
package com.cortica.interview.core.services;

import com.cortica.interview.BaseTest;
import com.cortica.interview.api.ImageStatus;
import com.cortica.interview.db.ImageDao;
import com.cortica.interview.db.ImageEntity;
import io.dropwizard.jackson.Jackson;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.*;
import org.mockito.runners.MockitoJUnitRunner;

import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyMap;
import static org.mockito.Mockito.*;

/**
 * Created by avgdorom on 7/23/2016.
 */
@RunWith(MockitoJUnitRunner.class)
public class ImageManipulationServiceTest extends BaseTest {

    private static final String MALFORMED_REQUEST_PARAMETERS = "{resize:w\":100,\"h\":100}}";

    private static final String MANIPULATOR_NAME = "resize";

    @InjectMocks
    private ImageManipulationService imageManipulationService;

    @Spy
    private List<ImageManipulator> imageManipulators = new ArrayList<>(1);

    @Mock
    private ImageDao imageDao;

    @Mock
    private ObjectMapperService objectMapperService;

    @Mock
    private ImageManipulator imageManipulator;

    @Captor
    private ArgumentCaptor<ImageEntity> imageEntityArgumentCaptor;

    private BufferedImage image = new BufferedImage(DEFAULT_DIMENSION_SIZE, DEFAULT_DIMENSION_SIZE, BufferedImage.TYPE_INT_RGB);

    @Before
    public void init() {
        when(objectMapperService.getObjectMapper()).thenReturn(Jackson.newObjectMapper());
        when(imageManipulator.getName()).thenReturn(MANIPULATOR_NAME);
        when(imageManipulator.manipulate(any(BufferedImage.class), anyMap())).thenReturn(image);
        imageManipulators.add(imageManipulator);
    }

    @Test
    public void processImage() throws Exception {
        testCustomProcessImage(REQUEST_PARAMETERS, ImageStatus.SUCCESS, true);
    }

    @Test
    public void processImageInvalidRequestParameters() throws Exception {
        testCustomProcessImage(MALFORMED_REQUEST_PARAMETERS, ImageStatus.FAILED, false);
    }

    private void testCustomProcessImage(String requestParameters, ImageStatus status, boolean verifyManipulator) {
        imageManipulationService.processImage(IMAGE_URL, requestParameters);
        verify(imageDao).persist(imageEntityArgumentCaptor.capture());
        ImageEntity imageEntity = imageEntityArgumentCaptor.getValue();
        assertThat(imageEntity.getName(), equalTo(IMAGE_NAME));
        assertThat(imageEntity.getStatus(), equalTo(status));
        if (verifyManipulator) {
            verify(imageManipulator).manipulate(any(BufferedImage.class), anyMap());
            assertThat(imageEntity.getWidth(), equalTo(DEFAULT_DIMENSION_SIZE));
            assertThat(imageEntity.getHeight(), equalTo(DEFAULT_DIMENSION_SIZE));
        }
    }

    @Test
    public void processDemoImages() throws Exception {
        imageManipulationService.processDemoImages(REQUEST_PARAMETERS);
        verify(imageManipulator, times(4)).manipulate(any(BufferedImage.class), anyMap());
    }

    @Test
    public void getImage() throws Exception {
        imageManipulationService.processImage(IMAGE_URL, REQUEST_PARAMETERS);
        byte[] imageData = imageManipulationService.getImage(IMAGE_NAME);
        assertThat(imageData.length, equalTo(823));
    }

    @Test
    public void getImageThatDoesNotExist() throws Exception {
        byte[] imageData = imageManipulationService.getImage(IMAGE_NAME);
        assertThat(imageData, equalTo(new byte[0]));
    }
}


text:
<?php

namespace Tiga\Framework\Contract;

interface OldInputInterface
{
    public function hasOldInput();
    public function getOldInput($key);
}


text:
package org.bitcoins.spvnode.serializers.messages.control

import org.bitcoins.core.number.{UInt32, UInt64}
import org.bitcoins.core.protocol.CompactSizeUInt
import org.bitcoins.core.util.BitcoinSUtil
import org.bitcoins.spvnode.bloom.BloomUpdateNone
import org.scalatest.{FlatSpec, MustMatchers}

/**
  * Created by chris on 7/20/16.
  */
class RawFilterLoadMessageSerializerTest extends FlatSpec with MustMatchers  {

  "RawFilterLoadMessageSerializer" must "deserialize and serialize a filter load message" in {
    //example from the bitcoin developer reference
    //https://bitcoin.org/en/developer-reference#filterload
    val hex = "02b50f0b0000000000000000"

    val filterLoadMsg = RawFilterLoadMessageSerializer.read(hex)
    filterLoadMsg.bloomFilter.filterSize must be (CompactSizeUInt(UInt64(2)))
    BitcoinSUtil.encodeHex(filterLoadMsg.bloomFilter.data) must be ("b50f")
    filterLoadMsg.bloomFilter.hashFuncs must be (UInt32(11))
    filterLoadMsg.bloomFilter.tweak must be (UInt32.zero)
    filterLoadMsg.bloomFilter.flags must be (BloomUpdateNone)

    RawFilterLoadMessageSerializer.write(filterLoadMsg) must be (hex)

  }
}


text:
"""Tango Code-active processors allow
to embed python code within tango documents.
"""

import ast
import doctest
import pprint

from tangolib.processor import CommandProcessor
from tangolib import markup

class PythonContext:
    def __init__(self, tango_globals):
        self.globals = tango_globals
        self.pprint = pprint.PrettyPrinter()
        self.defs = dict()

    def eval_python_expr(self, expr, filename='<unknown>', line_pos=None):
        code = ast.parse(expr, filename, 'eval')
        if line_pos is not None:
            ast.increment_lineno(code, line_pos)

        ccode = compile(code, filename, 'eval')
        ret = eval(ccode, self.globals)

        return ret

    def exec_python(self, source, filename='<unknown>', line_pos=None):
        code = ast.parse(source, filename, 'exec')
        if line_pos is not None:
            ast.increment_lineno(code, line_pos)
        ccode = compile(code, filename, 'exec')

        exec(ccode, self.globals)

    def def_python(self, def_name, def_source, filename='<unknown>', line_pos=None):
        self.exec_python(def_source, filename, line_pos)
        # TODO: check the def in the context
        self.defs[def_name] = def_source # TODO: register only if defined

class EvalPythonProcessor(CommandProcessor):
    def __init__(self, python_context):
        super().__init__()
        self.python_context = python_context

    def process_command(self, processor, cmd):
        # BREAKPOINT >>> # import pdb; pdb.set_trace()  # <<< BREAKPOINT #
        ret = self.python_context.eval_python_expr(cmd.content, processor.document.filename, cmd.header_end_pos.lpos)
        output = self.python_context.pprint.pformat(ret)
        return (markup.Preformated(cmd.doc, output, "python", cmd.start_pos, cmd.end_pos), False)

class ExecPythonProcessor(CommandProcessor):
    def __init__(self, python_context):
        super().__init__()
        self.python_context = python_context

    def process_command(self, processor, cmd):
        self.python_context.exec_python(cmd.content, processor.document.filename, cmd.header_end_pos.lpos)
        return (markup.SkipMarkup(cmd.doc, cmd.start_pos, cmd.end_pos), False)

class DefPythonProcessor(CommandProcessor):
    def __init__(self, python_context):
        super().__init__()
        self.python_context = python_context

    def process_command(self, processor, cmd):
        # BREAKPOINT >>> # import pdb; pdb.set_trace()  # <<< BREAKPOINT #
        def_name = None
        for name in cmd.cmd_opts:
            def_name = name
        self.python_context.def_python(def_name, cmd.content, processor.document.filename, cmd.header_end_pos.lpos)
        # TODO: log the registered function
        return (markup.SkipMarkup(cmd.doc, cmd.start_pos, cmd.end_pos), False)

class CheckPythonProcessor(CommandProcessor):
    def __init__(self, python_context):
        super().__init__()
        self.python_context = python_context

    def process_command(self, processor, cmd):
        test_parser = doctest.DocTestParser()
        test = test_parser.get_doctest(cmd.content, self.python_context.globals, "<checkPython>", processor.document.filename, cmd.header_end_pos.lpos)
        runner = CheckPythonRunner()
        runner.run(test)
        # XXX : for the moment an exception should be launched, think about different behaviors
        # if we are here then everything went fine (?)
        if cmd.cmd_opts == "hide":
            return (markup.SkipMarkup(cmd.doc, cmd.start_pos, cmd.end_pos), False)
        else:
            return (markup.Preformated(cmd.doc, cmd.content, "python-3", cmd.start_pos, cmd.end_pos), False)

class CheckPythonFailure(Exception):
    pass

class CheckPythonRunner(doctest.DocTestRunner):
    def __init__(self):
        super().__init__()

    def report_failure(self, out, test, example, got):
        super().report_failure(out, test, example, got)
        raise CheckPythonFailure()

def register_processors(processor, python_context):
    processor.register_command_processor("evalPython", EvalPythonProcessor(python_context))
    processor.register_command_processor("execPython", ExecPythonProcessor(python_context))
    processor.register_command_processor("defPython", DefPythonProcessor(python_context))
    processor.register_command_processor("checkPython", CheckPythonProcessor(python_context))


text:
<?php

namespace Jimdo\Logbook\Web\Validator;

class IntegerValidator extends Validator
{
    public function isValid($value): bool
    {
        if (is_array($value)) {
            $this->errorMessage = "Array is not an integer!";
            $this->errorCode = Validator::ERR_VALIDATOR_INTEGER;
            return false;
        }

        if (is_object($value)) {
            $className = get_class($value);
            $this->errorMessage = "'$className' is not an integer!";
            $this->errorCode = Validator::ERR_VALIDATOR_INTEGER;
            return false;
        }

        if (!is_numeric($value) || strpos($value, '.') !== false || is_float($value)) {
            $this->errorMessage = "'$value' is not an integer!";
            $this->errorCode = Validator::ERR_VALIDATOR_INTEGER;
            return false;
        }

        return true;
    }
}


text:
<phpunit bootstrap="./Bootstrap.php" colors="true">
    <testsuites>
        <testsuite name="ZFContentValidation Module Tests">
            <directory>./ZFTest</directory>
        </testsuite>
    </testsuites>
</phpunit>


text:
require "rails_helper"

describe ReplacePageItem do
  let(:page_content) { File.read(Rails.root.join("spec/fixtures/sample_page_content.txt")) }
  let(:collection) { Collection.new(id: 1) }
  let(:page) { Page.new(id: 1, content: page_content, collection: collection, collection_id: collection.id, ) }
  let(:image) { instance_double(Image, type: "Image") }
  let(:video) { instance_double(Video, type: "Video") }
  let(:audio) { instance_double(Audio, type: "Audio") }
  let(:item) { Item.new(unique_id: "ec625c51db", pages: [page]) }
  subject { described_class.call(page, item) }

  it "calls #replace!" do
    expect_any_instance_of(described_class).to receive(:replace!)
    subject
  end

  describe "#replace!" do
    it "replaces the changed item src target" do
      expect_any_instance_of(described_class).to receive(:new_image_uri).exactly(2).times.and_return("http://no.where")
      expect(page).to receive(:save!).and_return(true)
      subject
      expect(Nokogiri::HTML::DocumentFragment.parse(page.content).css(".hc_page_image").first["src"]).to eq "http://no.where"
    end

    it "replaces the changed item data-save-url target" do
      expect_any_instance_of(described_class).to receive(:new_image_uri).exactly(2).times.and_return("http://no.where")
      expect(page).to receive(:save!).and_return(true)
      subject
      expect(Nokogiri::HTML::DocumentFragment.parse(page.content).css(".hc_page_image").first["data-save-url"]).to eq "http://no.where"
    end
  end

  it "correctly retrieves the url from item image" do
    data = { "thumbnail/medium" => { "contentUrl" => "http://no.where" }}
    allow(page).to receive(:save!).and_return(true)
    allow(item).to receive(:media).and_return(image)
    expect(image).to receive(:json_response).exactly(2).times.and_return(data)

    subject
  end

  it "correctly retrieves the url from item video" do
    data = { "thumbnail/medium" => { "contentUrl" => "http://no.where" }}
    allow(page).to receive(:save!).and_return(true)
    allow(item).to receive(:media).and_return(video)
    expect(video).to receive(:thumbnail_url).exactly(2).times.and_return(data)

    subject
  end

  it "correctly retrieves the url from item audio" do
    data = { "thumbnail/medium" => { "contentUrl" => "http://no.where" }}
    allow(page).to receive(:save!).and_return(true)
    allow(item).to receive(:media).and_return(audio)
    expect(audio).to receive(:thumbnail_url).exactly(2).times.and_return(data)

    subject
  end
end


text:
// ------------------------------------------------------------------------------
//  <auto-generated>
//      This code was generated by SpecFlow (http://www.specflow.org/).
//      SpecFlow Version:1.9.0.77
//      SpecFlow Generator Version:1.9.0.0
//      Runtime Version:4.0.30319.42000
//
//      Changes to this file may cause incorrect behavior and will be lost if
//      the code is regenerated.
//  </auto-generated>
// ------------------------------------------------------------------------------
#region Designer generated code
#pragma warning disable
namespace Orchard.Specs
{
    using TechTalk.SpecFlow;

    [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.9.0.77")]
    [System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
    [NUnit.Framework.TestFixtureAttribute()]
    [NUnit.Framework.DescriptionAttribute("Pages")]
    public partial class PagesFeature
    {

        private static TechTalk.SpecFlow.ITestRunner testRunner;

#line 1 "Pages.feature"
#line hidden

        [NUnit.Framework.TestFixtureSetUpAttribute()]
        public virtual void FeatureSetup()
        {
            testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner();
            TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Pages", "  In order to add content pages to my site\r\n  As an author\r\n  I want to create, p" +
                    "ublish and edit pages", ProgrammingLanguage.CSharp, ((string[])(null)));
            testRunner.OnFeatureStart(featureInfo);
        }

        [NUnit.Framework.TestFixtureTearDownAttribute()]
        public virtual void FeatureTearDown()
        {
            testRunner.OnFeatureEnd();
            testRunner = null;
        }

        [NUnit.Framework.SetUpAttribute()]
        public virtual void TestInitialize()
        {
        }

        [NUnit.Framework.TearDownAttribute()]
        public virtual void ScenarioTearDown()
        {
            testRunner.OnScenarioEnd();
        }

        public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo)
        {
            testRunner.OnScenarioStart(scenarioInfo);
        }

        public virtual void ScenarioCleanup()
        {
            testRunner.CollectScenarioErrors();
        }

        [NUnit.Framework.TestAttribute()]
        [NUnit.Framework.DescriptionAttribute("In the admin (menu) there is a link to create a Page")]
        public virtual void InTheAdminMenuThereIsALinkToCreateAPage()
        {
            TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("In the admin (menu) there is a link to create a Page", ((string[])(null)));
#line 6
this.ScenarioSetup(scenarioInfo);
#line 7
    testRunner.Given("I have installed Orchard", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
#line 9
    testRunner.When("I go to \"Admin\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 10
    testRunner.Then("I should see \"]*>Page\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 13
    testRunner.When("I go to \"Admin/Contents/Create/Page\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line hidden
            TechTalk.SpecFlow.Table table1 = new TechTalk.SpecFlow.Table(new string[] {
                        "name",
                        "value"});
            table1.AddRow(new string[] {
                        "Title.Title",
                        "Super Duper"});
            table1.AddRow(new string[] {
                        "LayoutPart.LayoutEditor.Data",
                        @"{ ""type"": ""Content"", ""data"": ""TypeName=Orchard.Layouts.Elements.Text&Content=This+is+super"", ""isTemplated"": false, ""contentType"": ""Orchard.Layouts.Elements.Text"", ""contentTypeLabel"": ""Text"", ""contentTypeClass"": ""text"", ""html"": ""This is super"", ""hasEditor"": true }"});
#line 14
        testRunner.And("I fill in", ((string)(null)), table1, "And ");
#line 18
        testRunner.And("I hit \"Publish Now\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 19
        testRunner.And("I go to \"super-duper\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 20
    testRunner.Then("I should see \"
]*>.*?Super Duper.*?
\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 21
        testRunner.And("I should see \"This is super.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 24
    testRunner.When("I go to \"Admin/Contents/Create/Page\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line hidden
            TechTalk.SpecFlow.Table table2 = new TechTalk.SpecFlow.Table(new string[] {
                        "name",
                        "value"});
            table2.AddRow(new string[] {
                        "Title.Title",
                        "Super Duper"});
            table2.AddRow(new string[] {
                        "AutoroutePart.LayoutEditor.Data",
                        @"{ ""type"": ""Content"", ""data"": ""TypeName=Orchard.Layouts.Elements.Text&Content=This+is+super+number+two"", ""isTemplated"": false, ""contentType"": ""Orchard.Layouts.Elements.Text"", ""contentTypeLabel"": ""Text"", ""contentTypeClass"": ""text"", ""html"": ""This is super number two"", ""hasEditor"": true }"});
#line 25
        testRunner.And("I fill in", ((string)(null)), table2, "And ");
#line 29
        testRunner.And("I hit \"Publish Now\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 30
        testRunner.And("I go to \"super-duper-2\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 31
    testRunner.Then("I should see \"
]*>.*?Super Duper.*?
\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 32
        testRunner.And("I should see \"This is super number two.\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 35
    testRunner.When("I go to \"Admin/Contents/Create/Page\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line hidden
            TechTalk.SpecFlow.Table table3 = new TechTalk.SpecFlow.Table(new string[] {
                        "name",
                        "value"});
            table3.AddRow(new string[] {
                        "Title.Title",
                        "Another"});
            table3.AddRow(new string[] {
                        "AutoroutePart.PromoteToHomePage",
                        "true"});
#line 36
        testRunner.And("I fill in", ((string)(null)), table3, "And ");
#line 40
        testRunner.And("I hit \"Publish Now\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 41
        testRunner.And("I go to \"/\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 42
    testRunner.Then("I should see \"
Another
\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 43
    testRunner.When("I go to \"another\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 44
    testRunner.Then("the status should be 404 \"Not Found\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line 47
    testRunner.When("I go to \"Admin/Contents/Create/Page\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line hidden
            TechTalk.SpecFlow.Table table4 = new TechTalk.SpecFlow.Table(new string[] {
                        "name",
                        "value"});
            table4.AddRow(new string[] {
                        "Title.Title",
                        "Drafty"});
            table4.AddRow(new string[] {
                        "AutoroutePart.PromoteToHomePage",
                        "true"});
#line 48
        testRunner.And("I fill in", ((string)(null)), table4, "And ");
#line 52
        testRunner.And("I hit \"Save\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 53
        testRunner.And("I go to \"/\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 54
    testRunner.Then("I should see \"
Another
\"", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line hidden
            this.ScenarioCleanup();
        }
    }
}
#pragma warning restore
#endregion


text:
var oops = require('../').noConflict()
, defines = oops.create
;

function Favorite(greeting) {
	defines(this).value('greeting', greeting);
}

function Greeter(greeting){
	Greeter.super_.call(this, greeting);
}
oops.inherits(Greeter, Favorite);

defines(Greeter).enumerable
	.method(function greet(who) {
		console.log("".concat(this.greeting, ' ', who));
	});

var bob = new Greeter("Good day");
bob.greet("Jane");


text:
var doc = document
var body = doc.body

var addListener = document.addEventListener || document.attachEvent
var removeListener = document.removeEventListener || document.detachEvent

function JQLite (selector) {
	var elms

	if (isString(selector)) {
		elms = toArray(doc.querySelectorAll(selector))

	} else if (selector.get && selector.elms) {
		return selector

	} else {

		if (isArrayLike(selector)) {
			elms = toArray(selector)
		} else {
			elms = [selector]
		}

	}

	return {
		elms: elms,

		get: function(index) {
			return elms
		},

		each: function (fn) {
			elms = this.elms
			each(elms, fn)
			return this
		},

		on: function (eventName, fn) {
			this.each(function (elm) {
				addListener.call(elm, eventName, fn)
			})
			return this
		},

		off: function (eventName, fn) {
			this.each(function (elm) {
				removeListener.call(elm, eventName, fn)
			})
			return this
		},

		val: function(value) {
			var val

			if(!isUndefined(value)) {
				this.each(function(elm) {
					elm.value = value
				})
			} else {
				return this.elms[0].value
			}
		},

		attr: function(name, value) {
			var len = arguments.length

			if(len === 1) {

				return this.elms[0].getAttribute(name)

			} else {

				this.each(function (elm) {
					elm.setAttribute(name, value)
				})

				return this
			}
		},

		removeAttr: function(name) {
			this.each(function(elm) {
				elm.removeAttribute(name)
			})
		},

		hide: function (duration) {
			this.attr('hidden', true)
			return this
		},

		show: function (duration) {
			this.removeAttr('hidden')
			return this
		},

		text: function(text) {
			// Using textContent
			// http://kellegous.com/j/2013/02/27/innertext-vs-textcontent/
			if (text) {
				this.each(function(elm) {
					elm.textContent = text
				})
			} else {
				// A special way to get escaping text
				var div = doc.createElement('div')
				var elm = elms[0]
				div.textContent = elm.innerHTML
				return div.innerHTML
			}
			return this
		},

		html: function (html) {
			if (isUndefined(html)) {
				return this.elms[0].innerHTML
			} else {
				this.each(function(elm) {
					elm.innerHTML = html
				})
			}
			return this
		},

		css: function (name, value) {

			var len = arguments.length

			if (len === 1) {

				if (isObject(name)) {
					// if passing in an Object
					value = name

					property(value, function (prop, val) {
						prop = toCamelCase(prop)
						each(elms, function (elm) {
							elm.style[prop] = val
						})
					})

				} else {

					name = toCamelCase(name) // if passing a string, then return the css property
					return this.elms[0].style[name]
				}

			} else if(len === 2) { // if passing in css property name an value
				name = toCamelCase(name)

				this.each(function (elm) {
					elm.style[name] = value
				})
			}

			return this
		},

		append: function(elm) {
			var parent = this.elms[0]
			var elms = elm.elms
			if (elms) {
				append(parent, elms)
			} else {
				if (isArrayLike(elm)) {
					append(parent, elm)
				} else {
					if (isHTML(elm)) {
						append(parent, [elm])
					}
				}
			}
		},

		insertBefore: function(elms) {
			var basic = this.elms[0]
			var elms = elms.elms ? elms.elms : elms
			var wrapper = wrapWithDomFrag(elms)
			basic.parentNode.insertBefore(wrapper, basic)
			return this
		},

		remove: function() {
			this.each(function(elm) {
				var parent = elm.parentNode
				if (parent) {
					elm.parentNode.removeChild(elm)
				}
			})
			return this
		}
	}
}

function append(parent, childs) {
	var frag = doc.createDocumentFragment()

	each(childs, function (child, i) {
		frag.appendChild(child)
	})

	parent.appendChild(frag)
}

function find (frag, selector) {
	return frag.querySelectorAll(selector)
}

function createDomFrag () {
	return doc.createDocumentFragment()
}

function wrapWithDomFrag (nodes) {
	var frag = createDomFrag()

	each(nodes, function (node) {
		frag.appendChild(node)
	})

	return frag
}

var $
if (global.jQuery) {
	$ = jQuery
} else if (global.zepto) {
	$ = zepto
} else {
	$ = JQLite
}

// $('body').css({'border':'1px solid #ccc', 'background-color': '#000'})
// console.log($(document.body).css('background-color'))