text:
package Cards;

import Game.XML_240;
import Game.GameController;
import Game.Player;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.reflect.Array;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import Cards.OptionsCard;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.text.SimpleDateFormat;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.text.SimpleDateFormat;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.Timer;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import java.io.*;
import java.beans.*;

/**
 *
 * @author nickonofrio
 */
public class GameCard extends JPanel implements ActionListener, javax.swing.event.ChangeListener {

    GameController controller;
    OptionsCard gameOpt;
    XML_240 xmlGame;
    GameLeaderboard lb;

    JTextArea pMessage = new JTextArea("Power will be displayed here");
    JTextArea aMessage = new JTextArea("Accuracy will be displayed here");
    JTextArea wMessage = new JTextArea("Wind direction will be displayed here");
    JTextArea rMessage = new JTextArea("Outcome of kick will be shown here");
    JTextArea scoreMessage = new JTextArea("Score will be shown here");
    JLabel gameStatus = new JLabel(" ");
    JLabel showFinalScore = new JLabel(" ");
    JSlider accuracy, power;
    JButton b1, b2, b5, b6,b7,ball,jbGameOver;
    JLabel l1, l2, l3,countMessage, gAcc, gPow;
    JLabel showScore = new JLabel(" ");
    Timer tAccuracy;
    Timer tPower;
    Timer tWind;
    Timer tMessage;
    Timer tBall;
    Timer tFlip;
    Timer timer;
    int limit = 0;
    int aDelay = 0;
    int dDelay = 0;
    int wDelay = 0;
    int mDelay = 0;
    int bDelay = 0;
    int fDelay = 0;
    int i = 0;
    int j = 0;
    int a = 1, vA = 1;
    int p = 1, vP = 1;
    int flipCount = 0;
    double animatex = 0, animatey = 0, distance;
    double setX = 0, setY = 0;
    int ballx = 625, bally = 500;
    double wRandom = Math.random() * 4;
    double wx = 1;
    double wy = 1;
    int kickPoint[];
    int winLose;
    int keyCounter = 0;
    int score = 0;
    long startTime = -1;
    long duration = 30*1000;
    Player[] play;
    Player tempPlay[];
    int pnum=0;
    int tempScore = 0;

    ImageIcon north = new ImageIcon("images/north.png");
    ImageIcon northEast = new ImageIcon("images/northeast.png");
    ImageIcon northWest = new ImageIcon("images/northwest.png");
    ImageIcon south = new ImageIcon("images/south.png");
    ImageIcon southEast = new ImageIcon("images/southeast.png");
    ImageIcon southWest = new ImageIcon("images/southwest.png");
    ImageIcon east = new ImageIcon("images/east.png");
    ImageIcon west = new ImageIcon("images/west.png");
    ImageIcon fieldgoal = new ImageIcon("images/fieldgoal.png");
    ImageIcon blank = new ImageIcon("images/blank.png");
    ImageIcon missed = new ImageIcon("images/missed.png");
    ImageIcon football = new ImageIcon("images/football1.png");
    ImageIcon football2 = new ImageIcon("images/football2.png");
    ImageIcon start = new ImageIcon("images/start.png");
    ImageIcon stop = new ImageIcon("images/stop.png");
    ImageIcon gameover = new ImageIcon("images/gameover.png");
    ImageIcon accu = new ImageIcon ("images/acc.png");
    ImageIcon pow = new ImageIcon ("images/pow.png");

    public GameCard(GameController ctrl, OptionsCard opt, XML_240 xG, GameLeaderboard glead)
    {
        super();

        controller = ctrl;
        gameOpt = opt;
        xmlGame = xG;
        lb = glead;
        lb.jb2.addActionListener(this);

        setLayout(null);
        setBackground(Color.gray);

        //------Player setup ----------
        play = new Player[3];
        play[pnum] = new Player("Player 1", 0);
        play[1] = new Player("Player 2", 0);
        play[2] = new Player("Player 3", 0);
        play[pnum].setName("Player"+" "+ (pnum+1));
        tempPlay = new Player[3];
        tempPlay[0] = new Player(" ", 0);
        tempPlay[1] = new Player(" ", 0);
        tempPlay[2] = new Player(" ", 0);

        //------SLIDER TIMER -------------------------------------------
  	aDelay = 10; //milliseconds
        dDelay = 10; //milliseconds
        tAccuracy = new Timer(aDelay, this);
        tPower = new Timer(dDelay, this);

        //-------WIND TIMER---------------------------------------------
        wDelay = 10*1000;
        tWind = new Timer(wDelay, this);
        tWind.start();

        //-------MESSAGE TIMER------------------------------------------
        mDelay = 2*1000;
        tMessage = new Timer(mDelay, this);

        //--------Animation Timer-------------------------------------
        bDelay = 20;
        tBall = new Timer(bDelay, this);

        //-------Flip Timer---------------------------------------------
        fDelay = 75;
        tFlip = new Timer (fDelay, this);

        //-------Game Timer---------------------------------------------
        timer = new Timer(10, new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    if (startTime < 0) {
                        startTime = System.currentTimeMillis();
                    }
                    long now = System.currentTimeMillis();
                    long clockTime = now - startTime;
                    if (clockTime >= duration) {
                        clockTime = duration;
                        timer.stop();
                        gameStatus.setText("TIME HAS EXPIRED!!");
                        showFinalScore.setText("You Made " + score + " Field Goals");
                        showFinalScore.setVisible(true);
                        jbGameOver.setVisible(true);
                        //----stop timers, reset game, etc
                        b1.setVisible(true);
                        accuracy.setValue(0);
                        power.setValue(0);
                        tPower.stop();
                        tAccuracy.stop();
                        keyCounter = 0;
                        b2.setVisible(false);
                        //---------XML stuff for leader board-------------
                        xmlGame.openReaderXML("test.xml");
                        play[0] = (Player)xmlGame.ReadObject();
                        play[1] = (Player)xmlGame.ReadObject();
                        play[2] = (Player)xmlGame.ReadObject();
                        xmlGame.closeReaderXML();
                        tempScore = play[pnum].pScore;
                        if (tempScore < score)
                        {
                            play[pnum].pScore = score;
                            xmlGame.openWriterXML("test.xml");
                            xmlGame.writeObject(play[0]);
                            xmlGame.writeObject(play[1]);
                            xmlGame.writeObject(play[2]);
                            xmlGame.closeWriterXML();
                        }
                        lb.updateBoard();
                    }
                    SimpleDateFormat df = new SimpleDateFormat("ss:S");
                    countMessage.setText(df.format(duration - clockTime));
                }
            });
            timer.setInitialDelay(0);
            countMessage = new JLabel("Time Remaining");

        //Create JButtons
        b1 = new JButton();
        b1.addActionListener(this);
        b1.setHorizontalAlignment(JButton.CENTER);
        b1.setIcon(start);

        b2 = new JButton();
        b2.addActionListener(this);
        b2.setHorizontalAlignment(JButton.CENTER);
        b2.setIcon(stop);
        b2.setVisible(false);

        //Win or miss
        b6 = new JButton("");
        b6.addActionListener(this);
        b6.setHorizontalAlignment(JButton.CENTER);
        b6.setHorizontalTextPosition(SwingConstants.CENTER);
        b6.setBorder(null);
        b6.setBorderPainted(false);
        b6.setContentAreaFilled(false);

        //Compass
        b7 = new JButton("");
        b7.addActionListener(this);
        b7.setHorizontalAlignment(JButton.CENTER);
        b7.setHorizontalTextPosition(SwingConstants.CENTER);
        b7.setBorder(null);
        b7.setBorderPainted(false);
        b7.setContentAreaFilled(false);
        b7.setIcon(north);

        //-----Options button listeners----------
        gameOpt.jb1.addActionListener(this);
        gameOpt.jb2.addActionListener(this);
        gameOpt.jb3.addActionListener(this);
        gameOpt.jb7.addActionListener(this);
        gameOpt.jb8.addActionListener(this);
        gameOpt.jb9.addActionListener(this);

        //Football
        ball = new JButton("");
        ball.addActionListener(this);
        ball.setHorizontalAlignment(JButton.CENTER);
        ball.setHorizontalTextPosition(SwingConstants.CENTER);
        ball.setBorder(null);
        ball.setBorderPainted(false);
        ball.setContentAreaFilled(false);
        ball.setIcon(football);

        //game over
        jbGameOver = new JButton("");
        jbGameOver.addActionListener(this);
        jbGameOver.setHorizontalAlignment(JButton.CENTER);
        jbGameOver.setHorizontalTextPosition(SwingConstants.CENTER);
        jbGameOver.setBorder(null);
        jbGameOver.setBorderPainted(false);
        jbGameOver.setContentAreaFilled(false);
        jbGameOver.setIcon(gameover);

        //Create Sliders
        accuracy = new JSlider(JSlider.HORIZONTAL,0,100,0);
        accuracy.setMajorTickSpacing(25);
        accuracy.setBorder(BorderFactory.createTitledBorder("Accuracy"));
        accuracy.setPaintTicks(true);
        Color acc = new Color(118, 224, 92);
        accuracy.setBackground(acc);

        power = new JSlider(JSlider.VERTICAL,0,100,0);
        power.setMajorTickSpacing(25);
        power.setBorder(BorderFactory.createTitledBorder("power"));
        power.setPaintTicks(true);
        power.setBackground(acc);

        //Final Score
        showFinalScore.setForeground(Color.BLACK);
        showFinalScore.setFont(showScore.getFont().deriveFont(48.0f));
        showFinalScore.setHorizontalAlignment(SwingConstants.CENTER);
        showFinalScore.setVerticalAlignment(SwingConstants.CENTER);

        //Score or Miss Font
        showScore.setForeground(Color.BLACK);
        showScore.setFont(showScore.getFont().deriveFont(64.0f));
        showScore.setHorizontalAlignment(SwingConstants.CENTER);
        showScore.setVerticalAlignment(SwingConstants.CENTER);

        //Game Status Font
        gameStatus.setHorizontalAlignment(SwingConstants.CENTER);
        gameStatus.setVerticalAlignment(SwingConstants.CENTER);

        //Timer Font
        countMessage.setHorizontalAlignment(SwingConstants.CENTER);
        countMessage.setVerticalAlignment(SwingConstants.CENTER);

        //Create Graphics
        ImageIcon gameFar = new ImageIcon ("images/gameFar.png");
        ImageIcon gameAverage = new ImageIcon ("images/gameAverage.png");
        ImageIcon gameClose = new ImageIcon ("images/gameClose.png");
        l1 = new JLabel(gameClose);
        l2 = new JLabel (gameAverage);
        l3 = new JLabel (gameFar);
        l2.setVisible(false);
        l3.setVisible(false);
        gAcc = new JLabel (accu);
        gPow = new JLabel (pow);

        //Add Components
        add(gAcc);
        add(gPow);
        add(b1);
        add(b2);
        //add(b6);
        add(showFinalScore);
        add(showScore);
        add(ball);
        add(accuracy);
        add(power);
        add(pMessage);
        add(aMessage);
        add(wMessage);
        add(rMessage);
        add(scoreMessage);
        add(controller.optionsDifficulty);
        add(controller.optionsWind);
        add(controller.optionsDistance);
        add(b7);
        add(countMessage);
        add(gameStatus);
        add(jbGameOver);
        add(l1);
        add(l2);
        add(l3);

        //------------Placing------------------------------------
        // x,y, length, height)
        accuracy.setBounds(new Rectangle(500,625,300,75));
        gAcc.setBounds(500, 595, 300, 30);
        power.setBounds(new Rectangle(800,400,75,300));
        gPow.setBounds(875, 400, 30, 300);
        b1.setBounds(new Rectangle(100,110,120,76));
        b2.setBounds(new Rectangle(100,110,120,76));
        b6.setBounds(300, 50, 750, 400);
        showScore.setBounds(new Rectangle(0, 0, 1300, 200));
        showFinalScore.setBounds(new Rectangle(0, 0, 1300, 200));
        pMessage.setBounds(new Rectangle(100,260,200,20));
        aMessage.setBounds(new Rectangle(100,230,200,20));
        wMessage.setBounds(new Rectangle(1000,230,200,20));
        rMessage.setBounds(new Rectangle(1000,500,200,20));
        scoreMessage.setBounds(new Rectangle(10,500,200,20));
        l1.setBounds(0, 0, 1300, 800);
        l2.setBounds(0, 0, 1300, 800);
        l3.setBounds(0, 0, 1300, 800);
        controller.optionsDifficulty.setBounds(new Rectangle(10,580,200,20));
        controller.optionsWind.setBounds(new Rectangle(10,620,200,20));
        controller.optionsDistance.setBounds(new Rectangle(10,660,200,20));
        b7.setBounds(new Rectangle(1000,60,160,160));
        ball.setBounds(new Rectangle(ballx,bally,40,70));
        countMessage.setBounds(new Rectangle(0,10,1300,20));
        gameStatus.setBounds(new Rectangle(0,30,1300,20));
        jbGameOver.setBounds(360, 200, 580, 130); jbGameOver.setVisible(false);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        Object obj = e.getSource();
        String choice = e.getActionCommand();
	    if (obj == b1){
                tAccuracy.start();
                score = 0;
                scoreMessage.setText("Score: " + score);
                b1.setVisible(false);
                b2.setVisible(true);
                gameStatus.setText("");
                jbGameOver.setVisible(false);
                showFinalScore.setVisible(false);
                if (!timer.isRunning()) {
                        startTime = -1;
                        timer.start();
              }
            }

            if (obj == b2){
                //keyCounter determines which stage of the kick we are at
                //"0" is accuracy "1" is power
                if (keyCounter == 0)
                {
                    tAccuracy.stop();
                    aMessage.setText("Accuracy is: " + a);
                    keyCounter++;
                    tPower.start();
                }
                else {

                    tPower.stop();
                    pMessage.setText("Power is: " + p);
                    setX = ballx;
                    setY = bally;
                    //----------CALCULATES IF WIN ------------
                    kickPoint = controller.evaluateKick(p, a, wx, wy);
                    winLose = controller.evaluateGoal(kickPoint);
                    if (winLose == 1)
                    {
                        rMessage.setText("You Win!!");
                        //b6.setIcon(fieldgoal);
                        tAccuracy.stop();
                        tMessage.start();
                        score = (score + 1);
                        showScore.setText(""+score);
                        scoreMessage.setText("Score: " + score);
                    }
                    else {
                        rMessage.setText("You Lose :(");
                        b6.setIcon(missed);
                        showScore.setText("MISS!");
                        //b6.setIcon(missed);
                        tMessage.start();
                    }
                    kickPoint[0] = kickPoint[0] + ((1300 - (controller.kickX))/2);
                    kickPoint[1] = kickPoint[1] + (800 - controller.kickY);
                    tBall.start();
                    tFlip.start();

                    //----------RESETS THE GAME----------------
                    keyCounter = 0;
                    p = 0;
                    a = 0;
                    accuracy.setValue(0);
                    power.setValue(0);
                    }
            }
            if (obj == tAccuracy)
		{
		i = i+1;
                if (a < 0 || a > 100)
                {
                    vA = -vA;
                }
                a += vA;
                accuracy.setValue(a);
                }

            if (obj == tPower)
            {
                j = j+1;
                if (p < 0 || p > 100)
                {
                    vP = -vP;
                }
                p += vP;
                power.setValue(p);
            }
            //------Random wind direction for send into controller----------
            if (obj == tWind)
            {
                wRandom = Math.random()*8;
                if (wRandom <= 1) //East
                {
                    wx = 1;
                    wy = 0;
                    wMessage.setText("East");
                    b7.setIcon(east);
                }
                else if (wRandom <= 2) //South
                {
                    wx = 0;
                    wy = 1;
                    wMessage.setText("South");
                    b7.setIcon(south);
                }
                else if (wRandom <= 3) //West
                {
                    wx = 1;
                    wy = 0;
                    wMessage.setText("West");
                    b7.setIcon(west);
                }
                else if (wRandom <= 4)//North
                {
                    wx = 0;
                    wy = -1;
                    wMessage.setText("North");
                    b7.setIcon(north);
                }
                else if (wRandom <= 5) //North West
                {
                    wx = 1;
                    wy = 1;
                    wMessage.setText("South East");
                    b7.setIcon(southEast);
                }
                else if (wRandom <= 6) //South West
                {
                    wx = -1;
                    wy = 1;
                    wMessage.setText("South West");
                    b7.setIcon(southWest);
                }
                else if (wRandom <= 7) //North East
                {
                    wx = 1;
                    wy = -1;
                    wMessage.setText("North East");
                    b7.setIcon(northEast);
                }
                else if (wRandom <= 8) //North West
                {
                    wx = -1;
                    wy = -1;
                    wMessage.setText("North West");
                    b7.setIcon(northWest);
                }
            }
            if (obj == tMessage)
            {
                tAccuracy.start();
                tMessage.stop();
                tBall.stop();
                b6.setIcon(blank);
                showScore.setText("");
                animatex = 0;
                animatey = 0;
                ball.setBounds(ballx, bally, 40, 70);
                tBall.stop();
                ball.setIcon(football);
            }
            if (obj == tBall)
            {
                distance = Math.sqrt(animatex*animatex+animatey*animatey);
                animatex = ((double)kickPoint[0]-ballx)/20;
                animatey = ((double)kickPoint[1]-bally)/20;
                ball.setIcon(football2);
                if (distance >0)
                {
                    setX = (setX + animatex);
                    setY = (setY - animatey);
                    ball.setLocation((int)(setX + animatex), (int)(setY + animatey));
                }
            }
            if (obj == tFlip)
            {
                if (flipCount == 0)
                {
                    ball.setIcon(football2);
                    flipCount = 1;
                }
                if (flipCount == 1)
                {
                    ball.setIcon(football);
                    flipCount = 0;
                }
            }
            if (obj == gameOpt.jb1)
            {
                //reset timers
                aDelay = 10;
                dDelay = 10;
                tAccuracy.stop();
                tPower.stop();
                tAccuracy = new Timer(aDelay, this);
                tPower = new Timer (dDelay, this);
                tAccuracy.start();
                tPower.start();
            }
            if (obj == gameOpt.jb2)
            {
                //reset timers
                aDelay = 6;
                dDelay = 6;
                tAccuracy.stop();
                tPower.stop();
                tAccuracy = new Timer(aDelay, this);
                tPower = new Timer (dDelay, this);
                tAccuracy.start();
                tPower.start();
            }
            if (obj == gameOpt.jb3)
            {
                //reset timers
                aDelay = 4;
                dDelay = 4;
                tAccuracy.stop();
                tPower.stop();
                tAccuracy = new Timer(aDelay, this);
                tPower = new Timer (dDelay, this);
                tAccuracy.start();
                tPower.start();
            }
            if (obj == gameOpt.jb7)
            {
                l1.setVisible(true);
                l2.setVisible(false);
                l3.setVisible(false);
            }
            if (obj == gameOpt.jb8)
            {
                l1.setVisible(false);
                l2.setVisible(true);
                l3.setVisible(false);
            }
            if (obj == gameOpt.jb9)
            {
                l1.setVisible(false);
                l2.setVisible(false);
                l3.setVisible(true);
            }
            if (obj == lb.jb2)
            {
                lb.clearBoard();
            }

            repaint();
    }

    @Override
    public void stateChanged(ChangeEvent e) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

}


text:
__version__ = "1.10"
default_app_config = "dynamic_preferences.apps.DynamicPreferencesConfig"

redpajama_set_name: RedPajamaGithub


text:
package apple.vision;

import apple.NSObject;
import apple.coregraphics.opaque.CGPathRef;
import apple.foundation.NSArray;
import apple.foundation.NSError;
import apple.foundation.NSIndexPath;
import apple.foundation.NSMethodSignature;
import apple.foundation.NSSet;
import apple.foundation.protocol.NSCopying;
import apple.vision.protocol.VNRequestRevisionProviding;
import org.moe.natj.c.ann.FunctionPtr;
import org.moe.natj.general.NatJ;
import org.moe.natj.general.Pointer;
import org.moe.natj.general.ann.Generated;
import org.moe.natj.general.ann.Library;
import org.moe.natj.general.ann.Mapped;
import org.moe.natj.general.ann.MappedReturn;
import org.moe.natj.general.ann.NInt;
import org.moe.natj.general.ann.NUInt;
import org.moe.natj.general.ann.Owned;
import org.moe.natj.general.ann.ReferenceInfo;
import org.moe.natj.general.ann.Runtime;
import org.moe.natj.general.ptr.Ptr;
import org.moe.natj.general.ptr.VoidPtr;
import org.moe.natj.objc.Class;
import org.moe.natj.objc.ObjCRuntime;
import org.moe.natj.objc.SEL;
import org.moe.natj.objc.ann.ObjCClassBinding;
import org.moe.natj.objc.ann.Selector;
import org.moe.natj.objc.map.ObjCObjectMapper;

/**
 * The VNContour class describes a contour provided by a VNContoursObservation.
 *

 * VNContour objects are lightweight objects that act as a façade which allows access to a small slice of the usually
 * much larger block of data owned by a VNContoursObservation that represents all of the contours detected in an image.
 * While the interface does present the notion of a hierarchy of parent/child contours, the implementation purposefully
 * does not contain any explicit internal bookkeeping for this relationship. Instead, contours are uniquely identified
 * via their indexPath property.
 * As a side effect of this choice, repeated calls to methods that would return relational contours (e.g.,
 * -childContours or -childContourAtIndex:error:) are NOT guaranteed to return the same VNContour instances over and
 * over again. If this kind of parent/child object stability is an absolute requirement of the client, then they are
 * responsible for creating the necessary data structures to represent and build that instance-stable hierarchy.
 */
@Generated
@Library("Vision")
@Runtime(ObjCRuntime.class)
@ObjCClassBinding
public class VNContour extends NSObject implements NSCopying, VNRequestRevisionProviding {
    static {
        NatJ.register();
    }

    @Generated
    protected VNContour(Pointer peer) {
        super(peer);
    }

    @Generated
    @Selector("accessInstanceVariablesDirectly")
    public static native boolean accessInstanceVariablesDirectly();

    @Generated
    @Owned
    @Selector("alloc")
    public static native VNContour alloc();

    @Owned
    @Generated
    @Selector("allocWithZone:")
    public static native VNContour allocWithZone(VoidPtr zone);

    /**
     * The aspect ratio of the contour from the original image aspect ration expressed as width/height
     */
    @Generated
    @Selector("aspectRatio")
    public native float aspectRatio();

    @Generated
    @Selector("automaticallyNotifiesObserversForKey:")
    public static native boolean automaticallyNotifiesObserversForKey(String key);

    @Generated
    @Selector("cancelPreviousPerformRequestsWithTarget:")
    public static native void cancelPreviousPerformRequestsWithTarget(@Mapped(ObjCObjectMapper.class) Object aTarget);

    @Generated
    @Selector("cancelPreviousPerformRequestsWithTarget:selector:object:")
    public static native void cancelPreviousPerformRequestsWithTargetSelectorObject(
            @Mapped(ObjCObjectMapper.class) Object aTarget, SEL aSelector,
            @Mapped(ObjCObjectMapper.class) Object anArgument);

    /**
     * Returns a VNContour object that is a child of this VNContour at the specified index.
     *
     * @param childContourIndex The index into the childContours array.
     * @param error             The error returned if the child contour cannot be provided.
     * @return The VNContour object at the spefiied index path, or nil of a failure occurs.
     */
    @Generated
    @Selector("childContourAtIndex:error:")
    public native VNContour childContourAtIndexError(@NUInt long childContourIndex,
            @ReferenceInfo(type = NSError.class) Ptr<NSError> error);

    /**
     * The total number of child contours in the target contour.
     *

     * The use of this property is prefered over childContours.count due to the cost of building the child objects.
     */
    @Generated
    @Selector("childContourCount")
    @NInt
    public native long childContourCount();

    /**
     * The array of the contours enclosed by the target contour.
     *

     * This property may come with the cost of instantiating new VNContour objects; therefore, clients are strongly
     * encouraged to hold the results in a local variable instead of repeatedly invoking it.
     */
    @Generated
    @Selector("childContours")
    public native NSArray<? extends VNContour> childContours();

    @Generated
    @Selector("classFallbacksForKeyedArchiver")
    public static native NSArray<String> classFallbacksForKeyedArchiver();

    @Generated
    @Selector("classForKeyedUnarchiver")
    public static native Class classForKeyedUnarchiver();

    @Generated
    @Owned
    @Selector("copyWithZone:")
    @MappedReturn(ObjCObjectMapper.class)
    public native Object copyWithZone(VoidPtr zone);

    @Generated
    @Selector("debugDescription")
    public static native String debugDescription_static();

    @Generated
    @Selector("description")
    public static native String description_static();

    @Generated
    @Selector("hash")
    @NUInt
    public static native long hash_static();

    /**
     * The path to the target VNContour as it is stored in the owning VNContoursObservation's hierarchy of contours.
     */
    @Generated
    @Selector("indexPath")
    public native NSIndexPath indexPath();

    @Generated
    @Selector("init")
    public native VNContour init();

    @Generated
    @Selector("instanceMethodForSelector:")
    @FunctionPtr(name = "call_instanceMethodForSelector_ret")
    public static native NSObject.Function_instanceMethodForSelector_ret instanceMethodForSelector(SEL aSelector);

    @Generated
    @Selector("instanceMethodSignatureForSelector:")
    public static native NSMethodSignature instanceMethodSignatureForSelector(SEL aSelector);

    @Generated
    @Selector("instancesRespondToSelector:")
    public static native boolean instancesRespondToSelector(SEL aSelector);

    @Generated
    @Selector("isSubclassOfClass:")
    public static native boolean isSubclassOfClass(Class aClass);

    @Generated
    @Selector("keyPathsForValuesAffectingValueForKey:")
    public static native NSSet<String> keyPathsForValuesAffectingValueForKey(String key);

    @Generated
    @Owned
    @Selector("new")
    public static native VNContour new_objc();

    /**
     * The contour represented as a CGPath in normalized coordinates.
     *

     * The path is owned by this object and therefore will be alive as long as the the observation is alive.
     */
    @Generated
    @Selector("normalizedPath")
    public native CGPathRef normalizedPath();

    /**
     * The number of points that describe the contour.
     */
    @Generated
    @Selector("pointCount")
    @NInt
    public native long pointCount();

    /**
     * Simplifies the contour's collection of points into a polygon using the Ramer Douglas Peucker Algorithm.
     *

     * See <https://en.wikipedia.org/wiki/Ramer–Douglas–Peucker_algorithm>
     *
     * @param epsilon Points that have a perpendicular distance to the line segment they are on that greather than
     *                epsilon are kept, others are eliminated.
     * @param error   The error returned if a simplified contour cannot be created.
     * @return A new VNContour object with a simplified polygon consisting of a subset of the points that defined the
     *         original VNContour.
     */
    @Generated
    @Selector("polygonApproximationWithEpsilon:error:")
    public native VNContour polygonApproximationWithEpsilonError(float epsilon,
            @ReferenceInfo(type = NSError.class) Ptr<NSError> error);

    @Generated
    @Selector("requestRevision")
    @NUInt
    public native long requestRevision();

    @Generated
    @Selector("resolveClassMethod:")
    public static native boolean resolveClassMethod(SEL sel);

    @Generated
    @Selector("resolveInstanceMethod:")
    public static native boolean resolveInstanceMethod(SEL sel);

    @Generated
    @Selector("setVersion:")
    public static native void setVersion_static(@NInt long aVersion);

    @Generated
    @Selector("superclass")
    public static native Class superclass_static();

    @Generated
    @Selector("version")
    @NInt
    public static native long version_static();
}


text:
using System;
using System.Collections.Generic;

class Program
{
    static void Main()
    {
        var lines = int.Parse(Console.ReadLine());
        var persons = new List<Person>();
        for (int i = 0; i < lines; i++)
        {
            var cmdArgs = Console.ReadLine().Split();
            try
            {
                var person = new Person(cmdArgs[0], cmdArgs[1], int.Parse(cmdArgs[2]), decimal.Parse(cmdArgs[3]));
                persons.Add(person);
            }
            catch(ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        var bonus = decimal.Parse(Console.ReadLine());
        persons.ForEach(p => p.IncreaseSalary(bonus));
        persons.ForEach(p => Console.WriteLine(p.ToString()));

    }
}


text:
START_ATF_NAMESPACE
    namespace Detail
    {

        Info::_cash_event_inform_zoclctor__cash_event_inform_zocl2_ptr _cash_event_inform_zoclctor__cash_event_inform_zocl2_next(nullptr);
        Info::_cash_event_inform_zoclctor__cash_event_inform_zocl2_clbk _cash_event_inform_zoclctor__cash_event_inform_zocl2_user(nullptr);

        Info::_cash_event_inform_zoclsize4_ptr _cash_event_inform_zoclsize4_next(nullptr);
        Info::_cash_event_inform_zoclsize4_clbk _cash_event_inform_zoclsize4_user(nullptr);

        void _cash_event_inform_zoclctor__cash_event_inform_zocl2_wrapper(struct _cash_event_inform_zocl* _this)
        {
           _cash_event_inform_zoclctor__cash_event_inform_zocl2_user(_this, _cash_event_inform_zoclctor__cash_event_inform_zocl2_next);
        };
        int _cash_event_inform_zoclsize4_wrapper(struct _cash_event_inform_zocl* _this)
        {
           return _cash_event_inform_zoclsize4_user(_this, _cash_event_inform_zoclsize4_next);
        };

        ::std::array<hook_record, 2> _cash_event_inform_zocl_functions =
        {
            _hook_record {
                (LPVOID)0x14030d710L,
                (LPVOID *)&_cash_event_inform_zoclctor__cash_event_inform_zocl2_user,
                (LPVOID *)&_cash_event_inform_zoclctor__cash_event_inform_zocl2_next,
                (LPVOID)cast_pointer_function(_cash_event_inform_zoclctor__cash_event_inform_zocl2_wrapper),
                (LPVOID)cast_pointer_function((void(_cash_event_inform_zocl::*)())&_cash_event_inform_zocl::ctor__cash_event_inform_zocl)
            },
            _hook_record {
                (LPVOID)0x14030d760L,
                (LPVOID *)&_cash_event_inform_zoclsize4_user,
                (LPVOID *)&_cash_event_inform_zoclsize4_next,
                (LPVOID)cast_pointer_function(_cash_event_inform_zoclsize4_wrapper),
                (LPVOID)cast_pointer_function((int(_cash_event_inform_zocl::*)())&_cash_event_inform_zocl::size)
            },
        };
    }; // end namespace Detail
END_ATF_NAMESPACE


text:
package com.thoughtworks.go.domain;

import com.rits.cloning.Cloner;
import com.thoughtworks.go.config.*;
import com.thoughtworks.go.config.materials.MaterialConfigs;
import com.thoughtworks.go.config.materials.PackageMaterialConfig;
import com.thoughtworks.go.config.materials.PluggableSCMMaterialConfig;
import com.thoughtworks.go.config.materials.ScmMaterialConfig;
import com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig;
import com.thoughtworks.go.config.materials.git.GitMaterialConfig;
import com.thoughtworks.go.config.materials.perforce.P4MaterialConfig;
import com.thoughtworks.go.config.materials.svn.SvnMaterialConfig;
import com.thoughtworks.go.config.merge.MergeConfigOrigin;
import com.thoughtworks.go.config.merge.MergePipelineConfigs;
import com.thoughtworks.go.config.remote.*;
import com.thoughtworks.go.domain.config.Configuration;
import com.thoughtworks.go.domain.config.ConfigurationKey;
import com.thoughtworks.go.domain.config.ConfigurationProperty;
import com.thoughtworks.go.domain.config.ConfigurationValue;
import com.thoughtworks.go.domain.materials.MaterialConfig;
import com.thoughtworks.go.domain.packagerepository.*;
import com.thoughtworks.go.domain.scm.SCM;
import com.thoughtworks.go.domain.scm.SCMMother;
import com.thoughtworks.go.helper.*;
import com.thoughtworks.go.security.GoCipher;
import com.thoughtworks.go.util.ReflectionUtil;
import org.hamcrest.Matchers;
import org.hamcrest.core.Is;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

import java.util.*;

import static com.thoughtworks.go.helper.PipelineConfigMother.createGroup;
import static com.thoughtworks.go.helper.PipelineConfigMother.createPipelineConfig;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.*;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.*;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.same;
import static org.mockito.Mockito.*;

public abstract class CruiseConfigTestBase {
    public GoConfigMother goConfigMother;
    protected BasicPipelineConfigs pipelines;
    protected CruiseConfig cruiseConfig;

    protected abstract CruiseConfig createCruiseConfig(BasicPipelineConfigs pipelineConfigs);

    protected abstract BasicCruiseConfig createCruiseConfig();

    @Test
    public void shouldLoadPasswordForGivenMaterialFingerprint() {
        MaterialConfig svnConfig = new SvnMaterialConfig("url", "loser", "boozer", true);
        PipelineConfig one = PipelineConfigMother.pipelineConfig("one", svnConfig, new JobConfigs(new JobConfig("job")));
        cruiseConfig.addPipeline("group-1", one);

        P4MaterialConfig p4One = new P4MaterialConfig("server_and_port", "outside_the_window");
        p4One.setPassword("abcdef");
        PipelineConfig two = PipelineConfigMother.pipelineConfig("two", p4One, new JobConfigs(new JobConfig("job")));
        cruiseConfig.addPipeline("group-2", two);

        P4MaterialConfig p4Two = new P4MaterialConfig("port_and_server", "inside_yourself");
        p4Two.setPassword("fedcba");
        PipelineConfig three = PipelineConfigMother.pipelineConfig("three", p4Two, new JobConfigs(new JobConfig("job")));
        cruiseConfig.addPipeline("group-3", three);

        assertThat(cruiseConfig.materialConfigFor(svnConfig.getFingerprint()), is(svnConfig));
        assertThat(cruiseConfig.materialConfigFor(p4One.getFingerprint()), is((MaterialConfig) p4One));
        assertThat(cruiseConfig.materialConfigFor(p4Two.getFingerprint()), is((MaterialConfig) p4Two));
        assertThat(cruiseConfig.materialConfigFor("some_crazy_fingerprint"), is(nullValue()));
    }

    @Test
    public void canFindMaterialConfigForUnderGivenPipelineWithMaterialFingerprint() {
        MaterialConfig fullClone = new GitMaterialConfig("url", "master", false);
        PipelineConfig one = PipelineConfigMother.pipelineConfig("one", fullClone, new JobConfigs(new JobConfig("job")));
        cruiseConfig.addPipeline("group-1", one);

        MaterialConfig shallowClone = new GitMaterialConfig("url", "master", true);
        PipelineConfig two = PipelineConfigMother.pipelineConfig("two", shallowClone, new JobConfigs(new JobConfig("job")));
        cruiseConfig.addPipeline("group-2", two);

        MaterialConfig others = new GitMaterialConfig("bar", "master", true);
        PipelineConfig three = PipelineConfigMother.pipelineConfig("three", others, new JobConfigs(new JobConfig("job")));
        cruiseConfig.addPipeline("group-3", three);

        String fingerprint = new GitMaterialConfig("url", "master").getFingerprint();

        assertThat(((GitMaterialConfig) cruiseConfig.materialConfigFor(one.name(), fingerprint)).isShallowClone(), is(false));
        assertThat(((GitMaterialConfig) cruiseConfig.materialConfigFor(two.name(), fingerprint)).isShallowClone(), is(true));
        assertThat(cruiseConfig.materialConfigFor(three.name(), fingerprint), is(nullValue()));
    }

    @Test
    public void shouldFindAllAgentResources() {
        cruiseConfig.agents().add(new AgentConfig("uuid", "host1", "127.0.0.1", new Resources("from-agent")));
        assertThat(cruiseConfig.getAllResources(), hasItem(new Resource("from-agent")));
    }

    @Test
    public void shouldFindBuildPlanWithStages() throws Exception {
        try {
            cruiseConfig.jobConfigByName("cetaceans", "whales", "right whale", true);
            fail("Expected not to find right whale in stage whales in pipeline cetaceans");
        } catch (RuntimeException ex) {
            // ignore
        }

        addPipeline("cetaceans", "whales", jobConfig("whale"));

        try {
            cruiseConfig.jobConfigByName("cetaceans", "whales", "dolphin", true);
        } catch (Exception e) {
            assertThat(e.getMessage(), is("Job [dolphin] is not found in pipeline [cetaceans] stage [whales]."));
        }

        try {
            cruiseConfig.jobConfigByName("primates", "whales", "dolphin", true);
            fail("Expected not to find primates in stage whales in pipeline cetaceans");
        } catch (RuntimeException ex) {
            // ignore
        }
        JobConfig plan = jobConfig("baboon");
        addPipeline("primates", "apes", plan);
        assertThat(cruiseConfig.jobConfigByName("primates", "apes", "baboon", true), is(plan));
    }

    @Test
    public void shouldFindNextStage() {
        addPipelineWithStages("mingle", "dev", jobConfig("ut"), jobConfig("ft"));
        assertThat(cruiseConfig.hasNextStage(new CaseInsensitiveString("mingle"), new CaseInsensitiveString("dev")), is(true));
        StageConfig nextStage = cruiseConfig.nextStage(new CaseInsensitiveString("mingle"), new CaseInsensitiveString("dev"));
        assertThat(nextStage.name(), is(new CaseInsensitiveString("dev2")));
        assertThat(cruiseConfig.hasNextStage(new CaseInsensitiveString("mingle"), nextStage.name()), is(false));
    }

    @Test
    public void shouldFindPreviousStage() {
        addPipelineWithStages("mingle", "dev", jobConfig("ut"), jobConfig("ft"));
        assertThat(cruiseConfig.hasPreviousStage(new CaseInsensitiveString("mingle"), new CaseInsensitiveString("dev2")), is(true));
        StageConfig previousStage = cruiseConfig.previousStage(new CaseInsensitiveString("mingle"), new CaseInsensitiveString("dev2"));
        assertThat(previousStage.name(), is(new CaseInsensitiveString("dev")));
        assertThat(cruiseConfig.hasPreviousStage(new CaseInsensitiveString("mingle"), previousStage.name()), is(false));
    }

    @Test
    public void shouldKnowWhenBuildPlanNotInConfigFile() {
        pipelines.add(createPipelineConfig("pipeline", "stage", "build1", "build2"));
        assertThat(cruiseConfig.hasBuildPlan(new CaseInsensitiveString("pipeline"), new CaseInsensitiveString("stage"), "build1", true), is(true));
        assertThat(cruiseConfig.hasBuildPlan(new CaseInsensitiveString("pipeline"), new CaseInsensitiveString("stage"), "build2", true), is(true));
        assertThat(cruiseConfig.hasBuildPlan(new CaseInsensitiveString("pipeline"), new CaseInsensitiveString("stage"), "build3", true), is(false));
    }

    @Test
    public void shouldTellIfSMTPIsEnabled() {
        assertThat(cruiseConfig.isSmtpEnabled(), is(false));

        MailHost mailHost = new MailHost("abc", 12, "admin", "p", true, true, "anc@mail.com", "anc@mail.com");
        cruiseConfig.setServerConfig(new ServerConfig(null, mailHost, null, null));

        cruiseConfig.server().updateMailHost(mailHost);
        assertThat(cruiseConfig.isSmtpEnabled(), is(true));
    }

    @Test
    public void shouldReturnAMapOfTemplateNamesToListOfAssociatedPipelinesCaseInsensitively() {
        PipelineTemplateConfig template = template("first_template");
        PipelineConfig pipelineConfig1 = PipelineConfigMother.pipelineConfig("first");
        pipelineConfig1.clear();
        pipelineConfig1.setTemplateName(new CaseInsensitiveString("first_template"));
        pipelineConfig1.usingTemplate(template);

        PipelineConfig pipelineConfig2 = PipelineConfigMother.pipelineConfig("second");
        pipelineConfig2.clear();
        pipelineConfig2.setTemplateName(new CaseInsensitiveString("FIRST_template"));
        pipelineConfig2.usingTemplate(template);

        PipelineConfig pipelineConfigWithoutTemplate = PipelineConfigMother.pipelineConfig("third");

        BasicPipelineConfigs pipelineConfigs = new BasicPipelineConfigs(pipelineConfig1, pipelineConfig2, pipelineConfigWithoutTemplate);
        CruiseConfig cruiseConfig = createCruiseConfig(pipelineConfigs);

        cruiseConfig.addTemplate(template);
        SecurityConfig securityConfig = new SecurityConfig(new LdapConfig(new GoCipher()), new PasswordFileConfig("foo"), false);
        securityConfig.adminsConfig().add(new AdminUser(new CaseInsensitiveString("root")));
        cruiseConfig.server().useSecurity(securityConfig);

        Map<CaseInsensitiveString, List<CaseInsensitiveString>> templateWithPipelines = cruiseConfig.templatesWithPipelinesForUser("root");

        assertThat(templateWithPipelines.size(), is(1));
        assertThat(templateWithPipelines.get(new CaseInsensitiveString("first_template")), is(Arrays.asList(new CaseInsensitiveString("first"), new CaseInsensitiveString("second"))));
    }

    @Test
    public void shouldReturnAMapOfTemplateNamesToListOfAssociatedPipelinesBasedOnUserPermissions() {

        PipelineTemplateConfig firstTemplate = PipelineTemplateConfigMother.createTemplate("first_template", new Authorization(new AdminsConfig(
                new AdminUser(new CaseInsensitiveString("firstTemplate-admin")))), StageConfigMother.manualStage("stage-one"));
        PipelineConfig pipelineConfig1 = PipelineConfigMother.pipelineConfig("first");
        pipelineConfig1.clear();
        pipelineConfig1.setTemplateName(new CaseInsensitiveString("first_template"));
        pipelineConfig1.usingTemplate(firstTemplate);

        PipelineTemplateConfig secondTemplate = PipelineTemplateConfigMother.createTemplate("second_template", new Authorization(new AdminsConfig(
                new AdminUser(new CaseInsensitiveString("secondTemplate-admin")))), StageConfigMother.stageConfig("one-more"));
        PipelineConfig pipelineConfig2 = PipelineConfigMother.pipelineConfig("second");
        pipelineConfig2.clear();
        pipelineConfig2.setTemplateName(new CaseInsensitiveString("second_template"));
        pipelineConfig2.usingTemplate(secondTemplate);

        PipelineConfig pipelineConfigWithoutTemplate = PipelineConfigMother.pipelineConfig("third");

        CruiseConfig cruiseConfig = createCruiseConfig(new BasicPipelineConfigs(pipelineConfig1, pipelineConfig2, pipelineConfigWithoutTemplate));

        cruiseConfig.addTemplate(firstTemplate);
        cruiseConfig.addTemplate(secondTemplate);

        SecurityConfig securityConfig = new SecurityConfig(new LdapConfig(new GoCipher()), new PasswordFileConfig("foo"), false);
        securityConfig.adminsConfig().add(new AdminUser(new CaseInsensitiveString("root")));
        cruiseConfig.server().useSecurity(securityConfig);

        Map<CaseInsensitiveString, List<CaseInsensitiveString>> templateWithPipelines = cruiseConfig.templatesWithPipelinesForUser("firstTemplate-admin");

        assertThat(templateWithPipelines.size(), is(1));
        assertThat(templateWithPipelines.get(new CaseInsensitiveString("first_template")), is(Arrays.asList(new CaseInsensitiveString("first"))));
    }

    @Test
    public void shouldReturnAMapOfAllTemplateNamesToListOfAssociatedPipelinesIfUserIsSuperAdmin() {

        PipelineTemplateConfig firstTemplate = PipelineTemplateConfigMother.createTemplate("first_template", new Authorization(new AdminsConfig(
                new AdminUser(new CaseInsensitiveString("firstTemplate-admin")))), StageConfigMother.manualStage("stage-one"));
        PipelineConfig pipelineConfig1 = PipelineConfigMother.pipelineConfig("first");
        pipelineConfig1.clear();
        pipelineConfig1.setTemplateName(new CaseInsensitiveString("first_template"));
        pipelineConfig1.usingTemplate(firstTemplate);

        PipelineTemplateConfig secondTemplate = PipelineTemplateConfigMother.createTemplate("second_template", new Authorization(new AdminsConfig(
                new AdminUser(new CaseInsensitiveString("secondTemplate-admin")))), StageConfigMother.stageConfig("one-more"));
        PipelineConfig pipelineConfig2 = PipelineConfigMother.pipelineConfig("second");
        pipelineConfig2.clear();
        pipelineConfig2.setTemplateName(new CaseInsensitiveString("second_template"));
        pipelineConfig2.usingTemplate(secondTemplate);

        PipelineConfig pipelineConfigWithoutTemplate = PipelineConfigMother.pipelineConfig("third");

        CruiseConfig cruiseConfig = createCruiseConfig(new BasicPipelineConfigs(pipelineConfig1, pipelineConfig2, pipelineConfigWithoutTemplate));

        SecurityConfig securityConfig = new SecurityConfig(new LdapConfig(new GoCipher()), new PasswordFileConfig("foo"), false);
        securityConfig.adminsConfig().add(new AdminUser(new CaseInsensitiveString("root")));
        cruiseConfig.server().useSecurity(securityConfig);

        cruiseConfig.addTemplate(firstTemplate);
        cruiseConfig.addTemplate(secondTemplate);

        Map<CaseInsensitiveString, List<CaseInsensitiveString>> templateWithPipelines = cruiseConfig.templatesWithPipelinesForUser("root");

        assertThat(templateWithPipelines.size(), is(2));
        assertThat(templateWithPipelines.get(new CaseInsensitiveString("first_template")), is(Arrays.asList(new CaseInsensitiveString("first"))));
        assertThat(templateWithPipelines.get(new CaseInsensitiveString("second_template")), is(Arrays.asList(new CaseInsensitiveString("second"))));
    }

    private PipelineTemplateConfig template(final String name) {
        return new PipelineTemplateConfig(new CaseInsensitiveString(name), StageConfigMother.stageConfig("some_stage"));
    }

    @Test
    public void shouldThrowExceptionWhenThereIsNoGroup() {
        CruiseConfig config = createCruiseConfig();
        try {
            config.isInFirstGroup(new CaseInsensitiveString("any-pipeline"));
            fail("should throw exception when there is no group");
        } catch (Exception e) {
            assertThat(e.getMessage(), is("No pipeline group defined yet!"));
        }
    }

    @Test
    public void shouldOfferAllTasksToVisitors() throws Exception {
        CruiseConfig config = createCruiseConfig();
        Task task1 = new ExecTask("ls", "-a", "");
        Task task2 = new AntTask();
        setupJobWithTasks(config, task1, task2);

        final List<Task> tasksVisited = new ArrayList<Task>();
        config.accept(new TaskConfigVisitor() {

            public void visit(PipelineConfig pipelineConfig, StageConfig stageConfig, JobConfig jobConfig, Task task) {
                tasksVisited.add(task);
            }
        });

        assertThat(tasksVisited.size(), is(2));
        assertThat(tasksVisited.get(0), is(task1));
        assertThat(tasksVisited.get(1), is(task2));
    }

    @Test
    public void shouldOfferNothingToVisitorsIfThereAreNoTasks() throws Exception {
        CruiseConfig config = createCruiseConfig();
        setupJobWithTasks(config, new NullTask());

        final List<Task> tasksVisited = new ArrayList<Task>();
        config.accept(new TaskConfigVisitor() {

            public void visit(PipelineConfig pipelineConfig, StageConfig stageConfig, JobConfig jobConfig, Task task) {
                tasksVisited.add(task);
            }
        });

        assertThat(tasksVisited.size(), is(0));
    }

    @Test
    public void shouldReturnTrueIfThereAreTwoPipelineGroups() throws Exception {
        CruiseConfig config = goConfigMother.cruiseConfigWithTwoPipelineGroups();
        assertThat("shouldReturnTrueIfThereAreTwoPipelineGroups", config.hasMultiplePipelineGroups(), is(true));
    }

    @Test
    public void shouldReturnFalseIfThereIsOnePipelineGroup() throws Exception {
        CruiseConfig config = goConfigMother.cruiseConfigWithOnePipelineGroup();
        assertThat("shouldReturnFalseIfThereIsOnePipelineGroup", config.hasMultiplePipelineGroups(), is(false));
    }

    @Test
    public void shouldFindDownstreamPipelines() throws Exception {
        CruiseConfig config = goConfigMother.defaultCruiseConfig();
        goConfigMother.addPipeline(config, "pipeline-1", "stage-1", "job-1");
        PipelineConfig pipeline2 = goConfigMother.addPipeline(config, "pipeline-2", "stage-2", "job-2");
        PipelineConfig pipeline3 = goConfigMother.addPipeline(config, "pipeline-3", "stage-3", "job-3");
        goConfigMother.setDependencyOn(config, pipeline2, "pipeline-1", "stage-1");
        goConfigMother.setDependencyOn(config, pipeline3, "pipeline-1", "stage-1");
        Iterable<PipelineConfig> downstream = config.getDownstreamPipelines("pipeline-1");
        assertThat(downstream, hasItem(pipeline2));
        assertThat(downstream, hasItem(pipeline3));
    }

    @Test
    public void shouldReturnFalseForEmptyCruiseConfig() throws Exception {
        CruiseConfig config = createCruiseConfig();
        assertThat("shouldReturnFalseForEmptyCruiseConfig", config.hasMultiplePipelineGroups(), is(false));
    }

    @Test
    public void shouldReturnFalseIfNoMailHost() throws Exception {
        assertThat(createCruiseConfig().isMailHostConfigured(), is(false));
    }

    @Test
    public void shouldReturnTrueIfMailHostIsConfigured() throws Exception {
        MailHost mailHost = new MailHost("hostName", 1234, "user", "pass", true, true, "from", "admin@local.com");
        assertThat(GoConfigMother.cruiseConfigWithMailHost(mailHost).isMailHostConfigured(), is(true));
    }

    @Test
    public void shouldNotLockAPipelineWhenItIsAddedToAnEnvironment() throws Exception {
        CruiseConfig config = GoConfigMother.configWithPipelines("pipeline-1");
        EnvironmentConfig env = config.addEnvironment("environment");
        env.addPipeline(new CaseInsensitiveString("pipeline-1"));
        assertThat(config.isPipelineLocked("pipeline-1"), is(false));
    }

    @Test
    public void shouldBeAbleToExplicitlyLockAPipeline() throws Exception {
        CruiseConfig config = GoConfigMother.configWithPipelines("pipeline-1");
        PipelineConfig pipelineConfig = config.pipelineConfigByName(new CaseInsensitiveString("pipeline-1"));
        pipelineConfig.lockExplicitly();
        assertThat(config.isPipelineLocked("pipeline-1"), is(true));
    }

    @Test
    public void shouldCollectAllTheErrorsInTheChildren() {
        CruiseConfig config = GoConfigMother.configWithPipelines("pipeline-1");

        shouldCollectAllTheErrorsInTheChilderHelper(config);
    }

    protected void shouldCollectAllTheErrorsInTheChilderHelper(CruiseConfig config) {
        config.server().security().ldapConfig().errors().add("uri", "invalid ldap uri");
        config.server().security().ldapConfig().errors().add("searchBase", "invalid search base");

        PipelineConfig pipelineConfig = config.pipelineConfigByName(new CaseInsensitiveString("pipeline-1"));
        pipelineConfig.errors().add("base", "Some base errors");

        P4MaterialConfig p4MaterialConfig = new P4MaterialConfig("localhost:1999", "view");
        p4MaterialConfig.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "p4_folder"));
        pipelineConfig.addMaterialConfig(p4MaterialConfig);
        p4MaterialConfig.errors().add("materialName", "material name does not follow pattern");

        StageConfig stage = pipelineConfig.first();
        stage.errors().add("role", "Roles must be proper");

        List<ConfigErrors> allErrors = config.validateAfterPreprocess();
        assertThat(allErrors.size(), is(5));
        assertThat(allErrors.get(0).on("uri"), is("invalid ldap uri"));
        assertThat(allErrors.get(0).on("searchBase"), is("invalid search base"));
        assertThat(allErrors.get(1).on("base"), is("Some base errors"));
        assertThat(allErrors.get(2).on("role"), is("Roles must be proper"));
        assertThat(allErrors.get(3).on(ScmMaterialConfig.FOLDER), is("Destination directory is required when specifying multiple scm materials"));
        assertThat(allErrors.get(4).on("materialName"), is("material name does not follow pattern"));
    }

    @Test
    public void getAllErrors_shouldCollectAllErrorsInTheChildren() {
        CruiseConfig config = GoConfigMother.configWithPipelines("pipeline-1");

        config.server().security().ldapConfig().errors().add("uri", "invalid ldap uri");
        config.server().security().ldapConfig().errors().add("searchBase", "invalid search base");

        PipelineConfig pipelineConfig = config.pipelineConfigByName(new CaseInsensitiveString("pipeline-1"));
        pipelineConfig.errors().add("base", "Some base errors");

        P4MaterialConfig p4MaterialConfig = new P4MaterialConfig("localhost:1999", "view");
        pipelineConfig.addMaterialConfig(p4MaterialConfig);
        p4MaterialConfig.errors().add("materialName", "material name does not follow pattern");

        StageConfig stage = pipelineConfig.first();
        stage.errors().add("role", "Roles must be proper");

        List<ConfigErrors> allErrors = config.getAllErrors();
        assertThat(allErrors.size(), is(4));
        assertThat(allErrors.get(0).on("uri"), is("invalid ldap uri"));
        assertThat(allErrors.get(0).on("searchBase"), is("invalid search base"));
        assertThat(allErrors.get(1).on("base"), is("Some base errors"));
        assertThat(allErrors.get(2).on("role"), is("Roles must be proper"));
        assertThat(allErrors.get(3).on("materialName"), is("material name does not follow pattern"));
    }

    @Test
    public void getAllErrors_shouldIgnoreErrorsOnElementToBeSkipped() {
        CruiseConfig config = GoConfigMother.configWithPipelines("pipeline-1");

        config.server().security().ldapConfig().errors().add("uri", "invalid ldap uri");
        config.server().security().ldapConfig().errors().add("searchBase", "invalid search base");

        PipelineConfig pipelineConfig = config.pipelineConfigByName(new CaseInsensitiveString("pipeline-1"));
        pipelineConfig.errors().add("base", "Some base errors");

        P4MaterialConfig p4MaterialConfig = new P4MaterialConfig("localhost:1999", "view");
        pipelineConfig.addMaterialConfig(p4MaterialConfig);
        p4MaterialConfig.errors().add("materialName", "material name does not follow pattern");

        StageConfig stage = pipelineConfig.first();
        stage.errors().add("role", "Roles must be proper");

        List<ConfigErrors> allErrors = config.getAllErrorsExceptFor(p4MaterialConfig);
        assertThat(allErrors.size(), is(3));
        assertThat(allErrors.get(0).on("uri"), is("invalid ldap uri"));
        assertThat(allErrors.get(0).on("searchBase"), is("invalid search base"));
        assertThat(allErrors.get(1).on("base"), is("Some base errors"));
        assertThat(allErrors.get(2).on("role"), is("Roles must be proper"));
    }

    @Test
    public void getAllErrors_shouldRetainAllErrorsWhenNoSubjectGiven() {
        CruiseConfig config = GoConfigMother.configWithPipelines("pipeline-1");

        config.server().security().ldapConfig().errors().add("uri", "invalid ldap uri");
        config.server().security().ldapConfig().errors().add("searchBase", "invalid search base");

        PipelineConfig pipelineConfig = config.pipelineConfigByName(new CaseInsensitiveString("pipeline-1"));
        pipelineConfig.errors().add("base", "Some base errors");

        P4MaterialConfig p4MaterialConfig = new P4MaterialConfig("localhost:1999", "view");
        pipelineConfig.addMaterialConfig(p4MaterialConfig);
        p4MaterialConfig.errors().add("materialName", "material name does not follow pattern");

        StageConfig stage = pipelineConfig.first();
        stage.errors().add("role", "Roles must be proper");

        List<ConfigErrors> allErrors = config.getAllErrorsExceptFor(null);
        assertThat(allErrors.size(), is(4));
    }

    @Test
    public void shouldBuildTheValidationContextForAnOnCancelTask() {
        CruiseConfig config = GoConfigMother.configWithPipelines("pipeline-1");
        PipelineConfig pipelineConfig = config.pipelineConfigByName(new CaseInsensitiveString("pipeline-1"));
        StageConfig stageConfig = pipelineConfig.get(0);
        JobConfig jobConfig = stageConfig.getJobs().get(0);
        ExecTask execTask = new ExecTask("ls", "-la", "dir");
        Task mockTask = mock(Task.class);
        when(mockTask.errors()).thenReturn(new ConfigErrors());
        execTask.setCancelTask(mockTask);
        jobConfig.addTask(execTask);

        config.validateAfterPreprocess();

        verify(mockTask).validate(ConfigSaveValidationContext.forChain(
                config,
                config.getGroups(),
                config.getGroups().findGroup("defaultGroup"),
                pipelineConfig,
                stageConfig,
                stageConfig.getJobs(),
                jobConfig,
                jobConfig.getTasks(),
                execTask,
                execTask.onCancelConfig()));
    }

    @Test
    @Ignore("ShilpaG & RajeshM removed in 12208:39962f06092d, because they could not find any place in the codebase where circular reference existed(so the circular ref check was undone) - Sachin & JJ")
    public void shouldNotFailOnCircularReference() {
        MyValidatable foo = new MyValidatable();
        MyValidatable bar = new MyValidatable();
        foo.innerValidatable = bar;
        bar.innerValidatable = foo;

        GoConfigGraphWalker.Handler handler = mock(GoConfigGraphWalker.Handler.class);

        new GoConfigGraphWalker(foo).walk(handler);

        verify(handler).handle(same(foo), any(ValidationContext.class));
        verify(handler).handle(same(bar), any(ValidationContext.class));
    }

    @Test
    public void shouldNotConsiderEqualObjectsAsSame() {
        MyValidatable foo = new AlwaysEqualMyValidatable();
        MyValidatable bar = new AlwaysEqualMyValidatable();
        foo.innerValidatable = bar;

        GoConfigGraphWalker.Handler handler = mock(GoConfigGraphWalker.Handler.class);

        new GoConfigGraphWalker(foo).walk(handler);

        verify(handler).handle(same(foo), any(ValidationContext.class));
        verify(handler).handle(same(bar), any(ValidationContext.class));
    }

    @Test
    public void shouldIgnoreConstantFieldsWhileCollectingErrorsToAvoidPotentialCycles() {
        CruiseConfig config = GoConfigMother.configWithPipelines("pipeline-1");
        List<ConfigErrors> allErrors = config.validateAfterPreprocess();
        assertThat(allErrors.size(), is(0));
    }

    @Test
    public void shouldErrorOutWhenDependsOnItself() throws Exception {
        CruiseConfig cruiseConfig = createCruiseConfig();
        PipelineConfig pipelineConfig = goConfigMother.addPipeline(cruiseConfig, "pipeline1", "stage", "build");
        goConfigMother.addStageToPipeline(cruiseConfig, "pipeline1", "ft", "build");
        goConfigMother.setDependencyOn(cruiseConfig, pipelineConfig, "pipeline1", "ft");
        cruiseConfig.validate(null);
        ConfigErrors errors = pipelineConfig.materialConfigs().errors();
        assertThat(errors.on("base"), is("Circular dependency: pipeline1 <- pipeline1"));
    }

    @Test
    public void shouldNotDuplicateErrorWhenPipelineDoesnotExist() throws Exception {
        CruiseConfig cruiseConfig = createCruiseConfig();
        PipelineConfig pipelineConfig = goConfigMother.addPipeline(cruiseConfig, "pipeline1", "stage", "build");
        PipelineConfig pipelineConfig2 = goConfigMother.addPipeline(cruiseConfig, "pipeline2", "stage", "build");
        goConfigMother.addStageToPipeline(cruiseConfig, "pipeline1", "ft", "build");
        goConfigMother.setDependencyOn(cruiseConfig, pipelineConfig2, "pipeline1", "ft");
        goConfigMother.setDependencyOn(cruiseConfig, pipelineConfig, "invalid", "invalid");
        cruiseConfig.validate(null);
        List<ConfigErrors> allErrors = cruiseConfig.getAllErrors();
        List<String> errors = new ArrayList<String>();
        for (ConfigErrors allError : allErrors) {
            errors.addAll(allError.getAllOn("base"));
        }
        assertThat(errors.size(), is(1));
        assertThat(errors.get(0), is("Pipeline \"invalid\" does not exist. It is used from pipeline \"pipeline1\"."));
    }

    @Test
    public void shouldErrorOutWhenTwoPipelinesDependsOnEachOther() throws Exception {
        CruiseConfig cruiseConfig = createCruiseConfig();
        PipelineConfig pipeline1 = goConfigMother.addPipeline(cruiseConfig, "pipeline1", "stage", "build");
        PipelineConfig pipeline2 = goConfigMother.addPipeline(cruiseConfig, "pipeline2", "stage", "build");
        goConfigMother.setDependencyOn(cruiseConfig, pipeline2, "pipeline1", "stage");
        goConfigMother.setDependencyOn(cruiseConfig, pipeline1, "pipeline2", "stage");

        cruiseConfig.validate(null);

        assertThat(pipeline1.materialConfigs().errors().isEmpty(), is(false));
        assertThat(pipeline2.materialConfigs().errors().isEmpty(), is(false));
    }

    @Test
    public void shouldAddPipelineWithoutValidationInAnExistingGroup() {
        CruiseConfig cruiseConfig = createCruiseConfig();
        PipelineConfig pipeline1 = PipelineConfigMother.pipelineConfig("first");
        PipelineConfig pipeline2 = PipelineConfigMother.pipelineConfig("first");
        cruiseConfig.addPipelineWithoutValidation("first-group", pipeline1);

        assertThat(cruiseConfig.getGroups().size(), is(1));
        assertThat(cruiseConfig.findGroup("first-group").get(0), is(pipeline1));

        cruiseConfig.addPipelineWithoutValidation("first-group", pipeline2);
        assertThat(cruiseConfig.findGroup("first-group").get(0), is(pipeline1));
        assertThat(cruiseConfig.findGroup("first-group").get(1), is(pipeline2));
    }

    @Test
    public void shouldErrorOutWhenThreePipelinesFormACycle() throws Exception {
        CruiseConfig cruiseConfig = createCruiseConfig();
        PipelineConfig pipeline1 = goConfigMother.addPipeline(cruiseConfig, "pipeline1", "stage", "build");
        SvnMaterialConfig material = (SvnMaterialConfig) pipeline1.materialConfigs().get(0);
        material.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "svn_dir"));
        P4MaterialConfig p4MaterialConfig = new P4MaterialConfig("localhost:1999", "view");
        p4MaterialConfig.setConfigAttributes(Collections.singletonMap(ScmMaterialConfig.FOLDER, "p4_folder"));
        pipeline1.addMaterialConfig(p4MaterialConfig);
        PipelineConfig pipeline2 = goConfigMother.addPipeline(cruiseConfig, "pipeline3", "stage", "build");
        PipelineConfig pipeline3 = goConfigMother.addPipeline(cruiseConfig, "pipeline2", "stage", "build");
        goConfigMother.setDependencyOn(cruiseConfig, pipeline3, "pipeline3", "stage");
        goConfigMother.setDependencyOn(cruiseConfig, pipeline2, "pipeline1", "stage");
        goConfigMother.setDependencyOn(cruiseConfig, pipeline1, "pipeline2", "stage");
        cruiseConfig.validate(null);
        assertThat(pipeline1.materialConfigs().errors().isEmpty(), is(false));
        assertThat(pipeline2.materialConfigs().errors().isEmpty(), is(false));
        assertThat(pipeline3.materialConfigs().errors().isEmpty(), is(false));
    }

    @Test
    public void shouldAllowCleanupOfNonExistentStages() {
        CruiseConfig cruiseConfig = createCruiseConfig();
        assertThat(cruiseConfig.isArtifactCleanupProhibited("foo", "bar"), is(false));

        PipelineConfig pipelineConfig = PipelineConfigMother.createPipelineConfig("foo-pipeline", "bar-stage", "baz-job");
        cruiseConfig.addPipeline("defaultGrp", pipelineConfig);
        assertThat(cruiseConfig.isArtifactCleanupProhibited("foo-pipeline", "baz-stage"), is(false));
        assertThat(cruiseConfig.isArtifactCleanupProhibited("foo-pipeline", "bar-stage"), is(false));

        ReflectionUtil.setField(pipelineConfig.getFirstStageConfig(), "artifactCleanupProhibited", true);
        assertThat(cruiseConfig.isArtifactCleanupProhibited("foo-pipeline", "bar-stage"), is(true));
        assertThat(cruiseConfig.isArtifactCleanupProhibited("fOO-pipeLINE", "BaR-StagE"), is(true));
    }

    @Test
    public void shouldReturnDefaultGroupNameIfNoGroupNameIsSpecified() {
        CruiseConfig cfg = createCruiseConfig();
        assertThat(cfg.sanitizedGroupName(null), is(BasicPipelineConfigs.DEFAULT_GROUP));
        cfg.addPipeline("grp1", PipelineConfigMother.pipelineConfig("foo"));
        assertThat(cfg.sanitizedGroupName(null), is(BasicPipelineConfigs.DEFAULT_GROUP));
    }

    @Test
    public void shouldReturnSelectedGroupNameIfGroupNameIsSpecified() {
        CruiseConfig cfg = createCruiseConfig();
        cfg.addPipeline("grp1", PipelineConfigMother.pipelineConfig("foo"));
        assertThat(cfg.sanitizedGroupName("gr1"), is("gr1"));
    }

    @Test
    public void shouldRemoveUserFromRoleWhenRoleIsDeleted() {
        CruiseConfig config = createCruiseConfig();
        SecurityConfig securityConfig = new SecurityConfig(new LdapConfig(new GoCipher()), new PasswordFileConfig("foo"), false);
        securityConfig.adminsConfig().add(new AdminUser(new CaseInsensitiveString("root")));
        final Role role = goConfigMother.createRole("ldap-users", "root");
        securityConfig.addRole(role);
        config.server().useSecurity(securityConfig);

        assertTrue(config.server().security().getRoles().isRoleExist(new CaseInsensitiveString("ldap-users")));
        config.removeRole(role);
        assertFalse(config.server().security().getRoles().isRoleExist(new CaseInsensitiveString("ldap-users")));
    }

    @Test
    public void shouldDeleteAdminRolesInAllPipelineGroupWhenARoleIsDeleted() throws Exception {
        final Role role = setupSecurityWithRole();

        goConfigMother.addPipelineWithGroup(cruiseConfig, "group1", "p1", "s1", "b1");
        goConfigMother.addPipelineWithGroup(cruiseConfig, "group2", "p2", "s2", "b2");
        goConfigMother.addRoleAsViewerOfPipelineGroup(cruiseConfig, "ldap-users", "group1");
        goConfigMother.addRoleAsViewerOfPipelineGroup(cruiseConfig, "ldap-users", "group2");

        assertEquals(new HashSet<String>(Arrays.asList("group1", "group2")), cruiseConfig.groupsAffectedByDeletionOfRole("ldap-users").keySet());
        cruiseConfig.removeRole(role);
        assertEquals(new HashSet<String>(), cruiseConfig.groupsAffectedByDeletionOfRole("ldap-users").keySet());
    }

    @Test
    public void shouldDeleteAdminRoleFromAllApprovalsWhenARoleIsDeleted() throws Exception {
        final Role role = setupSecurityWithRole();
        goConfigMother.addPipelineWithGroup(cruiseConfig, "group1", "p1", "s1", "b1");
        goConfigMother.addApprovalForStage(cruiseConfig, "p1", "s1", "ldap-users");
        assertEquals(1, cruiseConfig.stagesWithPermissionForRole(role.getName().toLower()).size());
        cruiseConfig.removeRole(role);
        assertEquals(0, cruiseConfig.stagesWithPermissionForRole(role.getName().toLower()).size());
    }

    @Test
    public void shouldRemoveSystemAdminPermissionsForARoleWhenARoleIsDeleted() throws Exception {
        String adminRoleName = "admin-role";
        Role adminRole = new Role(new CaseInsensitiveString(adminRoleName));
        adminRole.addUser(new RoleUser(new CaseInsensitiveString("admin")));
        goConfigMother.addRole(cruiseConfig, adminRole);
        goConfigMother.addRoleAsSuperAdmin(cruiseConfig, adminRoleName);
        assertThat(cruiseConfig.doesAdminConfigContainRole(adminRoleName), is(true));
        assertThat(cruiseConfig.server().security().getRoles().contains(adminRole), is(true));
        cruiseConfig.removeRole(adminRole);
        assertThat(cruiseConfig.doesAdminConfigContainRole(adminRoleName), is(false));
        assertThat(cruiseConfig.server().security().getRoles().contains(adminRole), is(false));
    }

    @Test
    public void shouldAddPackageRepository() throws Exception {
        PackageRepository packageRepository = new PackageRepository();
        cruiseConfig.savePackageRepository(packageRepository);
        assertThat(cruiseConfig.getPackageRepositories().size(), is(1));
        assertThat(cruiseConfig.getPackageRepositories().get(0), is(packageRepository));
        assertThat(cruiseConfig.getPackageRepositories().get(0).getId(), is(notNullValue()));
    }

    @Test
    public void shouldUpdatePackageRepository() throws Exception {
        PackageRepository packageRepository = new PackageRepository();
        packageRepository.setName("old");
        cruiseConfig.savePackageRepository(packageRepository);

        packageRepository.setName("new");
        cruiseConfig.savePackageRepository(packageRepository);

        assertThat(cruiseConfig.getPackageRepositories().size(), is(1));
        assertThat(cruiseConfig.getPackageRepositories().get(0), is(packageRepository));
        assertThat(cruiseConfig.getPackageRepositories().get(0).getId(), is(notNullValue()));
        assertThat(cruiseConfig.getPackageRepositories().get(0).getName(), is("new"));
    }

    @Test
    public void shouldAddPackageDefinitionToGivenRepository() throws Exception {
        String repoId = "repo-id";
        PackageRepository packageRepository = PackageRepositoryMother.create(repoId, "repo-name", "plugin-id", "1.0", new Configuration());
        PackageDefinition existing = PackageDefinitionMother.create("pkg-1", "pkg1-name", new Configuration(), packageRepository);

        packageRepository.setPackages(new Packages(existing));
        cruiseConfig.setPackageRepositories(new PackageRepositories(packageRepository));

        Configuration configuration = new Configuration();
        configuration.add(new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("value")));
        configuration.add(new ConfigurationProperty(new ConfigurationKey("key-with-no-value"), new ConfigurationValue("")));
        PackageDefinition packageDefinition = PackageDefinitionMother.create(null, "pkg2-name", configuration, packageRepository);
        cruiseConfig.savePackageDefinition(packageDefinition);

        assertThat(cruiseConfig.getPackageRepositories().size(), is(1));
        assertThat(cruiseConfig.getPackageRepositories().get(0).getId(), is(repoId));

        assertThat(cruiseConfig.getPackageRepositories().get(0).getPackages().size(), is(2));
        assertThat(cruiseConfig.getPackageRepositories().get(0).getPackages().get(0).getId(), is(existing.getId()));
        PackageDefinition createdPkgDef = cruiseConfig.getPackageRepositories().get(0).getPackages().get(1);
        assertThat(createdPkgDef.getId(), is(notNullValue()));
        assertThat(createdPkgDef.getConfiguration().getProperty("key"), is(Matchers.notNullValue()));
        assertThat(createdPkgDef.getConfiguration().getProperty("key-with-no-value"), is(nullValue()));
    }

    @Test
    public void shouldClearPackageRepositoryConfigurationsWhichAreEmptyWithNoErrors() throws Exception {
        PackageRepository packageRepository = mock(PackageRepository.class);
        when(packageRepository.isNew()).thenReturn(true);
        cruiseConfig.savePackageRepository(packageRepository);
        verify(packageRepository).clearEmptyConfigurations();
    }

    @Test
    public void shouldRemovePackageRepositoryById() throws Exception {
        PackageRepository packageRepository = PackageRepositoryMother.create(null, "repo", "pid", "1.3", new Configuration());
        cruiseConfig.savePackageRepository(packageRepository);
        cruiseConfig.removePackageRepository(packageRepository.getId());
        assertThat(cruiseConfig.getPackageRepositories().find(packageRepository.getId()), is(Matchers.nullValue()));
    }

    @Test
    public void shouldDecideIfRepoCanBeDeleted_BasedOnPackageRepositoryBeingUsedByPipelines() throws Exception {
        PackageRepository repo1 = PackageRepositoryMother.create(null, "repo1", "plugin", "1.3", new Configuration());
        PackageRepository repo2 = PackageRepositoryMother.create(null, "repo2", "plugin", "1.3", new Configuration());
        PackageDefinition packageDefinition = PackageDefinitionMother.create("package", repo2);
        repo2.addPackage(packageDefinition);
        PipelineConfig pipeline = PipelineConfigMother.pipelineConfig("pipeline");
        pipeline.addMaterialConfig(new PackageMaterialConfig(new CaseInsensitiveString("p1"), packageDefinition.getId(), packageDefinition));
        cruiseConfig.addPipeline("existing_group", pipeline);
        cruiseConfig.savePackageRepository(repo1);
        cruiseConfig.savePackageRepository(repo2);
        assertThat(cruiseConfig.canDeletePackageRepository(repo1), is(true));
        assertThat(cruiseConfig.canDeletePackageRepository(repo2), is(false));
    }

    @Test
    public void shouldDecideIfPluggableSCMMaterialCanBeDeleted_BasedOnPluggableSCMMaterialBeingUsedByPipelines() throws Exception {
        SCM scmConfigOne = SCMMother.create("scm-id-1");
        SCM scmConfigTwo = SCMMother.create("scm-id-2");
        cruiseConfig.getSCMs().addAll(Arrays.asList(scmConfigOne, scmConfigTwo));
        PipelineConfig pipeline = PipelineConfigMother.pipelineConfig("pipeline");
        pipeline.addMaterialConfig(new PluggableSCMMaterialConfig(null, scmConfigOne, null, null));
        cruiseConfig.addPipeline("existing_group", pipeline);

        assertThat(cruiseConfig.canDeletePluggableSCMMaterial(scmConfigOne), is(false));
        assertThat(cruiseConfig.canDeletePluggableSCMMaterial(scmConfigTwo), is(true));
    }
    @Test
    public void shouldReturnConfigRepos(){
        assertNotNull(cruiseConfig.getConfigRepos());
    }

    @Test
    public void shouldReturnTrueWhenHasGroup()
    {
        assertThat(cruiseConfig.hasPipelineGroup("existing_group"), is(true));
    }
    @Test
    public void shouldReturnFalseWhenDoesNotHaveGroup()
    {
        assertThat(cruiseConfig.hasPipelineGroup("non_existing_group"),is(false));
    }

    @Test
    public  void shouldGetJobConfigByName()
    {
        goConfigMother.addPipeline(cruiseConfig, "cruise", "dev", "linux-firefox");
        JobConfig job = cruiseConfig.jobConfigByName("cruise", "dev", "linux-firefox", true);
        assertNotNull(job);
    }

    @Test
    public void shouldCheckCyclicDependency() throws Exception {
        BasicCruiseConfig mainCruiseConfig = new BasicCruiseConfig(pipelines);
        ConfigReposConfig reposConfig = new ConfigReposConfig();
        GitMaterialConfig configRepo = new GitMaterialConfig("http://git");
        reposConfig.add(new ConfigRepoConfig(configRepo,"myplug"));
        mainCruiseConfig.setConfigRepos(reposConfig);

        PartialConfig partialConfig = PartialConfigMother.withPipeline("pipe2");
        cruiseConfig = new BasicCruiseConfig(mainCruiseConfig,  partialConfig);
        PipelineConfig p1 = createPipelineConfig("p1", "s1", "j1");
        PipelineConfig p2 = createPipelineConfig("p2", "s2", "j1");
        p2.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("p1"), new CaseInsensitiveString("s1")));
        PipelineConfig p3 = createPipelineConfig("p3", "s3", "j1");
        p3.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("p2"), new CaseInsensitiveString("s2")));
        p1.addMaterialConfig(new DependencyMaterialConfig(new CaseInsensitiveString("p3"), new CaseInsensitiveString("s3")));
        pipelines.addAll(Arrays.asList(p1,p2,p3));
        cruiseConfig.validate(mock(ValidationContext.class));
        List<ConfigErrors> allErrors = cruiseConfig.getAllErrors();
        assertThat((allErrors.get(0).on("base")),is("Circular dependency: p1 <- p2 <- p3 <- p1"));

    }

    private Role setupSecurityWithRole() {
        SecurityConfig securityConfig = new SecurityConfig(new LdapConfig(new GoCipher()), new PasswordFileConfig("foo"), false);
        securityConfig.adminsConfig().add(new AdminUser(new CaseInsensitiveString("root")));
        final Role ldapUsersRole = goConfigMother.createRole("ldap-users", "root");
        securityConfig.addRole(ldapUsersRole);
        cruiseConfig.server().useSecurity(securityConfig);
        return ldapUsersRole;
    }

    private StageConfig stageConfig(String pipelineName, String stageName) {
        return cruiseConfig.stageConfigByName(new CaseInsensitiveString(pipelineName), new CaseInsensitiveString(stageName));
    }

    private void setupJobWithTasks(CruiseConfig config, Task... tasks) throws Exception {
        goConfigMother.addPipeline(config, "cruise", "dev", "linux-firefox");
        JobConfig job = config.jobConfigByName("cruise", "dev", "linux-firefox", true);

        for (Task task : tasks) {
            job.addTask(task);
        }
    }

    private JobConfig jobConfig(String jobConfigName) {
        return new JobConfig(new CaseInsensitiveString(jobConfigName), null, null);
    }

    private PipelineConfig addPipeline(String pipelineName, String stageName, JobConfig... jobConfigs) {
        PipelineConfig pipeline = new PipelineConfig(new CaseInsensitiveString(pipelineName), new MaterialConfigs());
        pipeline.add(new StageConfig(new CaseInsensitiveString(stageName), new JobConfigs(jobConfigs)));
        pipelines.add(pipeline);
        return pipeline;
    }

    private void addPipelineWithStages(String pipelineName, String stageName, JobConfig... jobConfigs) {
        PipelineConfig pipeline = new PipelineConfig(new CaseInsensitiveString(pipelineName), (MaterialConfigs) null);
        pipeline.add(new StageConfig(new CaseInsensitiveString(stageName), new JobConfigs(jobConfigs)));
        pipeline.add(new StageConfig(new CaseInsensitiveString(stageName + "2"), new JobConfigs(jobConfigs)));
        pipelines.add(pipeline);
    }

    private static class MyValidatable implements Validatable {
        public Validatable innerValidatable;

        public void validate(ValidationContext validationContext) {
        }

        public ConfigErrors errors() {
            return new ConfigErrors();
        }

        public void addError(String fieldName, String message) {
        }

    }

    private static class AlwaysEqualMyValidatable extends MyValidatable {
        @Override
        public final int hashCode() {
            return 42;
        }

        @Override
        public final boolean equals(Object obj) {
            return true;
        }
    }
}


text:
#ifndef _JOBS_GUARD
#define _JOBS_GUARD

#include "input.h"

#include <stdio.h>
#include <stdbool.h>
#include <sys/types.h>

typedef struct process {
	struct process* next;

	char* argv[MAX_ARGC];

	pid_t pid;
	bool completed;
	bool stopped;

	/* used for redirecting in/out of files */
	char* in_file;
	char* out_file;

	int status;
} process;

typedef struct job {
	struct job* next;

	int id;
	parsed_line* line;

	pid_t pgid;
	int stdin, stdout, stderr;
	bool foreground;

	process* first_proc;
} job;

typedef struct jobs_state {
	job* first_job;
} jobs_state;

jobs_state* jobs_init(void);
void jobs_destroy(jobs_state* jobs);

void jobs_process(jobs_state* jobs, parsed_line* line);

void jobs_update(int pd);

#endif


text:
@php
    $pdf->setField('name', $student->getLastFirst());
    $pdf->setField('student-id', $student->student_number);
    $pdf->setField('dob', $student->getDob()->format('m/d/Y'));
    $pdf->setField('grade', $student->getGrade());
    $pdf->setField('school', $student->getSchoolName());
@endphp

@foreach ($responses->responses as $response)
    @if ($response['type'] == 'checkbox' || $response['type'] == 'radio')
        @include('iep._partials.checkbox', ['checked' => 'On'])
    @else
        @include('iep._partials.text')
    @endif
@endforeach


text:
<?php

namespace RSPhp\Framework;

/**
 * Shared methods for DbConstraints
 */
interface IDbConstraint
{
    /**
     * Virtual method to get the actual sql for the constraint
     */
    public function getSql();
} // end interface IDbConstraint


text:
/*
* PROJECT:          Atomix Development
* LICENSE:          BSD 3-Clause (LICENSE.md)
* PURPOSE:          Stind_Ref MSIL
* PROGRAMMERS:      Aman Priyadarshi (aman.eureka@gmail.com)
*/

using System.Reflection;

using Atomix.Assembler;
using Atomix.Assembler.x86;
using Atomix.CompilerExt;
using Core = Atomix.Assembler.AssemblyHelper;

namespace Atomix.IL
{
    [ILOp(ILCode.Throw)]
    public class Throw : MSIL
    {
        public Throw(Compiler Cmp)
            : base("throw", Cmp) { }

        public override void Execute(ILOpCode instr, MethodBase aMethod)
        {
            var xEndException = aMethod.FullName() + ".Error";
            if (instr.Ehc != null && instr.Ehc.HandlerOffset > instr.Position)
            {
                xEndException = ILHelper.GetLabel(aMethod, instr.Ehc.HandlerOffset);
            }
            switch (ILCompiler.CPUArchitecture)
            {
                #region _x86_
                case CPUArch.x86:
                    {
                        Core.AssemblerCode.Add(new Call(Helper.lblSetException, true));
                        Core.AssemblerCode.Add(new Mov { DestinationReg = Registers.ECX, SourceRef = "0x2" });
                        Core.AssemblerCode.Add(new Jmp { DestinationRef = xEndException });
                    }
                    break;
                #endregion
                #region _x64_
                case CPUArch.x64:
                    {

                    }
                    break;
                #endregion
                #region _ARM_
                case CPUArch.ARM:
                    {

                    }
                    break;
                #endregion
            }
            Core.vStack.Pop();
        }
    }
}


text:
<!doctype html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=1024" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <title>NodeJS Architectural Introduction</title>

    <meta name="description" content="impress.js is a presentation tool based on the power of CSS3 transforms and transitions in modern browsers and inspired by the idea behind prezi.com." />

    <link href="http://fonts.googleapis.com/css?family=Open+Sans:regular,semibold,italic,italicsemibold|PT+Sans:400,700,400italic,700italic|PT+Serif:400,700,400italic,700italic" rel="stylesheet" />

    <link href="bower_components/impress.js/css/impress-demo.css" rel="stylesheet" />
    <link href="css/impressConsole.css" rel="stylesheet" />
    <link href="css/main.css" rel="stylesheet" />

    <link rel="shortcut icon" href="favicon.png" />
    <link rel="apple-touch-icon" href="apple-touch-icon.png" />


text:
package cli

// PluginVersionOutput is a struct that is used to output project version in
// machine readable format.
type PluginVersionOutput struct {
	Name    string `json:"name" yaml:"name"`
	Version string `json:"version" yaml:"version"`
	Image   string `json:"image" yaml:"image"`
}


text:
We are glad you want to contribute to the apache2 cookbook! The first
step is the desire to improve the project.

## Quick-contribute

* Create an issue on the github [issue tracker](https://github.com/svanzoest/apache2-cookbook/issues)
* Link to your patch as a rebased git branch or pull request from the ticket

We regularly review contributions and will get back to you if we have
any suggestions or concerns.

### Branches and Commits

You should submit your patch as a git branch named after the change.

It is a best practice to have your commit message have a _summary
line_, followed by an empty line and then a brief description of
the commit. This also helps other contributors understand the
purpose of changes to the code.

Remember that not all users use Chef in the same way or on the same
operating systems as you, so it is helpful to be clear about your use
case and change so they can understand it even when it doesn't apply
to them.

### Github and Pull Requests

We don't require you to use Github, and we will even take patch diffs
attached to tickets on the issue tracker. However Github has a lot of
convenient features, such as being able to see a diff of changes
between a pull request and the main repository quickly without
downloading the branch.

## Functional and Unit Tests

This cookbook is set up to run tests under
[Test Kitchen](http://kitchen.ci/). It uses serverspec to run
integration tests after the node has been converged to verify that
the state of the node.

Test kitchen should run completely without exception using the default
[baseboxes provided by Chef](http://chef.github.io/bento/).
Because Test Kitchen creates VirtualBox machines and runs through
every configuration in the .kitchen.yml file, it may take some time for
these tests to complete.

If your changes are only for a specific recipe, run only its
configuration with Test Kitchen. If you are adding a new recipe, or
other functionality such as a LWRP or definition, please add
appropriate tests and ensure they run with Test Kitchen.

If any don't pass, investigate them before submitting your patch.

Any new feature should have unit tests included with the patch with
good code coverage to help protect it from future changes. Similarly,
patches that fix a bug or regression should have a _regression test_.
Simply put, this is a test that would fail without your patch but
passes with it. The goal is to ensure this bug doesn't regress in the
future. Consider a regular expression that doesn't match a certain
pattern that it should, so you provide a patch and a test to ensure
that the part of the code that uses this regular expression works as
expected. Later another contributor may modify this regular expression
in a way that breaks your use cases. The test you wrote will fail,
signalling to them to research your ticket and use case and accounting
for it.

If you need help writing tests, please ask on the Chef Developer's
mailing list, or the #chef-hacking IRC channel.

## Cookbook Contribution Do's and Don't's

Please do include tests for your contribution. If you need help, ask
on the
[chef-dev mailing list](http://lists.opscode.com/sympa/info/chef-dev)
or the
[#chef-hacking IRC channel](https://botbot.me/freenode/chef-hacking/).
Not all platforms that a cookbook supports may be supported by Test
Kitchen. Please provide evidence of testing your contribution if it
isn't trivial so we don't have to duplicate effort in testing. Chef
10.14+ "doc" formatted output is sufficient.

Please do indicate new platform (families) or platform versions in the
commit message, and update the relevant ticket.  If a contribution adds
new platforms or platform versions, indicate such in the body of the commit message(s).

Please do use [foodcritic](http://www.foodcritic.io/) to
lint-check the cookbook. Except FC007, it should pass all correctness
rules. FC007 is okay as long as the dependent cookbooks are *required*
for the default behavior of the cookbook, such as to support an
uncommon platform, secondary recipe, etc.

Please do ensure that your changes do not break or modify behavior for
other platforms supported by the cookbook. For example if your changes
are for Debian, make sure that they do not break on CentOS.

Please do not modify the version number in the metadata.rb, the maintainer
will select the appropriate version based on the release cycle
information above.

Please do not update the CHANGELOG.md for a new version. Not all
changes to a cookbook may be merged and released in the same versions.
We will update the CHANGELOG.md when releasing a new version of
the cookbook.


text:
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

namespace StyleCop.Analyzers.Test.CSharp7.SpecialRules
{
    using StyleCop.Analyzers.Test.SpecialRules;

    public class SA0001CSharp7UnitTests : SA0001UnitTests
    {
    }
}


text:
<!DOCTYPE html>

  <meta charset="utf-8">
  <title>3800</title>
  <link href="style/main.css" rel="stylesheet" type="text/css">
  <link rel="shortcut icon" href="favicon.ico">
  <link rel="apple-touch-icon" href="meta/apple-touch-icon.png">
  <link rel="apple-touch-startup-image" href="meta/apple-touch-startup-image-640x1096.png" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)">
  <link rel="apple-touch-startup-image" href="meta/apple-touch-startup-image-640x920.png"  media="(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 2)">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="HandheldFriendly" content="True">
  <meta name="MobileOptimized" content="320">
  <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0, maximum-scale=1, user-scalable=no, minimal-ui">

3800

0

0

Kuran müslümanları için 2048!

      Yeni Oyun

	        Devam Et
          Yeniden dene

      Nasıl oynanır: Karoları hareket ettirmek için yönlendirme tuşlarını kullan. Aynı sayıları birleştirince onlar tek karo olacaklar!

    Hazırlayan: Mehmet Onurcan KAYA


text:
using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;

public class SentenceSlotHandler : MonoBehaviour, IDropHandler
{

    public GameObject symbol
    {
        get
        {
            if (transform.childCount > 0)
            {

                return transform.GetChild(0).gameObject;

            }
            return null;
        }
    }

    public void OnDrop(PointerEventData eventData)
    {
        //If there is already a symbol in the sentence slot, and the new symbol comes from the book, it should be destoyed and replaced by the new one.
        if (symbol && DragHandler._startParent.tag == "BookSlot")
        {
            Destroy(transform.GetChild(0).gameObject);
        }

        //If there is already a symbol in the sentence slot, and the new symbol comes from another sentence slot, it should switch places with the new one.
        if (symbol && DragHandler.SymbolBeingDragged.transform.parent.tag == "SentenceSlot")
        {

            transform.GetChild(0).gameObject.transform.SetParent(DragHandler._startParent);
            DragHandler.SymbolBeingDragged.transform.SetParent(transform);

        }

        //Need a new instace of the symbol at the old slot if it was dragged from the book.
        if (DragHandler._startParent.tag == "BookSlot")
        {
            GameObject sym;
            sym = Instantiate(DragHandler.SymbolBeingDragged);
            sym.transform.SetParent(DragHandler._startParent);
            sym.transform.name = DragHandler.SymbolBeingDragged.transform.name;
            sym.transform.localScale = Vector3.one;
            //Need to set the blockraycasts flag to true again.
            sym.GetComponent<CanvasGroup>().blocksRaycasts = true;
        }
        DragHandler.SymbolBeingDragged.transform.SetParent(transform);

    }
}


text:
require 'spec_helper'

describe Etherlite::Types::Integer do
  let(:size) { 256 }
  let(:type) { described_class.new signed, size }

  context "when signed" do
    let(:signed) { true }

    describe '#encode' do
      it "propery handles signed and unsigned values" do
        expect(type.encode(1))
          .to eq('0000000000000000000000000000000000000000000000000000000000000001')

        expect(type.encode(-1))
          .to eq('ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff')
      end
    end

    describe '#decode' do
      it "propery handles raw values" do
        expect(type.decode(:c, '0000000000000000000000000000000000000000000000000000000000000001'))
          .to eq(1)

        expect(type.decode(:c, 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'))
          .to eq(-1)
      end
    end
  end

  context "when unsigned" do
    let(:signed) { false }

    describe '#encode' do
      it "propery handles unsigned values" do
        expect(type.encode(1))
          .to eq('0000000000000000000000000000000000000000000000000000000000000001')
      end

      it "fails if a negative value is given" do
        expect { type.encode(-1) }.to raise_error ArgumentError
      end
    end

    describe '#decode' do
      it "propery handles raw values" do
        expect(type.decode(:c, '0000000000000000000000000000000000000000000000000000000000000001'))
          .to eq(1)

        expect(type.decode(:c, 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'))
          .to eq(2**256 - 1) # max 256 bit integer value
      end
    end
  end
end


text:
define("dojox/mobile/bidi/ToolBarButton", [
	"dojo/_base/declare",
	"dojo/_base/lang",
	"dojo/dom-class"
], function(declare, lang, domClass){

	// module:
	//		dojox/mobile/ToolBarButton

	return declare(null, {
		buildRendering: function(){
			this.inherited(arguments);
			//dojox.mobile mirroring support
			if(!this.isLeftToRight() && this.arrow){
				var cRemove1 = (this.arrow === "left" ? "mblToolBarButtonLeftArrow" : "mblToolBarButtonRightArrow");
				var cRemove2 = (this.arrow === "left" ? "mblToolBarButtonHasLeftArrow" : "mblToolBarButtonHasRightArrow");
				var cAdd1 = (this.arrow === "left" ? "mblToolBarButtonRightArrow" : "mblToolBarButtonLeftArrow");
				var cAdd2 = (this.arrow === "left" ? "mblToolBarButtonHasRightArrow" : "mblToolBarButtonHasLeftArrow");
				domClass.remove(this.arrowNode, cRemove1);
				domClass.add(this.arrowNode, cAdd1);
				domClass.remove(this.domNode, cRemove2);
				domClass.add(this.domNode, cAdd2);
			}
		},
		_setLabelAttr: function(/*String*/text){
			// summary:
			//		Sets the button label text.
			this.inherited(arguments);
			// dojox.mobile mirroring support
			if(!this.isLeftToRight()){
				domClass.toggle(this.tableNode, "mblToolBarButtonTextRtl", text || this.arrow);
			}
		}
	});
});