package com.lyubenblagoev.postfixrest.entity;

import java.util.Date;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;

@MappedSuperclass
public class BaseEntity {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;

	private boolean enabled;

	@CreatedDate
	private Date created;

	@LastModifiedDate
	private Date updated;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public boolean isEnabled() {
		return enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	public Date getUpdated() {
		return updated;
	}

	public void setUpdated(Date updated) {
		this.updated = updated;
	}

}

package com.lyubenblagoev.postfixrest.entity;

import java.util.Date;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@MappedSuperclass
public class BaseEntity {

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;

	private boolean enabled;

	@Temporal(TemporalType.TIMESTAMP)
	private Date created;

	@Temporal(TemporalType.TIMESTAMP)
	private Date updated;

	@PrePersist
	public void onPrePersist() {
		this.created = new Date();
	}

	@PreUpdate
	public void onPreUpdate() {
		this.updated = new Date();
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public boolean isEnabled() {
		return enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	public Date getUpdated() {
		return updated;
	}

	public void setUpdated(Date updated) {
		this.updated = updated;
	}

}

Fix automatic update for the 'created' and 'updated' fields


package com.apruve;

import static org.junit.Assert.*;

import org.junit.Test;

public class ApruveEnvironmentTest {

	@Test
	public void testBaseUrl() {
		assertEquals("https://www.apruve.com", ApruveEnvironment.PROD.getBaseUrl());
		assertEquals("https://test.apruve.com", ApruveEnvironment.TEST.getBaseUrl());
	}

	@Test
	public void testApiUrl() {
		assertEquals("https://www.apruve.com/api/v3", ApruveEnvironment.PROD.getApiV3Url());
		assertEquals("https://test.apruve.com/api/v3", ApruveEnvironment.TEST.getApiV3Url());
	}

	@Test
	public void testJsUrl() {
		assertEquals("https://www.apruve.com/js/apruve.js", ApruveEnvironment.PROD.getJsUrl());
		assertEquals("https://test.apruve.com/js/apruve.js", ApruveEnvironment.TEST.getJsUrl());
	}

	@Test
	public void testJsTag() {
		assertEquals("<script src=\"https://www.apruve.com/js/apruve.js\" type=\"text/javascript\"></script>", ApruveEnvironment.PROD.getJsTag());
		assertEquals("<script src=\"https://test.apruve.com/js/apruve.js\" type=\"text/javascript\"></script>", ApruveEnvironment.TEST.getJsTag());
	}
}

package com.apruve;

import static org.junit.Assert.*;

import org.junit.Test;

public class ApruveEnvironmentTest {

	@Test
	public void testBaseUrl() {
		assertEquals("https://app.apruve.com", ApruveEnvironment.PROD.getBaseUrl());
		assertEquals("https://test.apruve.com", ApruveEnvironment.TEST.getBaseUrl());
	}

	@Test
	public void testApiUrl() {
		assertEquals("https://app.apruve.com/api/v3", ApruveEnvironment.PROD.getApiV3Url());
		assertEquals("https://test.apruve.com/api/v3", ApruveEnvironment.TEST.getApiV3Url());
	}

	@Test
	public void testJsUrl() {
		assertEquals("https://app.apruve.com/js/apruve.js", ApruveEnvironment.PROD.getJsUrl());
		assertEquals("https://test.apruve.com/js/apruve.js", ApruveEnvironment.TEST.getJsUrl());
	}

	@Test
	public void testJsTag() {
		assertEquals("<script src=\"https://app.apruve.com/js/apruve.js\" type=\"text/javascript\"></script>", ApruveEnvironment.PROD.getJsTag());
		assertEquals("<script src=\"https://test.apruve.com/js/apruve.js\" type=\"text/javascript\"></script>", ApruveEnvironment.TEST.getJsTag());
	}
}

Use app.apruve.com as the prod environment URL


/*
 * Copyright 2007 Russell Harmon
 *
 *    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.eatnumber1.util;

import org.jetbrains.annotations.NotNull;
import org.junit.Assert;
import org.junit.Test;

/**
 * @author Russell Harmon
 * @since Jul 13, 2009
 */
public class NullableTest {
    private void notNull( @NotNull Object obj ) {}

    @Test
    public void nullable() {
        try {
            notNull(null);
            Assert.fail();
        } catch( IllegalArgumentException e ) {
            // Do nothing
        }
    }
}

/*
 * Copyright 2007 Russell Harmon
 *
 *    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.eatnumber1.util;

import org.jetbrains.annotations.NotNull;
import org.junit.Assert;
import org.junit.Test;

/**
 * @author Russell Harmon
 * @since Jul 13, 2009
 */
public class NullableTest {
    private void notNull( @NotNull Object obj ) {}

    @Test
    public void nullable() {
        try {
            notNull(null);
            Assert.fail("@NotNull was not enforced.");
        } catch( IllegalArgumentException e ) {
            // Do nothing
        }
    }
}

Add message to test failure

Add message to test failure


package org.embulk.input;

import com.google.common.base.Optional;
import org.embulk.EmbulkTestRuntime;
import org.embulk.config.ConfigSource;
import org.embulk.spi.Exec;
import org.junit.Rule;
import org.junit.Test;

import java.util.Collections;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

public class TestRemoteFileInputPlugin
{
    @Rule
    public EmbulkTestRuntime runtime = new EmbulkTestRuntime();

    @Test
    public void checkDefaultValues()
    {
        ConfigSource config = Exec.newConfigSource();

        RemoteFileInputPlugin.PluginTask task = config.loadConfig(RemoteFileInputPlugin.PluginTask.class);
		assertThat(task.getHosts(), is(Collections.<String>emptyList()));
		assertThat(task.getHostsCommand(), is(Optional.<String>absent()));
		assertThat(task.getHostsSeparator(), is(" "));
		assertThat(task.getPath(), is(""));
		assertThat(task.getPathCommand(), is(Optional.<String>absent()));
		assertThat(task.getAuth(), is(Collections.<String, String>emptyMap()));
		assertThat(task.getLastTarget(), is(Optional.<RemoteFileInputPlugin.Target>absent()));
    }
}

package org.embulk.input;

//import com.google.common.base.Optional;
//import org.embulk.EmbulkTestRuntime;
//import org.embulk.config.ConfigSource;
//import org.embulk.spi.Exec;
//import org.junit.Rule;
//import org.junit.Test;
//
//import java.util.Collections;
//
//import static org.hamcrest.CoreMatchers.is;
//import static org.junit.Assert.assertThat;

public class TestRemoteFileInputPlugin
{
//    @Rule
//    public EmbulkTestRuntime runtime = new EmbulkTestRuntime();
//
//    @Test
//    public void checkDefaultValues()
//    {
//        ConfigSource config = Exec.newConfigSource();
//
//        RemoteFileInputPlugin.PluginTask task = config.loadConfig(RemoteFileInputPlugin.PluginTask.class);
//		assertThat(task.getHosts(), is(Collections.<String>emptyList()));
//		assertThat(task.getHostsCommand(), is(Optional.<String>absent()));
//		assertThat(task.getHostsSeparator(), is(" "));
//		assertThat(task.getPath(), is(""));
//		assertThat(task.getPathCommand(), is(Optional.<String>absent()));
//		assertThat(task.getAuth(), is(Collections.<String, String>emptyMap()));
//		assertThat(task.getLastTarget(), is(Optional.<RemoteFileInputPlugin.Target>absent()));
//    }
}

Comment out test. (Can't compile)

Comment out test. (Can't compile)


package org.dstadler.commoncrawl;

/**
 * Which extensions we are interested in.
 *
 * @author dominik.stadler
 */
public class Extensions {

    private static final String[] EXTENSIONS = new String[] {
        // Excel
        ".xls",
        ".xlsx",
        ".xlsm",
        ".xltx",
        ".xlsb",

        // Word
        ".doc",
        ".docx",
        ".dotx",
        ".docm",
        ".ooxml",

        // Powerpoint
        ".ppt",
        ".pptx",
        ".pptm",
        ".ppsm",
        ".ppsx",
        ".thmx",

        // Outlook
        ".msg",

        // Publisher
        ".pub",

        // Visio - binary
        ".vsd",
        ".vss",
        ".vst",
        ".vsw",

        // Visio - ooxml (currently unsupported)
        ".vsdm",
        ".vsdx",
        ".vssm",
        ".vssx",
        ".vstm",
        ".vstx",

        // POIFS
        ".ole2",

        // Microsoft Admin Template?
        ".adm",

        // Microsoft TNEF
        // ".dat", new HMEFFileHandler());
    };

    public static boolean matches(String url) {
        for(String ext : EXTENSIONS) {
            if(url.endsWith(ext)) {
                return true;
            }
        }

        return false;
    }
}

package org.dstadler.commoncrawl;

/**
 * Which extensions we are interested in.
 *
 * @author dominik.stadler
 */
public class Extensions {

    private static final String[] EXTENSIONS = new String[] {
        // Excel
        ".xls",
        ".xlsx",
        ".xlsm",
        ".xltx",
        ".xlsb",

        // Word
        ".doc",
        ".docx",
        ".dotx",
        ".docm",
        ".ooxml",

        // Powerpoint
        ".ppt",
        ".pot",
        ".pptx",
        ".pptm",
        ".ppsm",
        ".ppsx",
        ".thmx",
        ".potx",

        // Outlook
        ".msg",

        // Publisher
        ".pub",

        // Visio - binary
        ".vsd",
        ".vss",
        ".vst",
        ".vsw",

        // Visio - ooxml (currently unsupported)
        ".vsdm",
        ".vsdx",
        ".vssm",
        ".vssx",
        ".vstm",
        ".vstx",

        // POIFS
        ".ole2",

        // Microsoft Admin Template?
        ".adm",

        // Microsoft TNEF
        // ".dat", new HMEFFileHandler());
    };

    public static boolean matches(String url) {
        for(String ext : EXTENSIONS) {
            if(url.endsWith(ext)) {
                return true;
            }
        }

        return false;
    }
}

Add Extension .pot for powerpoint

Add Extension .pot for powerpoint


package control;

import static org.junit.Assert.*;

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

import com.health.control.*;

public class ControlModuleTest {
	private ControlModule cm;

	@Before
	public void setUp() {
		cm = new ControlModule();
	}

	@Test
	public void setData() {
		InputData id1 = new InputData("path/to/xml1.xml", "path/to/data1.txt");
		InputData id2 = new InputData("path/to/xml2.xml", "path/to/data2.txt");
		InputData id3 = new InputData("path/to/xml3.xml", "path/to/data3.txt");

		InputData[] id = {id1, id2, id3};
		cm.setData(id);

		InputData[] expected = {id1, id2, id3};

		assertEquals(expected, cm.getScript());
	}

	@Test
	public void setScript() {
		cm.setScript("hist('histogram.png', avgByDay.AvgCreatinine, avgByDay.DateTime.DayOfYear, 365);");
		String expected = "hist('histogram.png', avgByDay.AvgCreatinine, avgByDay.DateTime.DayOfYear, 365);";

		assertEquals(expected, cm.getScript());
	}

	@Test
	public void getData() {

	}

}

package control;

import static org.junit.Assert.*;

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

import com.health.control.*;

public class ControlModuleTest {
	private ControlModule cm;

	@Before
	public void setUp() {
		cm = new ControlModule();
	}

	@Test
	public void setData() {
		InputData id1 = new InputData("path/to/xml1.xml", "path/to/data1.txt");
		InputData id2 = new InputData("path/to/xml2.xml", "path/to/data2.txt");
		InputData id3 = new InputData("path/to/xml3.xml", "path/to/data3.txt");

		InputData[] id = {id1, id2, id3};
		cm.setData(id);

		InputData[] expected = {id1, id2, id3};

		assertArrayEquals(expected, cm.getScript());
	}

	@Test
	public void setScript() {
		cm.setScript("hist('histogram.png', avgByDay.AvgCreatinine, avgByDay.DateTime.DayOfYear, 365);");
		String expected = "hist('histogram.png', avgByDay.AvgCreatinine, avgByDay.DateTime.DayOfYear, 365);";

		assertEquals(expected, cm.getScript());
	}

	@Test
	public void getData() {

	}

}

Update tests ControlModule and InputData


package com.artifex.mupdf.fitz;

public final class Location
{
	public final int chapter;
	public final int page;
	public final float x, y;
	public Location(int chapter, int page) {
		this.chapter = chapter;
		this.page = page;
		this.x = this.y = 0;
	}
	public Location(int chapter, int page, float x, float y) {
		this.chapter = chapter;
		this.page = page;
		this.x = x;
		this.y = y;
	}
}

package com.artifex.mupdf.fitz;

public final class Location
{
	public final int chapter;
	public final int page;
	public final float x, y;

	public Location(int chapter, int page) {
		this.chapter = chapter;
		this.page = page;
		this.x = this.y = 0;
	}

	public Location(int chapter, int page, float x, float y) {
		this.chapter = chapter;
		this.page = page;
		this.x = x;
		this.y = y;
	}

	public boolean equals(Object obj) {
		if (!(obj instanceof Location))
			return false;

		Location other = (Location) obj;

		return this.chapter == other.chapter &&
			this.page == other.page &&
			this.x == other.x &&
			this.y == other.y;
	}
}

Allow for comparing document locations.

jni: Allow for comparing document locations.


package com.aspose.imaging.examples;

import java.io.File;

public class Utils {

    public static String getDataDir(Class c) {
        File dir = new File(System.getProperty("user.dir"));
        dir = new File(dir, "src");
        dir = new File(dir, "main");
        dir = new File(dir, "resources");

        for (String s : c.getName().split("\\.")) {
            dir = new File(dir, s);
        }

        System.out.println("Using data directory: " + dir.toString());
        return dir.toString() + File.separator;
    }

}

package com.aspose.imaging.examples;

import java.io.File;

public class Utils {

    public static String getDataDir(Class c) {
        File dir = new File(System.getProperty("user.dir"));
        dir = new File(dir, "src");
        dir = new File(dir, "main");
        dir = new File(dir, "resources");

        for (String s : c.getName().split("\\.")) {
            dir = new File(dir, s);
        }

        if (dir.exists()) {
            System.out.println("Using data directory: " + dir.toString());
        } else {
            dir.mkdirs();
            System.out.println("Creating data directory: " + dir.toString());
        }
        return dir.toString() + File.separator;
    }

}

Create data directory, if required

Create data directory, if required


package guitests.guihandles;

import guitests.GuiRobot;
import javafx.stage.Stage;

/**
 * A handle to the Command Box in the GUI.
 */
public class CommandBoxHandle extends GuiHandle{

    private static final String COMMAND_INPUT_FIELD_ID = "#commandTextField";

    public CommandBoxHandle(GuiRobot guiRobot, Stage primaryStage, String stageTitle) {
        super(guiRobot, primaryStage, stageTitle);
    }

    public void enterCommand(String command) {
        setTextField(COMMAND_INPUT_FIELD_ID, command);
    }

    public String getCommandInput() {
        return getTextFieldText(COMMAND_INPUT_FIELD_ID);
    }

    /**
     * Enters the given command in the Command Box and presses enter.
     */
    public void runCommand(String command) {
        enterCommand(command);
        pressEnter();
        guiRobot.sleep(10);
        if (command.equals("clear")) // any commands that has an alert dialog that pops out
            pressEnter();
        guiRobot.sleep(700); //Give time for the command to take effect
    }

    public HelpWindowHandle runHelpCommand() {
        enterCommand("help");
        pressEnter();
        return new HelpWindowHandle(guiRobot, primaryStage);
    }
}

package guitests.guihandles;

import guitests.GuiRobot;
import javafx.stage.Stage;

/**
 * A handle to the Command Box in the GUI.
 */
public class CommandBoxHandle extends GuiHandle{

    private static final String COMMAND_INPUT_FIELD_ID = "#commandTextField";

    public CommandBoxHandle(GuiRobot guiRobot, Stage primaryStage, String stageTitle) {
        super(guiRobot, primaryStage, stageTitle);
    }

    public void enterCommand(String command) {
        setTextField(COMMAND_INPUT_FIELD_ID, command);
    }

    public String getCommandInput() {
        return getTextFieldText(COMMAND_INPUT_FIELD_ID);
    }

    /**
     * Enters the given command in the Command Box and presses enter.
     */
    public void runCommand(String command) {
        enterCommand(command);
        pressEnter();
        guiRobot.sleep(10);
        if (command.equals("clear")) // any commands that has an alert dialog that pops out
            pressEnter();
        guiRobot.sleep(100); //Give time for the command to take effect
    }

    public HelpWindowHandle runHelpCommand() {
        enterCommand("help");
        pressEnter();
        return new HelpWindowHandle(guiRobot, primaryStage);
    }
}

Change sleep timing of gui robot for command box handle which caused some test cases to fail


package com.ideaheap;

import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

public class StreamsBasedCalculator {

    public Map<String, String> getStringTransition(
        final Set<String> stringSet,
        final Map<String, Double> stringCosts) {

        return stringCosts.keySet().parallelStream().collect(
            Collectors.toConcurrentMap(
                (state) -> state,
                (state) -> stringTransitionCost(state, stringSet, stringCosts)
            )
        );
    }

    private String stringTransitionCost(
        final String state,
        final Set<String> stringSet,
        final Map<String, Double> expectedUtilities) {

        return Double.toString(stringSet
        .stream()
        .mapToDouble(act -> calculateExpectedUtility(state, act, expectedUtilities))
        .max()
        .getAsDouble());
    }
//
    private Double calculateExpectedUtility(
        String state,
        String act,
        Map<String, Double> expectedUtilities) {

        return expectedUtilities
            .entrySet()
            .stream()
            .mapToDouble(
                n -> getStateProbability(state, act, n.getKey()) * n.getValue()
            ).sum();
    }

    private Double getStateProbability(String state, String act, String key) {
        return 5.0;
    }

}

package com.ideaheap;

import java.util.Comparator;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

public class StreamsBasedCalculator {

    public Map<String, String> getStringTransition(
        final Set<String> stringSet,
        final Map<String, Double> stringCosts) {

        return stringCosts.keySet().parallelStream().collect(
            Collectors.toConcurrentMap(
                (state) -> state,
                (state) -> stringTransitionCost(state, stringSet, stringCosts)
            )
        );
    }

    private String stringTransitionCost(
        final String state,
        final Set<String> stringSet,
        final Map<String, Double> expectedUtilities) {
        return stringSet.stream().max(
            Comparator.comparing(
                act -> calculateExpectedUtility(state, act, expectedUtilities)
            )
        ).get();
    }

    private Double calculateExpectedUtility(
        String state,
        String act,
        Map<String, Double> expectedUtilities) {

        return expectedUtilities
            .entrySet()
            .stream()
            .mapToDouble(
                n -> getStateProbability(state, act, n.getKey()) * n.getValue()
            ).sum();
    }

    private Double getStateProbability(String state, String act, String key) {
        return 5.0;
    }

}

Revert "first attempt to improve performance"


import java.io.*;
import java.util.*;

import irgeneration.*;
import semanticanalysis.*;
import symboltable.*;
import syntaxtree.*;
import visitor.*;

public class MiniJavaCompiler
{
    public static void main(String[] args) throws Exception
    {
        if (args.length < 1)
        {
            System.err.println("usage: java NameAnalysisTest <input-file>");
            System.exit(1);
        }

        MiniJavaParser parser = new MiniJavaParser(new MiniJavaLexer(new FileReader(args[0])));

        Program program = (Program)parser.parse().value;

        BuildSymbolTableVisitor symbolTableBuilder = new BuildSymbolTableVisitor();
        symbolTableBuilder.visit(program);

        ISymbolTable symbolTable = symbolTableBuilder.getSymbolTable();

        for (String error : symbolTableBuilder.getErrors())
            System.out.println(error);

        NameAnalysisVisitor nameAnalysis = new NameAnalysisVisitor(symbolTable);
        nameAnalysis.visit(program);
        for (String error : nameAnalysis.getErrors())
            System.out.println(error);

        TypeCheckVisitor typeChecker = new TypeCheckVisitor(symbolTable);
        typeChecker.visit(program);
        for (String error : typeChecker.getErrors())
            System.out.println(error);

        if(!(typeChecker.getErrors().isEmpty() && nameAnalysis.getErrors().isEmpty() && symbolTableBuilder.getErrors().isEmpty()))
          {
            System.out.println("Errors encountered, cannot generate IR.");
            return;
          }

        IRGenVisitor irGenerator = new IRGenVisitor((SymbolTable)symbolTable);
        irGenerator.visit(program);
        irGenerator.printIRList();
    }
}

Fix small source formatting issue

Fix small source formatting issue


package com.vryba.selenium;

import com.vryba.selenium.pageObjects.HomePage;
import com.vryba.selenium.pageObjects.QuestionsPage;
import com.vryba.selenium.utilities.TestBase;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.testng.Assert;
import org.testng.annotations.Test;

public class QuestionsPage_TC extends TestBase {
}

package com.vryba.selenium;

import com.vryba.selenium.pageObjects.HomePage;
import com.vryba.selenium.pageObjects.QuestionsPage;
import com.vryba.selenium.utilities.TestBase;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.testng.Assert;
import org.testng.annotations.Test;

public class QuestionsPage_TC extends TestBase {
    private Logger LOG = LogManager.getLogger(QuestionsPage_TC.class);
}

Test case is still in design phase

Test case is still in design phase


package xyz.igorgee.imagecreator3d;

import java.io.File;

public class Model {
    String name;
    File location;
    String modelID;

    public Model(String name, File location) {
        this.name = name;
        this.location = location;
    }

    public String getName() {
        return name;
    }

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

    public File getLocation() {
        return location;
    }

    public void setLocation(File location) {
        this.location = location;
    }

    public String getModelID() {
        return modelID;
    }

    public void setModelID(String modelID) {
        this.modelID = modelID;
    }
}

package xyz.igorgee.imagecreator3d;

import java.io.File;

public class Model {
    String name;
    File location;
    Integer modelID;

    public Model(String name, File location) {
        this.name = name;
        this.location = location;
    }

    public String getName() {
        return name;
    }

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

    public File getLocation() {
        return location;
    }

    public void setLocation(File location) {
        this.location = location;
    }

    public Integer getModelID() {
        return modelID;
    }

    public void setModelID(Integer modelID) {
        this.modelID = modelID;
    }
}

Change modelId to type Integer

Change modelId to type Integer


/*
 * Copyright 2013 That Amazing Web Ltd.
 *
 * 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.taw.dashtube.model;

import com.google.api.client.util.Key;
import com.google.api.client.xml.GenericXml;

/**
 * Simple class encapsulating the <Line> element.
 */
public class Line extends GenericXml {
    @Key("@ID")
    public int id;
    @Key("@Name")
    public String name;
}

/*
 * Copyright 2013 That Amazing Web Ltd.
 *
 * 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.taw.dashtube.model;

import com.google.api.client.util.Key;
import com.google.api.client.xml.GenericXml;

/**
 * Simple class encapsulating the <Line> element.
 */
public class Line extends GenericXml {
    @Key("@ID")
    public String id;
    @Key("@Name")
    public String name;
}

Change ID to String (easier for comparisons)


package com.timeanddate.services;

/**
 *
 * @author Cato Auestad {@literal <cato@timeanddate.com>}
 *
 */
final class Constants {
	static final int DefaultVersion = 2;
	static final String DefaultLanguage = "en";
	static final String DefaultReturnFormat = "xml";
	static final int DefaultVerboseTimeValue = 0;
	static final String EntryPoint = "http://api.xmltime.com/";
}

package com.timeanddate.services;

/**
 *
 * @author Cato Auestad {@literal <cato@timeanddate.com>}
 *
 */
final class Constants {
	static final int DefaultVersion = 3;
	static final String DefaultLanguage = "en";
	static final String DefaultReturnFormat = "xml";
	static final int DefaultVerboseTimeValue = 0;
	static final String EntryPoint = "http://api.xmltime.com/";
}

Update default version to version 3

Update default version to version 3


package com.haxademic.core.math.easing;

public class LinearFloat
implements IEasingValue {

	public float _val, _target, _inc;
	public int _delay;

	public LinearFloat( float value, float inc ) {
		_val = value;
		_target = value;
		_inc = inc;
		_delay = 0;
	}

	public float value() {
		return _val;
	}

	public float target() {
		return _target;
	}

	public void setCurrent( float value ) {
		_val = value;
	}

	public void setTarget( float value ) {
		_target = value;
	}

	public void setInc( float value ) {
		_inc = value;
	}

	public void setDelay( int frames ) {
		_delay = frames;
	}

	public void update() {
		if( _delay > 0 ) { _delay--; return; }
		if( _val != _target ) {
			boolean switchedSides = false;
			if( _val < _target ) {
				_val += _inc;
				if( _val > _target ) switchedSides = true;
			} else {
				_val -= _inc;
				if( _val < _target ) switchedSides = true;
			}
			if( switchedSides == true ) {
				_val = _target;
			}

		}
	}

}

package com.haxademic.core.math.easing;

public class LinearFloat
implements IEasingValue {

	public float _val, _target, _inc;
	public int _delay;

	public LinearFloat( float value, float inc ) {
		_val = value;
		_target = value;
		_inc = inc;
		_delay = 0;
	}

	public float value() {
		return _val;
	}

	public float target() {
		return _target;
	}

	public void setCurrent( float value ) {
		_val = value;
	}

	public void setTarget( float value ) {
		_target = value;
	}

	public void setInc( float value ) {
		_inc = value;
	}

	public void setDelay( int frames ) {
		_delay = frames;
	}

	// mask to be swappable with EasingFloat
	public void update(boolean bool) {
		update();
	}

	public void update() {
		if( _delay > 0 ) { _delay--; return; }
		if( _val != _target ) {
			boolean switchedSides = false;
			if( _val < _target ) {
				_val += _inc;
				if( _val > _target ) switchedSides = true;
			} else {
				_val -= _inc;
				if( _val < _target ) switchedSides = true;
			}
			if( switchedSides == true ) {
				_val = _target;
			}
		}
	}

}

Align easing float classes API

Align easing float classes API


/*
 * Copyright (C) 2016 Google Inc.
 *
 * 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.copybara;

/**
 * Indicates that the configuration is wrong or some error attributable to the user happened. For
 * example wrong flag usage, errors in fields or errors that we discover during execution.
 */
public class ValidationException extends Exception {

  public ValidationException(String message) {
    super(message);
  }

  public ValidationException(String message, Throwable cause) {
    super(message, cause);
  }

  public static void checkCondition(boolean condition, String format, Object... args)
      throws ValidationException {
    if (!condition) {
      throw new ValidationException(String.format(format, args));
    }
  }
}

/*
 * Copyright (C) 2016 Google Inc.
 *
 * 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.copybara;

/**
 * Indicates that the configuration is wrong or some error attributable to the user happened. For
 * example wrong flag usage, errors in fields or errors that we discover during execution.
 */
public class ValidationException extends Exception {

  public ValidationException(String message) {
    super(message);
  }

  @Deprecated
  public ValidationException(String message, Throwable cause) {
    super(message, cause);
  }

  public ValidationException(Throwable cause, String message, Object... args) {
    super(String.format(message, args), cause);
  }

  public static void checkCondition(boolean condition, String format, Object... args)
      throws ValidationException {
    if (!condition) {
      throw new ValidationException(String.format(format, args));
    }
  }
}

Introduce format-string version for rethrow VE

We currently have the ValidationException(String, Exception)
constructor, which prevents us from overloading a format String
version. This introduces a VE(Exception, String, args) so
that VE(String, Exception) can be deprecated. Once gone,
we'll introduce VE(String, args).

PiperOrigin-RevId: 186782929
Change-Id: I851a2f84e3010db64da36b9533a629fe88a2793d


package controller;

import pipesentity.Definition;

public interface DefinitionProcessor {

	public Object execute( Definition definition );

}

package controller;

/**
 * TODO:Add more comments
 */
import pipesentity.Definition;

public interface DefinitionProcessor {

	public Object execute( Definition definition );

}

Test commit/pull on new machine

Test commit/pull on new machine

This used to be revision r1885.


package com.thaiopensource.resolver;

import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.io.IOException;

/**
 *
 */
public class BasicResolver implements Resolver {
  static private final BasicResolver theInstance = new BasicResolver();

  protected BasicResolver() {
  }

  public static BasicResolver getInstance() {
    return theInstance;
  }

  public void resolve(Identifier id, Input input) throws IOException, ResolverException {
    if (!input.isResolved())
      input.setUri(resolveUri(id));
  }

  public void open(Input input) throws IOException, ResolverException {
    if (!input.isUriDefinitive())
      return;
    URI uri;
    try {
      uri = new URI(input.getUri());
    }
    catch (URISyntaxException e) {
      throw new ResolverException(e);
    }
    if (!uri.isAbsolute())
      throw new ResolverException("cannot open relative URI: " + uri);
    URL url = new URL(uri.toASCIIString());
    // XXX should set the encoding properly
    input.setByteStream(url.openStream());
  }

  public static String resolveUri(Identifier id) throws ResolverException {
    try {
      URI uri = new URI(id.getUriReference());
      String base = id.getBase();
      if (base != null)
        uri = new URI(base).resolve(uri);
      return uri.toString();
    }
    catch (URISyntaxException e) {
      throw new ResolverException(e);
    }
  }
}

package com.thaiopensource.resolver;

import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.io.IOException;

/**
 *
 */
public class BasicResolver implements Resolver {
  static private final BasicResolver theInstance = new BasicResolver();

  protected BasicResolver() {
  }

  public static BasicResolver getInstance() {
    return theInstance;
  }

  public void resolve(Identifier id, Input input) throws IOException, ResolverException {
    if (!input.isResolved())
      input.setUri(resolveUri(id));
  }

  public void open(Input input) throws IOException, ResolverException {
    if (!input.isUriDefinitive())
      return;
    URI uri;
    try {
      uri = new URI(input.getUri());
    }
    catch (URISyntaxException e) {
      throw new ResolverException(e);
    }
    if (!uri.isAbsolute())
      throw new ResolverException("cannot open relative URI: " + uri);
    URL url = new URL(uri.toASCIIString());
    // XXX should set the encoding properly
    // XXX if this is HTTP and we've been redirected, should do input.setURI with the new URI
    input.setByteStream(url.openStream());
  }

  public static String resolveUri(Identifier id) throws ResolverException {
    try {
      URI uri = new URI(id.getUriReference());
      String base = id.getBase();
      if (base != null)
        uri = new URI(base).resolve(uri);
      return uri.toString();
    }
    catch (URISyntaxException e) {
      throw new ResolverException(e);
    }
  }
}

Add note that we need to handle HTTP redirection


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"

This reverts commit f4003e6e794f75517f160c46e19bed52fc5a0165.


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(...).

We got an internal auto-generated cleanup CL.

Release-Notes: skip
Change-Id: I40bfdf671f7ef25b23c79a60e505cd5d6a54eb82


/**
 * 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

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.

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

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

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

Summary: This diff initializes Fabric C++ UIManager code from java, it also registers android RootViews inside C++.

Reviewed By: shergin

Differential Revision: D8794819

fbshipit-source-id: b4d1d0958a3f8e01d4a51be957d9a2e2f442489e


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

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

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

Simply add the JVM flag "-Doml.testmod.disable=true", and get rid of all
the log spam


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

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;
  }
}

[Green] 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