/*
 * Copyright 2011 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.gradle.launcher.daemon.server.exec;

import org.gradle.launcher.daemon.server.api.DaemonCommandAction;
import org.gradle.launcher.daemon.server.api.DaemonCommandExecution;
import org.gradle.internal.deprecation.DeprecationLogger;

public class ResetDeprecationLogger implements DaemonCommandAction {
    @Override
    public void execute(DaemonCommandExecution execution) {
        DeprecationLogger.reset();
        execution.proceed();
    }
}

/*
 * Copyright 2011 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.gradle.launcher.daemon.server.exec;

import org.gradle.internal.deprecation.DeprecationLogger;
import org.gradle.launcher.daemon.server.api.DaemonCommandAction;
import org.gradle.launcher.daemon.server.api.DaemonCommandExecution;
import org.gradle.util.IncubationLogger;

public class ResetDeprecationLogger implements DaemonCommandAction {
    @Override
    public void execute(DaemonCommandExecution execution) {
        DeprecationLogger.reset();
        IncubationLogger.reset();
        execution.proceed();
    }
}

Reset incubation logger with deprecation logger


package org.junit.core;

import org.opentestalliance.TestAbortedException;

/**
 * @author Sam Brannen
 * @since 5.0
 */
public final class Assumptions {

	private Assumptions() {
		/* no-op */
	}

	public static void assumeTrue(boolean condition) {
		if (!condition) {
			throw new TestAbortedException("Assumption failed: condition is not true");
		}
	}

	public static void assumeFalse(boolean condition) {
		if (condition) {
			throw new TestAbortedException("Assumption failed: condition is not false");
		}
	}

	public static void assumingThat(boolean condition, Executable executable) {
		if (condition) {
			try {
				executable.execute();
			}
			catch (Throwable e) {
				throw new RuntimeException("Wrapped exception thrown from Executable", e);
			}
		}
	}

}

package org.junit.core;

import org.opentestalliance.TestAbortedException;

/**
 * @author Sam Brannen
 * @since 5.0
 */
public final class Assumptions {

	private Assumptions() {
		/* no-op */
	}

	public static void assumeTrue(boolean condition) {
		if (!condition) {
			throw new TestAbortedException("Assumption failed: condition is not true");
		}
	}

	public static void assumeFalse(boolean condition) {
		if (condition) {
			throw new TestAbortedException("Assumption failed: condition is not false");
		}
	}

	public static void assumingThat(boolean condition, Executable executable) {
		if (condition) {
			try {
				executable.execute();
			}
			catch (Throwable e) {
				// TODO Don't wrap Throwables such as OutOfMemoryError, etc.
				throw new RuntimeException("Wrapped exception thrown from Executable", e);
			}
		}
	}

}

Add TODO re: not wrapping exceptions like OutOfMemoryError


package net.kencochrane.raven.getsentry.connection;

import mockit.Deencapsulation;
import mockit.Injectable;
import mockit.Tested;
import org.testng.annotations.Test;

import javax.net.ssl.SSLHandshakeException;
import java.net.URL;
import java.net.URLConnection;

import static org.testng.Assert.fail;

public class GetSentryHttpsConnectionTest {
    @Tested
    private GetSentryHttpsConnection connection;
    @Injectable("projectId")
    private String projectId;
    @Injectable("privateKey")
    private String publicKey;
    @Injectable("secretKey")
    private String secretKey;

    @Test
    public void ensureHttpsConnectionToGetSentryIsSecure() throws Exception {
        connection.getConnection().connect();
    }

    @Test(expectedExceptions = SSLHandshakeException.class)
    public void ensureHttpsConnectionToGoogleComIsNotSecure() throws Exception {
        final URL url = new URL("https://www.google.com");
        Deencapsulation.setField(connection, "sentryUrl", url);

        connection.getConnection().connect();
    }

    @Test(expectedExceptions = SSLHandshakeException.class)
    public void ensureHttpsConnectionToGetSentryRequiresCustomSslFactory() throws Exception {
        final URLConnection httpsConnection = GetSentryHttpsConnection.getSentryUrl(projectId).openConnection();

        httpsConnection.connect();

        fail("Ensure that the StartCom certificate hasn't been added manually to the KeyStore or skip this test.");
    }
}

package net.kencochrane.raven.getsentry.connection;

import mockit.Deencapsulation;
import mockit.Injectable;
import mockit.Tested;
import org.testng.annotations.Test;

import javax.net.ssl.SSLHandshakeException;
import java.net.URL;
import java.net.URLConnection;

import static org.testng.Assert.fail;

public class GetSentryHttpsConnectionTest {
    @Tested
    private GetSentryHttpsConnection connection;
    @Injectable("projectId")
    private String projectId;
    @Injectable("privateKey")
    private String publicKey;
    @Injectable("secretKey")
    private String secretKey;

    @Test
    public void ensureHttpsConnectionToGetSentryIsSecure() throws Exception {
        connection.getConnection().connect();
    }

    @Test(expectedExceptions = SSLHandshakeException.class)
    public void ensureHttpsConnectionToGoogleComIsNotSecure() throws Exception {
        final URL url = new URL("https://www.google.com");
        Deencapsulation.setField(connection, "sentryUrl", url);

        connection.getConnection().connect();
    }

    /*
     * Test disabled as it will fail when the CA is available in the default KeyStore.
     * It is useful to be able to run it to ensure that it's indeed necessary to keep the entire module.
     */
    @Test(expectedExceptions = SSLHandshakeException.class, enabled = false)
    public void ensureHttpsConnectionToGetSentryRequiresCustomSslFactory() throws Exception {
        final URLConnection httpsConnection = GetSentryHttpsConnection.getSentryUrl(projectId).openConnection();

        httpsConnection.connect();

        fail("Ensure that the StartCom certificate hasn't been added manually to the KeyStore or skip this test.");
    }
}

Disable the test on ensureHttpsConnectionToGetSentryRequiresCustomSslFactory


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

public class ScrabbleTest {

  @Test
  public void scrabbleScore_returnsAScrabbleScoreForALetter_1() {
    Scrabble app = new Scrabble();
    Integer score = 1;
    assertEquals(score, app.scrabbleScore("a"));
  }

  // @Test
  // public void scrabbleScore_returnsAString_a() {
  //   Scrabble app = new Scrabble();
  //   String letter = "a";
  //   assertEquals(letter, app.scrabbleScore("a"));
  // }

  // @Test
  // public void scrabbleScore_returnsAnArrayList_aa() {
  //   Scrabble app = new Scrabble();
  //   ArrayList<String> expectedArray = new ArrayList<String>();
  //   expectedArray.add("a");
  //   expectedArray.add("a");
  //   assertEquals(expectedArray, app.scrabbleScore("aa"));
  // }

  @Test
  public void scrabbleScore_returnsTotalScore_2() {
    Scrabble app = new Scrabble();
    Integer total = 2;
    assertEquals(total, app.scrabbleScore("aa"));
  }

  @Test
    public void scrabbleScore_returnsDifferentTotalScore_5() {
      Scrabble app = new Scrabble();
      Integer total = 5;
      assertEquals(total, app.scrabbleScore("cat"));
    }

    @Test
      public void scrabbleScore_returnsTotalForTwoWords_9() {
        Scrabble app = new Scrabble();
        Integer total = 9;
        assertEquals(total, app.scrabbleScore("Cat dog"));
      }

  }

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

public class ScrabbleTest {

  @Test
  public void scrabbleScore_returnsAScrabbleScoreForALetter_1() {
    Scrabble app = new Scrabble();
    Integer score = 1;
    assertEquals(score, app.scrabbleScore("a"));
  }

  @Test
  public void scrabbleScore_returnsTotalScore_2() {
    Scrabble app = new Scrabble();
    Integer total = 2;
    assertEquals(total, app.scrabbleScore("aa"));
  }

  @Test
    public void scrabbleScore_returnsDifferentTotalScore_5() {
      Scrabble app = new Scrabble();
      Integer total = 5;
      assertEquals(total, app.scrabbleScore("cat"));
    }

    @Test
      public void scrabbleScore_returnsTotalForTwoWords_10() {
        Scrabble app = new Scrabble();
        Integer total = 10;
        assertEquals(total, app.scrabbleScore("Cat dog"));
      }

  }

Add new test with multiple words to pass, clean up comments in test.


package xyz.brassgoggledcoders.steamagerevolution.modules.storage.renderers;

import javax.annotation.Nonnull;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import xyz.brassgoggledcoders.steamagerevolution.modules.storage.tileentities.TileEntityBasicFluidTank;
import xyz.brassgoggledcoders.steamagerevolution.utils.RenderUtil;

public class TileEntityBasicFluidTankRenderer extends TileEntitySpecialRenderer<TileEntityBasicFluidTank> {

	protected static Minecraft mc = Minecraft.getMinecraft();

	@Override
	public void renderTileEntityFast(@Nonnull TileEntityBasicFluidTank tile, double x, double y, double z,
			float partialTicks, int destroyStage, float partial, net.minecraft.client.renderer.BufferBuilder buffer) {
		FluidTank tank = tile.tank;
		FluidStack liquid = tank.getFluid();

		if(liquid != null) {

			float height = ((float) liquid.amount) / (float) tank.getCapacity();

			float d = RenderUtil.FLUID_OFFSET;
			RenderUtil.renderFluidCuboid(liquid, tile.getPos(), x, y, z, d, d, d, 1d - d, height - d, 1d - d);
		}
	}
}

package xyz.brassgoggledcoders.steamagerevolution.modules.storage.renderers;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import xyz.brassgoggledcoders.steamagerevolution.modules.storage.tileentities.TileEntityBasicFluidTank;
import xyz.brassgoggledcoders.steamagerevolution.utils.RenderUtil;

public class TileEntityBasicFluidTankRenderer extends TileEntitySpecialRenderer<TileEntityBasicFluidTank> {

	protected static Minecraft mc = Minecraft.getMinecraft();

	@Override
	public void render(TileEntityBasicFluidTank tile, double x, double y, double z, float partialTicks,
			int destroyStage, float alpha) {
		FluidTank tank = tile.tank;
		FluidStack liquid = tank.getFluid();

		if(liquid != null) {

			float height = ((float) liquid.amount) / (float) tank.getCapacity();

			float d = RenderUtil.FLUID_OFFSET;
			RenderUtil.renderFluidCuboid(liquid, tile.getPos(), x, y, z, d, d, d, 1d - d, height - d, 1d - d);
		}
	}
}

Fix fluid in tank rendering


package backend;

public class ConstantValues {
	/*
	 * Certificate for the terminals should not have an expdate
	 * Certificate WITOUT expdate is a byte array that looks like:
	 * cert[0] = type (0 = smartcard, 1 = rentalterm, 2 = vehicleterm)
	 * cert[1..163] = rsapublickey (length 162bytes)
	 * cert[164...292] = Signature (128bytes)
	 */

	/* TODO: Change exp to short
	 * Certificate with expdate is a byte array that looks like:
	 * cert[0] = type (0 = smartcard, 1 = rentalterm, 2 = vehicleterm)
	 * cert[1..163] = rsapublickey (length 162bytes)
	 * cert[164..172] = expiration date of type long (8bytes)
	 * cert[173...301] = Signature (128bytes)
	 */
	public int RSAPUBLICKEYLENGTH = 162;
	public int EXP_LENGTH = 8;
	public int PK_EXP_LENGTH = 170; //162+8
	public int SIG_LENGTH = 128;

}

package backend;

public class ConstantValues {

	public int RSAPUBLICKEYLENGTH = 162;
	public int PUBMODULUS = 128; // after you strip off the first byte (which = 0)
	public int PUBEXPONENT = 3;
	public int PRIVMODULUS = 128; // after you strip off the first byte (which = 0)
	public int PRIVEXPONENT = 128; // after you strip off the first byte (which = 0)
	public int EXP_LENGTH = 8;
	public int PK_EXP_LENGTH = 170; //162+8
	public int SIG_LENGTH = 128;

}

Add modulus and exponent sizes


package ryhma57.gui;

import java.util.EnumMap;
import ryhma57.backend.BibtexReferenceField;

/**
 * This is the main class currently.
 */
public class Application {
    public static void main(String[] args) {
        Application app = new Application();
        Window window;
        window = new Window(app);

        window.setVisible(true);
        System.out.println("test");
    }

    public void generateBibTex() {
        //XXX do something here
        System.out.println("Generate the bibtext file in the backend");
    }

    public void createNewBookReference(EnumMap<BibtexReferenceField, String> fields) {
        //XXX do something here
        System.out.println("Create the book reference in the backend");

        /* Push the changes into backend */
        //Reference ref = new Reference();
        //ref = this.referenceList.addReference(ref);
        //
        //for (BibtexReferenceField field : fields.keySet()) {
        //    ref.setField(field, fields.get(field));
        //}
    }
}

package ryhma57.gui;

import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.EnumMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import ryhma57.backend.BibtexReferenceField;
import ryhma57.backend.Book;
import ryhma57.backend.Reference;

/**
 * This is the main class currently.
 */
public class Application {
    public static void main(String[] args) {
        Application app = new Application();
        Window window;
        window = new Window(app);

        window.setVisible(true);
        System.out.println("test");
    }

    public void generateBibTex() {
        PrintWriter writer;
        System.out.println("Generate the bibtext file in the backend");

        try {
            writer = new PrintWriter("database.bib", "UTF-8");
            writer.print("Implement" /*this.referenceList.toBibTex()*/);
            writer.close();

        } catch (FileNotFoundException | UnsupportedEncodingException ex) {
            Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void createNewBookReference(EnumMap<BibtexReferenceField, String> fields) {
        System.out.println("Create the book reference in the backend");

        String id = fields.get(BibtexReferenceField.ID);
        String author = fields.get(BibtexReferenceField.AUTHOR);
        String title = fields.get(BibtexReferenceField.TITLE);
        String year = fields.get(BibtexReferenceField.YEAR);
        String publisher = fields.get(BibtexReferenceField.PUBLISHER);

        Reference ref = new Book(id, author, title, year, publisher);
        //this.referenceList.addReference(ref);

        /* Alternative way to push the changes into backend */
        //Reference ref = new Reference();
        //this.referenceList.addReference(ref);
        //
        //for (BibtexReferenceField field : fields.keySet()) {
        //    ref.setField(field, fields.get(field));
        //}
    }
}

Implement most of the initial window contoller code.


package com.lukekorth.httpebble;

import android.app.Activity;
import android.os.Bundle;

public class Httpebble extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
	}
}

package com.lukekorth.httpebble;

import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;

public class Httpebble extends FragmentActivity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
	}

	@Override
	protected void onResume() {
		// Check that Google Play services is available
		int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

		// If Google Play services is unavailable
		if (ConnectionResult.SUCCESS != resultCode) {
			// Get the error dialog from Google Play services
			Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(resultCode, this, 0);

			// If Google Play services can provide an error dialog
			if (errorDialog != null) {
				// Create a new DialogFragment for the error dialog
				ErrorDialogFragment errorFragment = new ErrorDialogFragment();

				// Set the dialog in the DialogFragment
				errorFragment.setDialog(errorDialog);

				// Show the error dialog in the DialogFragment
				errorFragment.show(getSupportFragmentManager(), "Location Updates");
			}
		}
	}

	// Define a DialogFragment that displays the error dialog
	public static class ErrorDialogFragment extends DialogFragment {

		// Global field to contain the error dialog
		private Dialog mDialog;

		// Default constructor. Sets the dialog field to null
		public ErrorDialogFragment() {
			super();
			mDialog = null;
		}

		// Set the dialog to display
		public void setDialog(Dialog dialog) {
			mDialog = dialog;
		}

		// Return a Dialog to the DialogFragment.
		@Override
		public Dialog onCreateDialog(Bundle savedInstanceState) {
			return mDialog;
		}
	}
}

Add check for Google Play services


import java.util.Map.Entry;

public class DegreeOfSeperation {

	public static void main(String[] args) {
		// TODO Implement
	}

}

class Vertex {

	public boolean isAdjacent() {
		// TODO Implement
		return false;
	}

	public Entry<Vertex, Integer>[] getNeighbors() {
		// TODO Implement
		return null;
	}
}

import java.util.Map.Entry;

public class DegreeOfSeperation {

	public static void main(String[] args) {
		// TODO Implement
	}

}

class Vertex {
	public static String INPUT_FILENAME = "facebook_combined.txt";
	private int id;
	private boolean initialized;
	private boolean visited;
	private double costFromStart;
	private Entry<Vertex, Integer>[] neighbors;

	public Vertex(int id) {
		this.id = id;
		this.initialized = false;
		this.visited = false;
		this.costFromStart = Double.POSITIVE_INFINITY;
	}

	public double getCostFromStart() {
		return costFromStart;
	}

	public boolean setCostFromStartIfSmaller(double newCost) {
		boolean setSuccess = false;
		if(newCost < costFromStart) {
			costFromStart = newCost;
		}
		return setSuccess;
	}

	public Entry<Vertex, Integer>[] getNeighbors() {
		// TODO Implement
		return null;
	}

}

Implement constructor, getCostFromStart(), setCostFromStartIfSmaller in Vertex


package dk.cmol.arduinorgb_controller;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class FaderFragment extends Fragment {

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_fader,
				container, false);

		return rootView;
	}
}

package dk.cmol.arduinorgb_controller;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.NumberPicker;

public class FaderFragment extends Fragment {

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_fader, container,
				false);

		// Add min and max to number picker elements
		NumberPicker[] nps = {(NumberPicker) rootView.findViewById(R.id.numberPicker1),
				(NumberPicker) rootView.findViewById(R.id.numberPicker2),
				(NumberPicker) rootView.findViewById(R.id.numberPicker3)
		};

		for (int i = 0; i < nps.length; i++) {
			nps[i].setMaxValue(255);
			nps[i].setMinValue(0);
		}

		return rootView;
	}
}

Add value information to the numberPickers


// Copyright © 2011 - 2013 Forerunner Games
package com.forerunnergames.tools;

/**
 *
 * @author Aaron Mahan
 */
public class Point2D
{
  public Point2D (final int x, final int y)
  {
    x_ = x;
    y_ = y;
  }

  @Override
  public boolean equals (Object object)
  {
    if (this == object)
    {
      return true;
    }

    boolean equals = false;

    if (object != null && object.getClass() == getClass())
    {
      Point2D point2D = (Point2D) object;

      if (x_ == point2D.getX() && y_ == point2D.getY())
      {
        equals = true;
      }
    }

    return equals;
  }

  public int getX()
  {
    return x_;
  }

  public int getY()
  {
    return y_;
  }

  @Override
  public int hashCode()
  {
    int hash = 7;

    hash = 47 * hash + x_;
    hash = 47 * hash + y_;

    return hash;
  }

  @Override
  public String toString()
  {
    return String.format (getClass().getSimpleName() + ": (x: %1$6s, y: %2$6s)",
                          getX(), getY());
  }

  private final int x_;
  private final int y_;
}

// Copyright © 2011 - 2013 Forerunner Games
package com.forerunnergames.tools;

/**
 *
 * @author Aaron Mahan
 */
public class Point2D
{
  public Point2D (final int x, final int y)
  {
    x_ = x;
    y_ = y;
  }

  @Override
  public boolean equals (Object object)
  {
    if (this == object)
    {
      return true;
    }

    boolean equals = false;

    if (object != null && object.getClass() == getClass())
    {
      Point2D point = (Point2D) object;

      if (x_ == point.getX() && y_ == point.getY())
      {
        equals = true;
      }
    }

    return equals;
  }

  public int getX()
  {
    return x_;
  }

  public int getY()
  {
    return y_;
  }

  @Override
  public int hashCode()
  {
    int hash = 7;

    hash = 47 * hash + x_;
    hash = 47 * hash + y_;

    return hash;
  }

  @Override
  public String toString()
  {
    return String.format (getClass().getSimpleName() + ": (x: %1$6s, y: %2$6s)",
                          getX(), getY());
  }

  private final int x_;
  private final int y_;
}

Make local variable name more concise.


/*
 * Copyright 2014 Taylor Caldwell
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.rithms.riot.constant;

public enum GameMode {
	ARAM("ARAM"),
	ASCENSION("Ascension"),
	CLASSIC("Classic"),
	FIRSTBLOOD("Snowdown Showdown"),
	KINGPORO("King Poro"),
	ODIN("Dominion/Crystal Scar"),
	ONEFORALL("One for All"),
	TUTORIAL("Tutorial");

	private String name;

	GameMode(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	@Override
	public String toString() {
		return getName();
	}
}

/*
 * Copyright 2014 Taylor Caldwell
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.rithms.riot.constant;

public enum GameMode {
	ARAM("ARAM"),
	ASCENSION("Ascension"),
	CLASSIC("Classic"),
	FIRSTBLOOD("Snowdown Showdown"),
	KINGPORO("King Poro"),
	ODIN("Dominion/Crystal Scar"),
	ONEFORALL("One for All"),
	SIEGE("Nexus Siege"),
	TUTORIAL("Tutorial");

	private String name;

	GameMode(String name) {
		this.name = name;
	}

	public String getName() {
		return name;
	}

	@Override
	public String toString() {
		return getName();
	}
}

Add Nexus Siege game mode


package com.algorithms.tree;

public class BST<Key extends Comparable<Key>, Value> {
}

package com.algorithms.tree;

public class BST<Key extends Comparable<Key>, Value> {

    private Node root;

    private class Node {
        private Key key;
        private Value val;
        private Node left, right;
        public Node(Key key, Value val) {
            this.key = key;
            this.val = val;
        }
    }

    public void put(Key key, Value val) {}

    public Value get(Key key) {}

    public void delete(Key key) {}

    public Iterable<Key> iterator() {}
}

Create Node class and other skeleton code


public class Node {

  Node next = null;
  int data;

  public Node(int d) {
    data = d;
  }

  // Appends data to the end of the linked list
  private void appendToTail(int data) {

    Node curr = this;
    Node end = new Node(data);

    while(curr.next != null) {
      curr = curr.next;
    }

    curr.next = end;
  }

  // Iterate through the linked list
  private void traverseList() {
  }

  // Delete the node from linked list n with data
  private void delete(Node n, int data) {
  }

  // Example
  public static void main(String[] args) {

    Node head = new Node(10);

  }

}

public class Node {

  Node next = null;
  int data;

  public Node(int d) {
    data = d;
  }

  // Appends data to the end of the linked list
  private void appendToTail(int data) {

    Node curr = this;
    Node end = new Node(data);

    while(curr.next != null) {
      curr = curr.next;
    }

    curr.next = end;
  }

  // Iterate through the linked list
  private void traverseList() {
  }

  // Delete the node from linked list n with data
  private void delete(Node n, int data) {
  }

  // Find the median element in the linked list
  private void findMedianElement() {
  }

  // Example
  public static void main(String[] args) {

    Node head = new Node(10);

  }

}

Add median element function declaration.


package com.max.soundboard;

import java.io.File;
import java.util.ArrayList;

class FileManager {
    private FileManager() {}

    public static ArrayList<String> getSubdirectories(String path) {
        ArrayList<String> subdirectories = new ArrayList<>();
        File[] files = new File(path).listFiles();

        if (files != null) {
            for (File file : files) {
                if (file.isDirectory()) {
                    subdirectories.add(file.getName());
                }
            }
        }
        return subdirectories;
    }

    public static ArrayList<String> getSoundFileNames(String path) {
        ArrayList<String> soundFiles = new ArrayList<>();

        for (File file : new File(path).listFiles()) {
            if (file.isFile() && isSoundFileName(file.getName())) {
                soundFiles.add(file.getName());
            }
        }
        return soundFiles;
    }

    private static boolean isSoundFileName(String filename) {
        return filename.endsWith(".mp3") || filename.endsWith(".wav");
    }
}

package com.max.soundboard;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

class FileManager {
    private FileManager() {
    }

    public static List<String> getSubdirectories(String path) {
        List<String> subdirectories = new ArrayList<>();

        for (File file : new File(path).listFiles()) {
            if (file.isDirectory()) {
                subdirectories.add(file.getName());
            }
        }
        return subdirectories;
    }

    public static List<String> getSoundFileNames(String path) {
        List<String> soundFiles = new ArrayList<>();

        for (File file : new File(path).listFiles()) {
            if (file.isFile() && isSoundFileName(file.getName())) {
                soundFiles.add(file.getName());
            }
        }
        return soundFiles;
    }

    private static boolean isSoundFileName(String filename) {
        return filename.endsWith(".mp3") || filename.endsWith(".wav");
    }
}

Use generic types in Filemanager


package uk.co.craigwarren.gascalc.model;

public class Cylinder {

	private double volume;
	private double pressure;
	private Gas gas;
	private double ambientTemperatureKelvin;

	public double getVolume() {
		return volume;
	}
	public void setVolume(double volume) {
		this.volume = volume;
	}
	public double getPressure() {
		return pressure;
	}
	public void setPressure(double pressure) {
		this.pressure = pressure;
	}
	public Gas getGas() {
		return gas;
	}
	public void setGas(Gas gas) {
		this.gas = gas;
	}

	public Cylinder(double volume, double pressure, Gas gas) {
		this.volume = volume;
		this.pressure = pressure;
		this.gas = gas;
	}

	public Cylinder(double volume, double pressure) {
		this(volume, pressure, Gas.air());
	}

	public Cylinder(double volume) {
		this(volume, 0);
	}
    public double getAmbientTemperatureKelvin() {
        return ambientTemperatureKelvin;
    }
    public void setAmbientTemperatureKelvin(double ambientTemperatureKelvin) {
        this.ambientTemperatureKelvin = ambientTemperatureKelvin;
    }

}

package uk.co.craigwarren.gascalc.model;

public class Cylinder {

	private double volume;
	private double pressure;
	private Gas gas;
	private double ambientTemperatureKelvin;

	public double getVolume() {
		return volume;
	}
	public void setVolume(double volume) {
		this.volume = volume;
	}
	public double getPressure() {
		return pressure;
	}
	public void setPressure(double pressure) {
		this.pressure = pressure;
	}
	public Gas getGas() {
		return gas;
	}
	public void setGas(Gas gas) {
		this.gas = gas;
	}

	public Cylinder(double volume, double pressure, Gas gas, double tempKelvin) {
	    if(tempKelvin == 0.0) {
	        throw new IllegalArgumentException("Cannot mix gas at absolute zero");
	    }
		this.volume = volume;
		this.pressure = pressure;
		this.gas = gas;
		this.ambientTemperatureKelvin = tempKelvin;
	}

	public Cylinder(double volume, double pressure) {
		this(volume, pressure, Gas.air(), 20.0);
	}

	public Cylinder(double volume) {
		this(volume, 0);
	}
    public double getAmbientTemperatureKelvin() {
        return ambientTemperatureKelvin;
    }
    public void setAmbientTemperatureKelvin(double ambientTemperatureKelvin) {
        this.ambientTemperatureKelvin = ambientTemperatureKelvin;
    }

}

Add temperature to cylinder constructor


package bj.pranie.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 * Created by noon on 13.10.16.
 */
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.csrf().disable();
        http.authorizeRequests()
                .antMatchers("/", "/week", "/lastweek", "/wm", "/user/registration", "/user/restore", "/images/*", "/js/*").permitAll()
                .anyRequest().authenticated()
                .and()
                .formLogin()
                .loginPage("/")
                .permitAll()
                .and()
                .logout()
                .permitAll();
    }

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication()
                .withUser("admin").password("admin").roles("USER");
    }
}

package bj.pranie.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 * Created by noon on 13.10.16.
 */
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.csrf().disable();
        http.authorizeRequests()
                .antMatchers("/", "/week" ,"/week/*", "/wm/*", "/user/registration", "/user/restore", "/images/*", "/js/*").permitAll()
                .anyRequest().authenticated()
                .and()
                .formLogin()
                .loginPage("/")
                .permitAll()
                .and()
                .logout()
                .permitAll();
    }

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication()
                .withUser("admin").password("admin").roles("USER");
    }
}

Update permited path to all users.


/*
# Licensed Materials - Property of IBM
# Copyright IBM Corp. 2015
 */
/**
 * Low-level graph builder.
 * {@link com.ibm.streamsx.topology.builder.GraphBuilder} provides a layer
 * on top of {@code com.ibm.streams.flow.OperatorGraph}
 * to define a directed graph of connected operators.
 * Where possible information is maintained in
 * the graph declared by {@code OperatorGraph}
 * but this class maintains additional information
 * in order to allow SPL generation (through JSON).
 *
 */
package com.ibm.streamsx.topology.builder;

/*
# Licensed Materials - Property of IBM
# Copyright IBM Corp. 2015
 */
/**
 * Low-level graph builder.
 * {@link com.ibm.streamsx.topology.builder.GraphBuilder} provides a layer
 * on top of {@code com.ibm.streams.flow.OperatorGraph}
 * to define a directed graph of connected operators.
 * Where possible information is maintained in
 * the graph declared by {@code OperatorGraph}
 * but this class maintains additional information
 * in order to allow SPL generation (through JSON).
 *

 * Note that the classes and methods in this
 * package is subject to change including the resultant
 * JSON object describing the graph.
 *

 * The intended API for the Java Application API is the
 * functional API described by the package
 * {@code com.ibm.streamsx.topology}.
 *

 */
package com.ibm.streamsx.topology.builder;

Mark the builder api as subject to change


package com.vav.CTCI.Common;

/**
 * Created by Vaibhav on 5/6/2017.
 */
public class CTCICommon {
    public static void main(String arg[]){

    }
}

package com.vav.CTCI.Common;

/**
 * Created by Vaibhav on 5/6/2017.
 */
public class CTCICommon {
    public static void main(String arg[]){
        //No Code
    }
}

Test commit from new machine


package org.yukung.tutorial.junit;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;

import java.util.Date;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class DateTest {

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testDate() {
		assertThat(new Date(), is(IsDate.dateOf(2012, 1, 12)));
	}

}

package org.yukung.tutorial.junit;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import static org.yukung.tutorial.junit.IsDate.*;

import java.util.Date;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class DateTest {

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testDate() {
		assertThat(new Date(), is(dateOf(2012, 1, 12)));
	}

}

Fix test case using static import to 'IsDate' class.


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.wpi.first.wpilibj.templates.commands;

/**
 *
 * @author TJ2
 */
public class KickerAuto extends CommandBase {
    double timeout;
    double power = 1;
    public KickerAuto(double time) {
        super("kicker auto");
        requires(kicker);
        timeout = time;
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
    }

    // Called just before this Command runs the first time
    protected void initialize() {
        setTimeout(timeout);
    }

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
        kicker.KickerOpenLoop(power);
    }

    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        return isTimedOut();
    }

    // Called once after isFinished returns true
    protected void end() {
        kicker.KickerOpenLoop(0);
    }

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
    }
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.wpi.first.wpilibj.templates.commands;

import edu.wpi.first.wpilibj.templates.Wiring;

/**
 *
 * @author TJ2
 */
public class KickerAuto extends CommandBase {
    double timeout;
    double power = Wiring.kickerPower;
    public KickerAuto(double time) {
        super("kicker auto");
        requires(kicker);
        timeout = time;
        // Use requires() here to declare subsystem dependencies
        // eg. requires(chassis);
    }

    // Called just before this Command runs the first time
    protected void initialize() {
        setTimeout(timeout);
    }

    // Called repeatedly when this Command is scheduled to run
    protected void execute() {
        kicker.KickerOpenLoop(power);
    }

    // Make this return true when this Command no longer needs to run execute()
    protected boolean isFinished() {
        return isTimedOut();
    }

    // Called once after isFinished returns true
    protected void end() {
        kicker.KickerOpenLoop(0);
    }

    // Called when another command which requires one or more of the same
    // subsystems is scheduled to run
    protected void interrupted() {
    }
}

Add wiring constant for kicker power


package xyz.openmodloader.server;

import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.text.ITextComponent;
import xyz.openmodloader.OpenModLoader;
import xyz.openmodloader.SidedHandler;
import xyz.openmodloader.launcher.strippable.Side;

public class OMLServerHandler implements SidedHandler {
    private final MinecraftServer server;

    public OMLServerHandler(MinecraftServer server) {
        this.server = server;
    }

    @Override
    public void onInitialize() {

    }

    @Override
    public Side getSide() {
        return Side.SERVER;
    }

    @Override
    public void openSnackbar(ITextComponent component) {
        OpenModLoader.INSTANCE.getChannel()
                .send("snackbar")
                .set("component", component)
                .toAll();
    }

    @Override
    public EntityPlayerSP getClientPlayer() {
        return null;
    }

    @Override
    public void handleOnMainThread(Runnable runnable) {
        getServer().addScheduledTask(runnable);
    }

    @Override
    public MinecraftServer getServer() {
        return server;
    }
}

package xyz.openmodloader.server;

import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.text.ITextComponent;
import xyz.openmodloader.OpenModLoader;
import xyz.openmodloader.SidedHandler;
import xyz.openmodloader.event.impl.MessageEvent;
import xyz.openmodloader.launcher.strippable.Side;

public class OMLServerHandler implements SidedHandler {
    private final MinecraftServer server;

    public OMLServerHandler(MinecraftServer server) {
        this.server = server;
    }

    @Override
    public void onInitialize() {

    }

    @Override
    public Side getSide() {
        return Side.SERVER;
    }

    @Override
    public void openSnackbar(ITextComponent component) {
        component = MessageEvent.Snackbar.handle(component, Side.SERVER);
        if (component == null) {
            return;
        }
        OpenModLoader.INSTANCE.getChannel()
                .send("snackbar")
                .set("component", component)
                .toAll();
    }

    @Override
    public EntityPlayerSP getClientPlayer() {
        return null;
    }

    @Override
    public void handleOnMainThread(Runnable runnable) {
        getServer().addScheduledTask(runnable);
    }

    @Override
    public MinecraftServer getServer() {
        return server;
    }
}

Add snackbar event on server


package shouty;

import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class CoordinateTest {

    @Test
    public void itCalculatesTheDistanceFromAnotherCoordinateAlongXAxis() {
        Coordinate a = new Coordinate(0, 0);
        Coordinate b = new Coordinate(1000, 0);
        assertEquals(1000, a.distanceFrom(b));
    }
}

package shouty;

import org.junit.Test;
import static org.junit.Assert.assertEquals;

public class CoordinateTest {

    @Test
    public void it_calculates_the_distance_from_another_coordinate_along_x_axis() {
        Coordinate a = new Coordinate(0, 0);
        Coordinate b = new Coordinate(1000, 0);
        assertEquals(1000, a.distanceFrom(b));
    }
}

Improve legibility of JUnit test


package net.shadowfacts.foodies.item;

import cpw.mods.fml.common.registry.GameRegistry;

/**
 * Helper class for registering items.
 * @author shadowfacts
 */
public class FItems {
	// Foods
	public static Food toast;
	public static Food tomato;
	public static Food beefPattie;
	public static Food hamburger;

	public static void preInit() {
		// Create Items
		toast = new Food(3, 0.3f).setUnlocalizedName("foodToast").setTextureName("foodToast");
		tomato = new Food(1, 0.1f).setUnlocalizedName("fruitTomato").setTextureName("fruitTomato");
		beefPattie = new Food(7, 0.4f).setUnlocalizedName("foodBeefPattie").setTextureName("foodBeefPattie");
		hamburger = new Food(5, 0.7f).setUnlocalizedName("foodHamburger").setTextureName("foodHamburger");

		// Register items
		GameRegistry.registerItem(toast, "foodToast");
		GameRegistry.registerItem(tomato, "fruitTomato");
		GameRegistry.registerItem(beefPattie, "foodBeefPattie");
		GameRegistry.registerItem(hamburger, "foodHamburger");
	}

	public static void load() {

	}

	public static void postInit() {

	}
}

package net.shadowfacts.foodies.item;

import cpw.mods.fml.common.registry.GameRegistry;

/**
 * Helper class for registering items.
 * @author shadowfacts
 */
public class FItems {
	// Foods
	public static Food toast;
	public static Food tomato;
	public static Food beefPattie;
	public static Food hamburger;

	public static void preInit() {
		// Create Items
		toast = new Food(3, 0.3f).setUnlocalizedName("foodToast").setTextureName("foodToast");
		tomato = new Food(1, 0.1f).setUnlocalizedName("fruitTomato").setTextureName("fruitTomato");
		beefPattie = new Food(3, 0.6f).setUnlocalizedName("foodBeefPattie").setTextureName("foodBeefPattie");
		hamburger = new Food(5, 0.7f).setUnlocalizedName("foodHamburger").setTextureName("foodHamburger");

		// Register items
		GameRegistry.registerItem(toast, "foodToast");
		GameRegistry.registerItem(tomato, "fruitTomato");
		GameRegistry.registerItem(beefPattie, "foodBeefPattie");
		GameRegistry.registerItem(hamburger, "foodHamburger");
	}

	public static void load() {

	}

	public static void postInit() {

	}
}

Change hunger values for beef pattie


/**
 * Copyright 2011 The PlayN Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package playn.android;

import android.graphics.Typeface;

import java.util.HashMap;
import java.util.Map;

import playn.core.AbstractFont;

class AndroidFont extends AbstractFont {

  public final Typeface typeface;

  public AndroidFont(String name, Style style, float size) {
    super(name, style, size);
    this.typeface = Typeface.create(name, TO_ANDROID_STYLE.get(style));
  }

  protected static final Map<Style,Integer> TO_ANDROID_STYLE = new HashMap<Style,Integer>();
  static {
    TO_ANDROID_STYLE.put(Style.PLAIN,       Typeface.NORMAL);
    TO_ANDROID_STYLE.put(Style.BOLD,        Typeface.BOLD);
    TO_ANDROID_STYLE.put(Style.ITALIC,      Typeface.ITALIC);
    TO_ANDROID_STYLE.put(Style.BOLD_ITALIC, Typeface.BOLD_ITALIC);
  }
}

/**
 * Copyright 2011 The PlayN Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package playn.android;

import android.graphics.Typeface;

import java.util.EnumMap;
import java.util.Map;

import playn.core.AbstractFont;

class AndroidFont extends AbstractFont {

  public final Typeface typeface;

  public AndroidFont(String name, Style style, float size) {
    super(name, style, size);
    this.typeface = Typeface.create(name, TO_ANDROID_STYLE.get(style));
  }

  protected static final Map<Style,Integer> TO_ANDROID_STYLE =
    new EnumMap<Style,Integer>(Style.class);
  static {
    TO_ANDROID_STYLE.put(Style.PLAIN,       Typeface.NORMAL);
    TO_ANDROID_STYLE.put(Style.BOLD,        Typeface.BOLD);
    TO_ANDROID_STYLE.put(Style.ITALIC,      Typeface.ITALIC);
    TO_ANDROID_STYLE.put(Style.BOLD_ITALIC, Typeface.BOLD_ITALIC);
  }
}

Use an EnumMap rather than a HashMap.


/*
 * Copyright 2016-2020 Chronicle Software
 *
 * https://chronicle.software
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.openhft.chronicle.core.values;

public interface LongValue {
    long getValue();

    void setValue(long value);

    long getVolatileValue();

    void setVolatileValue(long value);

    void setOrderedValue(long value);

    long addValue(long delta);

    long addAtomicValue(long delta);

    boolean compareAndSwapValue(long expected, long value);

    default void setMaxValue(long value) {
        for (; ; ) {
            long pos = getVolatileValue();
            if (pos >= value)
                break;
            if (compareAndSwapValue(pos, value))
                break;
        }
    }

    default void setMinValue(long value) {
        for (; ; ) {
            long pos = getVolatileValue();
            if (pos <= value)
                break;
            if (compareAndSwapValue(pos, value))
                break;
        }
    }
}

/*
 * Copyright 2016-2020 Chronicle Software
 *
 * https://chronicle.software
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.openhft.chronicle.core.values;

public interface LongValue {
    long getValue();

    void setValue(long value);

    long getVolatileValue();

    default long getVolatileValue(long closedValue) {
        return getVolatileValue();
    }

    void setVolatileValue(long value);

    void setOrderedValue(long value);

    long addValue(long delta);

    long addAtomicValue(long delta);

    boolean compareAndSwapValue(long expected, long value);

    default void setMaxValue(long value) {
        for (; ; ) {
            long pos = getVolatileValue();
            if (pos >= value)
                break;
            if (compareAndSwapValue(pos, value))
                break;
        }
    }

    default void setMinValue(long value) {
        for (; ; ) {
            long pos = getVolatileValue();
            if (pos <= value)
                break;
            if (compareAndSwapValue(pos, value))
                break;
        }
    }
}

Support accessing a long value after being closed for graceful shutdown


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package epfc.cours3449;

/**
 *
 * @author jedepaepe
 */
public class lesson11 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
    }

}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package epfc.cours3449;

/**
 *
 * @author jedepaepe
 */
public class lesson11 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        System.out.println("Hello Git");
    }

}

Change code, add "hello git"


import individu.Assassin;
import individu.Barbare;

import java.rmi.RemoteException;

import controle.Console;

/**
 * Test de la Console avec un Element qui s'ajoute a l'Arene (apres lancement Arene et IHM). A lancer en plusieurs exemplaires.
 */
public class TestConsole {

	/**
	 * @param args
	 * @throws RemoteException
	 */
	public static void main(String[] args) throws RemoteException {
		Assassin ass1 = new Assassin();
		//Random r = new Random();
		new Console(ass1, 40, 40);

		Barbare bar1 = new Barbare();
		//Random r = new Random();
		new Console(bar1, 70, 70);
	}

}

import individu.Assassin;
import individu.Barbare;

import java.rmi.RemoteException;
import java.util.Random;

import serveur.Arene;

import controle.Console;

/**
 * Test de la Console avec un Element qui s'ajoute a l'Arene (apres lancement Arene et IHM). A lancer en plusieurs exemplaires.
 */
public class TestConsole {

	/**
	 * @param args
	 * @throws RemoteException
	 */
	public static void main(String[] args) throws RemoteException {
		Assassin ass1 = new Assassin();
		new Console(ass1, new Random().nextInt(Arene.tailleAreneX), new Random().nextInt(Arene.tailleAreneY));

		Barbare bar1 = new Barbare();
		// new Console(bar1, new Random().nextInt(Arene.tailleAreneX), new Random().nextInt(Arene.tailleAreneY));
	}

}

Test Console utilise maintenant les valeur de la taille d'arène et ne fait plus piper de barbares


package org.jvirtanen.nassau.util;

public class SystemClock implements Clock {

    public static final SystemClock INSTANCE = new SystemClock();

    private SystemClock() {
    }

    @Override
    public long currentTimeMillis() {
        return System.currentTimeMillis();
    }

}

package org.jvirtanen.nassau.util;

/**
 * The system time source.
 */
public class SystemClock implements Clock {

    public static final SystemClock INSTANCE = new SystemClock();

    private SystemClock() {
    }

    @Override
    public long currentTimeMillis() {
        return System.currentTimeMillis();
    }

}

Add documentation for system clock


package bool;

import java.util.List;

public class Evaluator implements Visitor<Boolean, List<String>> {
    @Override
    public Boolean visit(Var node, List<String> vars) {
        return vars.contains(node.token.getValue());
    }

    @Override
    public Boolean visit(And node, List<String> vars) {
        return evaluate(node.left, vars) && evaluate(node.right, vars);
    }

    @Override
    public Boolean visit(Or node, List<String> vars) {
        return evaluate(node.left, vars) || evaluate(node.right, vars);
    }

    @Override
    public Boolean visit(Not node, List<String> vars) {
        return !evaluate(node.operand, vars);
    }

    private Boolean evaluate(Node node, List<String> vars) {
        return node.accept(this, vars);
    }
}

package bool;

import java.util.Collection;

public class Evaluator implements Visitor<Boolean, Collection<String>> {
    @Override
    public Boolean visit(Var node, Collection<String> vars) {
        return vars.contains(node.token.getValue());
    }

    @Override
    public Boolean visit(And node, Collection<String> vars) {
        return evaluate(node.left, vars) && evaluate(node.right, vars);
    }

    @Override
    public Boolean visit(Or node, Collection<String> vars) {
        return evaluate(node.left, vars) || evaluate(node.right, vars);
    }

    @Override
    public Boolean visit(Not node, Collection<String> vars) {
        return !evaluate(node.operand, vars);
    }

    private Boolean evaluate(Node node, Collection<String> vars) {
        return node.accept(this, vars);
    }
}

Use collection instead of List


package bool;

import org.junit.Test;

import java.io.IOException;

import static org.junit.Assert.assertEquals;

public class LexerTest {
    @Test
    public void test_lex() throws IOException {
        Lexer lexer = new Lexer("foo && bar");
        assertEquals(Parser.TOKEN_VAR, lexer.yylex());
        assertEquals("foo", lexer.yytext());

        assertEquals(Parser.TOKEN_AND, lexer.yylex());
        assertEquals("&&", lexer.yytext());

        assertEquals(Parser.TOKEN_VAR, lexer.yylex());
        assertEquals("bar", lexer.yytext());
    }
}

package bool;

import org.junit.Test;

import java.io.IOException;

import static org.junit.Assert.assertEquals;

public class LexerTest {
    @Test
    public void test_simple_lex() throws IOException {
        Lexer lexer = new Lexer("foo && bar");
        assertEquals(Parser.TOKEN_VAR, lexer.yylex());
        assertEquals("foo", lexer.yytext());

        assertEquals(Parser.TOKEN_AND, lexer.yylex());
        assertEquals("&&", lexer.yytext());

        assertEquals(Parser.TOKEN_VAR, lexer.yylex());
        assertEquals("bar", lexer.yytext());
    }

    @Test
    public void test_lex_or() throws IOException {
        Lexer lexer = new Lexer("foo || bar");
        assertEquals(Parser.TOKEN_VAR, lexer.yylex());
        assertEquals("foo", lexer.yytext());

        assertEquals(Parser.TOKEN_OR, lexer.yylex());
        assertEquals("||", lexer.yytext());

        assertEquals(Parser.TOKEN_VAR, lexer.yylex());
        assertEquals("bar", lexer.yytext());
    }

    @Test
    public void test_less_simple_lex() throws IOException {
    	Lexer lexer = new Lexer("a && b && (!c || !d)");
        assertEquals(Parser.TOKEN_VAR, lexer.yylex());
        assertEquals("a", lexer.yytext());

        assertEquals(Parser.TOKEN_AND, lexer.yylex());
        assertEquals("&&", lexer.yytext());

        assertEquals(Parser.TOKEN_VAR, lexer.yylex());
        assertEquals("b", lexer.yytext());

        assertEquals(Parser.TOKEN_AND, lexer.yylex());
        assertEquals("&&", lexer.yytext());

        assertEquals(Parser.TOKEN_LPAREN, lexer.yylex());
        assertEquals("(", lexer.yytext());

        assertEquals(Parser.TOKEN_NOT, lexer.yylex());
        assertEquals("!", lexer.yytext());

        assertEquals(Parser.TOKEN_VAR, lexer.yylex());
        assertEquals("c", lexer.yytext());

        assertEquals(Parser.TOKEN_OR, lexer.yylex());
        assertEquals("||", lexer.yytext());

        assertEquals(Parser.TOKEN_NOT, lexer.yylex());
        assertEquals("!", lexer.yytext());

        assertEquals(Parser.TOKEN_VAR, lexer.yylex());
        assertEquals("d", lexer.yytext());

        assertEquals(Parser.TOKEN_RPAREN, lexer.yylex());
        assertEquals(")", lexer.yytext());
    }

}

Add a lexer test for all operators


package org.cryptonit.cloud.interfaces;

import org.bouncycastle.asn1.x500.X500Name;

public interface IdentityStore {
    public String newIdentity(String domain, String keyId, X500Name subject) throws Exception;
}

package org.cryptonit.cloud.interfaces;

import javax.security.cert.X509Certificate;
import org.bouncycastle.asn1.x500.X500Name;

public interface IdentityStore {

    public String newIdentity(String domain, String keyId, X500Name subject) throws Exception;

    public boolean setCertificate(String domain, String identityId, X509Certificate certificate) throws Exception;
}

Add interface to set certificate value


/*
 * Copyright 2012 Artur Dryomov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package ru.ming13.gambit;

import android.app.Application;
import com.bugsense.trace.BugSenseHandler;
import ru.ming13.gambit.local.DbProvider;

public class GambitApplication extends Application
{
	@Override
	public void onCreate() {
		super.onCreate();

		setUpDatabase();
		setUpBugsense();
	}

	private void setUpDatabase() {
		DbProvider.getInstance(this);
	}

	private void setUpBugsense() {
		if (BuildConfig.DEBUG) {
			return;
		}

		BugSenseHandler.initAndStartSession(this, getBugsenseProjectKey());
	}

	private String getBugsenseProjectKey() {
		return getString(R.string.key_bugsense_project);
	}
}

/*
 * Copyright 2012 Artur Dryomov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package ru.ming13.gambit;

import android.app.Application;
import com.bugsense.trace.BugSenseHandler;

public class GambitApplication extends Application
{
	@Override
	public void onCreate() {
		super.onCreate();

		setUpBugsense();
	}

	private void setUpBugsense() {
		if (BuildConfig.DEBUG) {
			return;
		}

		BugSenseHandler.initAndStartSession(this, getBugsenseProjectKey());
	}

	private String getBugsenseProjectKey() {
		return getString(R.string.key_bugsense_project);
	}
}

Remove database initialization via application.


package org.ingrahamrobotics.robottables.util;

public class Platform {

    private static final Object LOCK = new Object();
    private static boolean ready = false;
    private static boolean onRobot = false;

    public static boolean onRobot() {
        synchronized (LOCK) {
            if (!ready) {
                init();
            }
        }
        return onRobot;
    }

    private static void init() {
        try {
            Class.forName("java.util.ArrayList");
            onRobot = false;
        } catch (ClassNotFoundException ex) {
            onRobot = true;
        }
//        // One of these (or a combination thereof) will let me figure out if we're running on the robot
//        System.getProperty("java.version");
//        System.getProperty("java.vendor");
//        System.getProperty("java.compiler");
//        System.getProperty("os.name");
//        onRobot = false;

        ready = true;
    }
}

package org.ingrahamrobotics.robottables.util;

public class Platform {

    private static final Object LOCK = new Object();
    private static boolean ready = false;
    private static boolean onRobot = false;

    public static boolean onRobot() {
        synchronized (LOCK) {
            if (!ready) {
                init();
            }
        }
        return onRobot;
    }

    private static void init() {
        onRobot = false;
//        // One of these (or a combination thereof) will let me figure out if we're running on the robot
//        System.getProperty("java.version");
//        System.getProperty("java.vendor");
//        System.getProperty("java.compiler");
//        System.getProperty("os.name");
//        onRobot = false;
        ready = true;
    }
}

Remove temporary code to tell if networktables is running on the robot, as it no longer works with the RoboRIO.


package de.dbaelz.secludedness.level;

public class Player {
	private int mPositionX;
	private int mPositionY;

	public Player(int positionX, int positionY) {
		mPositionX = positionX;
		mPositionY = positionY;
	}

	public int getPositionX() {
		return mPositionX;
	}

	public void setPositionX(int positionX) {
		this.mPositionX = positionX;
	}

	public int getPositionY() {
		return mPositionY;
	}

	public void setPositionY(int positionY) {
		this.mPositionY = positionY;
	}

}

package de.dbaelz.secludedness.level;

public class Player {
	private final int mStartPositionX;
	private final int mStartPositionY;
	private int mPositionX;
	private int mPositionY;

	public Player(int positionX, int positionY) {
		mStartPositionX = positionX;
		mStartPositionY = positionY;

		mPositionX = positionX;
		mPositionY = positionY;
	}

	public int getPositionX() {
		return mPositionX;
	}

	public void setPositionX(int positionX) {
		this.mPositionX = positionX;
	}

	public void changeXPositionBy(int value) {
		this.mPositionX += value;
	}

	public int getPositionY() {
		return mPositionY;
	}

	public void setPositionY(int positionY) {
		this.mPositionY = positionY;
	}

	public void changeYPositionBy(int value) {
		this.mPositionY += value;
	}

	public void resetToStart() {
		mPositionX = mStartPositionX;
		mPositionY = mStartPositionY;
	}
}

Save fix start position and add method to reset player on this position


package com.royalrangers.utils;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.royalrangers.bean.ResponseResult;
import lombok.Getter;

public class ResponseBuilder {

    public static ResponseResult success() {
        return new ResponseResult(true, new EmptyJsonResponse());
    }

    public static ResponseResult success(Object data) {
        return new ResponseResult(true, data);
    }

    public static ResponseResult success(String message) {
        return new ResponseResult(true, new ResponseMessage(message));
    }

    public static ResponseResult fail() {
        return new ResponseResult(false, new EmptyJsonResponse());
    }

    public static ResponseResult fail(String message) {
        return new ResponseResult(false, new ResponseMessage(message));
    }

    @JsonSerialize
    private static class EmptyJsonResponse { }

    @Getter
    @JsonSerialize
    private static class ResponseMessage{
        private String message;

        ResponseMessage (String message) {
            this.message = message;
        }
    }
}

package com.royalrangers.utils;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.royalrangers.bean.ResponseResult;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

public class ResponseBuilder {

    public static ResponseResult success() {
        return new ResponseResult(true, new EmptyJsonResponse());
    }

    public static ResponseResult success(Object data) {
        return new ResponseResult(true, data);
    }

    public static ResponseResult success(String message) {
        return new ResponseResult(true, new ResponseMessage(message));
    }
    public static ResponseResult success(String key, String value) {
        Map<String, String> data = new HashMap<>();
        data.put(key, value);
        return new ResponseResult(true, data);
    }

    public static ResponseResult fail() {
        return new ResponseResult(false, new EmptyJsonResponse());
    }

    public static ResponseResult fail(String message) {
        return new ResponseResult(false, new ResponseMessage(message));
    }

    @JsonSerialize
    private static class EmptyJsonResponse { }

    @Getter
    @JsonSerialize
    private static class ResponseMessage{
        private String message;

        ResponseMessage (String message) {
            this.message = message;
        }
    }
}

Add success method for custom message in data.


/*
 * VowlData.java
 *
 */

package de.uni_stuttgart.vis.vowl.owl2vowl.model;

import de.uni_stuttgart.vis.vowl.owl2vowl.model.nodes.classes.AbstractClass;

import java.util.HashSet;
import java.util.Set;

/**
 * Contains all data WebVOWL needs.
 */
public class VowlData {

	private Set<AbstractClass> classes = new HashSet<>();

	public void addClass(AbstractClass vowlClass) {
		classes.add(vowlClass);
	}

}

/*
 * VowlData.java
 *
 */

package de.uni_stuttgart.vis.vowl.owl2vowl.model;

import de.uni_stuttgart.vis.vowl.owl2vowl.model.nodes.AbstractNode;
import de.uni_stuttgart.vis.vowl.owl2vowl.model.nodes.classes.AbstractClass;

import org.semanticweb.owlapi.model.IRI;

import java.util.HashMap;

/**
 * Contains all data WebVOWL needs.
 */
public class VowlData {

	private HashMap<IRI, AbstractClass> classMap = new HashMap<>();

	public void addClass(AbstractClass vowlClass) {
		classMap.put(vowlClass.getIri(), vowlClass);
	}

	public AbstractNode getNodeForIri(IRI iri) {
		if (classMap.containsKey(iri)) {
			return classMap.get(iri);
		} else {
			throw new IllegalStateException("Can't find node for passed iri: " + iri);
		}
	}
}

Add method for requesting nodes by iri


import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class TrieExample {
  public static void main(String[] args) {

    // Open the data file
    Scanner scf = null;
    try {
      scf = new Scanner(new File("./data/peter_piper.txt"));
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }

    TrieST<Integer> st = new TrieST<Integer>();

    // Read file's next line
    while (scf.hasNextLine()) {
      Scanner scl = new Scanner(scf.nextLine());

      // Read line's next word
      int i = 0;
      while (scl.hasNext()) {
        String key = scl.next();
        st.put(key, i);
        i++;
      }
    }

    // print results
    for (String key : st.keys()) {
      System.out.println(key + " " + st.get(key));
    }

    System.out.println();

    System.out.println("Keys with prefix \"pi\"");
    for (String key : st.keysWithPrefix("pi")) {
      System.out.println(key);
    }
    System.out.println();
  }
}

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class TrieExample {
  public static void main(String[] args) {

    // Open the data file
    Scanner scf = null;
    try {
      scf = new Scanner(new File("./data/peter_piper.txt"));
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }

    TrieST<Integer> st = new TrieST<Integer>();

    // Read file's next line
    while (scf.hasNextLine()) {
      Scanner scl = new Scanner(scf.nextLine());

      // Read line's next word
      int i = 0;
      while (scl.hasNext()) {
        String key = scl.next();
        st.put(key, i);
        i++;
      }
    }

    // print results
    System.out.println("Symbol table:");
    for (String key : st.keys()) {
      System.out.println("* " + key + " " + st.get(key));
    }

    System.out.println();

    System.out.println("Keys with prefix \"pi\":");
    for (String key : st.keysWithPrefix("pi")) {
      System.out.println("* " + key);
    }
    System.out.println();

    System.out.println("Longest prefix of \"peckleton\":");
    System.out.println("* " + st.longestPrefixOf("peckleton"));
    System.out.println();
  }
}

Add usage example for longestPRefixOf() method


package app;

import app.action.Action;
import app.action.ActionEvent;
import app.action.Drop;
import app.shipper.BasicShipper;

import java.util.ArrayList;
import java.util.List;
import java.util.Observable;
import java.util.Observer;

/**
 * Created by Benjamin on 03/02/2016.
 */
public class ShippingTrackerObserver implements Observer {
	List<String> achievedDeliveries = new ArrayList<>();

	@Override
	public void update(Observable o, Object arg) {
		ActionEvent actionEvent = (ActionEvent) arg;

		if(o instanceof Drop && actionEvent.equals(ActionEvent.ENDED)) {

			Drop action = (Drop) o;
			System.out.printf("\n\t[DELIVERY DONE] %s has performed package %s\n", action.getTarget().getName(), action.getTarget().getPack());

		}
	}
}

package app;

import app.action.Action;
import app.action.ActionEvent;
import app.action.Drop;
import app.shipper.BasicShipper;

import java.util.ArrayList;
import java.util.List;
import java.util.Observable;
import java.util.Observer;

/**
 * Created by Benjamin on 03/02/2016.
 */
public class ShippingTrackerObserver implements Observer {
	List<String> achievedDeliveries = new ArrayList<>();

	@Override
	public void update(Observable o, Object arg) {
		ActionEvent actionEvent = (ActionEvent) arg;

		if(o instanceof Drop && actionEvent.equals(ActionEvent.ENDED)) {

			Drop action = (Drop) o;
			System.out.printf("\n\t[DELIVERY DONE] %s has performed package %s\n", action.getTarget().getName(), action.getTarget().getPack());
			achievedDeliveries.add(action.getTarget().getPack());
		}
	}

	public void sendToServer(String packageDelivered) {
		// TODO: 03/02/2016 do http call
	}
}

Update new spy shipping tracker observer


package de.fred4jupiter.plaincamel;

import org.apache.camel.CamelContext;
import org.apache.camel.main.Main;

/**
 * Created by michael on 12.09.2017.
 */
public class Application extends org.apache.camel.main.Main {

	public Application() throws Exception {
		super();
		getOrCreateCamelContext().addRoutes(new MyRouteBuilder());
	}

	@Override
	protected CamelContext createContext() {
		CamelContext camelContext = CamelContextCreator.createCamelContext();
		return camelContext;
	}

	public static void main(String[] args) throws Exception {

		Application application = new Application();
		application.run();

	}
}

package de.fred4jupiter.plaincamel;

import org.apache.camel.CamelContext;
import org.apache.camel.main.Main;

/**
 * Created by michael on 12.09.2017.
 */
public class Application extends Main {

    public Application() throws Exception {
        super();
        getOrCreateCamelContext().addRoutes(new MyRouteBuilder());
    }

    @Override
    protected CamelContext createContext() {
        CamelContext camelContext = CamelContextCreator.createCamelContext();
        return camelContext;
    }

    public static void main(String[] args) throws Exception {
        Application application = new Application();
        application.run();
    }
}

Use org.apache.camel.main.Main for sample application


package structures.data.actions.library;

import structures.data.DataAction;
import structures.data.actions.params.CheckboxParam;
import structures.data.actions.params.DoubleParam;
import structures.data.actions.params.StringParam;

public class SetGlobalVariable extends DataAction {

	public SetGlobalVariable(){
		init(new StringParam("EditVariableKey"),
				new DoubleParam("EditVariableValue"),
				new CheckboxParam("RelativeVariable?"));
	}

	@Override
	public String getTitle() {
		return "SetGlobalVariable";
	}

	@Override
	public String getDescription() {
		if((boolean) get("RelativeVariable?").getValue()){
			return String.format("change %s by %.2f", get("EditVariableKey").getValue(), get("EditVariableValue").getValue());
		}
		else{
			return String.format("make %s equal %.2f", get("EditVariableKey").getValue(), get("EditVariableValue").getValue());
		}
	}

	@Override
	protected String getSyntax() {
		return "library.set_variable('%s', %f, %b);";
	}

}

package structures.data.actions.library;

import structures.data.DataAction;
import structures.data.actions.params.CheckboxParam;
import structures.data.actions.params.GroovyParam;
import structures.data.actions.params.StringParam;

public class SetGlobalVariable extends DataAction {

	public SetGlobalVariable(){
		init(new StringParam("Variable Name"),
				new GroovyParam("Value"),
				new CheckboxParam("Relative"));
	}

	@Override
	public String getTitle() {
		return "Set Global Var";
	}

	@Override
	public String getDescription() {
		if ((boolean) get("Relative").getValue()) {
			return String.format("Change global '%s' by %s", get("Variable Name").getValue(), get("Value").getValue());
		}
		else{
			return String.format("Set global '%s' to %s", get("Variable Name").getValue(), get("Value").getValue());
		}
	}

	@Override
	public String compileSyntax() {
		if ((boolean) get("Relative").getValue()) {
			return String.format("globals.%s = globals.%s + %s;\n", get("Variable Name").getValue(), get("Variable Name").getValue(), get("Value").getValue());
		} else {
			return String.format("globals.%s = %s;\n", get("Variable Name").getValue(), get("Value").getValue());
		}

	}

	@Override
	protected String getSyntax() {
		return null;
	}

}

Set Global Variable action created


/*
 * Copyright 2016 Exorath
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.exorath.service.treasurehunt.test;

import com.exorath.service.treasurehunt.Treasure;
import org.junit.Assert;
import org.junit.Test;

public class TreasureTest {
	private static final String TREASURE_TEST_ID_1 = "598782lklsjflasf;09";

	@Test
	public void testTreasureIdEqualsConstructorId() {
		Treasure treasure = new Treasure(TREASURE_TEST_ID_1);
		Assert.assertEquals(treasure.getId(), TREASURE_TEST_ID_1);

		treasure = new Treasure("");
		Assert.assertEquals(treasure.getId(), TREASURE_TEST_ID_1);
	}
}

/*
 * Copyright 2016 Exorath
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.exorath.service.treasurehunt.test;

import com.exorath.service.treasurehunt.Treasure;
import org.junit.Assert;
import org.junit.Test;

public class TreasureTest {
	private static final String TREASURE_TEST_ID_1 = "598782lklsjflasf;09";
	private static final String TREASURE_TEST_ID_2 = "";

	@Test
	public void testTreasureIdEqualsConstructorId() {
		Treasure treasure = new Treasure(TREASURE_TEST_ID_1);
		Assert.assertEquals(treasure.getId(), TREASURE_TEST_ID_1);

		treasure = new Treasure(TREASURE_TEST_ID_2);
		Assert.assertEquals(treasure.getId(), TREASURE_TEST_ID_2);
	}
}

Fix 2nd treasureId in test


package edu.kit.iks.Cryptographics;

import edu.kit.iks.CryptograhicsLib.AbstractController;

public class StartController extends AbstractController {
	private PopoverView _popoverView;

	private TimelineView _timelineView;

	private WelcomeView _welcomeView;

	public void presentPopoverAction(AbstractVisualizationInfo visualizationInfo) {

	}

	public void dismissPopoverAction() {

	}

	public void startVisualizationAction(AbstractVisualizationInfo visualizationInfo) {

	}

	private void _loadAllVisualizationInfos() {

	}
}

package edu.kit.iks.Cryptographics;

import java.util.List;
import edu.kit.iks.CryptograhicsLib.AbstractController;

public class StartController extends AbstractController {
	private PopoverView _popoverView;

	private TimelineView _timelineView;

	private WelcomeView _welcomeView;

	private List<AbstractVisualizationInfo> visualizationInfos;

	public void presentPopoverAction(AbstractVisualizationInfo visualizationInfo) {

	}

	public void dismissPopoverAction() {

	}

	public void startVisualizationAction(AbstractVisualizationInfo visualizationInfo) {

	}

	private void _loadAllVisualizationInfos() {

	}
}

Add list of visualization infos.


package org.example.shelf.auth;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
            .antMatchers("/secure/**", "/users/**").hasRole("USER")
            .and()
            .httpBasic();
    }

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication().withUser("testuser").password("password").roles("USER");
    }
}

package org.example.shelf.auth;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
            .antMatchers("/secure/**", "/users/**").hasRole("USER")
            .anyRequest().permitAll()
            .and()
            .httpBasic();
    }

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
        auth.inMemoryAuthentication().withUser("testuser").password("password").roles("USER");
    }
}

Fix javascript access in spring security


package com.github.aureliano.verbum_domini.helper;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;

public final class UrlHelper {

	private UrlHelper() {
		super();
	}

	public static String join(Object...tokens) {
		return "/" + StringUtils.join(tokens, '/');
	}

	public static String buildWebAppUrl(ServletRequest request, String path) {
		String contextPath = ((HttpServletRequest) request).getContextPath();
		return join(contextPath.substring(1), path);
	}

	public static String buildWebAppUrl(String path) {
		return buildWebAppUrl(WebHelper.getRequest(), path);
	}
}

package com.github.aureliano.verbum_domini.helper;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;

public final class UrlHelper {

	private UrlHelper() {
		super();
	}

	public static String join(Object...tokens) {
		return "/" + StringUtils.join(tokens, '/');
	}

	public static String buildWebAppUrl(ServletRequest request, String path) {
		String contextPath = ((HttpServletRequest) request).getContextPath();
		if (contextPath.startsWith("/")) {
			contextPath = contextPath.substring(1);
		}
		return join(contextPath, path);
	}

	public static String buildWebAppUrl(String path) {
		return buildWebAppUrl(WebHelper.getRequest(), path);
	}
}

Build URL with server context path.


package com.bungleton.yarrgs;

import java.io.File;
import java.util.List;

public class cp
{
    public boolean recursive;

    @Positional(0) @Unmatched
    public List<File> sourceFiles;

    @Positional(-1)
    public File destination;
}

package com.bungleton.yarrgs;

import java.io.File;
import java.util.List;

public class cp
{
    @Usage("Should subdirectories of directores in sourceFiles be copied")
    public boolean recursive;

    @Usage("Files and directories to be copied") @Positional(0) @Unmatched
    public List<File> sourceFiles;

    @Usage("Directory to which sourceFiles should be copied") @Positional(-1)
    public File destination;

    public static void main (String[] args)
    {
        cp cp = Yarrgs.parseInMain(cp.class, args);
        System.out.println("Recursive: " + cp.recursive);
        System.out.println("Source files: " + cp.sourceFiles);
        System.out.println("Dest: " + cp.destination);
    }
}

Add some usage and a main to let me use this as an example


package com.galvarez.ttw.model.components;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.artemis.Component;
import com.artemis.Entity;
import com.galvarez.ttw.model.map.MapPosition;

public final class AIControlled extends Component {

  /** All neighboring empires. */
  public final Set<Entity> neighbors = new HashSet<>();

  public List<MapPosition> estimatedTiles;

  public int estimationTurn;

  public int lastMove;

  public MapPosition lastPosition;

  public AIControlled() {
  }

}

package com.galvarez.ttw.model.components;

import com.artemis.Component;
import com.galvarez.ttw.model.map.MapPosition;

public final class AIControlled extends Component {

  public int lastMove;

  public MapPosition lastPosition;

  public AIControlled() {
  }

}

Remove unused variables from AI component.


package dgcj;

public class DgcjProblem {
	private static boolean single;

	public void testLocally() {
		testLocally(1, 6, 1);
	}

	public void testLocally(int nodes) {
		LocalTesting.run(this.getClass().getSimpleName(), nodes);
	}

	public void testLocally(int nodesFrom, int nodesTo, int step) {
		for (int i = nodesFrom; i < nodesTo; i += step) {
			testLocally(i);
		}
	}

	public static boolean single() {
		return single;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof String[]) {
			String[] args = (String[]) obj;
			if (args.length == 1 && args[0].equals("0")) {
				testLocally();
				System.exit(0);
			}
			if (args.length == 1 && args[0].equals("1")) {
				single = true;
			}
			return false;
		}
		LocalTesting.log(obj.toString());
		return false;
	}

	// To avoid a warning
	@Override
	public int hashCode() {
		return super.hashCode();
	}
}

package dgcj;

public class DgcjProblem {
	private static boolean single;

	public void testLocally() {
		testLocally(1, 6, 1);
		testLocally(7);
		testLocally(100);
	}

	public void testLocally(int nodes) {
		LocalTesting.run(this.getClass().getSimpleName(), nodes);
	}

	public void testLocally(int nodesFrom, int nodesTo, int step) {
		for (int i = nodesFrom; i < nodesTo; i += step) {
			testLocally(i);
		}
	}

	public static boolean single() {
		return single;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof String[]) {
			String[] args = (String[]) obj;
			if (args.length == 1 && args[0].equals("0")) {
				testLocally();
				System.exit(0);
			}
			if (args.length == 1 && args[0].equals("1")) {
				single = true;
			}
			return false;
		}
		LocalTesting.log(obj.toString());
		return false;
	}

	// To avoid a warning
	@Override
	public int hashCode() {
		return super.hashCode();
	}
}

Add default testing with 7 and 100 nodes


package com.jakewharton.trakt.enumerations;

import java.util.HashMap;
import java.util.Map;
import com.jakewharton.trakt.TraktEnumeration;

public enum Rating implements TraktEnumeration {
    Love("love"),
    Hate("hate"),
    Unrate("unrate");

    private final String value;

    private Rating(String value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return this.value;
    }

    private static final Map<String, Rating> STRING_MAPPING = new HashMap<String, Rating>();

    static {
        for (Rating via : Rating.values()) {
            STRING_MAPPING.put(via.toString().toUpperCase(), via);
        }
    }

    public static Rating fromValue(String value) {
        return STRING_MAPPING.get(value.toUpperCase());
    }
}

package com.jakewharton.trakt.enumerations;

import java.util.HashMap;
import java.util.Map;
import com.jakewharton.trakt.TraktEnumeration;

public enum Rating implements TraktEnumeration {
    WeakSauce("1"),
    Terrible("2"),
    Bad("3"),
    Poor("4"),
    Meh("5"),
    Fair("6"),
    Good("7"),
    Great("8"),
    Superb("9"),
    TotallyNinja("10"),
    Unrate("0");

    private final String value;

    private Rating(String value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return this.value;
    }

    private static final Map<String, Rating> STRING_MAPPING = new HashMap<String, Rating>();

    static {
        for (Rating via : Rating.values()) {
            STRING_MAPPING.put(via.toString().toUpperCase(), via);
        }
    }

    public static Rating fromValue(String value) {
        return STRING_MAPPING.get(value.toUpperCase());
    }
}

Use new rating values. It is recommended to always send the new ones, so removed Love and Hate and modified Unrate to be 0 instead of 'unrate'.


package editor;

import utility.Observer;
import xml.Element;

import javax.swing.*;

/**
 * The ElementTreeView controls the section of the GUI that displays the tree
 * representation of an XML element tree.
 */
public class ElementTreeView extends JPanel implements Observer {
    private JTree tree;
    private Element root;

    /**
     * Create the tree view and associate it with a particular model (root of
     * the XML element tree)
     * @param root The root element of the XML element tree.
     */
    public ElementTreeView(Element root) {
        root.registerObserver(this);
        this.root = root;

        tree = new JTree();
        add(tree);

        setVisible(false);
    }

    /**
     * When the associated element tree root has changed, change the view
     */
    public void notifyObserver() {
        if (root != null) {
            // TODO: Change the tree
            System.out.println("[DEBUG] root has changed");
            setVisible(true);
        }
    }
}

package editor;

import utility.Observer;
import xml.Element;

import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;

/**
 * The ElementTreeView controls the section of the GUI that displays the tree
 * representation of an XML element tree.
 */
public class ElementTreeView extends JPanel implements Observer {
    private JTree tree;
    private Element root;
    private DefaultMutableTreeNode treeNode;
    private DefaultTreeModel model;

    /**
     * Create the tree view and associate it with a particular model (root of
     * the XML element tree)
     * @param root The root element of the XML element tree.
     */
    public ElementTreeView(Element root) {
        root.registerObserver(this);
        this.root = root;

        treeNode = new DefaultMutableTreeNode();
        tree = new JTree(treeNode);
        model = (DefaultTreeModel) tree.getModel();
        add(tree);

        setVisible(false);
    }

    /**
     * When the associated element tree root has changed, change the view
     */
    public void notifyObserver() {
        if (root != null) {
            // TODO: Change the tree
            treeNode.setUserObject("DEBUG_ROOT");
            model.nodeChanged(treeNode);
            System.out.println("[DEBUG] root has changed");
            setVisible(true);
        }
    }
}

Add the setting of root element label


package org.texastorque.texastorque20145.subsystem;

import edu.wpi.first.wpilibj.Solenoid;
import edu.wpi.first.wpilibj.Victor;
import org.texastorque.texastorque20145.constants.Constants;
import org.texastorque.texastorque20145.torquelib.Motor;

public class Drivebase extends Subsystem {

    private Motor left;
    private Motor right;
    private Solenoid shifter;

    public Drivebase()
    {
        left = new Motor(new Victor(Constants.leftDrivePort.getInt()), false);
        right = new Motor(new Victor(Constants.rightDrivePort.getInt()), true);
        shifter = new Solenoid(Constants.shifterPort.getInt());
    }

    public void update() {
        if (outputEnabled)
        {
            left.set(input.getLeftSpeed());
            right.set(input.getRightSpeed());
            shifter.set(input.getGear());
        }
    }

}

Remove unneeded method that shouldnt have been committed


package com.jeffreydiaz.search;

/**
 * Implementation of the classic Linear Search algorithm.
 * @author Jeffrey Diaz
 */
public class LinearSearch {

	/**
	 * Linearly search for item elem in array items.
	 * @param items an array of Item objects who've implemented the equals method.
	 * @param elem item to search array items for.
	 * @return true if elem is found within items.
	 */
	public static <Item> boolean search(Item[] items, Item elem)
	{
		for (int i = 0; i < items.length; ++i) {
			if (items[i].equals(elem)){
				return true;
			}
		}
		return false;
	}

	/**
	 * Linearly search for elem in Iterable items.
	 * @param items Collection implementing the Iterable interface.
	 * @param elem Item to search collection for.
	 * @return true if elem is found within items.
	 */
	public static <Item> boolean search(Iterable<Item> items, Item elem)
	{
		for (Item item : items) {
			if (item.equals(elem)) {
				return true;
			}
		}
		return false;
	}
}

package com.jeffreydiaz.search;

/**
 * Implementation of the classic Linear Search algorithm.
 * Complexity: ~N
 * @author Jeffrey Diaz
 */
public class LinearSearch {

	/**
	 * Linearly search for item elem in array items.
	 * @param items an array of Item objects who've implemented the equals method.
	 * @param elem item to search array items for.
	 * @return true if elem is found within items.
	 */
	public static <Item> boolean search(Item[] items, Item elem)
	{
		for (int i = 0; i < items.length; ++i) {
			if (items[i].equals(elem)){
				return true;
			}
		}
		return false;
	}

	/**
	 * Linearly search for elem in Iterable items.
	 * @param items Collection implementing the Iterable interface.
	 * @param elem Item to search collection for.
	 * @return true if elem is found within items.
	 */
	public static <Item> boolean search(Iterable<Item> items, Item elem)
	{
		for (Item item : items) {
			if (item.equals(elem)) {
				return true;
			}
		}
		return false;
	}
}

Add complexity in tilde notation.


package test.integration;

import static org.junit.jupiter.api.Assertions.assertEquals;

import com.github.sormuras.bach.Project;
import com.github.sormuras.bach.project.JavaStyle;
import com.github.sormuras.bach.project.Libraries;
import java.lang.module.ModuleDescriptor.Version;
import org.junit.jupiter.api.Test;

class ProjectTests {

  @Test
  void defaults() {
    var project = new Project();
    assertEquals("noname", project.name().name());
    assertEquals(Version.parse("0"), project.version().version());
    assertEquals(Libraries.of(), project.libraries());
    assertEquals(JavaStyle.FREE, project.spaces().style());
  }
}

package test.integration;

import static org.junit.jupiter.api.Assertions.assertEquals;

import com.github.sormuras.bach.Project;
import com.github.sormuras.bach.project.JavaStyle;
import com.github.sormuras.bach.project.Libraries;
import java.lang.module.ModuleDescriptor;
import org.junit.jupiter.api.Test;

class ProjectTests {

  @Test
  void defaults() {
    var project = new Project();
    assertEquals("noname", project.name().name());
    assertEquals(ModuleDescriptor.Version.parse("0"), project.version().version());
    assertEquals(Libraries.of(), project.libraries());
    assertEquals(JavaStyle.FREE, project.spaces().style());
  }
}

Optimize readability of expected value


package com.twu.biblioteca;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import static org.junit.Assert.assertEquals;

/**
 * Created by watsonarw on 16/04/15.
 */
public class MainMenuTest {

    private ByteArrayOutputStream outStream = new ByteArrayOutputStream();

    @Before
    public void setupStreams() {
        System.setOut(new PrintStream(outStream));
    }

    @After
    public void tearDown() {
        System.setOut(null);
    }

    @Test
    public void testDisplayMainMenu() {
        String expected = "------ Main Menu ------\n" +
                          "Select an option below:\n" +
                          " 1 | List Books\n";
        MainMenu menu = new MainMenu();
        menu.show();
        assertEquals(expected, outStream.toString());
    }
}

package com.twu.biblioteca;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import static org.junit.Assert.assertEquals;

/**
 * Created by watsonarw on 16/04/15.
 */
public class MainMenuTest {

    private ByteArrayOutputStream outStream = new ByteArrayOutputStream();

    @Before
    public void setupStreams() {
        System.setOut(new PrintStream(outStream));
    }

    @After
    public void tearDown() {
        System.setOut(null);
        System.setIn(System.in);
    }

    @Test
    public void testDisplayMainMenu() {
        String expected = "------ Main Menu ------\n" +
                          "Select an option below:\n" +
                          " 1 | List Books\n";
        MainMenu menu = new MainMenu();
        menu.show();
        assertEquals(expected, outStream.toString());
    }

    @Test
    public void testSelectionOneShowsListOfBooks() {
        String expected = BibliotecaApp.getLibrary().getBookList();
        MainMenu menu = new MainMenu();
        nextInputAs("1\n");
        menu.handleResponse();

        assertEquals(expected, outStream.toString());
    }

    private void nextInputAs(String s) {
        ByteArrayInputStream inStream = new ByteArrayInputStream(s.getBytes());
        System.setIn(inStream);
    }
}

Add test for handling input (not working)


/**
 * Copyright 2012 The PlayN Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package playn.ios;

import playn.core.Keyboard;
import playn.core.PlayN;
import playn.core.util.Callback;

class IOSKeyboard implements Keyboard
{
  @Override
  public void setListener(Listener listener) {
    PlayN.log().warn("Keyboard not (currently) supported on iOS.");
  }

  @Override
  public boolean hasHardwareKeyboard() {
    return false;
  }

  @Override
  public void getText(TextType textType, String label, String initVal, Callback<String> callback) {
    callback.onFailure(new UnsupportedOperationException("Not yet implemented."));
  }
}

/**
 * Copyright 2012 The PlayN Authors
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package playn.ios;

import playn.core.Keyboard;
import playn.core.PlayN;
import playn.core.util.Callback;

class IOSKeyboard implements Keyboard
{
  @Override
  public void setListener(Listener listener) {
    PlayN.log().warn("iOS cannot generate keyboard events. Use Keyboard.getText() instead");
  }

  @Override
  public boolean hasHardwareKeyboard() {
    return false;
  }

  @Override
  public void getText(TextType textType, String label, String initVal, Callback<String> callback) {
    callback.onFailure(new UnsupportedOperationException("Not yet implemented."));
  }
}

Update setListener() warning for iOS.