/**
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
 */
package com.codeup.movies.console;

import com.codeup.console.Console;
import com.codeup.validation.NonEmptyString;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public class CategoriesConsoleTest {

    @Test
    public void it_accepts_a_valid_category_name() {
        String categoryName = "action";
        when(console.promptForText(anyString(), any(NonEmptyString.class)))
            .thenReturn(categoryName)
        ;
        assertThat(categoriesConsole.askForCategoryName(), is(categoryName));
    }

    @Before
    public void configureConsole() {
        categoriesConsole = new CategoriesConsole(console);
    }

    @Mock
    private Console console;
    private CategoriesConsole categoriesConsole;
}

/**
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
 */
package com.codeup.movies.console;

import com.codeup.console.Console;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;

import java.io.ByteArrayInputStream;
import java.io.PrintStream;
import java.util.Scanner;

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

@RunWith(MockitoJUnitRunner.class)
public class CategoriesConsoleTest {
    @Test
    public void it_accepts_a_valid_category_name() {
        console = aConsoleWithInput(categoryName);

        assertThat(console.askForCategoryName(), is(equalTo(categoryName)));
    }

    @Test
    public void it_keeps_prompting_until_a_valid_name_is_given() {
        console = aConsoleWithInput(emptyText, emptyText, categoryName);

        assertThat(console.askForCategoryName(), is(equalTo(categoryName)));
    }

    private CategoriesConsole aConsoleWithInput(String... userInput) {
        ByteArrayInputStream input = new ByteArrayInputStream(
            String.join("\n", userInput).getBytes()
        );
        return new CategoriesConsole(new Console(
            new Scanner(input).useDelimiter("\n"),
            output
        ));
    }

    private CategoriesConsole console;

    private final String categoryName = "action";
    private final String emptyText = "    ";

    @Mock
    private PrintStream output;
}

Add test to verify that the console prompts more than once if needed.


package se.ericthelin.fractions;

import org.junit.Test;

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

public class GreatestCommonDivisorTest {

	@Test
	public void returnsFirstWhenSecondIsZero() {
		assertThat(GreatestCommonDivisor.of(6, 0), is(6));
	}

	@Test
	public void returnsSecondWhenFirstIsZero() {
		assertThat(GreatestCommonDivisor.of(0, 4), is(4));
	}

	@Test
	public void returnsGreatestCommonDivisorOfFirstAndSecond() {
		assertThat(GreatestCommonDivisor.of(6, 4), is(2));
	}

	@Test
	public void acceptsArgumentsInReverseOrder() {
		assertThat(GreatestCommonDivisor.of(4, 6), is(2));
	}

	@Test
	public void acceptsNegativeFirstArgument() {
		assertThat(GreatestCommonDivisor.of(-6, 4), is(-2));
	}

	@Test
	public void acceptsNegativeSecondArgument() {
		assertThat(GreatestCommonDivisor.of(6, -4), is(2));
	}

	@Test
	public void acceptsBothArgumentsNegative() {
		assertThat(GreatestCommonDivisor.of(-6, -4), is(-2));
	}
}

package se.ericthelin.fractions;

import org.junit.Test;

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

public class GreatestCommonDivisorTest {

	@Test
	public void returnsFirstWhenSecondIsZero() {
		assertThat(GreatestCommonDivisor.of(6, 0), is(6));
	}

	@Test
	public void returnsSecondWhenFirstIsZero() {
		assertThat(GreatestCommonDivisor.of(0, 4), is(4));
	}

	@Test
	public void returnsGreatestCommonDivisorOfFirstAndSecond() {
		assertThat(GreatestCommonDivisor.of(6, 4), is(2));
	}

	@Test
	public void acceptsArgumentsInReverseOrder() {
		assertThat(GreatestCommonDivisor.of(4, 6), is(2));
	}

	@Test
	public void acceptsNegativeFirstArgument() {
		assertThat(GreatestCommonDivisor.of(-6, 4), is(-2));
	}

	@Test
	public void acceptsNegativeSecondArgument() {
		assertThat(GreatestCommonDivisor.of(6, -4), is(2));
	}

	@Test
	public void acceptsBothArgumentsNegative() {
		assertThat(GreatestCommonDivisor.of(-6, -4), is(-2));
	}

	@Test
	public void canComputeGreatestCommonDivisorOfLargeArguments() {
		assertThat(GreatestCommonDivisor.of(1071, 462), is(21));
	}
}

Check that GreatestCommonDivisor handles large numbers


package com.myyearbook.hudson.plugins.confluence;

import java.net.URI;
import java.util.logging.Logger;

/**
 * Utility methods
 *
 * @author Joe Hansche <jhansche@myyearbook.com>
 */
public class Util {
    private static final Logger LOGGER = Logger.getLogger(Util.class.getName());

    /** Relative path to resolve the XmlRpc endpoint URL */
    private static final String XML_RPC_URL_PATH = "/rpc/xmlrpc";

    /** Relative path to resolve the SOAP endpoint URL */
    private static final String SOAP_URL_PATH = "/rpc/soap-axis/confluenceservice-v1";

    /**
     * Convert a generic Confluence URL into the XmlRpc endpoint URL
     *
     * @param url
     * @return
     * @see #XML_RPC_URL_PATH
     */
    public static String confluenceUrlToXmlRpcUrl(String url) {
	URI uri = URI.create(url);
	return uri.resolve(uri.getPath() + XML_RPC_URL_PATH).normalize().toString();
    }

    /**
     * Convert a generic Confluence URL into the SOAP endpoint URL
     *
     * @param url
     * @return
     * @see #SOAP_URL_PATH
     */
    public static String confluenceUrlToSoapUrl(String url) {
	URI uri = URI.create(url);
	return uri.resolve(uri.getPath() + SOAP_URL_PATH).normalize().toString();
    }
}

package com.myyearbook.hudson.plugins.confluence;

import java.net.URI;

/**
 * Utility methods
 *
 * @author Joe Hansche <jhansche@myyearbook.com>
 */
public class Util {
    /** Relative path to resolve the XmlRpc endpoint URL */
    private static final String XML_RPC_URL_PATH = "rpc/xmlrpc";

    /** Relative path to resolve the SOAP endpoint URL */
    private static final String SOAP_URL_PATH = "rpc/soap-axis/confluenceservice-v1";

    /**
     * Convert a generic Confluence URL into the XmlRpc endpoint URL
     *
     * @param url
     * @return
     * @see #XML_RPC_URL_PATH
     */
    public static String confluenceUrlToXmlRpcUrl(String url) {
        URI uri = URI.create(url);
        return uri.resolve(XML_RPC_URL_PATH).normalize().toString();
    }

    /**
     * Convert a generic Confluence URL into the SOAP endpoint URL
     *
     * @param url
     * @return
     * @see #SOAP_URL_PATH
     */
    public static String confluenceUrlToSoapUrl(String url) {
        URI uri = URI.create(url);
        return uri.resolve(SOAP_URL_PATH).normalize().toString();
    }
}

Fix bug with GH-1 for root-installations.


package uk.ac.ebi.biosamples.model.util;

import java.util.concurrent.atomic.AtomicInteger;

public class ExecutionInfo {
    private AtomicInteger submitted;
    private AtomicInteger completed;
    private AtomicInteger error;

    public ExecutionInfo() {
        submitted = new AtomicInteger(0);
        completed = new AtomicInteger(0);
        error = new AtomicInteger(0);
    }

    public void incrementSubmitted(int value) {
        int oldValue = submitted.get();
        submitted.set(oldValue + value);
    }

    public void incrementCompleted(int value) {
        int oldValue = completed.get();
        completed.set(oldValue + value);
    }

    public void incrementError(int value) {
        int oldValue = error.get();
        error.set(oldValue + value);
    }

    public int getCompleted() {
        return completed.get();
    }

    public int getSubmitted() {
        return submitted.get();
    }

    public int getErrors() {
       return error.get();
    }
}

package uk.ac.ebi.biosamples.model.util;

import java.util.concurrent.atomic.AtomicInteger;

public class ExecutionInfo {
    private final AtomicInteger submitted;
    private final AtomicInteger completed;
    private final AtomicInteger error;

    public ExecutionInfo() {
        submitted = new AtomicInteger(0);
        completed = new AtomicInteger(0);
        error = new AtomicInteger(0);
    }

    public void incrementSubmitted(int value) {
        submitted.getAndAdd(value);
    }

    public void incrementCompleted(int value) {
        completed.getAndAdd(value);
    }

    public void incrementError(int value) {
        error.getAndAdd(value);
    }

    public int getCompleted() {
        return completed.get();
    }

    public int getSubmitted() {
        return submitted.get();
    }

    public int getErrors() {
       return error.get();
    }
}

Use atomic operation to increment the execution stats values


package com.thegongoliers.pathFollowing;

import edu.wpi.first.wpilibj.command.Command;

public abstract class PathTaskCommand extends Command {

    protected SmartDriveTrainSubsystem drivetrain;

    public PathTaskCommand(SmartDriveTrainSubsystem drivetrain){
        requires(drivetrain);
        this.drivetrain = drivetrain;
    }

    @Override
    abstract protected void execute();

    @Override
    abstract protected boolean isFinished();
}

package com.thegongoliers.pathFollowing;

import edu.wpi.first.wpilibj.command.Command;

public abstract class PathTaskCommand extends Command {

    protected SmartDriveTrainSubsystem drivetrain;

    public PathTaskCommand(SmartDriveTrainSubsystem drivetrain){
        requires(drivetrain);
        this.drivetrain = drivetrain;
    }

    @Override
    abstract protected void execute();

    @Override
    abstract protected boolean isFinished();

    @Override
    protected void end() {
        drivetrain.stop();
    }

    @Override
    protected void interrupted() {
        drivetrain.stop();
    }
}

Make drivetrain stop at end of path


/*
 * Copyright 2015 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.gwt.junit.tools;

import junit.framework.TestSuite;

/**
 * This is a slimmed down version of GWTTestSuite, so that we can compile and run GWT's emul
 * tests in a JRE.
 */
public class GWTTestSuite extends TestSuite {

  public GWTTestSuite() {
  }

  public GWTTestSuite(String name) {
  }
}

/*
 * Copyright 2015 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.gwt.junit.tools;

/**
 * This is a slimmed down version of GWTTestSuite, so that we can compile and run GWT's emul tests
 * in a JRE.
 */
public class GWTTestSuite {

  public GWTTestSuite() {
  }

  public GWTTestSuite(String name) {
  }
}

Remove more code from TestCase Remove TestResult Remove TestSuite Remove Test


package com.natpryce.worktorule.issues.github;

import org.junit.Test;

import java.io.IOException;

import static org.junit.Assert.assertFalse;

public class GitHubIssuesTest {
    GitHubIssues issues = new GitHubIssues("npryce", "worktorule");

    @Test
    public void closedIssue() throws IOException {
        assertFalse(issues.isOpen("1"));
    }
}

package com.natpryce.worktorule.issues.github;

import org.junit.Test;

import java.io.IOException;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class GitHubIssuesTest {
    GitHubIssues issues = new GitHubIssues("npryce", "worktorule");

    @Test
    public void closedIssue() throws IOException {
        assertFalse(issues.isOpen("1"));
    }

    @Test
    public void openIssue() throws IOException {
        assertTrue(issues.isOpen("2"));
    }
}

Test for open github issue


package org.genericsystem.reactor;

public class ReactorStatics {

	public static final String BACKGROUND = "background";
	public static final String CHECKED = "checked";
	public static final String DISABLED = "disabled";
}

package org.genericsystem.reactor;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Base64;

public class ReactorStatics {

	public static final String BACKGROUND = "background";
	public static final String CHECKED = "checked";
	public static final String DISABLED = "disabled";

	public static <T> T fromString(String s) {
		byte[] data = Base64.getDecoder().decode(s);
		ObjectInputStream ois;
		try {
			ois = new ObjectInputStream(
					new ByteArrayInputStream(data));
			Object o = ois.readObject();
			ois.close();
			return (T) o;
		} catch (IOException | ClassNotFoundException e) {
			throw new IllegalStateException(e);
		}
	}

	public static String toString(Serializable o) {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		ObjectOutputStream oos;
		try {
			oos = new ObjectOutputStream(baos);
			oos.writeObject(o);
			oos.close();
		} catch (IOException e) {
			return null;
		}
		return Base64.getEncoder().encodeToString(baos.toByteArray());
	}
}

Add two methods for serialize/deserialize lambda in strings


package com.kiselev.reflection.ui.impl.exception;

import java.lang.reflect.Executable;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

public class ExceptionUtils {

    public String getExceptions(Executable executable) {
        String exceptions = "";

        List<String> exceptionTypes = new ArrayList<>();

        for (Type type : executable.getGenericExceptionTypes()) {
            exceptionTypes.add(Class.class.cast(type).getSimpleName());
        }

        if (!exceptionTypes.isEmpty()) {
            exceptions += " throws " + String.join(", ", exceptionTypes);
        }

        return exceptions;
    }
}

package com.kiselev.reflection.ui.impl.exception;

import com.kiselev.reflection.ui.impl.generic.GenericsUtils;

import java.lang.reflect.Executable;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

public class ExceptionUtils {

    public String getExceptions(Executable executable) {
        String exceptions = "";

        List<String> exceptionTypes = new ArrayList<>();

        for (Type type : executable.getGenericExceptionTypes()) {
            exceptionTypes.add(new GenericsUtils().resolveType(type));
        }

        if (!exceptionTypes.isEmpty()) {
            exceptions += " throws " + String.join(", ", exceptionTypes);
        }

        return exceptions;
    }
}

Revert another one missed fix


package es.tododev.auth.server.provider;

import java.io.IOException;

import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
import javax.ws.rs.ext.Provider;

@Provider
public class AllowCrossDomain implements ContainerResponseFilter {

	@Override
	public void filter(ContainerRequestContext request, ContainerResponseContext response) throws IOException {
		response.getHeaders().add("Access-Control-Allow-Origin", "*");
		response.getHeaders().add("Access-Control-Allow-Headers", "origin, content-type, accept, authorization");
		response.getHeaders().add("Access-Control-Allow-Credentials", "true");
		response.getHeaders().add("Access-Control-Allow-Methods", "GET, OPTIONS, HEAD");
	}

}

package es.tododev.auth.server.provider;

import java.io.IOException;

import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
import javax.ws.rs.ext.Provider;

@Provider
public class AllowCrossDomain implements ContainerResponseFilter {

	@Override
	public void filter(ContainerRequestContext request, ContainerResponseContext response) throws IOException {
		response.getHeaders().add("Access-Control-Allow-Origin", "*");
		response.getHeaders().add("Access-Control-Allow-Headers", "origin, content-type, accept, authorization");
		response.getHeaders().add("Access-Control-Allow-Credentials", "true");
		response.getHeaders().add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS, HEAD");
	}

}

Allow cross origin POST, DELETE, PUT


/**
 * Copyright (C) 2009-2013 Simonsoft Nordic AB
 *
 * 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 se.simonsoft.cms.item.commit;

import se.simonsoft.cms.item.CmsItemLock;
import se.simonsoft.cms.item.CmsItemPath;
import se.simonsoft.cms.item.CmsRepository;

public class CmsItemLockedException extends RuntimeException {

	private static final long serialVersionUID = 1L;

	public CmsItemLockedException(CmsRepository repository, CmsItemPath path) {
		super("Item is locked at path " + path);
	}

	public CmsItemLockedException(CmsRepository repository, CmsItemPath path, CmsItemLock lock) {
		super("Item is locked by user " + lock.getOwner() + " at path " + path);
	}

}

/**
 * Copyright (C) 2009-2013 Simonsoft Nordic AB
 *
 * 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 se.simonsoft.cms.item.commit;

import se.simonsoft.cms.item.CmsItemLock;
import se.simonsoft.cms.item.CmsItemPath;
import se.simonsoft.cms.item.CmsRepository;

public class CmsItemLockedException extends RuntimeException {

	private static final long serialVersionUID = 1L;

	public CmsItemLockedException(CmsRepository repository, CmsItemPath path) {
		super("Item is already locked at path " + path);
	}

	public CmsItemLockedException(CmsRepository repository, CmsItemPath path, CmsItemLock lock) {
		super("Item is already locked by user " + lock.getOwner() + " at path " + path);
	}

}

Clarify error message when item is already locked.


package com.herocc.bukkit.core.commands;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

import com.herocc.bukkit.core.Core;

public class CommandFakeblock implements CommandExecutor {
  private final Core plugin = Core.getPlugin();

  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (cmd.getName().equalsIgnoreCase("fakeblock")) {
    sender.sendMessage("Testing..");
  }

}

package com.herocc.bukkit.core.commands;

import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import com.herocc.bukkit.core.Core;

import net.md_5.bungee.api.ChatColor;

public class CommandFakeblock implements CommandExecutor {
	private final Core plugin = Core.getPlugin();

	@SuppressWarnings("deprecation")
	@Override
	public boolean onCommand(CommandSender sender, Command cmd, String label, String[] arg) {
		if (cmd.getName().equalsIgnoreCase("fakeblock")) {
	        if (sender.hasPermission("core.head.get")) {
	        	Player player = (Player) sender;
	        	player.sendBlockChange(player.getLocation(), Material.WOOL, (byte) 0);
	        	sender.sendMessage("The block has changed!");
	        } else {
	        	sender.sendMessage(ChatColor.RED + "Sorry, You do not have permission to use this command!");
	        }
		}
		return false;
	}

}

Add more functions to this command.


package de.philipp1994.lunch.common;

import java.io.Serializable;

public class LunchMenuItem implements Serializable {

	private static final long serialVersionUID = -1796231509545846611L;
	private final String itemName;
	private final double price;

	public static final double PRICE_UNKOWN = -1;

	public LunchMenuItem(String itemName, double price) {
		super();
		this.itemName = itemName;
		this.price = price;
	}

	public String getItemName() {
		return itemName;
	}

	public double getPrice() {
		return price;
	}

	@Override
	public String toString() {
		return "LunchMenuItem [itemName=" + itemName + ", price=" + price + "]";
	}
}

package de.philipp1994.lunch.common;

import java.io.Serializable;

public class LunchMenuItem implements Serializable {

	private static final long serialVersionUID = -1796231509545846611L;
	private final String itemName, comment;
	private final double price;

	public static final double PRICE_UNKOWN = -1;

	public LunchMenuItem(String itemName, double price) {
		this.itemName = itemName;
		this.price = price;
		this.comment = null;
	}

	public LunchMenuItem(String itemName, double price, String comment) {
		this.itemName = itemName;
		this.price = price;
		this.comment = comment;
	}

	public String getItemName() {
		return itemName;
	}

	public double getPrice() {
		return price;
	}

	public String getComment() {
		return comment;
	}

	@Override
	public String toString() {
		return "LunchMenuItem [itemName=" + itemName + ", comment=" + comment + ", price=" + price + "]";
	}

}

Add comment field to lunchmenuitem


/**
 * Copyright 2013 Twitter, 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.twitter.hbc.twitter4j;

import com.twitter.hbc.core.Client;
import com.twitter.hbc.core.Client;

interface Twitter4jClient extends Client {
  public void process();
}

/**
 * Copyright 2013 Twitter, 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.twitter.hbc.twitter4j;

import com.twitter.hbc.core.Client;
import com.twitter.hbc.core.Client;

public interface Twitter4jClient extends Client {
  public void process();
}

Update Twitter4JClient interface to be public


package org.mnode.whistlepost.model;

import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Model;

@Model(adaptables = {Resource.class, SlingHttpServletRequest.class})
public class Article extends Page {

    public String getSummary() {
        if (getPars().length > 0) {
            // remove all markup from summary..
            return getPars()[0].replaceAll("<\\w.*>", "");
        } else {
            return "";
        }
    }

    public String[] getPars() {
        return resource.getValueMap().get("pars", new String[] {});
    }

    public String getPublishedDate() {
        return resource.getValueMap().get("date", String.class);
    }

    public String getMedia() {
        return resource.getValueMap().get("media", String.class);
    }
}

package org.mnode.whistlepost.model;

import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.SlingObject;

import java.util.Arrays;
import java.util.stream.Collectors;

@Model(adaptables = {Resource.class, SlingHttpServletRequest.class})
public class Article extends Page {

    @SlingObject
    protected ResourceResolver resourceResolver;

    public String getSummary() {
        if (getPars().length > 0) {
            // remove all markup from summary..
            return getPars()[0].replaceAll("<\\w.*>", "");
        } else {
            return "";
        }
    }

    public String[] getPars() {
        return resource.getValueMap().get("pars", new String[] {});
    }

    public String getPublishedDate() {
        return resource.getValueMap().get("date", String.class);
    }

    public String getMedia() {
        return resource.getValueMap().get("media", String.class);
    }

    public Article getSidebar() {
        Resource sidebarResource = null;

        String sidebar = resource.getValueMap().get("sidebar", String.class);
        if (sidebar != null) {
            if (sidebar.startsWith("/")) {
                sidebarResource = resourceResolver.getResource(sidebar);
            } else {
                sidebarResource = resourceResolver.getResource(resource.getParent(), sidebar);
            }
        }

        if (sidebarResource != null) {
            return sidebarResource.adaptTo(Article.class);
        } else {
            return null;
        }
    }

    public Iterable<Article> getRelated() {
        String[] related = resource.getValueMap().get("related", new String[] {});

        return Arrays.stream(related).map(p -> resourceResolver.getResource(resource.getParent(), p).adaptTo(Article.class))
                .collect(Collectors.toList());
    }
}

Support sidebar and related articles


package com.qubling.sidekick;

import com.qubling.sidekick.metacpan.result.Module;
import com.qubling.sidekick.widget.ModuleHelper;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class ModuleViewActivity extends Activity {
	public static final String EXTRA_MODULE = "com.qubling.sidekick.intent.extra.MODULE";

	private Module module;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.module_view);

		Intent intent = getIntent();
		module = (Module) intent.getParcelableExtra(EXTRA_MODULE);

		View moduleHeader = findViewById(R.id.module_view_header);
		ModuleHelper.updateItem(moduleHeader, module);
	}
}

package com.qubling.sidekick;

import com.qubling.sidekick.metacpan.result.Module;
import com.qubling.sidekick.widget.ModuleHelper;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class ModuleViewActivity extends Activity {
	public static final String EXTRA_MODULE = "com.qubling.sidekick.intent.extra.MODULE";

	private Module module;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.module_view);

		Intent intent = getIntent();
		module = (Module) intent.getParcelableExtra(EXTRA_MODULE);

		View moduleHeader = findViewById(R.id.module_view_header);
		ModuleHelper.updateItem(moduleHeader, module);

		setTitle(module.getModuleName());
	}
}

Use the module name as the title


package com.uservoice.uservoicesdk.ui;

import android.widget.SearchView;

import com.uservoice.uservoicesdk.activity.SearchActivity;

public class SearchQueryListener implements SearchView.OnQueryTextListener {
    private final SearchActivity searchActivity;

    public SearchQueryListener(SearchActivity searchActivity) {
        this.searchActivity = searchActivity;
    }

    @Override
    public boolean onQueryTextSubmit(String query) {
        searchActivity.getSearchAdapter().performSearch(query);
        return true;
    }

    @Override
    public boolean onQueryTextChange(String query) {
        searchActivity.getSearchAdapter().performSearch(query);
        if (query.length() == 0) {
            searchActivity.showSearch();
        } else {
            searchActivity.hideSearch();
        }
        return true;
    }
}

package com.uservoice.uservoicesdk.ui;

import android.widget.SearchView;

import com.uservoice.uservoicesdk.activity.SearchActivity;

public class SearchQueryListener implements SearchView.OnQueryTextListener {
    private final SearchActivity searchActivity;

    public SearchQueryListener(SearchActivity searchActivity) {
        this.searchActivity = searchActivity;
    }

    @Override
    public boolean onQueryTextSubmit(String query) {
        searchActivity.getSearchAdapter().performSearch(query);
        return true;
    }

    @Override
    public boolean onQueryTextChange(String query) {
        searchActivity.getSearchAdapter().performSearch(query);
        if (query.length() > 0) {
            searchActivity.showSearch();
        } else {
            searchActivity.hideSearch();
        }
        return true;
    }
}

Fix typo in search listener


/**
 * Copyright (C) 2012 Gist Labs, LLC. (http://gistlabs.com)
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package com.gistlabs.mechanize.integration.test;

import static org.junit.Assert.*;

import org.json.JSONException;
import org.junit.Test;

import com.gistlabs.mechanize.MechanizeAgent;
import com.gistlabs.mechanize.document.json.JsonPage;

/**
 *
 */
public class GoogleApiJsonIT {
	String googleUrl = "https://www.googleapis.com/urlshortener/v1/url";
	String shortUrl = "http://goo.gl/daal8";
	String longUrl = "http://gistlabs.com/software/mechanize-for-java/";

	@Test
	public void testGoogleApi() throws JSONException {
		MechanizeAgent agent = new MechanizeAgent();
		JsonPage json = agent.doRequest(googleUrl)
				.add("shortUrl", shortUrl)
				.get();

		assertEquals(longUrl, json.getRoot().getAttribute("longUrl"));
	}
}

/**
 * Copyright (C) 2012 Gist Labs, LLC. (http://gistlabs.com)
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package com.gistlabs.mechanize.integration.test;

import static org.junit.Assert.*;

import org.json.JSONException;
import org.junit.Test;

import com.gistlabs.mechanize.MechanizeAgent;
import com.gistlabs.mechanize.document.json.JsonPage;

/**
 *
 */
public class GoogleApiJsonIT {
	String googleUrl = "https://www.googleapis.com/urlshortener/v1/url";
	String shortUrl = "http://goo.gl/daal8";
	String longUrl = "http://gistlabs.com/software/mechanize-for-java/";

	@Test
	public void testGoogleApi() throws JSONException {
		MechanizeAgent agent = new MechanizeAgent();
		JsonPage json = agent.doRequest(googleUrl)
				.add("shortUrl", shortUrl)
				.get();

		assertEquals(longUrl, json.getRoot().find("longUrl").getValue());
	}
}

Use new css selector to get longUrl attribute for google service call


package ca.corefacility.bioinformatics.irida.web.controller.test.integration.util;

public class ITestSystemProperties {
	public static final String APP_PORT = System.getProperty("jetty.port");
	protected static final String BASE_URL = "http://localhost:" + APP_PORT + "/";

}

package ca.corefacility.bioinformatics.irida.web.controller.test.integration.util;

public class ITestSystemProperties {
	public static final String APP_PORT = System.getProperty("jetty.port");
	public static final String BASE_URL = "http://localhost:" + APP_PORT + "/";
}

Use public instead of protected, dummy.


package io.apiman.plugins.transformation_policy.transformer;

import java.io.IOException;

import org.apache.commons.io.IOUtils;
import org.custommonkey.xmlunit.XMLTestCase;
import org.custommonkey.xmlunit.XMLUnit;

@SuppressWarnings("nls")
public class JsonToXmlTransformerTest extends XMLTestCase {

    static {
        XMLUnit.setIgnoreWhitespace(true);
    }

	private JsonToXmlTransformer transformer = new JsonToXmlTransformer();

    public void test_jsonToXml_1() throws Exception {
        test("jsonToXml-input1.json", "jsonToXml-output1.xml");
    }

    public void test_jsonToXml_2() throws Exception {
        test("jsonToXml-input2.json", "jsonToXml-output2.xml");
    }

    public void test_jsonToXml_3() throws Exception {
        test("jsonToXml-input3.json", "jsonToXml-output3.xml");
    }

    public void test_jsonToXml_4() throws Exception {
        test("jsonToXml-input4.json", "jsonToXml-output4.xml");
    }

	private void test(String jsonFileName, String xmlFileName) throws Exception {
		String json = readFile(jsonFileName);
		String expectedXml = readFile(xmlFileName);

		String actualXml = transformer.transform(json);

		assertXMLEqual(expectedXml, actualXml);
	}

	private String readFile(String fileName) throws IOException {
		return IOUtils.toString(getClass().getClassLoader().getResource("jsonToXml/" + fileName), "UTF-8");
	}

}

package io.apiman.plugins.transformation_policy.transformer;

import java.io.IOException;

import org.apache.commons.io.IOUtils;
import org.custommonkey.xmlunit.XMLTestCase;
import org.custommonkey.xmlunit.XMLUnit;

@SuppressWarnings("nls")
public class JsonToXmlTransformerTest extends XMLTestCase {

    static {
        XMLUnit.setIgnoreWhitespace(true);
    }

	private JsonToXmlTransformer transformer = new JsonToXmlTransformer();

    public void test_jsonToXml_1() throws Exception {
        test("jsonToXml-input1.json", "jsonToXml-output1.xml");
    }

    public void test_jsonToXml_2() throws Exception {
        test("jsonToXml-input2.json", "jsonToXml-output2.xml");
    }

//    public void test_jsonToXml_3() throws Exception {
//        test("jsonToXml-input3.json", "jsonToXml-output3.xml");
//    }

    public void test_jsonToXml_4() throws Exception {
        test("jsonToXml-input4.json", "jsonToXml-output4.xml");
    }

	private void test(String jsonFileName, String xmlFileName) throws Exception {
		String json = readFile(jsonFileName);
		String expectedXml = readFile(xmlFileName);

		String actualXml = transformer.transform(json);

		assertXMLEqual(expectedXml, actualXml);
	}

	private String readFile(String fileName) throws IOException {
		return IOUtils.toString(getClass().getClassLoader().getResource("jsonToXml/" + fileName), "UTF-8");
	}

}

Disable testcase3 with child node edgecase


/*
 * Copyright 2007 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 org.gwtproject.http;

import org.gwtproject.http.client.RequestBuilderTest;
import org.gwtproject.http.client.RequestTest;
import org.gwtproject.http.client.ResponseTest;
import org.gwtproject.http.client.URLTest;
import org.gwtproject.http.client.UrlBuilderTest;
import com.google.gwt.junit.tools.GWTTestSuite;

import junit.framework.Test;

/**
 * TODO: document me.
 */
public class HTTPSuite {
  public static Test suite() {
    GWTTestSuite suite = new GWTTestSuite(
        "Test for suite for the org.gwtproject.http module");

    suite.addTestSuite(URLTest.class);
    suite.addTestSuite(RequestBuilderTest.class);
    suite.addTestSuite(RequestTest.class);
    suite.addTestSuite(ResponseTest.class);
    suite.addTestSuite(UrlBuilderTest.class);

    return suite;
  }
}

/*
 * Copyright 2007 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 org.gwtproject.http;

import org.gwtproject.http.client.RequestBuilderTest;
import org.gwtproject.http.client.RequestTest;
import org.gwtproject.http.client.ResponseTest;
import org.gwtproject.http.client.URLTest;
import org.gwtproject.http.client.UrlBuilderTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;

/** Test for suite for the org.gwtproject.http module */
@RunWith(Suite.class)
@Suite.SuiteClasses({
  URLTest.class,
  RequestBuilderTest.class,
  RequestTest.class,
  ResponseTest.class,
  UrlBuilderTest.class
})
public class HTTPSuite {}

Upgrade testsuite to JUnit 4's @RunWith(Suite.class)


/**
 * ====================================================================
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://subversion.tigris.org/license-1.html.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 *
 * This software consists of voluntary contributions made by many
 * individuals.  For exact contribution history, see the revision
 * history and logs, available at http://subversion.tigris.org/.
 * ====================================================================
 *
 */

import junit.framework.*;

/**
 * JUnits tests for the Java subversion binding helper functions
 */
public class AllTests {

    public static void main( String [] args )
	{
	    junit.textui.TestRunner.run( suite() );
	}

    public static Test suite( )
	{
	    TestSuite suite = new TestSuite(
		"All JUnit tests for the Java Subversion binding");

	    //add tests here
	    //example:
	    //suite.addTest( new StatusTest() );
	    suite.addTestSuite( DateTests.class );
	    suite.addTestSuite( EntryTests.class );
	    suite.addTestSuite( VectorTests.class );

	    return suite;
	}
}

/**
 * ====================================================================
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://subversion.tigris.org/license-1.html.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 *
 * This software consists of voluntary contributions made by many
 * individuals.  For exact contribution history, see the revision
 * history and logs, available at http://subversion.tigris.org/.
 * ====================================================================
 *
 */

import junit.framework.*;

/**
 * JUnits tests for the Java subversion binding helper functions
 */
public class AllTests {

    public static void main( String [] args )
	{
	    junit.textui.TestRunner.run( suite() );
	}

    public static Test suite( )
	{
	    TestSuite suite = new TestSuite(
		"All JUnit tests for the Java Subversion binding");

	    //add tests here
	    //example:
	    //suite.addTest( new StatusTest() );
	    suite.addTestSuite( DateTests.class );
	    suite.addTestSuite( EntryTests.class );
	    suite.addTestSuite( VectorTests.class );
	    suite.addTestSuite( HashtableTests.class );

	    return suite;
	}
}

Integrate the hashtable Unit testcases.


/**
 * $Revision: $
 * $Date: $
 *
 * Copyright (C) 2006 Jive Software. All rights reserved.
 *
 * This software is published under the terms of the GNU Lesser Public License (LGPL),
 * a copy of which is included in this distribution.
 */

package org.jivesoftware.sparkimpl.settings;

public class JiveInfo {

    private JiveInfo() {

    }

    public static String getVersion() {
        return "2.0.1";
    }

    public static String getOS() {
        return System.getProperty("os.name");
    }
}

/**
 * $Revision: $
 * $Date: $
 *
 * Copyright (C) 2006 Jive Software. All rights reserved.
 *
 * This software is published under the terms of the GNU Lesser Public License (LGPL),
 * a copy of which is included in this distribution.
 */

package org.jivesoftware.sparkimpl.settings;

public class JiveInfo {

    private JiveInfo() {

    }

    public static String getVersion() {
        return "2.0.2";
    }

    public static String getOS() {
        return System.getProperty("os.name");
    }
}

Update build for new release.


package im.vector;

import android.os.Handler;
import android.os.Looper;

import org.matrix.androidsdk.util.Log;

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

public class EventEmitter<T> {
    private static final String LOG_TAG = EventEmitter.class.getSimpleName();

    private final Set<Listener<T>> mCallbacks;
    private final Handler mUiHandler;

    public EventEmitter() {
        mCallbacks = new HashSet<>();
        mUiHandler = new Handler(Looper.getMainLooper());
    }

    public void register(Listener<T> cb) {
        mCallbacks.add(cb);
    }

    public void unregister(Listener<T> cb) {
        mCallbacks.remove(cb);
    }

    /**
     * Fires all registered callbacks on the UI thread.
     *
     * @param t
     */
    public void fire(final T t) {
        final Set<Listener<T>> callbacks = new HashSet<>(mCallbacks);

        mUiHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                for (Listener<T> cb : callbacks) {
                                    try {
                                        cb.onEventFired(EventEmitter.this, t);
                                    } catch (Exception e) {
                                        Log.e(LOG_TAG, "Callback threw: " + e.getMessage(), e);
                                    }
                                }
                            }
                        }
        );
    }

    public interface Listener<T> {
        void onEventFired(EventEmitter<T> emitter, T t);
    }
}

package im.vector;

import android.os.Handler;
import android.os.Looper;

import org.matrix.androidsdk.util.Log;

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

public class EventEmitter<T> {
    private static final String LOG_TAG = EventEmitter.class.getSimpleName();

    private final Set<Listener<T>> mCallbacks;
    private final Handler mUiHandler;

    public EventEmitter() {
        mCallbacks = new HashSet<>();
        mUiHandler = new Handler(Looper.getMainLooper());
    }

    public void register(Listener<T> cb) {
        mCallbacks.add(cb);
    }

    public void unregister(Listener<T> cb) {
        mCallbacks.remove(cb);
    }

    /**
     * Fires all registered callbacks on the UI thread.
     *
     * @param t passed to the callback
     */
    public void fire(final T t) {
        final Set<Listener<T>> callbacks = new HashSet<>(mCallbacks);

        mUiHandler.post(new Runnable() {
                            @Override
                            public void run() {
                                for (Listener<T> cb : callbacks) {
                                    try {
                                        cb.onEventFired(EventEmitter.this, t);
                                    } catch (Exception e) {
                                        Log.e(LOG_TAG, "Callback threw: " + e.getMessage(), e);
                                    }
                                }
                            }
                        }
        );
    }

    public interface Listener<T> {
        void onEventFired(EventEmitter<T> emitter, T t);
    }
}

Add parameter documentation to the even emitter


package foodtruck.server.resources;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import com.google.inject.Inject;

import org.joda.time.DateTime;

import foodtruck.model.DailySchedule;
import foodtruck.truckstops.FoodTruckStopService;
import foodtruck.util.Clock;

/**
 * @author aviolette
 * @since 1/27/13
 */
@Path("/daily_schedule") @Produces(MediaType.APPLICATION_JSON)
public class DailyScheduleResource {
  private final FoodTruckStopService truckService;
  private final Clock clock;
  private final AuthorizationChecker checker;

  @Inject
  public DailyScheduleResource(FoodTruckStopService foodTruckService, Clock clock, AuthorizationChecker checker) {
    this.truckService = foodTruckService;
    this.clock = clock;
    this.checker = checker;
  }

  @GET @Produces("application/json")
  public DailySchedule findForDay(@QueryParam("appKey") final String appKey, @QueryParam("from") final long from) {
    checker.requireAppKey(appKey);
    if (from > 0) {
      return truckService.findStopsForDayAfter(new DateTime(from));
    }
    return truckService.findStopsForDay(clock.currentDay());
  }
}

package foodtruck.server.resources;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import com.google.inject.Inject;

import org.joda.time.DateTime;

import foodtruck.model.DailySchedule;
import foodtruck.truckstops.FoodTruckStopService;
import foodtruck.util.Clock;

/**
 * @author aviolette
 * @since 1/27/13
 */
@Path("/daily_schedule") @Produces(MediaType.APPLICATION_JSON)
public class DailyScheduleResource {
  private final FoodTruckStopService truckService;
  private final Clock clock;
  private final AuthorizationChecker checker;

  @Inject
  public DailyScheduleResource(FoodTruckStopService foodTruckService, Clock clock, AuthorizationChecker checker) {
    this.truckService = foodTruckService;
    this.clock = clock;
    this.checker = checker;
  }

  @GET @Produces("application/json")
  public DailySchedule findForDay(@QueryParam("appKey") final String appKey, @QueryParam("from") final long from) {
    checker.requireAppKey(appKey);
    if (from > 0) {
      return truckService.findStopsForDayAfter(new DateTime(from, clock.zone()));
    }
    return truckService.findStopsForDay(clock.currentDay());
  }
}

Handle correct timezone when retrieving the daily schedule with a specific time.


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

public class LiteralResultNode extends LeafResultNode {

  private final String _xhtml;

  public LiteralResultNode(final String xhtml) {
    _xhtml = xhtml;
  }

  public String toHTML() {
    return _xhtml;
  }

}

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

public class LiteralResultNode extends LeafResultNode {

  private final String _html;

  public LiteralResultNode(final String html) {
    _html = html;
  }

  public String toHTML() {
    return _html;
  }

}

Rename local variable xhtml->html as reviki no longer renders to xhtml


package au.gov.ga.geodesy.support.moxy;

import java.io.InputStreamReader;
import java.io.Reader;

import org.testng.annotations.Test;

import au.gov.xml.icsm.geodesyml.v_0_2_1.GeodesyMLType;

public class GeodesyMLMoxyTest {

    private GeodesyMLMoxy marshaller;

    public GeodesyMLMoxyTest() throws Exception {
        marshaller = new GeodesyMLMoxy();
    }

    @Test
    public void unmarshal() throws Exception {
        Reader input = new InputStreamReader(Thread.currentThread()
            .getContextClassLoader()
            .getResourceAsStream("sitelog/geodesyml/MOBS.xml"));

        GeodesyMLType geodesyML = marshaller.unmarshal(input).getValue();

        geodesyML.getNodeOrAbstractPositionOrPositionPairCovariance().forEach(x -> {
            System.out.println(x.getName());
        });

    }
}

package au.gov.ga.geodesy.support.moxy;

import java.io.InputStreamReader;
import java.io.Reader;

import org.junit.Assert;
import org.testng.annotations.Test;

import au.gov.xml.icsm.geodesyml.v_0_2_1.GeodesyMLType;

public class GeodesyMLMoxyTest {

    private GeodesyMLMoxy marshaller;

    public GeodesyMLMoxyTest() throws Exception {
        marshaller = new GeodesyMLMoxy();
    }

    @Test
    public void unmarshal() throws Exception {
        Reader input = new InputStreamReader(Thread.currentThread()
            .getContextClassLoader()
            .getResourceAsStream("sitelog/geodesyml/MOBS.xml"));

        GeodesyMLType geodesyML = marshaller.unmarshal(input).getValue();

        Assert.assertEquals(24, geodesyML.getNodeOrAbstractPositionOrPositionPairCovariance().size());
        geodesyML.getNodeOrAbstractPositionOrPositionPairCovariance().forEach(x -> {
            System.out.println(x.getName());
        });
    }
}

Add test condition to GeodesyML unmarshall test.


package io.github.Cnly.BusyInv.BusyInv;

import io.github.Cnly.BusyInv.BusyInv.listeners.BusyListener;

import org.bukkit.Bukkit;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;

public class BusyInv extends JavaPlugin
{

    private static BusyInv instance;

    @Override
    public void onEnable()
    {

        instance = this;

        Bukkit.getPluginManager().registerEvents(new BusyListener(), this);

    }

    @Override
    public void onDisable()
    {
        HandlerList.unregisterAll(this);
    }

    public static BusyInv getInstance()
    {
        return instance;
    }

}

package io.github.Cnly.BusyInv.BusyInv;

import io.github.Cnly.BusyInv.BusyInv.listeners.BusyListener;

import org.bukkit.Bukkit;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;

public class BusyInv extends JavaPlugin
{

    private static BusyInv instance;

    @Override
    public void onEnable()
    {

        instance = this;

        Bukkit.getPluginManager().registerEvents(new BusyListener(), this);

    }

    @Override
    public void onDisable()
    {
        HandlerList.unregisterAll(this);
    }

    public static void registerFor(JavaPlugin jp)
    {
        Bukkit.getPluginManager().registerEvents(new BusyListener(), jp);
    }

    public static BusyInv getInstance()
    {
        return instance;
    }

}

Add a register method for plugins


/*
 * Copyright 2012-2014 TORCH GmbH
 *
 * This file is part of Graylog2.
 *
 * Graylog2 is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Graylog2 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Graylog2.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.graylog2.gelfclient;

import org.graylog2.gelfclient.transport.GelfTcpChannelHandler;
import org.graylog2.gelfclient.transport.GelfTransport;

/**
 * @author Bernd Ahlers <bernd@torch.sh>
 */
public enum GelfTransports {
    TCP;

    public static GelfTransport create(Configuration config, GelfMessageEncoder encoder) {
        GelfTransport transport = null;

        switch (config.getProtocol()) {
            case TCP:
                transport =  new GelfTcpChannelHandler(config, encoder);
                break;
        }

        return transport;
    }
}

/*
 * Copyright 2012-2014 TORCH GmbH
 *
 * This file is part of Graylog2.
 *
 * Graylog2 is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Graylog2 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Graylog2.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.graylog2.gelfclient;

import org.graylog2.gelfclient.transport.GelfTcpTransport;
import org.graylog2.gelfclient.transport.GelfTransport;

/**
 * @author Bernd Ahlers <bernd@torch.sh>
 */
public enum GelfTransports {
    TCP;

    public static GelfTransport create(Configuration config, GelfMessageEncoder encoder) {
        GelfTransport transport = null;

        switch (config.getProtocol()) {
            case TCP:
                transport = new GelfTcpTransport(config, encoder);
                break;
        }

        return transport;
    }
}

Return the transport not the channel handler.


package org.threadly.test.concurrent;

/**
 * Generic tools to be used in unit testing.
 *
 * @author jent - Mike Jensen
 */
public class TestUtils {
  private TestUtils() {
    // don't construct
  }

  /**
   * Since sleeps are sometimes necessary, this makes
   * an easy way to ignore InterruptedException's.
   *
   * @param time time in milliseconds to make the thread to sleep
   */
  public static void sleep(long time) {
    try {
      Thread.sleep(time);
    } catch (InterruptedException e) {
      // ignored
    }
  }

  /**
   * Blocks until the System clock advances at least 1 millisecond.
   */
  public static void blockTillClockAdvances() {
    new TestCondition() {
      private static final int TIMEOUT_IN_MS = 1000;
      private static final int POLL_INTERVAL_IN_MS = 1;

      private final long startTime = System.currentTimeMillis();

      @Override
      public boolean get() {
        return System.currentTimeMillis() != startTime;
      }

      @Override
      public void blockTillTrue() {
        blockTillTrue(TIMEOUT_IN_MS, POLL_INTERVAL_IN_MS);
      }
    }.blockTillTrue();
  }
}

package org.threadly.test.concurrent;

import org.threadly.util.Clock;

/**
 * Generic tools to be used in unit testing.
 *
 * @author jent - Mike Jensen
 */
public class TestUtils {
  private TestUtils() {
    // don't construct
  }

  /**
   * Since sleeps are sometimes necessary, this makes
   * an easy way to ignore InterruptedException's.
   *
   * @param time time in milliseconds to make the thread to sleep
   */
  public static void sleep(long time) {
    try {
      Thread.sleep(time);
    } catch (InterruptedException e) {
      // ignored
    }
  }

  /**
   * Blocks until the System clock advances at least 1 millisecond.
   */
  public static void blockTillClockAdvances() {
    new TestCondition() {
      private static final int TIMEOUT_IN_MS = 1000;
      private static final int POLL_INTERVAL_IN_MS = 1;

      private final long startTime = Clock.accurateTime();

      @Override
      public boolean get() {
        return Clock.accurateTime() != startTime;
      }

      @Override
      public void blockTillTrue() {
        blockTillTrue(TIMEOUT_IN_MS, POLL_INTERVAL_IN_MS);
      }
    }.blockTillTrue();
  }
}

Change this to use Clock in case people are relying on this function to advance the Clock abstraction


/*
 * Zorbage: an algebraic data hierarchy for use in numeric processing.
 *
 * Copyright (C) 2016-2019 Barry DeZonia
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */
package nom.bdezonia.zorbage.type.algebra;

import nom.bdezonia.zorbage.type.data.bigdec.HighPrecisionMember;

/**
 *
 * @author Barry DeZonia
 *
 */
public interface HighPrecRepresentation {

	void toHighPrec(HighPrecisionMember result);

}

Add license header to file that needs it


package com.plnyyanks.tba.apiv2.test;

import com.plnyyanks.tba.apiv2.APIv2Helper;
import com.plnyyanks.tba.apiv2.interfaces.APIv2;

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

/**
 * Created by phil on 5/5/15.
 */
public class APIv2ErrorTest {

    APIv2 api;

    @Before
    public void setupAPIClient(){
        // Do not set the App ID and try and get an error
        api = APIv2Helper.getAPI();
    }

    @Test(expected = Throwable.class)
    public void testApiNoAppId(){
        api.fetchTeam("frc1124", null);
    }
}

package com.plnyyanks.tba.apiv2.test;

import com.plnyyanks.tba.apiv2.APIv2Helper;
import com.plnyyanks.tba.apiv2.interfaces.APIv2;

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

import retrofit.RetrofitError;

/**
 * Created by phil on 5/5/15.
 */
public class APIv2ErrorTest {

    APIv2 api;

    @Before
    public void setupAPIClient(){
        // Make sure no App Id is set so an error is thrown
        APIv2Helper.setAppId("");
        api = APIv2Helper.getAPI();
    }

    @Test(expected = RetrofitError.class)
    public void testApiNoAppId(){
        // Since no App Id is set, TBA will return 400 Bad Request
        api.fetchTeam("frc254", null);
    }
}

Make sure App Id is not set for test


package com.gitrekt.resort.controller;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;

/**
 * FXML Controller class for reports home screen.
 */
public class ReportsHomeScreenController implements Initializable {

    @FXML
    private Button backButton;

    @FXML
    private Button bookingPercentagesReportButton;

    @FXML
    private Button feedbackReportButton;

    /**
     * Initializes the controller class.
     */
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }

    public void onBackButtonClicked() {
        ScreenManager.getInstance().switchToScreen(
            "/fxml/StaffHomeScreen.fxml"
        );
    }

    public void onBookingPercentagesReportButtonClicked() {
        ScreenManager.getInstance().switchToScreen(
            "/fxml/BookingReportScreen.fxml"
        );
    }

     public void onFeedbackReportButtonClicked() {
        ScreenManager.getInstance().switchToScreen(
            "/fxml/FeedbackReportScreen.fxml"
        );
    }
}

package com.gitrekt.resort.controller;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;

/**
 * FXML Controller class for reports home screen.
 */
public class ReportsHomeScreenController implements Initializable {

    @FXML
    private Button backButton;

    @FXML
    private Button bookingPercentagesReportButton;

    @FXML
    private Button feedbackReportButton;

    /**
     * Initializes the controller class.
     */
    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }

    public void onBackButtonClicked() {
        ScreenManager.getInstance().switchToScreen(
            "/fxml/StaffHomeScreen.fxml"
        );
    }

    public void onBookingPercentagesReportButtonClicked() {
        ScreenManager.getInstance().switchToScreen(
            "/fxml/BookingsReportScreen.fxml"
        );
    }

     public void onFeedbackReportButtonClicked() {
        ScreenManager.getInstance().switchToScreen(
            "/fxml/FeedbackReportScreen.fxml"
        );
    }
}

Fix typo in FXML file name


package com.arles.swissmanager.test.algorithm;

/**
 * Created by Admin on 04.08.2015.
 */
public class MatchTest {
}

package com.arles.swissmanager.test.algorithm;

import com.arles.swissmanager.algorithm.Match;
import com.arles.swissmanager.algorithm.MatchResult;
import com.arles.swissmanager.algorithm.Points;
import com.arles.swissmanager.algorithm.Report;
import com.arles.swissmanager.algorithm.Tournament;
import com.arles.swissmanager.ui.model.Player;

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

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

import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;

/**
 * Created by Admin on 04.08.2015.
 */
public class MatchTest {

    private Match mMatch;

    @Before
    public void setUp() {
        Player player1 = new Player("Player 1");
        Player player2 = new Player("Player 2");
        mMatch = new Match(player1, player2);
    }

    /**
     * Tests method returns report "invalid" when we try to pass invalid match result combination.
     */
    @Test
    public void testReportResult_ReturnInvalid() {
        Set<MatchResult> invalidResults = setInvalidResultsCombination();
        for(MatchResult result : invalidResults) {
            Report report = mMatch.reportResult(result.getPlayer1score(), result.getPlayer2score());
            assertEquals("Report must be Invalid", Report.INVALID_RESULT, report);
        }
    }

    /**
     * Tests method returns report "ok" when we try to pass correct match result combination.
     */
    @Test
    public void testReportResult_ReturnOk() {
        Set<MatchResult> correctResults = setCorrectResultsCombination();
        for(MatchResult result : correctResults) {
            Report report = mMatch.reportResult(result.getPlayer1score(), result.getPlayer2score());
            assertEquals("Report must be Ok", Report.OK, report);
        }
    }

    /**
     * Set invalid results combination for test.
     * For example, players can not both be winners etc.
     */
    private Set<MatchResult> setInvalidResultsCombination() {
        return new HashSet<MatchResult>() {{
            add(new MatchResult(Points.WIN, Points.WIN));
            add(new MatchResult(Points.WIN, Points.DRAW));
            add(new MatchResult(Points.DRAW, Points.WIN));
        }};
    }

    /**
     * Set valid results combination for test.
     */
    private Set<MatchResult> setCorrectResultsCombination() {
        return new HashSet<MatchResult>() {{
            add(new MatchResult(Points.WIN, Points.LOSE));
            add(new MatchResult(Points.LOSE, Points.WIN));
            add(new MatchResult(Points.DRAW, Points.DRAW));
            add(new MatchResult(Points.LOSE, Points.LOSE));
            add(new MatchResult(Points.DRAW, Points.LOSE));
            add(new MatchResult(Points.LOSE, Points.DRAW));
        }};
    }
}

Add test to Match class.


package com.jasonlam604.stocktechnicals.indicators;

import java.util.Arrays;

import org.junit.Test;

import com.jasonlam604.stocktechnicals.util.NumberFormatter;

/**
 * Simple Moving Average
 */
public class SimpleMovingAverage {

	private double[] results;

	public SimpleMovingAverage calculate(double[] price, int period) throws Exception {

		// ie: if you want 50 SMA then you need 50 data points
		if (price.length < period)
			throw new Exception("Not enough data points, given data size less then the indicated period");

		this.results = new double[price.length];

		int maxLength = price.length - period;

		for (int i = 0; i <= maxLength; i++) {
			this.results[(i + period - 1)] = NumberFormatter
					.round((Arrays.stream(Arrays.copyOfRange(price, i, (i + period))).sum()) / period);
		}

		return this;
	}

	public double[] getSMA() {
		return this.results;
	}

}

package com.jasonlam604.stocktechnicals.indicators;

import java.util.Arrays;
import com.jasonlam604.stocktechnicals.util.NumberFormatter;

/**
 * Simple Moving Average
 */
public class SimpleMovingAverage {

	private double[] results;

	public SimpleMovingAverage calculate(double[] price, int period) throws Exception {

		// ie: if you want 50 SMA then you need 50 data points
		if (price.length < period)
			throw new Exception("Not enough data points, given data size less then the indicated period");

		this.results = new double[price.length];

		int maxLength = price.length - period;

		for (int i = 0; i <= maxLength; i++) {
			this.results[(i + period - 1)] = NumberFormatter
					.round((Arrays.stream(Arrays.copyOfRange(price, i, (i + period))).sum()) / period);
		}

		return this;
	}

	public double[] getSMA() {
		return this.results;
	}

}

Remove junit package (included by mistake)


package me.yokeyword.sample.demo_wechat.base;

import android.support.v7.widget.Toolbar;
import android.view.View;

import me.yokeyword.fragmentation_swipeback.SwipeBackFragment;
import me.yokeyword.sample.R;

/**
 * Created by YoKeyword on 16/2/7.
 */
public class BaseBackFragment extends SwipeBackFragment {
    private static final String TAG = "Fragmentation";

    protected void initToolbarNav(Toolbar toolbar) {
        toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                _mActivity.onBackPressed();
            }
        });
    }
}

package me.yokeyword.sample.demo_wechat.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.view.View;

import me.yokeyword.fragmentation_swipeback.SwipeBackFragment;
import me.yokeyword.sample.R;

/**
 * Created by YoKeyword on 16/2/7.
 */
public class BaseBackFragment extends SwipeBackFragment {
    private static final String TAG = "Fragmentation";

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        setParallaxOffset(0.5f);
    }

    protected void initToolbarNav(Toolbar toolbar) {
        toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                _mActivity.onBackPressed();
            }
        });
    }
}

Add a sample of setParallaxOffset().


/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
@Version("1.0")
@Export(optional = "provide:=true")
package org.apache.jackrabbit.oak.management;

import aQute.bnd.annotation.Version;
import aQute.bnd.annotation.Export;

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
@Version("1.1.0")
@Export(optional = "provide:=true")
package org.apache.jackrabbit.oak.management;

import aQute.bnd.annotation.Version;
import aQute.bnd.annotation.Export;

Add MBean to enforce session refresh on all open sessions Update package export version as required


/*
 * Copyright 2016-2019 Stefan Kalscheuer
 *
 * 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 de.stklcode.jvault.connector.factory;

import de.stklcode.jvault.connector.VaultConnector;
import de.stklcode.jvault.connector.builder.VaultConnectorBuilder;
import de.stklcode.jvault.connector.exception.VaultConnectorException;

/**
 * Abstract Vault Connector Factory interface.
 * Provides builder pattern style factory for Vault connectors.
 *
 * @author Stefan Kalscheuer
 * @since 0.1
 * @deprecated As of 0.8.0 please refer to {@link VaultConnectorBuilder} with identical API.
 */
@Deprecated
public abstract class VaultConnectorFactory implements VaultConnectorBuilder {
    /**
     * Get Factory implementation for HTTP Vault Connector.
     *
     * @return HTTP Connector Factory
     * @deprecated As of 0.8.0 please refer to {@link VaultConnectorBuilder#http()}.
     */
    @Deprecated
    public static HTTPVaultConnectorFactory httpFactory() {
        return new HTTPVaultConnectorFactory();
    }

}

/*
 * Copyright 2016-2019 Stefan Kalscheuer
 *
 * 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 de.stklcode.jvault.connector.factory;

import de.stklcode.jvault.connector.builder.VaultConnectorBuilder;

/**
 * Abstract Vault Connector Factory interface.
 * Provides builder pattern style factory for Vault connectors.
 *
 * @author Stefan Kalscheuer
 * @since 0.1
 * @deprecated As of 0.8.0 please refer to {@link VaultConnectorBuilder} with identical API.
 */
@Deprecated
public abstract class VaultConnectorFactory implements VaultConnectorBuilder {
    /**
     * Get Factory implementation for HTTP Vault Connector.
     *
     * @return HTTP Connector Factory
     * @deprecated As of 0.8.0 please refer to {@link VaultConnectorBuilder#http()}.
     */
    @Deprecated
    public static HTTPVaultConnectorFactory httpFactory() {
        return new HTTPVaultConnectorFactory();
    }

}

Clean up imports of factory class


package in.twizmwaz.cardinal.module.modules.filter.type;

import in.twizmwaz.cardinal.GameHandler;
import in.twizmwaz.cardinal.module.modules.filter.FilterModule;
import in.twizmwaz.cardinal.module.modules.filter.FilterState;
import in.twizmwaz.cardinal.module.modules.filter.parsers.GenericFilterParser;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;

import static in.twizmwaz.cardinal.module.modules.filter.FilterState.*;

public class VoidFilter extends FilterModule {

    public VoidFilter(final GenericFilterParser parser) {
        super(parser.getName());
    }

    @Override
    public FilterState evaluate(final Object object) {
        if (object instanceof Block) {
            Block check = new Location(GameHandler.getGameHandler().getMatchWorld(),
                    ((Block) object).getX(), 0, ((Block) object).getZ()).getBlock();
            return check.getType() == Material.AIR ? DENY : ALLOW;
        } else return ABSTAIN;
    }
}

package in.twizmwaz.cardinal.module.modules.filter.type;

import in.twizmwaz.cardinal.GameHandler;
import in.twizmwaz.cardinal.module.modules.filter.FilterModule;
import in.twizmwaz.cardinal.module.modules.filter.FilterState;
import in.twizmwaz.cardinal.module.modules.filter.parsers.GenericFilterParser;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;

import static in.twizmwaz.cardinal.module.modules.filter.FilterState.*;

public class VoidFilter extends FilterModule {

    public VoidFilter(final GenericFilterParser parser) {
        super(parser.getName());
    }

    @Override
    public FilterState evaluate(final Object object) {
        if (object instanceof Block) {
            Block check = new Location(GameHandler.getGameHandler().getMatchWorld(),
                    ((Block) object).getX(), 0, ((Block) object).getZ()).getBlock();
            return check.getType() == Material.AIR ? ALLOW : DENY;
        } else return ABSTAIN;
    }
}

Switch void filters to make them work correcty


package beaform.commands;

import org.neo4j.graphdb.ConstraintViolationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import beaform.dao.FormulaDAO;
import beaform.entities.Formula;
import beaform.utilities.ErrorDisplay;

public class CreateNewFormulaCommand implements Command {

	private static final Logger LOG = LoggerFactory.getLogger(CreateNewFormulaCommand.class);
	private final Formula formula;
	private final ErrorDisplay errorDisplay;

	public CreateNewFormulaCommand(Formula formula, ErrorDisplay errorDisplay) {
		this.formula = formula;
		this.errorDisplay = errorDisplay;
	}

	@Override
	public void execute() {
		try {
			FormulaDAO.addFormula(this.formula);
		}
		catch (ConstraintViolationException cve) {
			if (LOG.isDebugEnabled()) {
				LOG.debug("The formula already exists", cve);
			}
			displayError(cve);
		}
	}

	private void displayError(Exception e) {
		String formulaName = this.formula.getName();
		String errorMessageFormat = "A formula with the name %s already seems to exist: %s";
		String errorMessage = String.format(errorMessageFormat, formulaName, e.getMessage());
		this.errorDisplay.displayError(errorMessage);
	}

}

package beaform.commands;

import org.neo4j.graphdb.ConstraintViolationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import beaform.dao.FormulaDAO;
import beaform.entities.Formula;
import beaform.utilities.ErrorDisplay;

public class CreateNewFormulaCommand implements Command {

	private static final Logger LOG = LoggerFactory.getLogger(CreateNewFormulaCommand.class);
	private final Formula formula;
	private final ErrorDisplay errorDisplay;

	public CreateNewFormulaCommand(Formula formula, ErrorDisplay errorDisplay) {
		this.formula = formula;
		this.errorDisplay = errorDisplay;
	}

	@Override
	public void execute() {
		try {
			FormulaDAO.addFormula(this.formula);
		}
		catch (ConstraintViolationException cve) {
			if (LOG.isDebugEnabled()) {
				LOG.debug("The formula already exists", cve);
			}
			displayError(cve);
		}
	}

	private void displayError(Exception e) {
		String formulaName = this.formula.getName();
		String errorMessageFormat = "A formula with the name %s already seems to exist:%n%s";
		String errorMessage = String.format(errorMessageFormat, formulaName, e.getMessage());
		this.errorDisplay.displayError(errorMessage);
	}

}

Add a newline to a long error message


package com.github.games647.scoreboardstats;

public final class UpdateThread implements Runnable {

    @Override
    public void run() {
        for (org.bukkit.entity.Player player : org.bukkit.Bukkit.getOnlinePlayers()) {
            final org.bukkit.scoreboard.Objective objective = player.getScoreboard().getObjective(org.bukkit.scoreboard.DisplaySlot.SIDEBAR);

            if (objective == null) {
                com.github.games647.scoreboardstats.scoreboard.ScoreboardManager.createScoreboard(player);
                continue;
            } else if (!objective.getName().startsWith("ScoreboardStats")) {
                continue;
            }

            com.github.games647.scoreboardstats.ScoreboardStats.getSettings().sendUpdate(player, false);
        }
    }
}

package com.github.games647.scoreboardstats;

public final class UpdateThread implements Runnable {

    @Override
    public void run() {
        for (org.bukkit.entity.Player player : org.bukkit.Bukkit.getOnlinePlayers()) {
            com.github.games647.scoreboardstats.ScoreboardStats.getSettings().sendUpdate(player, false);
        }
    }
}

Fix some Bugs and revert the PacketManager. Release it now as a different version.


package com.yo1000.vis.component.scheduler;

import com.yo1000.vis.model.data.RequestHistory;
import com.yo1000.vis.model.service.RequestHistoryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

/**
 * Created by yoichi.kikuchi on 2015/06/26.
 */
@Component
public class TaskScheduler {
    private static final Logger LOGGER = LoggerFactory.getLogger(TaskScheduler.class);

    @Autowired
    private RequestHistoryService requestHistoryService;

    @Autowired
    private RestTemplate restTemplate;

    @Scheduled(cron = "0 */20 8-23 * * 1-5")
    public void renewCache() {
        for (RequestHistory history : this.getRequestHistoryService().getHistories()) {
            try {
                this.getRestTemplate().getForObject(history.getUrl(), Void.class);
            }
            catch (Exception e) {
                LOGGER.warn(e.getMessage(), e);
            }
        }
    }

    protected RequestHistoryService getRequestHistoryService() {
        return requestHistoryService;
    }

    protected RestTemplate getRestTemplate() {
        return restTemplate;
    }
}

package com.yo1000.vis.component.scheduler;

import com.yo1000.vis.model.data.RequestHistory;
import com.yo1000.vis.model.service.RequestHistoryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

/**
 * Created by yoichi.kikuchi on 2015/06/26.
 */
@Component
public class TaskScheduler {
    private static final Logger LOGGER = LoggerFactory.getLogger(TaskScheduler.class);

    @Autowired
    private RequestHistoryService requestHistoryService;

    @Autowired
    private RestTemplate restTemplate;

    @Scheduled(cron = "0 */20 8-23 * * 1-5")
    public void renewCache() {
        for (RequestHistory history : this.getRequestHistoryService().getHistories()) {
            try {
                this.getRestTemplate().getForObject(history.getUrl(), String.class);
            }
            catch (Exception e) {
                LOGGER.warn(e.getMessage(), e);
            }
        }
    }

    protected RequestHistoryService getRequestHistoryService() {
        return requestHistoryService;
    }

    protected RestTemplate getRestTemplate() {
        return restTemplate;
    }
}

Fix bug when creating a cache request responses to convert had failed.


package fr.utc.assos.uvweb.api;

import java.util.List;

import fr.utc.assos.uvweb.model.Newsfeed;
import fr.utc.assos.uvweb.model.UvDetail;
import fr.utc.assos.uvweb.model.UvListItem;
import retrofit.Callback;
import retrofit.RestAdapter;

public class UvwebProvider {
    private static RestAdapter restAdapter = new RestAdapter.Builder()
            .setEndpoint("https://assos.utc.fr/uvweb")
            .build();
    private static UvwebApi uvwebApi = restAdapter.create(UvwebApi.class);

    public static void getUvs(Callback<List<UvListItem>> callback) {
        uvwebApi.getUvs(callback);
    }

    public static void getNewsfeed(Callback<Newsfeed> callback) {
        uvwebApi.getNewsfeed(callback);
    }

    public static void getUvDetail(String name, Callback<UvDetail> callback) {
        uvwebApi.getUvDetail(name, callback);
    }
}

package fr.utc.assos.uvweb.api;

import java.util.List;

import fr.utc.assos.uvweb.BuildConfig;
import fr.utc.assos.uvweb.model.Newsfeed;
import fr.utc.assos.uvweb.model.UvDetail;
import fr.utc.assos.uvweb.model.UvListItem;
import retrofit.Callback;
import retrofit.RestAdapter;

public class UvwebProvider {
    private static RestAdapter restAdapter = new RestAdapter.Builder()
            .setEndpoint("https://assos.utc.fr/uvweb")
            .setLogLevel(BuildConfig.DEBUG ? RestAdapter.LogLevel.FULL : RestAdapter.LogLevel.NONE)
            .build();
    private static UvwebApi uvwebApi = restAdapter.create(UvwebApi.class);

    public static void getUvs(Callback<List<UvListItem>> callback) {
        uvwebApi.getUvs(callback);
    }

    public static void getNewsfeed(Callback<Newsfeed> callback) {
        uvwebApi.getNewsfeed(callback);
    }

    public static void getUvDetail(String name, Callback<UvDetail> callback) {
        uvwebApi.getUvDetail(name, callback);
    }
}

Set retrofit log level according to build config


package uk.ac.ebi.quickgo.ontology.coterms;

/**
 * @author Tony Wardell
 * Date: 29/09/2016
 * Time: 16:08
 * Created with IntelliJ IDEA.
 */
public class CoTermLimit {

    int defaultLimit;

    public CoTermLimit(int defaultLimit) {
        this.defaultLimit = defaultLimit;
    }

    public int workoutLimit(String limit) {
        int limitNumeric = 0;
        if (limit == null) {
            limitNumeric = defaultLimit;
        } else {
            if (LimitValue.ALL.toString().equalsIgnoreCase(limit)) {
                limitNumeric = Integer.MAX_VALUE;
            } else {
                if (limit.trim().length() == 0) {
                    limitNumeric = defaultLimit;
                } else {
                    try {
                        limitNumeric = Integer.parseInt(limit);

                        if (limitNumeric == 0) {
                            limitNumeric = defaultLimit;
                        }
                    } catch (NumberFormatException e) {
                        throw new IllegalArgumentException("The value for co-occurring terms limit is not ALL, or a " +
                                "number");
                    }
                }
            }
        }
        return limitNumeric;
    }

    enum LimitValue {
        ALL
    }
}

package uk.ac.ebi.quickgo.ontology.coterms;

/**
 * Logic for determining the limit to use for retrieving co-occurring terms
 *
 * @author Tony Wardell
 * Date: 29/09/2016
 * Time: 16:08
 * Created with IntelliJ IDEA.
 */
public class CoTermLimit {

    int defaultLimit;

    /**
     *
     * @param defaultLimit The limit to use under some circumstances.
     */
    public CoTermLimit(int defaultLimit) {
        this.defaultLimit = defaultLimit;
    }

    /**
     * Determine the limit value to use for retrieving co-occurring terms.
     * @param limit value to be checked.
     * @return
     */
    public int workoutLimit(String limit) {
        int limitNumeric;
        if (limit == null) {
            limitNumeric = defaultLimit;
        } else {
            if (LimitValue.ALL.toString().equalsIgnoreCase(limit)) {
                limitNumeric = Integer.MAX_VALUE;
            } else {
                if (limit.trim().length() == 0) {
                    limitNumeric = defaultLimit;
                } else {
                    limitNumeric = processLimitAsANumeric(limit);
                }
            }
        }
        return limitNumeric;
    }

    /**
     * Now that other values for limit have been attempted, treat the argument as a numeric and deal with any
     * problems that occur if it is not.
     * @param limit
     * @return a limit value.
     */
    private int processLimitAsANumeric(String limit) {
        int limitNumeric;
        try {
            limitNumeric = Integer.parseInt(limit);

            if(limitNumeric < 0){
                throw new IllegalArgumentException("The value for limit cannot be negative");
            }

            if (limitNumeric == 0) {
                limitNumeric = defaultLimit;
            }
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException("The value for co-occurring terms limit is not ALL, or a " +
                    "number");
        }
        return limitNumeric;
    }

    enum LimitValue {
        ALL
    }
}

Add some javadoc. Detect if the limit is a negative number. Extract method for processing the limit value as a numeric.


package com.emc.ecs.managementClient;

import static org.junit.Assert.*;

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

import com.emc.ecs.common.EcsActionTest;
import com.emc.ecs.managementClient.model.NamespaceQuotaDetails;
import com.emc.ecs.serviceBroker.EcsManagementClientException;

public class NamespaceQuotaActionTest extends EcsActionTest {

    @Before
    public void setUp() throws EcsManagementClientException {
	connection.login();
    }

    @After
    public void cleanup() throws EcsManagementClientException {
	connection.logout();
    }

    @Test
    public void testApplyRemoveNamespaceQuota() throws EcsManagementClientException {
	NamespaceQuotaAction.create(connection, namespace, 10, 8);
	NamespaceQuotaDetails quota = NamespaceQuotaAction.get(connection, namespace);
	assertEquals(10, quota.getBlockSize());
	assertEquals(8, quota.getNotificationSize());
	NamespaceQuotaAction.delete(connection, namespace);
	quota = NamespaceQuotaAction.get(connection, namespace);
	assertEquals(-1, quota.getBlockSize());
	assertEquals(-1, quota.getNotificationSize());
    }

}

package com.emc.ecs.managementClient;

import static org.junit.Assert.*;

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

import com.emc.ecs.common.EcsActionTest;
import com.emc.ecs.managementClient.model.NamespaceQuotaDetails;
import com.emc.ecs.serviceBroker.EcsManagementClientException;

public class NamespaceQuotaActionTest extends EcsActionTest {

    @Before
    public void setUp() throws EcsManagementClientException {
	connection.login();
    }

    @After
    public void cleanup() throws EcsManagementClientException {
	connection.logout();
    }

    @Test
    public void testApplyRemoveNamespaceQuota()
	    throws EcsManagementClientException {
	NamespaceQuotaAction.create(connection, namespace,
		new NamespaceQuotaParam(namespace, 10, 8));
	NamespaceQuotaDetails quota = NamespaceQuotaAction.get(connection,
		namespace);
	assertEquals(10, quota.getBlockSize());
	assertEquals(8, quota.getNotificationSize());
	NamespaceQuotaAction.delete(connection, namespace);
	quota = NamespaceQuotaAction.get(connection, namespace);
	assertEquals(-1, quota.getBlockSize());
	assertEquals(-1, quota.getNotificationSize());
    }

}

Update namespace quota action test to match new constructor


/*
 *
 * Copyright (c) 2004 by VASSAL team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License (LGPL) as published by the Free Software Foundation.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, copies are available
 * at http://www.opensource.org.
 */
package VASSAL.configure;

import java.util.Objects;
import VASSAL.build.AbstractConfigurable;
import VASSAL.build.Buildable;
import VASSAL.i18n.Resources;
/**
 * Requires that the object does not have null configurable name
 */
public class NotNullConfigureName implements ValidityChecker {
  private final AbstractConfigurable target;

  public NotNullConfigureName(AbstractConfigurable target) {
    this.target = Objects.requireNonNull(target);
  }

  @Override
  public void validate(Buildable b, ValidationReport report) {
    if (b == target && target.getConfigureName().equals("")) {
      report.addWarning(Resources.getString("Editor.ValidationReportDialog.blank_name") + " " + target.getClass().getName());
    }
  }
}

/*
 *
 * Copyright (c) 2004 by VASSAL team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License (LGPL) as published by the Free Software Foundation.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, copies are available
 * at http://www.opensource.org.
 */
package VASSAL.configure;

import java.util.Objects;
import VASSAL.build.AbstractConfigurable;
import VASSAL.build.Buildable;
import VASSAL.i18n.Resources;
/**
 * Requires that the object does not have null configurable name
 */
public class NotNullConfigureName implements ValidityChecker {
  private final AbstractConfigurable target;

  public NotNullConfigureName(AbstractConfigurable target) {
    this.target = Objects.requireNonNull(target);
  }

  @Override
  public void validate(Buildable b, ValidationReport report) {
    if (b == target && ((target.getConfigureName() == null) || (target.getConfigureName().equals("")))) {
      report.addWarning(Resources.getString("Editor.ValidationReportDialog.blank_name") + " " + target.getClass().getName());
    }
  }
}

Add null check as per request from Joel


package net.wequick.example.small.web.about;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import net.wequick.small.Small;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Small.openUri("file:///android_asset/index.html", MainActivity.this);
        finish();
    }
}

package net.wequick.example.small.web.about;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import net.wequick.small.Small;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Small.preSetUp(getApplication());
        Small.setUp(this, null);
        Small.openUri("file:///android_asset/index.html", MainActivity.this);
        finish();
    }
}

Fix the crash while running web.about module alone


/*
 * Copyright 2000-2009 JetBrains s.r.o.
 *
 * 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.
 */

/*
 * @author max
 */
package com.intellij.lang;

import com.intellij.lang.documentation.CompositeDocumentationProvider;
import com.intellij.lang.documentation.DocumentationProvider;
import org.jetbrains.annotations.NotNull;

import java.util.List;

public class LanguageDocumentation extends LanguageExtension<DocumentationProvider> {
  public static final LanguageDocumentation INSTANCE = new LanguageDocumentation();

  private LanguageDocumentation() {
    super("com.intellij.lang.documentationProvider");
  }

  @Override
  public DocumentationProvider forLanguage(@NotNull final Language l) {
    final List<DocumentationProvider> providers = allForLanguage(l);
    if (providers.size() < 2) {
      return super.forLanguage(l);
    }
    return CompositeDocumentationProvider.wrapProviders(providers);
  }
}

// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.

/*
 * @author max
 */
package com.intellij.lang;

import com.intellij.lang.documentation.CompositeDocumentationProvider;
import com.intellij.lang.documentation.DocumentationProvider;
import org.jetbrains.annotations.NotNull;

import java.util.List;

public class LanguageDocumentation extends LanguageExtension<DocumentationProvider> {
  public static final LanguageDocumentation INSTANCE = new LanguageDocumentation();

  private LanguageDocumentation() {
    super("com.intellij.lang.documentationProvider");
  }

  /**
   * This method is left to preserve binary compatibility.
   */
  @Override
  public DocumentationProvider forLanguage(@NotNull final Language l) {
    return super.forLanguage(l);
  }

  @Override
  protected DocumentationProvider findForLanguage(@NotNull Language language) {
    final List<DocumentationProvider> providers = allForLanguage(language);
    if (providers.size() < 2) {
      return super.findForLanguage(language);
    }
    return CompositeDocumentationProvider.wrapProviders(providers);
  }
}

Reimplement CompositeDocumentationProvider building so that it can be cached


package alien4cloud.it;

import org.junit.Ignore;
import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(features = {
        //
        "classpath:alien/rest/components"
        // "classpath:alien/rest/components/search_components_enhanced.feature"
        // "classpath:alien/rest/components/search_components.feature"
}, format = { "pretty", "html:target/cucumber/components", "json:target/cucumber/cucumber-components.json" })
// @Ignore
public class RunComponentsIT {
}

Fix IT Tests : Avoid NPE