package codechicken.lib.render;

import codechicken.lib.colour.ColourRGBA;

public class ColourMultiplier implements CCRenderState.IVertexOperation
{
    private static ColourMultiplier instance = new ColourMultiplier(-1);

    public static ColourMultiplier instance(int colour) {
        instance.colour = colour;
        return instance;
    }

    public static final int operationIndex = CCRenderState.registerOperation();
    public int colour;

    public ColourMultiplier(int colour) {
        this.colour = colour;
    }

    @Override
    public boolean load() {
        if(colour == -1)
            return false;

        CCRenderState.pipeline.addDependency(CCRenderState.colourAttrib);
        return true;
    }

    @Override
    public void operate() {
        CCRenderState.setColour(ColourRGBA.multiply(CCRenderState.colour, colour));
    }

    @Override
    public int operationID() {
        return operationIndex;
    }
}

package codechicken.lib.render;

import codechicken.lib.colour.ColourRGBA;

public class ColourMultiplier implements CCRenderState.IVertexOperation
{
    private static ColourMultiplier instance = new ColourMultiplier(-1);

    public static ColourMultiplier instance(int colour) {
        instance.colour = colour;
        return instance;
    }

    public static final int operationIndex = CCRenderState.registerOperation();
    public int colour;

    public ColourMultiplier(int colour) {
        this.colour = colour;
    }

    @Override
    public boolean load() {
        if(colour == -1) {
            CCRenderState.setColour(-1);
            return false;
        }

        CCRenderState.pipeline.addDependency(CCRenderState.colourAttrib);
        return true;
    }

    @Override
    public void operate() {
        CCRenderState.setColour(ColourRGBA.multiply(CCRenderState.colour, colour));
    }

    @Override
    public int operationID() {
        return operationIndex;
    }
}

Fix colour not being set when a colour multiplier with white was added


import java.time.format.*;
import java.time.*;
import java.io.*;
import java.nio.file.*;
import java.net.*;
import java.util.*;

public class DumpOpenFiles {
    public static void main(String[] args) throws Exception {
        String url = "http://localhost:" + parsePort() + "/dump";
        System.out.println("Sending request to " + url);
        try (BufferedReader response = new BufferedReader(new InputStreamReader(new URL(url).openStream()))) {
            String line = null;
            while ((line = response.readLine()) != null) {
                System.out.println(line);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static String parsePort() throws Exception {
        if (new File("port.txt").isFile()) {
            return Files.readAllLines(new File("port.txt").toPath()).get(0).trim();
        } else {
            System.err.println("Port not found, skip");
            System.exit(0);
            return "";
        }
    }
}

import java.time.format.*;
import java.time.*;
import java.io.*;
import java.nio.file.*;
import java.net.*;
import java.util.*;

public class DumpOpenFiles {
    public static void main(String[] args) throws Exception {
        String url = "http://localhost:" + parsePort() + "/dump";
        System.out.println("Sending request to " + url);
        try (BufferedReader response = new BufferedReader(new InputStreamReader(new URL(url).openStream()))) {
            String line = null;
            while ((line = response.readLine()) != null) {
                System.out.println(line);
            }
        }
    }

    private static String parsePort() throws Exception {
        if (new File("port.txt").isFile()) {
            return Files.readAllLines(new File("port.txt").toPath()).get(0).trim();
        } else {
            System.err.println("Port not found, skip");
            System.exit(0);
            return "";
        }
    }
}

Revert "Not fail the build if file-leak-detector server down"


package com.africastalking;

import retrofit2.Call;
import retrofit2.http.*;

interface IVoice {

    @FormUrlEncoded
    @POST("call")
    Call<String> call(@Field("username") String username, @Field("to") String to,
                      @Field("from") String from);

    @GET("/queueStatus")
    Call<String> queueStatus(@Query("username") String username, @Query("phoneNumbers") String phoneNumbers);

    @FormUrlEncoded
    @POST("/mediaUpload")
    Call<String> mediaUpload(@Field("username") String username, @Field("url") String url,
                            @Field("phoneNumber") String phoneNumber);

}

package com.africastalking;

import retrofit2.Call;
import retrofit2.http.*;

interface IVoice {

    @FormUrlEncoded
    @POST("call")
    Call<String> call(@Field("username") String username, @Field("to") String to,
                      @Field("from") String from);

    @FormUrlEncoded
    @POST("/queueStatus")
    Call<String> queueStatus(@Field("username") String username, @Field("phoneNumbers") String phoneNumbers);

    @FormUrlEncoded
    @POST("/mediaUpload")
    Call<String> mediaUpload(@Field("username") String username, @Field("url") String url,
                            @Field("phoneNumber") String phoneNumber);

}

Fix HTTP method on voice fetch queued calls


// Copyright (C) 2019 The Android Open Source Project
//
// 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.google.gerrit.acceptance.api.plugin;

import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.NoHttpd;
import com.google.gerrit.acceptance.config.GerritConfig;
import com.google.gerrit.server.plugins.MissingMandatoryPluginsException;
import org.junit.Test;
import org.junit.runner.Description;

@NoHttpd
public class PluginLoaderIT extends AbstractDaemonTest {

  Description testDescription;

  @Override
  protected void beforeTest(Description description) throws Exception {
    this.testDescription = description;
  }

  @Override
  protected void afterTest() throws Exception {}

  @Test(expected = MissingMandatoryPluginsException.class)
  @GerritConfig(name = "plugins.mandatory", value = "my-mandatory-plugin")
  public void shouldFailToStartGerritWhenMandatoryPluginsAreMissing() throws Exception {
    super.beforeTest(testDescription);
  }
}

// Copyright (C) 2019 The Android Open Source Project
//
// 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.google.gerrit.acceptance.api.plugin;

import static com.google.gerrit.testing.GerritJUnit.assertThrows;

import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.NoHttpd;
import com.google.gerrit.acceptance.config.GerritConfig;
import com.google.gerrit.server.plugins.MissingMandatoryPluginsException;
import org.junit.Test;
import org.junit.runner.Description;

@NoHttpd
public class PluginLoaderIT extends AbstractDaemonTest {

  Description testDescription;

  @Override
  protected void beforeTest(Description description) throws Exception {
    this.testDescription = description;
  }

  @Override
  protected void afterTest() throws Exception {}

  @Test
  @GerritConfig(name = "plugins.mandatory", value = "my-mandatory-plugin")
  public void shouldFailToStartGerritWhenMandatoryPluginsAreMissing() throws Exception {
    assertThrows(MissingMandatoryPluginsException.class, () -> super.beforeTest(testDescription));
  }
}

Migrate from strongly discouraged @Test(expected = ...) to assertThrows(...).


/**
 * Copyright (C) 2009-2013 FoundationDB, LLC
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.foundationdb.qp.operator;

public abstract class OperatorCursor extends OperatorExecutionBase implements Cursor
{
    protected OperatorCursor(QueryContext context) {
        super(context);
    }

    @Override
    public QueryBindings openTopLevel() {
        openBindings();
        QueryBindings bindings = nextBindings();
        assert (bindings != null);
        open();
        return bindings;
    }

    @Override
    public void closeTopLevel() {
        close();
        if (CURSOR_LIFECYCLE_ENABLED) {
            QueryBindings bindings = nextBindings();
            assert (bindings == null);
        }
        closeBindings();
    }
}

/**
 * Copyright (C) 2009-2013 FoundationDB, LLC
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.foundationdb.qp.operator;

public abstract class OperatorCursor extends OperatorExecutionBase implements Cursor
{
    protected OperatorCursor(QueryContext context) {
        super(context);
    }

    @Override
    public QueryBindings openTopLevel() {
        openBindings();
        QueryBindings bindings = nextBindings();
        assert (bindings != null);
        open();
        return bindings;
    }

    @Override
    public void closeTopLevel() {
        close();
        closeBindings();
    }
}

Remove the code instead of having the compiler do this.


package me.hugmanrique.pokedata.tiles;

import lombok.Getter;
import me.hugmanrique.pokedata.Data;
import me.hugmanrique.pokedata.roms.ROM;

/**
 * http://datacrystal.romhacking.net/wiki/Pok%C3%A9mon_3rd_Generation#Maps
 * @author Hugmanrique
 * @since 02/07/2017
 */
@Getter
public class TilesetHeader extends Data {
    private boolean compressed;
    private boolean primary;
    private long tilesetImgPtr;
    private long palettesPtr;
    private long blocksPtr;
    private long animationPtr;
    private long behaviorPtr;

    public TilesetHeader(ROM rom) {
        compressed = rom.readByte() == 1;
        primary = rom.readByte() == 0;

        // Skip two unknown bytes
        rom.addInternalOffset(2);

        tilesetImgPtr = rom.getPointer();
        palettesPtr = rom.getPointer();
        blocksPtr = rom.getPointer();

        System.out.println("Read: Tileset imgs -> " + tilesetImgPtr + " Palettes -> " + palettesPtr + " Blocks -> " + blocksPtr);

        if (rom.getGame().isElements()) {
            animationPtr = rom.getPointer();
            behaviorPtr = rom.getPointer();
        } else {
            behaviorPtr = rom.getPointer();
            animationPtr = rom.getPointer();
        }
    }
}

package me.hugmanrique.pokedata.tiles;

import lombok.Getter;
import me.hugmanrique.pokedata.Data;
import me.hugmanrique.pokedata.roms.ROM;

/**
 * http://datacrystal.romhacking.net/wiki/Pok%C3%A9mon_3rd_Generation#Maps
 * @author Hugmanrique
 * @since 02/07/2017
 */
@Getter
public class TilesetHeader extends Data {
    private boolean compressed;
    private boolean primary;
    private long tilesetImgPtr;
    private long palettesPtr;
    private long blocksPtr;
    private long animationPtr;
    private long behaviorPtr;

    public TilesetHeader(ROM rom) {
        compressed = rom.readByte() == 1;
        primary = rom.readByte() == 0;

        // Skip two unknown bytes
        rom.addInternalOffset(2);

        tilesetImgPtr = rom.getPointer();
        palettesPtr = rom.getPointer();
        blocksPtr = rom.getPointer();

        if (rom.getGame().isElements()) {
            animationPtr = rom.getPointer();
            behaviorPtr = rom.getPointer();
        } else {
            behaviorPtr = rom.getPointer();
            animationPtr = rom.getPointer();
        }
    }
}

Remove tileset load debug message


package com.flexibledeveloper.observer;

import org.junit.Test;

/**
 * Created by kharyam on 5/17/14.
 */
public class ObserverTest {

  @Test
  public void nominalBehavior() {
    ConcreteSubject subject = new ConcreteSubject();
    Data originalData = new Data("Original Value 1","Original Value 2","Original Value 3");
    subject.setData(originalData);

    Observer observer1 = new ConcreteObserver1();
    Observer observer2 = new ConcreteObserver2();
    Observer observer3 = new ConcreteObserver3();

    subject.registerObserver(observer1);
    subject.registerObserver(observer2);
    subject.registerObserver(observer3);

    subject.notifyObservers();

    Data newData = new Data("New Value 1","New Value 2","New Value 3");

    subject.notifyObservers(newData);

  }
}

package com.flexibledeveloper.observer;

import org.junit.Test;

/**
 * Created by kharyam on 5/17/14.
 */
public class ObserverTest {

  @Test
  public void nominalBehavior() {

    System.out.println("Creating Subject");
    ConcreteSubject subject = new ConcreteSubject();
    Data originalData = new Data("Original Value 1","Original Value 2","Original Value 3");
    subject.setData(originalData);

    System.out.println("Creating Observers");
    Observer observer1 = new ConcreteObserver1();
    Observer observer2 = new ConcreteObserver2();
    Observer observer3 = new ConcreteObserver3();

    System.out.println("Registering Observers");
    subject.registerObserver(observer1);
    subject.registerObserver(observer2);
    subject.registerObserver(observer3);

    System.out.println("\nNotifying observers");
    subject.notifyObservers();

    Data newData = new Data("New Value 1","New Value 2","New Value 3");

    System.out.println("\nNotifying observers with new data");
    subject.notifyObservers(newData);

    System.out.println("\nRemoving observer2");
    subject.removeObserver(observer2);

    System.out.println("\nNotifying remaining observers");
    subject.notifyObservers(newData);

  }
}

Test the removal of an observer.


package com.elmakers.mine.bukkit.action;

import com.elmakers.mine.bukkit.api.action.CastContext;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Entity;

public abstract class BaseTeleportAction extends BaseSpellAction
{
    protected int verticalSearchDistance;
    protected boolean safe = true;

    @Override
    public void prepare(CastContext context, ConfigurationSection parameters) {
        super.prepare(context, parameters);
        verticalSearchDistance = parameters.getInt("vertical_range", context.getVerticalSearchDistance());
        safe = parameters.getBoolean("safe", true);
    }

    protected void teleport(CastContext context, Entity entity, Location targetLocation) {
        context.teleport(entity, targetLocation, verticalSearchDistance, safe);
    }
}

package com.elmakers.mine.bukkit.action;

import com.elmakers.mine.bukkit.api.action.CastContext;
import com.elmakers.mine.bukkit.api.spell.SpellResult;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Entity;

public abstract class BaseTeleportAction extends BaseSpellAction
{
    protected int verticalSearchDistance;
    protected boolean safe = true;
    private boolean requiresBuildPermission = false;

    @Override
    public void prepare(CastContext context, ConfigurationSection parameters) {
        super.prepare(context, parameters);
        verticalSearchDistance = parameters.getInt("vertical_range", context.getVerticalSearchDistance());
        safe = parameters.getBoolean("safe", true);
        requiresBuildPermission = parameters.getBoolean("require_build", false);
    }

    protected SpellResult teleport(CastContext context, Entity entity, Location targetLocation) {
        if (requiresBuildPermission && !context.hasBuildPermission(targetLocation.getBlock())) {
            return SpellResult.INSUFFICIENT_PERMISSION;
        }
        return context.teleport(entity, targetLocation, verticalSearchDistance, safe) ? SpellResult.CAST : SpellResult.FAIL;
    }
}

Add require_build parameter to teleport actions


package de.schlegel11.eventdispatcher;

import java.util.EventListener;
import java.util.Objects;

/**
 * Created by schlegel11 on 05.11.14.
 */
final class EventListenerWrapper {

    public final static int INFINITE_CALLS = -1;
    private final EventListener listener;
    private final int maxCalls;
    private int currentCalls;

    public EventListenerWrapper(EventListener listener, int maxCalls) {
        this.listener = listener;
        this.maxCalls = maxCalls;
    }

    public EventListener getListener() {
        return listener;
    }

    public int getMaxCalls() {
        return maxCalls;
    }

    public int getCurrentCalls() {
        return currentCalls;
    }

    public void addCurrentCalls(int currentCalls) {
        this.currentCalls += currentCalls;
    }

    @Override
    public int hashCode() {
        return Objects.hash(listener);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        final EventListenerWrapper other = (EventListenerWrapper) obj;
        return Objects.equals(this.listener, other.listener);
    }
}

package de.schlegel11.eventdispatcher;

import java.util.EventListener;
import java.util.Objects;

/**
 * Created by schlegel11 on 05.11.14.
 */
final class EventListenerWrapper {

    public static final EventListenerWrapper DUMMY_ELW = new EventListenerWrapper();
    public final static int INFINITE_CALLS = -1;
    private final EventListener listener;
    private final int maxCalls;
    private int currentCalls;

    public EventListenerWrapper(final EventListener listener, final int maxCalls) {
        this.listener = listener;
        this.maxCalls = maxCalls;
    }

    private EventListenerWrapper() {
        this(null, 0);
    }

    public EventListener getListener() {
        return listener;
    }

    public int getMaxCalls() {
        return maxCalls;
    }

    public int getCurrentCalls() {
        return currentCalls;
    }

    public void addCurrentCalls(final int currentCalls) {
        this.currentCalls += currentCalls;
    }

    @Override
    public int hashCode() {
        return Objects.hash(listener);
    }

    @Override
    public boolean equals(final Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        final EventListenerWrapper other = (EventListenerWrapper) obj;
        return Objects.equals(this.listener, other.listener);
    }
}

Add final modifier to method arguments. Add dummy object which represents an empty elw.


/*
 * RESTHeart - the Web API for MongoDB
 * Copyright (C) SoftInstigate Srl
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.restheart.extensions;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 *
 * @author Andrea Di Cesare <andrea@softinstigate.com>
 */
@Retention(RetentionPolicy.RUNTIME)
public @interface Initializer {
    /**
     * Defines the name of the initializer that can be used in the configuration
     * file to pass arguments
     */
    String name();

    /**
     * Describes the initializer
     */
    String description();

    /**
     * Defines the order of execution (less is higher priority)
     */
    int priority() default 10;
}

/*
 * RESTHeart - the Web API for MongoDB
 * Copyright (C) SoftInstigate Srl
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.restheart.extensions;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 *
 * @author Andrea Di Cesare <andrea@softinstigate.com>
 */
@Retention(RetentionPolicy.RUNTIME)
public @interface Service {
    /**
     * Defines the name of the service that can be used in the configuration
     * file to define the confArgs to pass to it or to disable it
     */
    String name();

    /**
     * Describes the service
     */
    String description();

    /**
     * Defines the service uri
     */
    String uri();
}

Add annotation for service extension


package stream.flarebot.flarebot.objects;

import net.dv8tion.jda.core.requests.RestAction;
import stream.flarebot.flarebot.commands.Command;

public class RestActionWrapper {

    private final RestAction action;
    private final Class<? extends Command> origin;

    public RestActionWrapper(RestAction action, Class<? extends Command> origin) {

        this.action = action;
        this.origin = origin;
    }

    public RestAction getAction() {
        return action;
    }

    public Class<? extends Command> getOrigin() {
        return origin;
    }
}

package stream.flarebot.flarebot.objects;

import net.dv8tion.jda.core.requests.RestAction;
import stream.flarebot.flarebot.commands.Command;

public class RestActionWrapper {

    private final RestAction action;
    private final Class<? extends Command> origin;

    public RestActionWrapper(RestAction action, Class<? extends Command> origin) {

        this.action = action;
        this.origin = origin;
    }

    public RestAction getAction() {
        return action;
    }

    public Class<? extends Command> getOrigin() {
        return origin;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        RestActionWrapper wrapper = (RestActionWrapper) o;

        if (!getAction().equals(wrapper.getAction())) return false;
        return getOrigin().equals(wrapper.getOrigin());
    }

    @Override
    public int hashCode() {
        int result = getAction().hashCode();
        result = 31 * result + getOrigin().hashCode();
        return result;
    }
}

Implement to equals and hashcode


/*
 * $Id: AltRepTest.java [23-Apr-2004]
 *
 * Copyright (c) 2004, Ben Fortuna All rights reserved.
 */
package net.fortuna.ical4j.model.parameter;

import java.net.URI;
import java.net.URISyntaxException;

import net.fortuna.ical4j.model.Parameter;
import net.fortuna.ical4j.model.ParameterFactoryImpl;

import junit.framework.TestCase;

/**
 * Test case for AltRep.
 * @author benfortuna
 */
public class AltRepTest extends TestCase {

    /*
     * Class to test for void AltRep(String)
     */
    public void testAltRepString() throws URISyntaxException {

        try {
            new AltRep("::...invalid...");

            fail("URISyntaxException not thrown!");
        }
        catch (URISyntaxException use) {
            // test success.
        }

        AltRep ar = (AltRep) ParameterFactoryImpl.getInstance().createParameter(Parameter.ALTREP, "mailto:valid@test.com");

        assertNotNull(ar.getUri());
    }

    /*
     * Class to test for void AltRep(URI)
     */
    public void testAltRepURI() throws URISyntaxException {

        AltRep ar = new AltRep(new URI("mailto:valid@test.com"));

        assertNotNull(ar.getUri());
    }

}

/*
 * $Id: AltRepTest.java [23-Apr-2004]
 *
 * Copyright (c) 2004, Ben Fortuna All rights reserved.
 */
package net.fortuna.ical4j.model.parameter;

import java.net.URI;
import java.net.URISyntaxException;

import net.fortuna.ical4j.model.Parameter;
import net.fortuna.ical4j.model.ParameterFactoryImpl;

import junit.framework.TestCase;

/**
 * Test case for AltRep.
 * @author benfortuna
 */
public class AltRepTest extends TestCase {

    /*
     * Class to test for void AltRep(String)
     */
    public void testAltRepString() throws URISyntaxException {

        try {
            new AltRep("<mailto:../:...invalid...>");

            fail("URISyntaxException not thrown!");
        }
        catch (URISyntaxException use) {
            // test success.
        }

        AltRep ar = (AltRep) ParameterFactoryImpl.getInstance().createParameter(Parameter.ALTREP, "mailto:valid@test.com");

        assertNotNull(ar.getUri());
    }

    /*
     * Class to test for void AltRep(URI)
     */
    public void testAltRepURI() throws URISyntaxException {

        AltRep ar = new AltRep(new URI("mailto:valid@test.com"));

        assertNotNull(ar.getUri());
    }

}

Update invalid URI to correctly throw exception


package br.com.bloder.blorm;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import br.com.bloder.blormlib.Blorm;
import br.com.bloder.blormlib.validation.Action;

import static br.com.bloder.blormlib.validation.Validations.*;

public class MainActivity extends AppCompatActivity {

  private EditText editTextFilled;
  private Button submit;

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

    editTextFilled = (EditText) findViewById(R.id.edit_text_filled);
    submit = (Button) findViewById(R.id.submit);

    editTextFilled.setText("Hello");

      new Blorm.Builder()
              .field(editTextFilled).is(filled)
              .onSuccess(new Action() {
          @Override
          public void call() { onSuccess();
          }})
              .onError(new Action() {
                @Override
                public void call() {
                  onError();
                }
              })
              .submitOn(submit);
  }

  private void onSuccess() {
    editTextFilled.setError(null);
    Toast.makeText(this, "Success", Toast.LENGTH_SHORT).show();
  }

  private void onError() {
    Toast.makeText(this, "Error", Toast.LENGTH_SHORT).show();
  }
}

package br.com.bloder.blorm;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;

import br.com.bloder.blormlib.Blorm;
import br.com.bloder.blormlib.validation.Action;

import static br.com.bloder.blormlib.validation.Validations.*;

public class MainActivity extends AppCompatActivity {

  private EditText editTextFilled;
  private Button submit;
  private CheckBox checkBox;

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

    editTextFilled = (EditText) findViewById(R.id.edit_text_filled);
    submit = (Button) findViewById(R.id.submit);
    checkBox = (CheckBox) findViewById(R.id.check_box);

    editTextFilled.setText("Hello");

      new Blorm.Builder()
              .field(editTextFilled).is(filled)
              .field(checkBox).is(checked)
              .onSuccess(new Action() {
                  @Override
                  public void call() {
                      onSuccess();
                  }
              })
              .onError(new Action() {
                @Override
                public void call() {
                  onError();
                }
              })
              .submitOn(submit);
  }

  private void onSuccess() {
    editTextFilled.setError(null);
    checkBox.setError(null);
    Toast.makeText(this, "Success", Toast.LENGTH_SHORT).show();
  }

  private void onError() {
    Toast.makeText(this, "Error", Toast.LENGTH_SHORT).show();
  }
}

Add checkbox validation in main activity


/**
 * Copyright (c) 2014-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

package com.facebook.react.fabric;

public interface FabricBinder {

  void setBinding(FabricBinding binding);

}

/**
 * Copyright (c) 2014-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

package com.facebook.react.fabric;

public interface FabricBinder<T extends FabricBinding> {

  void setBinding(T binding);

}

Initialize FabricXX C++ code and register rootview


package mezz.jei;

import javax.annotation.Nonnull;

import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;

import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import mezz.jei.api.JEIManager;
import mezz.jei.config.Config;

public class TooltipEventHandler {
	@SubscribeEvent
	public void onToolTip(@Nonnull ItemTooltipEvent event) {
		if (!Config.tooltipModNameEnabled) {
			return;
		}

		ItemStack itemStack = event.itemStack;
		if (itemStack == null) {
			return;
		}

		Item item = itemStack.getItem();
		if (item == null) {
			return;
		}

		String modName = JEIManager.itemRegistry.getModNameForItem(item);
		event.toolTip.add(EnumChatFormatting.BLUE + modName);
	}
}

package mezz.jei;

import javax.annotation.Nonnull;

import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;

import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import mezz.jei.api.JEIManager;
import mezz.jei.config.Config;

public class TooltipEventHandler {
	private static final String chatFormatting = EnumChatFormatting.BLUE.toString() + EnumChatFormatting.ITALIC.toString();

	@SubscribeEvent
	public void onToolTip(@Nonnull ItemTooltipEvent event) {
		if (!Config.tooltipModNameEnabled) {
			return;
		}

		ItemStack itemStack = event.itemStack;
		if (itemStack == null) {
			return;
		}

		Item item = itemStack.getItem();
		if (item == null) {
			return;
		}

		String modName = JEIManager.itemRegistry.getModNameForItem(item);
		event.toolTip.add(chatFormatting + modName);
	}
}

Make mod name tooltip italic


package water.api;

import java.io.File;

import com.google.gson.*;

public class TypeaheadFileRequest extends TypeaheadRequest {

  public TypeaheadFileRequest() {
    super("Provides a simple JSON array of filtered local files.","");
  }

  @Override
  protected JsonArray serve(String filter, int limit) {
    File base = null;
    String filterPrefix = "";
    if( !filter.isEmpty() ) {
      File file = new File(filter);
      if( file.isDirectory() ) {
        base = file;
      } else {
        base = file.getParentFile();
        filterPrefix = file.getName().toLowerCase();
      }
    }
    if( base == null ) base = new File(".");

    JsonArray array = new JsonArray();
    for( File file : base.listFiles() ) {
      if( file.isHidden() ) continue;
      if( file.getName().toLowerCase().startsWith(filterPrefix) ) {
        String s = file.getPath();
        array.add(new JsonPrimitive(s));
      }
      if( array.size() == limit) break;
    }
    return array;
  }
}

package water.api;

import java.io.File;

import com.google.gson.*;

public class TypeaheadFileRequest extends TypeaheadRequest {

  public TypeaheadFileRequest() {
    super("Provides a simple JSON array of filtered local files.","");
  }

  @Override
  protected JsonArray serve(String filter, int limit) {
    File base = null;
    String filterPrefix = "";
    if( !filter.isEmpty() ) {
      File file = new File(filter);
      if( file.isDirectory() ) {
        base = file;
      } else {
        base = file.getParentFile();
        filterPrefix = file.getName().toLowerCase();
      }
    }
    if( base == null ) base = new File(".");

    JsonArray array = new JsonArray();
    File[] files = base.listFiles();
    if( files == null ) return array;
    for( File file : files ) {
      if( file.isHidden() ) continue;
      if( file.getName().toLowerCase().startsWith(filterPrefix) )
        array.add(new JsonPrimitive(file.getPath()));
      if( array.size() == limit) break;
    }
    return array;
  }
}

Fix NPE for mispelled/missing directories in type-ahead file lookup


package de.croesch.diff.subject;

import de.croesch.diff.subject.api.Subject;

/**
 * The basic implementation of a Subject, contains code that all Subjects share.
 *
 * @param <CT> the type of the content this subject represents
 */
public abstract class BasicSubject<CT extends Object> implements Subject {
  /** the representation of the value/content of this subject. */
  private CT content;

  public BasicSubject(CT ct) {
    content = ct;
  }

  @Override
  public int hashCode() {
    return content.hashCode();
  }

  @Override
  public boolean equals(Object obj) {
    if (!(obj instanceof BasicSubject)) {
      return false;
    }
    return content.equals(((BasicSubject) obj).content);
  }

  protected CT getContent() {
    return content;
  }
}

package de.croesch.diff.subject;

import de.croesch.diff.subject.api.Subject;

/**
 * The basic implementation of a Subject, contains code that all Subjects share.
 *
 * @param <CT> the type of the content this subject represents
 */
public abstract class BasicSubject<CT extends Object> implements Subject {
  /** the representation of the value/content of this subject. */
  private CT content;

  public BasicSubject(CT ct) {
    content = ct;
  }

  @Override
  public int hashCode() {
    return content.hashCode();
  }

  @Override
  public boolean equals(Object obj) {
    if (!(obj instanceof BasicSubject)) {
      return false;
    }
    return content.equals(((BasicSubject) obj).content);
  }

  protected CT getContent() {
    return content;
  }

  @Override
  public String toString() {
    return super.toString() + " >" + content + "<";
  }
}

Implement toString() for debug purposes.


package ee.shy.storage;

import org.junit.Before;

import java.nio.file.Path;
import java.util.Arrays;

public class FileStorageTest extends DataStorageTest {
    private Path storageDirectory;

    @Before
    public void setUp() throws Exception {
        storageDirectory = temporaryDirectory.newDirectory("storage");
        storage = new FileStorage(
                Arrays.asList(
                        new GitFileLocator(storageDirectory),
                        new FlatFileLocator(storageDirectory)),
                new AggregateFileAccessor(Arrays.asList(
                        new GzipFileAccessor(),
                        new PlainFileAccessor())));
        super.setUp();
    }
}

package ee.shy.storage;

import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.Test;

import java.nio.file.Path;
import java.util.Arrays;

public class FileStorageTest extends DataStorageTest {
    private Path storageDirectory;

    @Before
    public void setUp() throws Exception {
        storageDirectory = temporaryDirectory.newDirectory("storage");
        storage = new FileStorage(
                Arrays.asList(
                        new GitFileLocator(storageDirectory),
                        new FlatFileLocator(storageDirectory)),
                new AggregateFileAccessor(Arrays.asList(
                        new GzipFileAccessor(),
                        new PlainFileAccessor())));
        super.setUp();
    }

    @Test
    public void testDataChange() throws Exception {
        Hash hash = storage.put(getClass().getResourceAsStream("/fox.txt"));

        GitFileLocator gitFileLocator = new GitFileLocator(storageDirectory);
        GzipFileAccessor gzipFileAccessor = new GzipFileAccessor();

        gzipFileAccessor.add(gitFileLocator.locate(hash), IOUtils.toInputStream("Hello, World!"));

        expectedException.expect(RuntimeException.class);
        expectedException.expectMessage("not");
        expectedException.expectMessage("match");
        storage.get(hash);
    }
}

Add test for hash mismatch checking


package xyz.openmodloader.test;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import xyz.openmodloader.modloader.Mod;

public class OMLTestMod implements Mod {

    private static final Logger LOGGER = LogManager.getFormatterLogger("Open Mod Tests");

    @Override
    public void onInitialize() {
        LOGGER.info("Loading test mods");

        try {
            final List<Class<?>> testMods = Mirrorpool.getClasses("xyz.openmodloader.test.mods");
            final Method init = TestMod.class.getMethod("onInitialize", new Class[] {});
            for (Class<?> mod : testMods) {
                if (TestMod.class.isAssignableFrom(mod)) {
                    init.invoke(mod.newInstance(), null);
                    LOGGER.info("Loading " + mod.getName());
                }
            }
        } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | InstantiationException | ClassNotFoundException e) {
            LOGGER.warn(e);
        }
    }
}

package xyz.openmodloader.test;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import xyz.openmodloader.modloader.Mod;

public class OMLTestMod implements Mod {

    private static final Logger LOGGER = LogManager.getFormatterLogger("Open Mod Tests");

    @Override
    public void onInitialize() {
        if (Boolean.parseBoolean(System.getProperty("oml.testmod.disable"))) {
            return;
        }
        LOGGER.info("Loading test mods");

        try {
            final List<Class<?>> testMods = Mirrorpool.getClasses("xyz.openmodloader.test.mods");
            final Method init = TestMod.class.getMethod("onInitialize", new Class[] {});
            for (Class<?> mod : testMods) {
                if (TestMod.class.isAssignableFrom(mod)) {
                    init.invoke(mod.newInstance(), null);
                    LOGGER.info("Loading " + mod.getName());
                }
            }
        } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | InstantiationException | ClassNotFoundException e) {
            LOGGER.warn(e);
        }
    }
}

Allow disabling of the test mod by setting a system property


package com.github.blindpirate.gogradle.core.mode;

import com.github.blindpirate.gogradle.core.dependency.GolangDependencySet;

import static com.github.blindpirate.gogradle.core.dependency.GolangDependencySet.merge;

public enum BuildMode {
    DEVELOP {
        @Override
        public GolangDependencySet determine(GolangDependencySet declaredDependencies,
                                             GolangDependencySet vendorDependencies,
                                             GolangDependencySet lockedDependencies) {
            return merge(declaredDependencies, vendorDependencies, lockedDependencies);
        }
    },
    REPRODUCIBLE {
        @Override
        public GolangDependencySet determine(GolangDependencySet declaredDependencies,
                                             GolangDependencySet vendorDependencies,
                                             GolangDependencySet lockedDependencies) {
            return merge(vendorDependencies, lockedDependencies, declaredDependencies);
        }
    };

    public abstract GolangDependencySet determine(
            GolangDependencySet declaredDependencies,
            GolangDependencySet vendorDependencies,
            GolangDependencySet lockedDependencies);
}

package com.github.blindpirate.gogradle.core.mode;

import com.github.blindpirate.gogradle.core.dependency.GolangDependencySet;

import static com.github.blindpirate.gogradle.core.dependency.GolangDependencySet.merge;

public enum BuildMode {
    DEVELOP {
        @Override
        public GolangDependencySet determine(GolangDependencySet declaredDependencies,
                                             GolangDependencySet vendorDependencies,
                                             GolangDependencySet lockedDependencies) {
            return merge(declaredDependencies, lockedDependencies, vendorDependencies);
        }
    },
    REPRODUCIBLE {
        @Override
        public GolangDependencySet determine(GolangDependencySet declaredDependencies,
                                             GolangDependencySet vendorDependencies,
                                             GolangDependencySet lockedDependencies) {
            return merge(vendorDependencies, lockedDependencies, declaredDependencies);
        }
    };

    public abstract GolangDependencySet determine(
            GolangDependencySet declaredDependencies,
            GolangDependencySet vendorDependencies,
            GolangDependencySet lockedDependencies);
}

Adjust order of dependency set in DEVELOP mode


package com.elmakers.mine.bukkit.entity;

import org.bukkit.DyeColor;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Wolf;

import com.elmakers.mine.bukkit.api.magic.MageController;

public class EntityWolfData extends EntityAnimalData {
    private boolean isAngry;
    private DyeColor collarColor;

    public EntityWolfData() {

    }

    public EntityWolfData(ConfigurationSection parameters, MageController controller) {
        super(parameters, controller);

        String colorString = parameters.getString("color");
        if (colorString != null) {
            try {
                collarColor = DyeColor.valueOf(colorString.toUpperCase());
            } catch (Exception ex) {
                collarColor = null;
            }
        }
        isAngry = parameters.getBoolean("angry", false);
    }

    public EntityWolfData(Entity entity) {
        super(entity);
        if (entity instanceof Wolf) {
            Wolf wolf = (Wolf)entity;
            collarColor = wolf.getCollarColor();
            isAngry = wolf.isAngry();
            sitting = wolf.isSitting();
        }
    }

    @Override
    public void apply(Entity entity) {
        super.apply(entity);
        if (entity instanceof Wolf) {
            Wolf wolf = (Wolf)entity;
            wolf.setCollarColor(collarColor);
            wolf.setAngry(isAngry);
            wolf.setSitting(sitting);
        }
    }
}

package com.elmakers.mine.bukkit.entity;

import org.bukkit.DyeColor;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Wolf;

import com.elmakers.mine.bukkit.api.magic.MageController;

public class EntityWolfData extends EntityAnimalData {
    private boolean isAngry;
    private DyeColor collarColor;

    public EntityWolfData() {

    }

    public EntityWolfData(ConfigurationSection parameters, MageController controller) {
        super(parameters, controller);

        String colorString = parameters.getString("color");
        if (colorString != null) {
            try {
                collarColor = DyeColor.valueOf(colorString.toUpperCase());
            } catch (Exception ex) {
                collarColor = null;
            }
        }
        isAngry = parameters.getBoolean("angry", false);
    }

    public EntityWolfData(Entity entity) {
        super(entity);
        if (entity instanceof Wolf) {
            Wolf wolf = (Wolf)entity;
            collarColor = wolf.getCollarColor();
            isAngry = wolf.isAngry();
            sitting = wolf.isSitting();
        }
    }

    @Override
    public void apply(Entity entity) {
        super.apply(entity);
        if (entity instanceof Wolf) {
            Wolf wolf = (Wolf)entity;
            if (collarColor != null) {
                wolf.setCollarColor(collarColor);
            }
            wolf.setAngry(isAngry);
            wolf.setSitting(sitting);
        }
    }
}

Fix NPE in applying wolf entity data from config


package com.avairebot.orion.commands;

import net.dv8tion.jda.core.entities.Message;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CommandHandler {

    private static final Map<List<String>, CommandContainer> commands = new HashMap<>();

    public static CommandContainer getCommand(Message message) {
        String commandTrigger = message.getContent().split(" ")[0].toLowerCase();

        for (Map.Entry<List<String>, CommandContainer> entry : commands.entrySet()) {
            for (String trigger : entry.getKey()) {
                if (commandTrigger.equalsIgnoreCase(entry.getValue().getDefaultPrefix() + trigger)) {
                    return entry.getValue();
                }
            }
        }

        return null;
    }

    public static boolean register(Command command) {
        for (String trigger : command.getTriggers()) {
            for (Map.Entry<List<String>, CommandContainer> entry : commands.entrySet()) {
                if (entry.getKey().contains(trigger.toLowerCase())) {
                    return false;
                }
            }
        }

        Category category = Category.fromCommand(command);
        if (category == null) {
            return false;
        }

        commands.put(command.getTriggers(), new CommandContainer(command, category));
        return true;
    }

    public static Collection<CommandContainer> getCommands() {
        return commands.values();
    }
}

package com.avairebot.orion.commands;

import net.dv8tion.jda.core.entities.Message;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CommandHandler {

    private static final Map<List<String>, CommandContainer> commands = new HashMap<>();

    public static CommandContainer getCommand(Message message) {
        return getCommand(message.getContent().split(" ")[0].toLowerCase());
    }

    public static CommandContainer getCommand(String commandTrigger) {
        for (Map.Entry<List<String>, CommandContainer> entry : commands.entrySet()) {
            for (String trigger : entry.getKey()) {
                if (commandTrigger.equalsIgnoreCase(entry.getValue().getDefaultPrefix() + trigger)) {
                    return entry.getValue();
                }
            }
        }

        return null;
    }

    public static boolean register(Command command) {
        for (String trigger : command.getTriggers()) {
            for (Map.Entry<List<String>, CommandContainer> entry : commands.entrySet()) {
                if (entry.getKey().contains(trigger.toLowerCase())) {
                    return false;
                }
            }
        }

        Category category = Category.fromCommand(command);
        if (category == null) {
            return false;
        }

        commands.put(command.getTriggers(), new CommandContainer(command, category));
        return true;
    }

    public static Collection<CommandContainer> getCommands() {
        return commands.values();
    }
}

Add getCommand handler for strings


package info.u_team.u_team_core.container;

import info.u_team.u_team_core.api.fluid.IFluidHandlerModifiable;
import net.minecraftforge.fluids.FluidStack;

public class FluidSlot {

	private final IFluidHandlerModifiable fluidHandler;
	private final int index;
	private final int x;
	private final int y;

	public FluidSlot(IFluidHandlerModifiable fluidHandler, int index, int x, int y) {
		this.fluidHandler = fluidHandler;
		this.index = index;
		this.x = x;
		this.y = y;
	}

	public boolean isFluidValid(FluidStack stack) {
		if (stack.isEmpty()) {
			return false;
		}
		return fluidHandler.isFluidValid(index, stack);
	}

	public FluidStack getStack() {
		return fluidHandler.getFluidInTank(index);
	}

	public void putStack(FluidStack stack) {
		fluidHandler.setFluidInTank(index, stack);
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

}

package info.u_team.u_team_core.container;

import info.u_team.u_team_core.api.fluid.IFluidHandlerModifiable;
import net.minecraftforge.fluids.FluidStack;

public class FluidSlot {

	private final IFluidHandlerModifiable fluidHandler;
	private final int index;
	private final int x;
	private final int y;

	public FluidSlot(IFluidHandlerModifiable fluidHandler, int index, int x, int y) {
		this.fluidHandler = fluidHandler;
		this.index = index;
		this.x = x;
		this.y = y;
	}

	public boolean isFluidValid(FluidStack stack) {
		if (stack.isEmpty()) {
			return false;
		}
		return fluidHandler.isFluidValid(index, stack);
	}

	public FluidStack getStack() {
		return fluidHandler.getFluidInTank(index);
	}

	public void putStack(FluidStack stack) {
		fluidHandler.setFluidInTank(index, stack);
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	public boolean isEnabled() {
		return true;
	}
}

Add isEnable method to the slot for render things


package net.liquidpineapple.pang;

import lombok.Getter;

/**
 * @author Govert de Gans
 * @date 2016-10-25
 */
public final class SoundEffect {
  public static final SoundEffect COLLECT_COIN = new SoundEffect("coin");
  public static final SoundEffect COLLECT_BOMB = new SoundEffect("genericPowerup");
  public static final SoundEffect COLLECT_FREEZE = new SoundEffect("genericPowerup");
  public static final SoundEffect COLLECT_HEART = new SoundEffect("genericPowerup");
  public static final SoundEffect COLLECT_HOOK = new SoundEffect("genericPowerup");
  public static final SoundEffect COLLECT_SHIELD = new SoundEffect("shield");
  public static final SoundEffect COLLECT_STICKY = new SoundEffect("genericPowerup");
  public static final SoundEffect FOOTSTEP = new SoundEffect("step");
  public static final SoundEffect HOOK_SHOOT = new SoundEffect("lazor");
  public static final SoundEffect PLAYER_HIT = new SoundEffect("hit");
  public static final SoundEffect BALL_DESTROY = new SoundEffect("pop");

  @Getter
  private String name;
  private SoundEffect(String name) {
    this.name = name;
  }
}

package net.liquidpineapple.pang;

/**
 * @author Govert de Gans
 * @date 2016-10-25
 */
public final class SoundEffect {
  public static final SoundEffect COLLECT_COIN = new SoundEffect("coin");
  public static final SoundEffect COLLECT_BOMB = new SoundEffect("genericPowerup");
  public static final SoundEffect COLLECT_FREEZE = new SoundEffect("genericPowerup");
  public static final SoundEffect COLLECT_HEART = new SoundEffect("genericPowerup");
  public static final SoundEffect COLLECT_HOOK = new SoundEffect("genericPowerup");
  public static final SoundEffect COLLECT_SHIELD = new SoundEffect("shield");
  public static final SoundEffect COLLECT_STICKY = new SoundEffect("genericPowerup");
  public static final SoundEffect FOOTSTEP = new SoundEffect("step");
  public static final SoundEffect HOOK_SHOOT = new SoundEffect("lazor");
  public static final SoundEffect PLAYER_HIT = new SoundEffect("hit");
  public static final SoundEffect BALL_DESTROY = new SoundEffect("pop");

  private String name;

  private SoundEffect(String name) {
    this.name = name;
  }

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

Write getName() manually instead of using lombok to please PMD


package com.flipper83.katapotter;

import java.util.List;

public class BasketCalculator {
    public int calculatePrice(List<String> books) {
        return 0;
    }
}

package com.flipper83.katapotter;

import java.util.List;

public class BasketCalculator {
  private static final int BOOK_PRICE = 8;

  public int calculatePrice(List<String> books) {
    int amount = BOOK_PRICE * books.size();
    return amount;
  }
}

Return valid total amount for a basket with one book


/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 * 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 io.appium.java_client;

import org.openqa.selenium.remote.Response;

import java.util.Map;

public final class CommandExecutionHelper {

    public static <T extends Object> T execute(ExecutesMethod executesMethod,
        Map.Entry<String, Map<String, ?>> keyValuePair) {
        return handleResponse(executesMethod.execute(keyValuePair.getKey(), keyValuePair.getValue()));
    }

    public static <T extends Object> T execute(ExecutesMethod executesMethod, String command) {
        return handleResponse(executesMethod.execute(command));
    }

    private static <T extends Object> T handleResponse(Response response) {
        if (response != null) {
            return (T) response.getValue();
        }
        return null;
    }
}

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 * 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 io.appium.java_client;

import org.openqa.selenium.remote.Response;

import java.util.Map;

public final class CommandExecutionHelper {

    public static <T> T execute(ExecutesMethod executesMethod,
        Map.Entry<String, Map<String, ?>> keyValuePair) {
        return handleResponse(executesMethod.execute(keyValuePair.getKey(), keyValuePair.getValue()));
    }

    public static <T> T execute(ExecutesMethod executesMethod, String command) {
        return handleResponse(executesMethod.execute(command));
    }

    private static <T> T handleResponse(Response response) {
        if (response != null) {
            return (T) response.getValue();
        }
        return null;
    }
}

Remove redundant type parameter extension of Object


package butterknife;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

@Retention(RUNTIME) @Target(FIELD)
public @interface InjectView {
  int value();
}

package butterknife;

import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.CLASS;

@Retention(CLASS) @Target(FIELD)
public @interface InjectView {
  int value();
}

Reduce the retention of the annotation to compile-time only.


/*                                                                      *\
**                    SICU Stress Measurement System                    **
**                      Project P04  |  C380 Team A                     **
**          EBME 380: Biomedical Engineering Design Experience          **
**                    Case Western Reserve University                   **
**                          2016 Fall Semester                          **
\*                                                                      */

package edu.cwru.sicu_sms;

/**
 * This class is delegated to managing the "Channel Data" plot in the front-end program.
 *
 * @since December 5, 2016
 * @author Ted Frohlich <ttf10@case.edu>
 * @author Abby Walker <amw138@case.edu>
 */
class TemporalPlot {

}

/*                                                                      *\
**                    SICU Stress Measurement System                    **
**                      Project P04  |  C380 Team A                     **
**          EBME 380: Biomedical Engineering Design Experience          **
**                    Case Western Reserve University                   **
**                          2016 Fall Semester                          **
\*                                                                      */

package edu.cwru.sicu_sms;

import javafx.fxml.FXML;
import javafx.scene.chart.LineChart;

/**
 * This class is delegated to managing the "Channel Data" plot in the front-end program.
 *
 * @since December 5, 2016
 * @author Ted Frohlich <ttf10@case.edu>
 * @author Abby Walker <amw138@case.edu>
 */
class TemporalPlot {

    @FXML LineChart temporalChart;

}

Add 'temporalChart' as FXML-injected field


package com.springapp.batch;

import com.springapp.batch.bo.Person;
import org.joda.time.DateTime;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;

import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class CompareEntryTest {

    public static final String BILL_DOB = "1970-01-08T12:30:49+05:30";
    public static final String PAUL_DOB = "1970-01-09T15:30:49+05:30";

    /**
     * This test implements Task 3 of the assignment
     * If this fails we don't get the job
     *
     * @throws Exception
     */
    @Test
    public void testAssignmentTask() throws Exception {
        Person bill = mock(Person.class);
        Person paul = mock(Person.class);

        when(bill.getDateOfBirth()).thenReturn(DateTime.parse(BILL_DOB));
        when(paul.getDateOfBirth()).thenReturn(DateTime.parse(PAUL_DOB));

        Assert.assertEquals(1, bill.compareTo(paul));
    }

}

package com.springapp.batch;

import com.springapp.batch.bo.Person;
import org.joda.time.DateTime;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;

import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class CompareEntryTest {

    public static final String BILL_DOB = "1970-01-08T12:30:49+05:30";
    public static final String PAUL_DOB = "1970-01-09T15:30:49+05:30";

    /**
     * This test implements Task 3 of the assignment
     * If this fails we don't get the job
     *
     * @throws Exception
     */
    @Test
    public void testAssignmentTask() throws Exception {
        Person bill = mock(Person.class);
        Person paul = mock(Person.class);

        when(bill.getDateOfBirth()).thenReturn(DateTime.parse(BILL_DOB));
        when(paul.getDateOfBirth()).thenReturn(DateTime.parse(PAUL_DOB));

        Assert.assertEquals(1, bill.compareTo(paul));
    }

    @Test
    public void testPersonWithInvalidDate() throws Exception {
        Person bill = mock(Person.class);
        Person invalidPerson = null;

        when(bill.getDateOfBirth()).thenReturn(DateTime.parse(BILL_DOB));

        try {
            bill.compareTo(invalidPerson);
            fail("Exception should have been thrown");
        } catch (Exception e) {
        }
    }
}

Add new test to see if we are failing correctly


package com.gdxjam.base.android;

import android.os.Bundle;

import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.gdxjam.Main;

public class AndroidLauncher extends AndroidApplication {
	@Override
	protected void onCreate (Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
		config.useImmersiveMode = true;
		initialize(new Main(), config);
	}
}

package com.gdxjam.base.android;

import android.os.Bundle;

import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.gdxjam.Main;

public class AndroidLauncher extends AndroidApplication {
	@Override
	protected void onCreate (Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
		initialize(new Main(), config);
	}
}

Revert "Android build now uses immersive mode."


package com.github.aureliano.verbum_domini.domain.bean;

import java.io.Serializable;

public interface IBean extends Serializable {

	public abstract <T extends Object> T toResource();
}

package com.github.aureliano.verbum_domini.domain.bean;

import java.io.Serializable;

public interface IBean extends Serializable {

	public abstract Integer getId();

	public abstract <T extends Object> T toResource();
}

Define id reader as contract method.


/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package com.skelril.skree.content.world;

import com.flowpowered.math.vector.Vector3i;
import org.spongepowered.api.block.BlockTypes;
import org.spongepowered.api.world.World;
import org.spongepowered.api.world.extent.ImmutableBiomeArea;
import org.spongepowered.api.world.extent.MutableBlockVolume;
import org.spongepowered.api.world.gen.GenerationPopulator;

public class VoidTerrainGenerator implements GenerationPopulator {
    @Override
    public void populate(World world, MutableBlockVolume buffer, ImmutableBiomeArea biomes) {
        Vector3i min = buffer.getBlockMin();
        Vector3i max = buffer.getBlockMax();
        for (int x = min.getX(); x <= max.getX(); ++x) {
            for (int z = min.getZ(); z <= max.getZ(); ++z) {
                buffer.setBlockType(x, 0, z, BlockTypes.BEDROCK);
                buffer.setBlockType(x, 1, z, BlockTypes.STONE);
                buffer.setBlockType(x, 5, z, BlockTypes.STONE);
            }
        }
    }
}

/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package com.skelril.skree.content.world;

import org.spongepowered.api.world.World;
import org.spongepowered.api.world.extent.ImmutableBiomeArea;
import org.spongepowered.api.world.extent.MutableBlockVolume;
import org.spongepowered.api.world.gen.GenerationPopulator;

public class VoidTerrainGenerator implements GenerationPopulator {
    @Override
    public void populate(World world, MutableBlockVolume buffer, ImmutableBiomeArea biomes) {

    }
}

Revert changes to the Void Terrain Generator


package com.alexrnl.commons.utils.object;

import static org.junit.Assert.fail;

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

/**
 * Test suite for the {@link ComparisonError} class.
 * @author Alex
 */
public class ComparisonErrorTest {

	/**
	 * Set up attributes.
	 */
	@Before
	public void setUp () {
	}

	/**
	 * Test method for {@link java.lang.Throwable#getMessage()}.
	 */
	@Test
	public void testGetMessage () {
		fail("Not yet implemented"); // TODO
	}

	/**
	 * Test method for {@link java.lang.Throwable#getCause()}.
	 */
	@Test
	public void testGetCause () {
		fail("Not yet implemented"); // TODO
	}
}

package com.alexrnl.commons.utils.object;

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

import org.junit.Test;

/**
 * Test suite for the {@link ComparisonError} class.
 * @author Alex
 */
public class ComparisonErrorTest {
	/** A blank error */
	private final ComparisonError	blank			= new ComparisonError();
	/** An error with a message */
	private final ComparisonError	message			= new ComparisonError("Error while comparing Integer");
	/** An error with a code */
	private final ComparisonError	cause			= new ComparisonError(new RuntimeException());
	/** An error with a message and a code */
	private final ComparisonError	messageAndCause	= new ComparisonError("Error while comparing Dummy", new NullPointerException());

	/**
	 * Test method for {@link java.lang.Throwable#getMessage()}.
	 */
	@Test
	public void testGetMessage () {
		assertNull(blank.getMessage());
		assertEquals("Error while comparing Integer", message.getMessage());
		assertEquals(RuntimeException.class.getName(), cause.getMessage());
		assertEquals("Error while comparing Dummy", messageAndCause.getMessage());
	}

	/**
	 * Test method for {@link java.lang.Throwable#getCause()}.
	 */
	@Test
	public void testGetCause () {
		assertNull(blank.getCause());
		assertNull(message.getCause());
		assertEquals(RuntimeException.class, cause.getCause().getClass());
		assertEquals(NullPointerException.class, messageAndCause.getCause().getClass());
	}
}

Implement tests of ComparisonError class


package cpw.mods.fml.common.event;

import cpw.mods.fml.common.LoaderState.ModState;

public class FMLPostInitializationEvent extends FMLStateEvent
{
    public FMLPostInitializationEvent(Object... data)
    {
        super(data);
    }

    @Override
    public ModState getModState()
    {
        return ModState.POSTINITIALIZED;
    }

}

package cpw.mods.fml.common.event;

import com.google.common.base.Throwables;

import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.LoaderState.ModState;

public class FMLPostInitializationEvent extends FMLStateEvent
{
    public FMLPostInitializationEvent(Object... data)
    {
        super(data);
    }

    @Override
    public ModState getModState()
    {
        return ModState.POSTINITIALIZED;
    }

    public Object buildSoftDependProxy(String modId, String className)
    {
        if (Loader.isModLoaded(modId))
        {
            try
            {
                Class<?> clz = Class.forName(className,true,Loader.instance().getModClassLoader());
                return clz.newInstance();
            }
            catch (Exception e)
            {
                Throwables.propagateIfPossible(e);
                return null;
            }
        }
        return null;
    }
}

Add in a convenience method for getting a class instance based on existence of another Mod. Useful for soft dependencies.


package org.vovkasm.WebImage;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;

import java.util.Collections;
import java.util.List;

public class WebImagePackage implements ReactPackage {

    @Override
    public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
        return Collections.emptyList();
    }

    @Override
    public List<Class<? extends JavaScriptModule>> createJSModules() {
        return Collections.emptyList();
    }

    @Override
    public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
        return Collections.<ViewManager>singletonList(new WebImageViewManager());
    }
}

package org.vovkasm.WebImage;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;

import java.util.Collections;
import java.util.List;

public class WebImagePackage implements ReactPackage {

    @Override
    public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
        return Collections.emptyList();
    }

    @Override
    public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
        return Collections.<ViewManager>singletonList(new WebImageViewManager());
    }
}

Fix for RN 0.47 breaking change.


package com.xmartlabs.template.module;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import java.util.Date;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

/**
 * Created by santiago on 23/10/15.
 */
@Module
public class GsonModule {
  @Provides
  @Singleton
  public Gson provideGson() {
    return new GsonBuilder()
        .registerTypeAdapter(Date.class, new GsonUtcDateAdapter())
        .create();
  }
}

package com.xmartlabs.template.module;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.xmartlabs.template.BuildConfig;

import java.util.Date;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

/**
 * Created by santiago on 23/10/15.
 */
@Module
public class GsonModule {
  @Provides
  @Singleton
  public Gson provideGson() {
    GsonBuilder gsonBuilder = new GsonBuilder()
        .registerTypeAdapter(Date.class, new GsonUtcDateAdapter());

    if (BuildConfig.DEBUG) {
      gsonBuilder.setPrettyPrinting();
    }

    return gsonBuilder
        .create();
  }
}

Enable pretty printing of JSON in logs


package modules.storage;

import com.google.inject.AbstractModule;
import play.Configuration;
import play.Environment;

public class StorageModule extends AbstractModule {
    private final Environment environment;
    private final Configuration configuration;

    public StorageModule(Environment environment, Configuration configuration) {
        this.environment = environment;
        this.configuration = configuration;
    }

    @Override
    protected void configure() {
        String storageType = configuration.getString("storage.type", "mock");

        switch (storageType) {
            case "mock" :
                bind (Storage.class).to(MockStorage.class);
                break;
            case "local" :
                bind (Storage.class).to(LocalFilesystemStorage.class);
                break;
            case "s3" :
                bind (Storage.class).to(AmazonS3Storage.class);
                break;
        }
    }
}

package modules.storage;

import com.google.inject.AbstractModule;
import play.Configuration;
import play.Environment;

public class StorageModule extends AbstractModule {
    private final Environment environment;
    private final Configuration configuration;

    public StorageModule(Environment environment, Configuration configuration) {
        this.environment = environment;
        this.configuration = configuration;
    }

    @Override
    protected void configure() {
        String storageType = configuration.getString("storage.type", "local");

        switch (storageType) {
            case "mock" :
                bind (Storage.class).to(MockStorage.class);
                break;
            case "local" :
                bind (Storage.class).to(LocalFilesystemStorage.class);
                break;
            case "s3" :
                bind (Storage.class).to(AmazonS3Storage.class);
                break;
        }
    }
}

Set local storage as default storage type


package br.com.bloder.blormlib;

import android.view.View;

import java.util.ArrayList;
import java.util.List;

import br.com.bloder.blormlib.validation.Validate;
import br.com.bloder.blormlib.validation.Validation;

/**
 * Created by bloder on 05/06/16.
 */
public class Blorm {

  public static class Builder {

    private List<Validate> validations;
    private View field;

    public Builder() {
      validations = new ArrayList<>();
    }

    public Builder field(View field) {
      this.field = field;
      return this;
    }

    public Builder is(Validate validation) {
      this.validations.add(validation);
      return this;
    }

    public Builder is(Validation validation) {
      validation.field = this.field;
      this.validations.add(validation.validate());
      return this;
    }

    public Builder is(String errorMessgae, Validation validation) {
      validation.field = this.field;
      validation.errorMessage = errorMessgae;
      this.validations.add(validation.validate());
      return this;
    }

    public void onSubmit(View submittedItem) {
      new Blorm(this.validations).onSubmitted();
    }
  }

  private List<Validate> validations;

  public Blorm(List<Validate> validations) {
    this.validations = validations;
  }

  private void onSubmitted() {
    for(Validate validate : validations) {
      if(!validate.validate()) {
        validate.onError();
      }
    }
  }
}

package br.com.bloder.blormlib;

import android.view.View;

import java.util.ArrayList;
import java.util.List;

import br.com.bloder.blormlib.validation.Validate;
import br.com.bloder.blormlib.validation.Validation;

/**
 * Created by bloder on 05/06/16.
 */
public class Blorm {

  public static class Builder {

    private List<Validate> validations;
    private View field;

    public Builder() {
      validations = new ArrayList<>();
    }

    public Builder field(View field) {
      this.field = field;
      return this;
    }

    public Builder is(Validate validation) {
      this.validations.add(validation);
      return this;
    }

    public Builder is(Validation validation) {
      validation.field = this.field;
      this.validations.add(validation.validate());
      return this;
    }

    public Builder is(String errorMessgae, Validation validation) {
      validation.field = this.field;
      validation.errorMessage = errorMessgae;
      this.validations.add(validation.validate());
      return this;
    }

    public void onSubmit(View submittedItem) {
      submittedItem.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
          new Blorm(validations).onSubmitted();
        }
      });
    }
  }

  private List<Validate> validations;

  public Blorm(List<Validate> validations) {
    this.validations = validations;
  }

  private void onSubmitted() {
    for(Validate validate : validations) {
      if(!validate.validate()) {
        validate.onError();
      }
    }
  }
}

Add on click listener in on submit function


package com.mooo.aimmac23.hub.proxy;

import java.util.Map;

import org.openqa.grid.internal.utils.CapabilityMatcher;

public class ReliableCapabilityMatcher implements CapabilityMatcher {

	private CapabilityMatcher innerMatcher;
	private ReliableProxy proxy;

	public ReliableCapabilityMatcher(ReliableProxy proxy, CapabilityMatcher innerMatcher) {
		this.proxy = proxy;
		this.innerMatcher = innerMatcher;
	}

	@Override
	public boolean matches(Map<String, Object> currentCapability,
			Map<String, Object> requestedCapability) {

		// to allow the node to be tested
		if(requestedCapability.containsKey("proxyId")) {
			return innerMatcher.matches(currentCapability, requestedCapability);
		}

		// check to see if we're allowed to use that config
		if(!proxy.isCapabilityWorking(currentCapability)) {
			return false;
		}

		// otherwise, match on the capabilities
		return innerMatcher.matches(currentCapability, requestedCapability);
	}
}

package com.mooo.aimmac23.hub.proxy;

import java.util.Map;

import org.openqa.grid.internal.utils.CapabilityMatcher;

public class ReliableCapabilityMatcher implements CapabilityMatcher {

	private CapabilityMatcher innerMatcher;
	private ReliabilityAwareProxy proxy;

	public ReliableCapabilityMatcher(ReliabilityAwareProxy proxy, CapabilityMatcher innerMatcher) {
		this.proxy = proxy;
		this.innerMatcher = innerMatcher;
	}

	@Override
	public boolean matches(Map<String, Object> currentCapability,
			Map<String, Object> requestedCapability) {

		// to allow the node to be tested - we're calling enough internal
		// methods to ensure that we're calling this on the correct node
		if(requestedCapability.containsKey("proxyId")) {
			return innerMatcher.matches(currentCapability, requestedCapability);
		}

		// check to see if we're allowed to use that config
		if(!proxy.isCapabilityWorking(currentCapability)) {
			return false;
		}

		// otherwise, match on the capabilities
		return innerMatcher.matches(currentCapability, requestedCapability);
	}
}

Use the interface for this


package net.aeten.core.spi.factory;

import java.util.concurrent.atomic.AtomicInteger;

import net.aeten.core.spi.SpiFactory;

class ThreadFactory implements
		SpiFactory <java.util.concurrent.ThreadFactory, String> {
	private static final AtomicInteger threadCount = new AtomicInteger (0);

	@Override
	public java.util.concurrent.ThreadFactory create (String prefix) {
		final String name = prefix + "-" + threadCount.incrementAndGet ();
		return new java.util.concurrent.ThreadFactory () {
			@Override
			public Thread newThread (Runnable runnable) {
				return new Thread (runnable, name);
			}
		};
	}

	@Override
	public Class <?>[] getTypes () {
		return new Class[] {
			java.util.concurrent.ThreadFactory.class
		};
	}

	@Override
	public Class <String> getParameterType () {
		return String.class;
	}
}

package net.aeten.core.spi.factory;

import java.util.concurrent.atomic.AtomicInteger;

import net.aeten.core.spi.SpiFactory;

public class ThreadFactory implements
		SpiFactory <java.util.concurrent.ThreadFactory, String> {
	private static final AtomicInteger threadCount = new AtomicInteger (0);

	@Override
	public java.util.concurrent.ThreadFactory create (String prefix) {
		final String name = prefix + "-" + threadCount.incrementAndGet ();
		return new java.util.concurrent.ThreadFactory () {
			@Override
			public Thread newThread (Runnable runnable) {
				return new Thread (runnable, name);
			}
		};
	}

	@Override
	public Class <?>[] getTypes () {
		return new Class[] {
			java.util.concurrent.ThreadFactory.class
		};
	}

	@Override
	public Class <String> getParameterType () {
		return String.class;
	}
}

Increase to public visibility (better for use)


package io.github.jordao76.quotes;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

import org.junit.*;
import org.junit.runner.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.boot.test.*;
import org.springframework.test.context.junit4.*;
import org.springframework.test.context.web.*;
import org.springframework.test.web.servlet.*;
import org.springframework.test.web.servlet.setup.*;
import org.springframework.web.context.*;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = QuoteApplication.class)
@WebAppConfiguration
public class QuoteControllerTest {

  @Autowired
  private WebApplicationContext wac;

  private MockMvc client;

  @Before
  public void setup() {
    client = MockMvcBuilders.webAppContextSetup(wac).build();
  }

  @Test
  public void getQuotes() throws Exception {
    client
      .perform(get("/quotes"))
      .andExpect(status().isOk())
      .andExpect(content().contentType("application/json;charset=UTF-8"));
  }

}

package io.github.jordao76.quotes;

import static org.hamcrest.Matchers.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

import org.junit.*;
import org.junit.runner.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.boot.test.*;
import org.springframework.test.context.junit4.*;
import org.springframework.test.context.web.*;
import org.springframework.test.web.servlet.*;
import org.springframework.test.web.servlet.setup.*;
import org.springframework.web.context.*;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = QuoteApplication.class)
@WebAppConfiguration
public class QuoteControllerTest {

  @Autowired
  private WebApplicationContext wac;

  private MockMvc client;

  @Before
  public void setup() {
    client = MockMvcBuilders.webAppContextSetup(wac).build();
  }

  @Test
  public void getQuotes() throws Exception {
    client
      .perform(get("/quotes"))
      .andExpect(status().isOk())
      .andExpect(content().contentType("application/json;charset=UTF-8"))
      .andExpect(content().string(containsString("Any sufficiently advanced technology is indistinguishable from magic.")));
  }

}

Check for some JSON content in the test


package org.usfirst.frc.team2503.r2016.component;

import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.SpeedController;

public class Intake extends SpeedControllerComponent {

	public enum IntakeMode {
		UNKNOWN,
		STOPPED,
		INBOUND,
		OUTBOUND,
		FIRE
	}

	public DigitalInput limitSwitch;

	private IntakeMode mode = IntakeMode.UNKNOWN;

	public void setMode(IntakeMode mode) { this.mode = mode; }
	public IntakeMode getMode() { return this.mode; }

	public void tick() {
		switch(mode) {
		case STOPPED:
			this.controller.set(0.0);
			break;

		case INBOUND:
			if(limitSwitch.get()) {
				this.controller.set(0.0);
			} else {
				this.controller.set(1.0);
			}

			break;

		case OUTBOUND:
			this.controller.set(-1.0);
			break;

		case FIRE:
			this.controller.set(1.0);
			break;

		case UNKNOWN:
		default:
			break;
		}
	}

	public Intake(SpeedController controller, DigitalInput limitSwitch) {
		super(controller);

		this.limitSwitch = limitSwitch;
	}

}

package org.usfirst.frc.team2503.r2016.component;

import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.SpeedController;

public class Intake extends SpeedControllerComponent {

	public enum IntakeMode {
		UNKNOWN,
		STOPPED,
		INBOUND,
		OUTBOUND,
		FIRE
	}

	public DigitalInput limitSwitch;

	private IntakeMode mode = IntakeMode.UNKNOWN;

	public void setMode(IntakeMode mode) { this.mode = mode; }
	public IntakeMode getMode() { return this.mode; }

	public void tick() {
		switch(this.mode) {
		case STOPPED:
			this.controller.set(0.0);
			break;

		case INBOUND:
			if(this.limitSwitch.get()) {
				this.controller.set(0.0);
			} else {
				this.controller.set(1.0);
			}

			break;

		case OUTBOUND:
			this.controller.set(-1.0);
			break;

		case FIRE:
			this.controller.set(1.0);
			break;

		case UNKNOWN:
		default:
			break;
		}
	}

	public Intake(SpeedController controller, DigitalInput limitSwitch) {
		super(controller);

		this.limitSwitch = limitSwitch;
	}

}

Use this. notation instead of expecting things to autocomplete to ivs


package com.digistratum.microhost;

import com.digistratum.microhost.Process.MHRunnable;

/**
 * @TODO Add support for receiving, starting, and monitoring multiple MHRunnable's
 */
public class MicroHostApp {

	/**
	 * Constructor
	 *
	 * This should be called from the application main() with an instance of the RestApi; we will
	 * put the RestApi into its own thread and let it run while we monitor. This gives us the
	 * ability to potentially spawn more threads and/or perform additional work as needed while the
	 * RestApi service does its job.
	 *
	 * @param mHRunnable RestApi RestApi instance
	 */
	public MicroHostApp(MHRunnable mHRunnable) {
		// Start and monitor...
		Thread t = new Thread(mHRunnable, "MHRunnable Instance");
		t.start();
		while (mHRunnable.isRunning()) {
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				// Restore the interrupted status
				Thread.currentThread().interrupt();
			}
		}
	}
}

package com.digistratum.microhost;

import com.digistratum.microhost.Process.MHRunnable;

/**
 * @TODO Add support for receiving, starting, and monitoring multiple MHRunnable's
 */
abstract public class MicroHostApp {

	/**
	 * Constructor
	 *
	 * This should be called from the application main() with an instance of the RestApi; we will
	 * put the RestApi into its own thread and let it run while we monitor. This gives us the
	 * ability to potentially spawn more threads and/or perform additional work as needed while the
	 * RestApi service does its job.
	 *
	 * @param mHRunnable RestApi RestApi instance
	 */
	public MicroHostApp(MHRunnable mHRunnable) {
		// Start and monitor...
		Thread t = new Thread(mHRunnable, "MHRunnable Instance");
		t.start();
		while (mHRunnable.isRunning()) {
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				// Restore the interrupted status
				Thread.currentThread().interrupt();
			}
		}
	}
}

Make MHRunnableImpl abstract to force subclassing


package com.devinhartzell.chess.gui;

import javax.swing.JFrame;

public class PawnPromotionWindow extends JFrame {

	private static final long serialVersionUID = -1686304609750241736L;

	public PawnPromotionWindow() {
		getContentPane().setLayout(null);
		setSize(400, 200);
	}

}

package com.devinhartzell.chess.gui;

import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JTextArea;

public class PawnPromotionWindow extends JFrame {

	private static final long serialVersionUID = -1686304609750241736L;

	public PawnPromotionWindow() {
		super("Pawn Promotion");
		getContentPane().setLayout(null);

		JButton btnKnight = new JButton("Knight");
		btnKnight.setBounds(6, 6, 117, 29);
		getContentPane().add(btnKnight);

		JButton btnBishop = new JButton("Bishop");
		btnBishop.setBounds(6, 35, 117, 29);
		getContentPane().add(btnBishop);

		JButton btnRook = new JButton("Rook");
		btnRook.setBounds(6, 63, 117, 29);
		getContentPane().add(btnRook);

		JButton btnQueen = new JButton("Queen");
		btnQueen.setBounds(6, 92, 117, 29);
		getContentPane().add(btnQueen);

		JTextArea info = new JTextArea();
		info.setOpaque(false);
		info.setLineWrap(true);
		info.setText("Since your pawn reached the far end of the board, you may upgrade it to a better piece.");
		info.setBounds(135, 11, 159, 67);
		getContentPane().add(info);
		setSize(315, 155);
		setVisible(true);
	}
}

Add a pawn promotion window with no functionality


//
// $Id: SafeScrollPane.java,v 1.6 2002/11/05 21:03:31 mdb Exp $

package com.threerings.media;

import java.awt.Component;
import java.awt.Point;

import javax.swing.JComponent;
import javax.swing.JScrollPane;
import javax.swing.JViewport;

/**
 * A scroll pane that is safe to use in frame managed views.
 */
public class SafeScrollPane extends JScrollPane
{
    public SafeScrollPane ()
    {
    }

    public SafeScrollPane (Component view)
    {
        super(view);
    }

    protected JViewport createViewport ()
    {
        JViewport vp = new JViewport() {
            public void setViewPosition (Point p) {
                super.setViewPosition(p);
                // simple scroll mode results in setViewPosition causing
                // our view to become invalid, but nothing ever happens to
                // queue up a revalidate for said view, so we have to do
                // it here
                Component c = getView();
                if (c instanceof JComponent) {
                    ((JComponent)c).revalidate();
                }
            }
        };
        vp.setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
        return vp;
    }
}

//
// $Id: SafeScrollPane.java,v 1.7 2003/03/22 01:56:09 mdb Exp $

package com.threerings.media;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;

import javax.swing.JComponent;
import javax.swing.JScrollPane;
import javax.swing.JViewport;

/**
 * A scroll pane that is safe to use in frame managed views.
 */
public class SafeScrollPane extends JScrollPane
{
    public SafeScrollPane ()
    {
    }

    public SafeScrollPane (Component view)
    {
        super(view);
    }

    public SafeScrollPane (Component view, int owidth, int oheight)
    {
        super(view);
        if (owidth != 0 || oheight != 0) {
            _override = new Dimension(owidth, oheight);
        }
    }

    // documentation inherited
    public Dimension getPreferredSize ()
    {
        Dimension d = super.getPreferredSize();
        if (_override != null) {
            if (_override.width != 0) {
                d.width = _override.width;
            }
            if (_override.height != 0) {
                d.height = _override.height;
            }
        }
        return d;
    }

    protected JViewport createViewport ()
    {
        JViewport vp = new JViewport() {
            public void setViewPosition (Point p) {
                super.setViewPosition(p);
                // simple scroll mode results in setViewPosition causing
                // our view to become invalid, but nothing ever happens to
                // queue up a revalidate for said view, so we have to do
                // it here
                Component c = getView();
                if (c instanceof JComponent) {
                    ((JComponent)c).revalidate();
                }
            }
        };
        vp.setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
        return vp;
    }

    protected Dimension _override;
}

Allow preferred width or height to be overridden since it seems that JScrollPane will happily return some insane value when it's wrapping an empty JList.


/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you 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 groovy.transform;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * The Generated annotation is used to mark members that have been generated.
 *
 * @author Andres Almiray
 * @author Jochen Theodorou
 * @author Mark Hoffmann
 */
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Generated {
}

/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you 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 groovy.transform;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * The Generated annotation is used to mark members that have been generated.
 */
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Generated {
}

Remove author tags from javadoc


/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.apache.jorphan.test;

/**
 * Implement this interface to work with the AllTests class. This interface
 * allows AllTests to pass a configuration file to your application before
 * running the junit unit tests.
 *
 * @see AllTests
 * @author Michael Stover (mstover at apache.org)
 * @version $Revision$
 */
public interface UnitTestManager {
	/**
	 * Your implementation will be handed the filename that was provided to
	 * AllTests as a configuration file. It can hold whatever properties you
	 * need to configure your system prior to the unit tests running.
	 *
	 * @param filename
	 */
	public void initializeProperties(String filename);
}

/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.apache.jorphan.test;

/**
 * Implement this interface to work with the AllTests class. This interface
 * allows AllTests to pass a configuration file to your application before
 * running the junit unit tests.
 *
 * @see AllTests
 *
 * N.B. This must be in the main src/ tree (not test/) because it is
 * implemented by JMeterUtils
 */
public interface UnitTestManager {
	/**
	 * Your implementation will be handed the filename that was provided to
	 * AllTests as a configuration file. It can hold whatever properties you
	 * need to configure your system prior to the unit tests running.
	 *
	 * @param filename
	 */
	public void initializeProperties(String filename);
}

Document that this part of the unit test code must remain in src/


package sizebay.catalog.client.model;

import java.util.*;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.*;

@Getter
@Setter
public class Modeling   {

  private Long id;
  private String name;

  private Gender gender;
  private String gMerchantBrandName;
  private String gMerchantAgeGroup;
  private String gMerchantSizeType;

  private TypeEnum type;
  private Long brandId;
  private Long categoryId;
  private List<ModelingSizeMeasures> measures = new ArrayList<>();

  @Getter
  @RequiredArgsConstructor
  public enum TypeEnum {
    PRODUCT("product"),
    BODY("body");

    final private String value;

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

  @Getter
  @RequiredArgsConstructor
  public enum Gender {
    M("M"), F("F"), U("U");

    final private String value;

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

package sizebay.catalog.client.model;

import java.util.*;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.*;

@Getter
@Setter
public class Modeling   {

  private Long id;
  private String name;

  private Gender gender;
  private String gMerchantBrandName;
  private String gMerchantAgeGroup;
  private String gMerchantSizeType;

  private TypeEnum type;
  private Long brandId;
  private Long categoryId;
  private List<ModelingSizeMeasures> measures = new ArrayList<>();

  private Integer strongCategoryTypeId;
  private String strongCategoryTypeName;

  @Getter
  @RequiredArgsConstructor
  public enum TypeEnum {
    PRODUCT("product"),
    BODY("body");

    final private String value;

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

  @Getter
  @RequiredArgsConstructor
  public enum Gender {
    M("M"), F("F"), U("U");

    final private String value;

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

Add type id attribute in modeling