text:
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="CollectionExtensionsTest.cs" company="OBeautifulCode">
//   Copyright (c) OBeautifulCode 2018. All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace OBeautifulCode.Collection.Recipes.Test
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    using FluentAssertions;

    using Xunit;

    public static class CollectionExtensionsTest
    {
        [Fact]
        public static void AddRange___Should_throw_ArgumentNullException___When_parameter_collection_is_null()
        {
            // Arrange
            var valuesToAdd = new List<int>();

            // Act, Assert
            Assert.Throws<ArgumentNullException>(() => CollectionExtensions.AddRange(null, valuesToAdd));
        }

        [Fact]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Addis", Justification = "Code Analysis does not recognize the underscore as a word breaker.")]
        public static void AddRange___Should_throw_ArgumentNullException___When_parameter_valuesToAdd_is_null()
        {
            // Arrange
            var collection = new List<string>();

            // Act, Assert
            Assert.Throws<ArgumentNullException>(() => collection.AddRange(null));
        }

        [Fact]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Addis", Justification = "Code Analysis does not recognize the underscore as a word breaker.")]
        public static void AddRange___Should_not_add_any_elements_to_collection___When_collection_is_empty_and_valuesToAdd_is_empty()
        {
            // Arrange
            var collection = new HashSet<string>();
            var valuesToAdd = new List<string>();

            // Act
            collection.AddRange(valuesToAdd);

            // Assert
            Assert.Empty(collection);
        }

        [Fact]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Addis", Justification = "Code Analysis does not recognize the underscore as a word breaker.")]
        public static void AddRange___Should_add_all_elements_in_valuesToAdd_to_collection___When_collection_is_empty_and_valuesToAdd_is_not_empty()
        {
            // Arrange
            var collection1 = new HashSet<string>();
            var valuesToAdd1 = new List<string> { "a" };

            var collection2 = new HashSet<string>();
            var valuesToAdd2 = new List<string> { "a", "b" };

            // Act
            collection1.AddRange(valuesToAdd1);
            collection2.AddRange(valuesToAdd2);

            // Assert
            collection1.Should().ContainSingle();
            Assert.Contains("a", collection1);

            Assert.Equal(2, collection2.Count);
            Assert.Contains("a", collection2);
            Assert.Contains("b", collection2);
        }

        [Fact]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Addis", Justification = "Code Analysis does not recognize the underscore as a word breaker.")]
        public static void AddRange___Should_not_add_any_elements_to_collection___When_collection_is_not_empty_and_valuesToAdd_is_empty()
        {
            // Arrange
            var collection1 = new HashSet<string> { "a" };
            var valuesToAdd1 = new List<string>();

            var collection2 = new HashSet<string> { "a", "b" };
            var valuesToAdd2 = new List<string>();

            // Act
            collection1.AddRange(valuesToAdd1);
            collection2.AddRange(valuesToAdd2);

            // Assert
            collection1.Should().ContainSingle();
            Assert.Contains("a", collection1);

            Assert.Equal(2, collection2.Count);
            Assert.Contains("a", collection2);
            Assert.Contains("b", collection2);
        }

        [Fact]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "Addis", Justification = "Code Analysis does not recognize the underscore as a word breaker.")]
        public static void AddRange___Should_add_all_elements_in_valuesToAdd_to_collection___When_collection_is_not_empty_and_valuesToAdd_is_not_empty()
        {
            // Arrange
            var collection1 = new HashSet<string> { "d", "e", "f" };
            var valuesToAdd1 = new List<string> { "g" };

            var collection2 = new List<string> { "d", "e", "f", "g" };
            var valuesToAdd2 = new List<string> { "d", "e", "h" };

            var collection3 = new HashSet<string> { "d", "e", "f", "g" };
            var valuesToAdd3 = new List<string> { "d", "e", "h" };

            // Act
            collection1.AddRange(valuesToAdd1);
            collection2.AddRange(valuesToAdd2);
            collection3.AddRange(valuesToAdd3);

            // Assert
            Assert.Equal(4, collection1.Count);
            Assert.Contains("d", collection1);
            Assert.Contains("e", collection1);
            Assert.Contains("f", collection1);

            Assert.Equal(7, collection2.Count);
            Assert.Contains("d", collection2);
            Assert.Contains("e", collection2);
            Assert.Contains("f", collection2);
            Assert.Contains("g", collection2);
            Assert.Contains("h", collection2);
            Assert.Equal(2, collection2.Count(item => item == "d"));
            Assert.Equal(2, collection2.Count(item => item == "e"));

            Assert.Equal(5, collection3.Count);
            Assert.Contains("d", collection3);
            Assert.Contains("e", collection3);
            Assert.Contains("f", collection3);
            Assert.Contains("g", collection3);
            Assert.Contains("h", collection3);
        }
    }
}


text:
require 'patches/xmpp4r_patches'
require 'patches/standard_library_patches'

redpajama_set_name: RedPajamaGithub


text:
package org.jbehave.core.steps;

import java.beans.IntrospectionException;

import org.jbehave.core.i18n.LocalizedKeywords;
import org.jbehave.core.steps.StepCreator.PendingStep;
import org.junit.Test;

import static org.apache.commons.lang.StringEscapeUtils.escapeJava;

import static org.hamcrest.MatcherAssert.assertThat;

import static org.hamcrest.Matchers.equalTo;

public class PendingStepMethodGeneratorBehaviour {

    private PendingStepMethodGenerator generator = new PendingStepMethodGenerator(new LocalizedKeywords());

    @Test
    public void shouldGenerateMethodForNonAndPendingStep() throws IntrospectionException {
        // When
        PendingStep pendingStep = (PendingStep) StepCreator.createPendingStep("When I am pending", null);

        // Then
        String method =
            "@When(\"I am pending\")\n" +
            "@Pending\n"+
            "public void whenIAmPending() {\n"+
            "  // PENDING\n"+
            "}\n";
       assertThat(generator.generateMethod(pendingStep), equalTo(method));
    }

    @Test
    public void shouldGenerateMethodForAndPendingStepWithPreviousNonAndStep() throws IntrospectionException {

        // When
        PendingStep pendingStep = (PendingStep) StepCreator.createPendingStep("And I am pending", "Given I was pending");

        // Then
        String method =
            "@Given(\"I am pending\")\n" +
            "@Pending\n"+
            "public void givenIAmPending() {\n"+
            "  // PENDING\n"+
            "}\n";
       assertThat(generator.generateMethod(pendingStep), equalTo(method));
    }

    @Test
    public void shouldNormaliseStepPatternToJavaCompatibleMethodNameAndString() throws IntrospectionException {
        // When
        String pattern = "I'm searching for \".*\", and for others chars such as :;!|, and I look for <this>: $ \\ / () {} [] ";
        PendingStep pendingStep = (PendingStep) StepCreator.createPendingStep("When "+pattern, null);

        // Then
        String method =
            "@When(\""+escapeJava(pattern)+"\")\n" +
            "@Pending\n"+
            "public void whenImSearchingForAndForOthersCharsSuchAsAndILookForthis() {\n"+
            "  // PENDING\n"+
            "}\n";
       assertThat(generator.generateMethod(pendingStep), equalTo(method));

       // test basically all characters (issue JBEHAVE-710)
       // When
       pattern = "I'm searching for ";
       for(int i=32;i<128;i++) {
           pattern+=(char)i;
       }
       pendingStep = (PendingStep) StepCreator.createPendingStep("When "+pattern, null);

       // Then
       method =
           "@When(\""+escapeJava(pattern)+"\")\n" +
           "@Pending\n"+
           "public void whenImSearchingFor0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz() {\n"+
           "  // PENDING\n"+
           "}\n";
       assertThat(generator.generateMethod(pendingStep), equalTo(method));

       // When
       pattern = "I'm searching for ";
       for(int i=160;i<256;i++) {
           pattern+=(char)i;
       }
       pendingStep = (PendingStep) StepCreator.createPendingStep("When "+pattern, null);

       // Then
       method =
           "@When(\""+escapeJava(pattern)+"\")\n" +
           "@Pending\n"+
           "public void whenImSearchingFor¢£¤¥ªµºÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ() {\n"+
           "  // PENDING\n"+
           "}\n";
       assertThat(generator.generateMethod(pendingStep), equalTo(method));
    }

}


text:
package com.xcysoft.foundation.cppt.dao.base;

import java.io.Serializable;

import cn.newcapec.framework.core.dao.hibernate.HibernateEntityDao;

import com.xcysoft.foundation.cppt.model.Menu;

/**
 *
 * @author huangxin
 *
 */
@SuppressWarnings("all")
public abstract class BaseMenuDao extends HibernateEntityDao {

	@Override
	protected Class getReferenceClass() {
		return Menu.class;
	}

	public Menu get(Serializable key) {
		return (Menu) get(getReferenceClass(), key);
	}
}


text:
import {Component} from '@angular/core';

@Component({
  selector: 'hello-world-app',
  template: `

Hello {{ name }}!

    <input type="text" [value]="name" (input)="name = $event.target.value"/>
  `,
})
export class HelloWorldComponent {
  name: string = 'world';
}


text:
package patterns;

public class Singleton {
  public static void main(String[] args) {
    Elvis theKing = Elvis.INSTANCE;
    theKing.hasLeftTheBuilding();

    AnotherElvis anotherKing = AnotherElvis.getInstance();
    anotherKing.hasLeftTheBuilding();

    EnumElvis enumElvis = EnumElvis.INSTANCE;
    enumElvis.hasLeftTheBuilding();
  }
}

// With public static method.
class Elvis {
  public static final Elvis INSTANCE = new Elvis();
  private Elvis() {}

  public void hasLeftTheBuilding() {
    System.out.println("Elvis:Long live the king!");
  }
}

// With static factory.
class AnotherElvis {
  private static final AnotherElvis INSTANCE = new AnotherElvis();
  private AnotherElvis() {}

  public static AnotherElvis getInstance() { return INSTANCE; }

  public void hasLeftTheBuilding() {
    System.out.println("AnotherElvis: Long live the king!");
  }

}

// With Enum.
enum EnumElvis {
  INSTANCE;

  public void hasLeftTheBuilding() {
    System.out.println("EnumElvis:Long live the king!");
  }
}

//


text:
require "test_helper"

module ShopifyApp
  class NullUserSessionStoreTest < ActiveSupport::TestCase
    test ".retrieve returns nil" do
      assert_nil NullUserSessionStore.retrieve("payload")
    end

    test ".store raises ConfigurationError" do
      assert_raises(::ShopifyApp::ConfigurationError) do
        NullUserSessionStore.store("session", "user")
      end
    end

    test ".retrieve_by_jwt returns nil" do
      assert_nil NullUserSessionStore.retrieve_by_shopify_user_id("jwt_payload")
    end
  end
end