/**
 * Copyright 2005-2011 The Kuali Foundation
 *
 * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
 *
 * 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 edu.samplu.mainmenu.test;

import org.junit.Test;

import edu.samplu.common.MainMenuLookupLegacyITBase;

/**
 * tests that user 'admin' can display the Term lookup screen, search,
 * initiate an Term maintenance document via an edit action on the search results and
 * finally cancel the maintenance document
 *
 * @author Kuali Rice Team (rice.collab@kuali.org)
 */
public class TermLookUpLegacyIT extends MainMenuLookupLegacyITBase {
    @Override
    public String getLinkLocator() {
        return "Term Lookup";
    }

    @Test
    public void lookupAssertions() throws Exception{
        gotoMenuLinkLocator();
        super.testTermLookUp();
    }
}

/**
 * Copyright 2005-2011 The Kuali Foundation
 *
 * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
 *
 * 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 edu.samplu.mainmenu.test;

import org.junit.Test;

import edu.samplu.common.MainMenuLookupLegacyITBase;

/**
 * tests that user 'admin' can display the Term lookup screen, search,
 * initiate an Term maintenance document via an edit action on the search results and
 * finally cancel the maintenance document
 *
 * @author Kuali Rice Team (rice.collab@kuali.org)
 */
public class TermLookUpLegacyIT extends MainMenuLookupLegacyITBase {
    @Override
    public void testLookUp() {} // no-op to avoid https://jira.kuali.org/browse/KULRICE-9047 messing up the server state

    @Override
    public String getLinkLocator() {
        return "Term Lookup";
    }

    @Test
    public void lookupAssertions() throws Exception{
        gotoMenuLinkLocator();
        super.testTermLookUp();
    }
}

Disable term lookup smoke test to avoid any server impact till fixed.


package edu.pdx.cs410J.chances;

import edu.pdx.cs410J.AbstractAppointment;

import java.util.Date;

public class Appointment extends AbstractAppointment {
  private String beginTime;
  private String endTime;
  private String description;

  public Appointment() {}

  public Appointment(String description) {
    this.description = description;
  }

  /**
   * Set the time this appointment begins.
   */
  public void setBeginTime(Date beginTime) {
    this.beginTime = beginTime.toString();
  }

  /**
   * Set the time this appointment ends.
   */
  public void setEndTime(Date endTime) {
    this.endTime = endTime.toString();
  }

  /**
   * Get the time this appointment begins.
   *
   * @return String representation of appointment begin time
     */
  @Override
  public String getBeginTimeString() {
    return beginTime;
  }

  /**
   * Get the time this appointment ends.
   *
   * @return String representation of appointment end time
   */
  @Override
  public String getEndTimeString() {
    return endTime;
  }

  /**
   * Get the description of this appointment.
   *
   * @return Description of this appointment
   */
  @Override
  public String getDescription() {
    return description;
  }
}

package edu.pdx.cs410J.chances;

import edu.pdx.cs410J.AbstractAppointment;

import java.util.Date;

public class Appointment extends AbstractAppointment {
  private Date beginTime;
  private Date endTime;
  private String description;

  public Appointment() {}

  public Appointment(String description) {
    this.description = description;
  }

  /**
   * Set the time this appointment begins.
   */
  public void setBeginTime(Date beginTime) {
    this.beginTime = beginTime;
  }

  /**
   * Set the time this appointment ends.
   */
  public void setEndTime(Date endTime) {
    this.endTime = endTime;
  }

  /**
   * Get the time this appointment begins.
   *
   * @return String representation of appointment begin time
     */
  @Override
  public String getBeginTimeString() {
    return beginTime.toString();
  }

  /**
   * Get the time this appointment ends.
   *
   * @return String representation of appointment end time
   */
  @Override
  public String getEndTimeString() {
    return endTime.toString();
  }

  /**
   * Get the description of this appointment.
   *
   * @return Description of this appointment
   */
  @Override
  public String getDescription() {
    return description;
  }
}

Store begin and end times as dates


//
// XsltProc.java
//

import java.io.FileReader;
import java.io.IOException;
import loci.common.XMLTools;

import java.io.StringWriter;
import javax.xml.transform.Templates;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

/**
 * Transforms an XML document according to the given stylesheet,
 * similar to the xsltproc command line tool.
 */
public class XsltProc {
  public static void main(String[] args) throws Exception {
    if (args.length != 2) {
      System.out.println("Usage: java XsltProc stylesheet.xsl document.xml");
      System.exit(1);
    }
    String xsl = args[0];
    String xml = args[1];

    StreamSource xmlSource = new StreamSource(new FileReader(xml));
    StringWriter xmlWriter = new StringWriter();
    StreamResult xmlResult = new StreamResult(xmlWriter);

    // transform from source to result
    Templates stylesheet = XMLTools.getStylesheet(xsl, null);
    XMLTools.transformXML(xmlSource, stylesheet);

    String output = xmlWriter.toString();
    System.out.println(output);
  }
}

//
// XsltProc.java
//

import java.io.FileReader;
import java.io.IOException;
import loci.common.xml.XMLTools;

import java.io.StringWriter;
import javax.xml.transform.Templates;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

/**
 * Transforms an XML document according to the given stylesheet,
 * similar to the xsltproc command line tool.
 */
public class XsltProc {
  public static void main(String[] args) throws Exception {
    if (args.length != 2) {
      System.out.println("Usage: java XsltProc stylesheet.xsl document.xml");
      System.exit(1);
    }
    String xsl = args[0];
    String xml = args[1];

    StreamSource xmlSource = new StreamSource(new FileReader(xml));
    StringWriter xmlWriter = new StringWriter();
    StreamResult xmlResult = new StreamResult(xmlWriter);

    // transform from source to result
    Templates stylesheet = XMLTools.getStylesheet(xsl, null);
    XMLTools.transformXML(xmlSource, stylesheet);

    String output = xmlWriter.toString();
    System.out.println(output);
  }
}

Fix LOCI common utils compilation.


package com.github.therapi.core.interceptor;

import java.lang.annotation.Annotation;
import java.util.function.Predicate;

import com.github.therapi.core.MethodDefinition;
import org.aopalliance.intercept.MethodInterceptor;

/**
 * Factory methods for common method predicates, useful for registering method interceptors.
 *
 * @see com.github.therapi.core.MethodRegistry#intercept(Predicate, MethodInterceptor)
 */
public class MethodPredicates {
    private MethodPredicates() {
    }

    public static Predicate<MethodDefinition> any() {
        return methodDef -> true;
    }

    public static Predicate<MethodDefinition> methodAnnotatedWith(Class<? extends Annotation> annotationClass) {
        return methodDef -> methodDef.getMethod().getAnnotation(annotationClass) != null;
    }

    public static Predicate<MethodDefinition> qualifiedName(String name) {
        return methodDef -> methodDef.getQualifiedName(".").equals(name);
    }

    public static Predicate<MethodDefinition> namespace(String namespace) {
        return methodDef -> methodDef.getNamespace().orElse("").equals(namespace);
    }
}

package com.github.therapi.core.interceptor;

import java.lang.annotation.Annotation;
import java.util.function.Predicate;

import com.github.therapi.core.MethodDefinition;

/**
 * Factory methods for common method predicates, useful for registering method interceptors.
 *
 * @see com.github.therapi.core.MethodRegistry#intercept(Predicate, org.aopalliance.intercept.MethodInterceptor)
 */
public class MethodPredicates {
    private MethodPredicates() {
    }

    public static Predicate<MethodDefinition> any() {
        return methodDef -> true;
    }

    public static Predicate<MethodDefinition> methodAnnotatedWith(Class<? extends Annotation> annotationClass) {
        return methodDef -> methodDef.getMethod().getAnnotation(annotationClass) != null;
    }

    public static Predicate<MethodDefinition> qualifiedName(String name) {
        return methodDef -> methodDef.getQualifiedName(".").equals(name);
    }

    public static Predicate<MethodDefinition> namespace(String namespace) {
        return methodDef -> methodDef.getNamespace().orElse("").equals(namespace);
    }
}

Fix "unused import". It was used, but only by Javadoc.


/**
 * Copyright 2009 Joe LaPenna
 */

package com.joelapenna.foursquared;

/**
 * @author Joe LaPenna (joe@joelapenna.com)
 */
public class FoursquaredSettings {

    public static final boolean USE_DEBUG_SERVER = false;

    public static final boolean DEBUG = false;
    public static final boolean API_DEBUG = false;
    public static final boolean PARSER_DEBUG = false;

    public static final boolean USE_DUMPCATCHER = true;
    public static final boolean DUMPCATCHER_TEST = false;

}

/**
 * Copyright 2009 Joe LaPenna
 */

package com.joelapenna.foursquared;

/**
 * @author Joe LaPenna (joe@joelapenna.com)
 */
public class FoursquaredSettings {

    public static final boolean USE_DEBUG_SERVER = false;

    public static final boolean DEBUG = false;
    public static final boolean API_DEBUG = false;
    public static final boolean PARSER_DEBUG = false;
    public static final boolean LOCATION_DEBUG = false;

    public static final boolean USE_DUMPCATCHER = true;
    public static final boolean DUMPCATCHER_TEST = false;

}

Update example settings file for LOCATION_DEBUG


package de.paymill.net;

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

/**
 * A thin wrapper around a map object for declaring a list filter when querying
 * the webservice.
 */
public class Filter {

	private Map<String, Object> data;

	public Filter() {
		data = new HashMap<String, Object>();
	}

	/**
	 * Adds a new filter criteria.
	 *
	 * @param key
	 * @param filter
	 */
	public void add(String key, Object filter) {
		data.put(key, filter);
	}

	public Map<String, Object> toMap() {
		return new HashMap<String, Object>(data);
	}
}

package de.paymill.net;

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

/**
 * A thin wrapper around a map object for declaring a list filter when querying
 * the webservice.
 */
public class Filter {

	private Map<String, Object> data;

	public Filter() {
		data = new HashMap<String, Object>();
	}

	public Filter(Map<String, Object> data) {
		data = new HashMap<String, Object>(data);
	}

	/**
	 * Adds a new filter criteria.
	 *
	 * @param key
	 * @param filter
	 * @return this filter. Allows for method chaining.
	 */
	public Filter add(String key, Object filter) {
		data.put(key, filter);
		return this;
	}

	public Map<String, Object> toMap() {
		return new HashMap<String, Object>(data);
	}
}

Return instance from add for chaining. Add constructor that takes a map.


/*
       Licensed to the Apache Software Foundation (ASF) under one
       or more contributor license agreements.  See the NOTICE file
       distributed with this work for additional information
       regarding copyright ownership.  The ASF licenses this file
       to you under the Apache License, Version 2.0 (the
       "License"); you may not use this file except in compliance
       with the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

       Unless required by applicable law or agreed to in writing,
       software distributed under the License is distributed on an
       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
       KIND, either express or implied.  See the License for the
       specific language governing permissions and limitations
       under the License.
 */

package __ID__;

import android.app.Activity;
import android.os.Bundle;
import org.apache.cordova.*;

public class __ACTIVITY__ extends DroidGap
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        super.loadUrl("file:///android_asset/www/index.html");
    }
}

/*
       Licensed to the Apache Software Foundation (ASF) under one
       or more contributor license agreements.  See the NOTICE file
       distributed with this work for additional information
       regarding copyright ownership.  The ASF licenses this file
       to you under the Apache License, Version 2.0 (the
       "License"); you may not use this file except in compliance
       with the License.  You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

       Unless required by applicable law or agreed to in writing,
       software distributed under the License is distributed on an
       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
       KIND, either express or implied.  See the License for the
       specific language governing permissions and limitations
       under the License.
 */

package __ID__;

import android.os.Bundle;
import org.apache.cordova.*;

public class __ACTIVITY__ extends DroidGap
{
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        Config.init(this);
        super.loadUrl("file:///android_asset/www/index.html");
    }
}

Move config.xml parsing into its own Config class


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

package com.google.gerrit.metrics;

import java.time.Duration;

/** Configuration of the Metrics' reservoir type and size. */
public interface MetricsReservoirConfig {

  /** @return the reservoir type. */
  ReservoirType reservoirType();

  /** @return the reservoir window duration. */
  Duration reservoirWindow();

  /** @return the number of samples that the reservoir can contain */
  int reservoirSize();

  /** @return the alpha parameter of the ExponentiallyDecaying reservoir */
  double reservoirAlpha();
}

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

package com.google.gerrit.metrics;

import java.time.Duration;

/** Configuration of the Metrics' reservoir type and size. */
public interface MetricsReservoirConfig {

  /** Returns the reservoir type. */
  ReservoirType reservoirType();

  /** Returns the reservoir window duration. */
  Duration reservoirWindow();

  /** Returns the number of samples that the reservoir can contain */
  int reservoirSize();

  /** Returns the alpha parameter of the ExponentiallyDecaying reservoir */
  double reservoirAlpha();
}

Fix javadoc summary for Google Java Style


package models;

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

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import com.fasterxml.jackson.annotation.JsonIgnore;

import play.db.ebean.Model;
import play.db.ebean.Model.Finder;

//tar magnus feil?
@Entity
public class Guest extends Model {

	@Id
	public Long id;

	@OneToMany(cascade = CascadeType.ALL, mappedBy = "guest")
	@JsonIgnore
	public List<Booking> booking =new ArrayList<Booking>();

	/** TODO REMOVE TEST **/
	public Guest(long id) {
		this.id = id;
	}
	/** END TEST **/
	public static Finder<Long, Guest> find = new Finder<Long, Guest>(Long.class, Guest.class);
}

package models;

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

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

import com.fasterxml.jackson.annotation.JsonIgnore;

import play.db.ebean.Model;
import play.db.ebean.Model.Finder;

@Entity
public class Guest extends Model {

	@Id
	public Long id;

	@OneToMany(cascade = CascadeType.ALL, mappedBy = "guest")
	@JsonIgnore
	public List<Booking> booking =new ArrayList<Booking>();

	/** TODO REMOVE TEST **/
	public Guest(long id) {
		this.id = id;
	}
	/** END TEST **/
	public static Finder<Long, Guest> find = new Finder<Long, Guest>(Long.class, Guest.class);
}

Test commit, magnus tok ikke feil


package org.agmip.ui.acmoui;

import org.agmip.acmo.translators.AcmoTranslator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TranslateRunner implements Runnable {
	private AcmoTranslator translator;
	private String inputDirectory;
	private String outputDirectory;
	private static Logger LOG = LoggerFactory.getLogger(TranslateRunner.class);

	public TranslateRunner(AcmoTranslator translator, String inputDirectory,
			String outputDirectory) {
		this.translator = translator;
		this.inputDirectory = inputDirectory;
		this.outputDirectory = outputDirectory;
	}

	@Override
	public void run() {
		LOG.debug("Starting new thread!");
		boolean success = translator.execute(inputDirectory, outputDirectory);
		if (!success) {
			// TODO: Something to relate to the user something bad has happened.
		}

	}
}

package org.agmip.ui.acmoui;

import java.io.File;
import org.agmip.acmo.translators.AcmoTranslator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TranslateRunner implements Runnable {
	private AcmoTranslator translator;
	private String inputDirectory;
	private String outputDirectory;
	private static Logger LOG = LoggerFactory.getLogger(TranslateRunner.class);

	public TranslateRunner(AcmoTranslator translator, String inputDirectory,
			String outputDirectory) {
		this.translator = translator;
		this.inputDirectory = inputDirectory;
		this.outputDirectory = outputDirectory;
	}

	@Override
	public void run() {
		LOG.debug("Starting new thread!");
		File ret = translator.execute(inputDirectory, outputDirectory);
		if (ret != null && ret.exists()) {
			// TODO: Something to relate to the user something bad has happened.
		}

	}
}

Change return type handling for AcmoTranslator


package com.skraylabs.poker;

import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;

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

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

public class ApplicationTest {

  private static final String MSG_TOO_FEW_ARGS = "Too few arguments";
  private static final String MSG_TOO_MANY_ARGS = "Too many arguments";
  private static final String MSG_USAGE = "Usage: PokerCalculator filepath";

  /**
   * Output stream from Application.main() for test verification.
   */
  private ByteArrayOutputStream output;

  /**
   * Temporary reference to System.out
   */
  private PrintStream console;

  @Before
  public void setUp() throws Exception {
    output = new ByteArrayOutputStream();
    console = System.out;
    System.setOut(new PrintStream(output));
  }

  @After
  public void tearDown() throws Exception {
    System.setOut(console);
  }

  @Test
  public void testShowUsageForTooFewArguments() {
    // Exercise
    Application.main();
    // Verify
    String outputString = output.toString();
    assertThat(outputString, allOf(containsString(MSG_TOO_FEW_ARGS),
        containsString(MSG_USAGE)));
  }

}

package com.skraylabs.poker;

import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;

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

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

public class ApplicationTest {

  private static final String MSG_TOO_FEW_ARGS = "Too few arguments";
  private static final String MSG_TOO_MANY_ARGS = "Too many arguments";
  private static final String MSG_USAGE = "Usage: PokerCalculator filepath";

  /**
   * Output stream from Application.main() for test verification.
   */
  private ByteArrayOutputStream output;

  /**
   * Temporary reference to System.out
   */
  private PrintStream console;

  @Before
  public void setUp() throws Exception {
    output = new ByteArrayOutputStream();
    console = System.out;
    System.setOut(new PrintStream(output));
  }

  @After
  public void tearDown() throws Exception {
    System.setOut(console);
  }

  @Test
  public void testShowUsageForTooFewArguments() {
    // Exercise
    Application.main();
    // Verify
    String outputString = output.toString();
    assertThat(outputString, allOf(containsString(MSG_TOO_FEW_ARGS),
        containsString(MSG_USAGE)));
  }

  @Test
  public void testShowUsageForTooManyArguments() {
    // Exercise
    Application.main("1", "2");
    // Verify
    String outputString = output.toString();
    assertThat(outputString, allOf(containsString(MSG_TOO_MANY_ARGS),
        containsString(MSG_USAGE)));
  }

}

Add application test for “too many arguments”.


package org.cyclops.integratedtunnels.core;

import net.minecraft.item.ItemStack;

import javax.annotation.Nonnull;
import java.util.function.Predicate;

/**
 * A predicate for matching ItemStacks.
 * @author rubensworks
 */
public abstract class ItemStackPredicate implements Predicate<ItemStack> {

    private final ItemStack itemStack;
    private final int matchFlags;
    private final boolean blacklist;

    public ItemStackPredicate(@Nonnull ItemStack itemStack, int matchFlags, boolean blacklist) {
        this.itemStack = itemStack;
        this.matchFlags = matchFlags;
        this.blacklist = blacklist;
    }

    public ItemStackPredicate(boolean blacklist) {
        this(ItemStack.EMPTY, -1, blacklist);
    }

    @Nonnull
    public ItemStack getItemStack() {
        return itemStack;
    }

    public int getMatchFlags() {
        return matchFlags;
    }

    public boolean hasMatchFlags() {
        return getMatchFlags() >= 0;
    }

    public boolean isBlacklist() {
        return blacklist;
    }
}

package org.cyclops.integratedtunnels.core;

import net.minecraft.item.ItemStack;

import javax.annotation.Nonnull;
import java.util.function.Predicate;

/**
 * A predicate for matching ItemStacks.
 * @author rubensworks
 */
public abstract class ItemStackPredicate implements Predicate<ItemStack> {

    private final ItemStack itemStack;
    private final int matchFlags;
    private final boolean blacklist;

    public ItemStackPredicate(@Nonnull ItemStack itemStack, int matchFlags, boolean blacklist) {
        this.itemStack = itemStack;
        this.matchFlags = matchFlags;
        this.blacklist = blacklist;
    }

    public ItemStackPredicate(boolean blacklist) {
        this(ItemStack.EMPTY, -1, blacklist);
    }

    @Nonnull
    public ItemStack getItemStack() {
        return itemStack;
    }

    public int getMatchFlags() {
        return matchFlags;
    }

    public boolean hasMatchFlags() {
        return getMatchFlags() >= 0 && !getItemStack().isEmpty();
    }

    public boolean isBlacklist() {
        return blacklist;
    }
}

Fix item transfer happening on all items when an empty filter was given


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.zols.datastore.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class LoginController {

    @RequestMapping(value = "/login", method = RequestMethod.GET)
    public String login(ModelMap model) {
        return "login";
    }

    @RequestMapping(value = "/loginfailed", method = RequestMethod.GET)
    public String loginerror(ModelMap model) {
        model.addAttribute("error", "true");
        return "login";
    }

    @RequestMapping(value = "/logout", method = RequestMethod.GET)
    public String logout(ModelMap model) {
        return "login";
    }

}

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.zols.web.config.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class LoginController {

    @RequestMapping(value = "/login", method = RequestMethod.GET)
    public String login(ModelMap model) {
        return "login";
    }

    @RequestMapping(value = "/loginfailed", method = RequestMethod.GET)
    public String loginerror(ModelMap model) {
        model.addAttribute("error", "true");
        return "login";
    }

    @RequestMapping(value = "/logout", method = RequestMethod.GET)
    public String logout(ModelMap model) {
        return "login";
    }

}

Rename package to fix compilation issue


package utils;

public class EmailType {

    /*
    The local-part of the e-mail address may use any of these ASCII characters:
      - Uppercase and lowercase English letters (a-z, A-Z)
      - Digits 0 to 9
      - Characters ! # $ % & ' * + - / = ? ^ _ ` { | } ~
      - Character . (dot, period, full stop) provided that it is not the first or last character, and provided also that it does not appear two or more times consecutively.
    */
    public static Boolean isValid(String s){
      if(s != null && s.equals("") || s.matches("^([a-zA-Z0-9!#$%&'*\\+\\-/=\\?\\^_`{|}~\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)")) {
        return true;
      }
      return false;
    }

}

package utils;

public class EmailType {

    /*
    The local-part of the e-mail address may use any of these ASCII characters:
      - Uppercase and lowercase English letters (a-z, A-Z)
      - Digits 0 to 9
      - Characters ! # $ % & ' * + - / = ? ^ _ ` { | } ~
      - Character . (dot, period, full stop) provided that it is not the first or last character, and provided also that it does not appear two or more times consecutively.
    */
    public static Boolean isValid(String s){
      if(s != null && s.equals("") || s.matches("^([a-zA-Z0-9!#$%&'*\\+\\-/=\\?\\^_`{|}~\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,20}|[0-9]{1,3})(\\]?)")) {
        return true;
      }
      return false;
    }

}

Allow long domain extensions in email addresses


package com.ezardlabs.lostsector.objects;

import com.ezardlabs.dethsquare.Vector2;
import com.ezardlabs.lostsector.Game.DamageType;

public abstract class ShieldedEntity extends Entity {
	protected final int maxShield;
	protected int shield;
	private long shieldRegenTime;
	private long nextShieldRegen;

	public ShieldedEntity(int maxHealth, int maxShield, long shieldRegenTime) {
		super(maxHealth);
		this.maxShield = maxShield;
		shield = maxShield;
		this.shieldRegenTime = shieldRegenTime;
	}

	public int getShield() {
		return shield;
	}

	public void addShield(int shield) {
		this.shield += shield;
		if (this.shield > maxShield) {
			this.shield = maxShield;
		}
	}

	@Override
	public final void update() {
		if (shield < maxShield && System.currentTimeMillis() > nextShieldRegen) {
			shield++;
			nextShieldRegen = System.currentTimeMillis() + shieldRegenTime;
		}
	}

	@Override
	public void applyDamage(int damage, DamageType damageType,
			Vector2 attackOrigin) {
		if (shield > 0) {
			shield--;
			nextShieldRegen = System.currentTimeMillis() + shieldRegenTime;
			super.applyDamage(0, damageType, attackOrigin);
		} else {
			super.applyDamage(damage, damageType, attackOrigin);
		}
	}
}

package com.ezardlabs.lostsector.objects;

import com.ezardlabs.dethsquare.Vector2;
import com.ezardlabs.lostsector.Game.DamageType;

public abstract class ShieldedEntity extends Entity {
	protected final int maxShield;
	protected int shield;
	private long shieldRegenTime;
	private long nextShieldRegen;

	public ShieldedEntity(int maxHealth, int maxShield, long shieldRegenTime) {
		super(maxHealth);
		this.maxShield = maxShield;
		shield = maxShield;
		this.shieldRegenTime = shieldRegenTime;
	}

	public int getShield() {
		return shield;
	}

	public void addShield(int shield) {
		this.shield += shield;
		if (this.shield > maxShield) {
			this.shield = maxShield;
		}
	}

	@Override
	public final void update() {
		if (shield < maxShield && System.currentTimeMillis() > nextShieldRegen) {
			shield++;
			nextShieldRegen = System.currentTimeMillis() + shieldRegenTime;
		}
	}

	@Override
	public void applyDamage(int damage, DamageType damageType,
			Vector2 attackOrigin) {
		if (shield > 0) {
			shield--;
			super.applyDamage(0, damageType, attackOrigin);
		} else {
			super.applyDamage(damage, damageType, attackOrigin);
		}
		nextShieldRegen = System.currentTimeMillis() + shieldRegenTime;
	}
}

Reset shield regen timer every time damage is taken, even if the shield isn't damaged


package biz.plexers.sparrow.db;

import java.net.MalformedURLException;

import org.ektorp.CouchDbConnector;
import org.ektorp.CouchDbInstance;
import org.ektorp.DbAccessException;
import org.ektorp.http.HttpClient;
import org.ektorp.http.StdHttpClient;
import org.ektorp.impl.StdCouchDbInstance;

import biz.plexers.sparrow.db.exceptions.SignInException;

public class DbManager {
	private static HttpClient client = null;
	private static CouchDbConnector db = null;
	private static String dbURL = "db.plexers.biz:96";
	private static String dbName = "sol";

	public static boolean signIn(String username, String password) throws SignInException {
		if (client == null) {
			try {
				client = new StdHttpClient.Builder().url(dbURL)
						.username(username).password(password).build();
			} catch (MalformedURLException e) {
				e.printStackTrace();
			}
			CouchDbInstance dbInstance = new StdCouchDbInstance(client);
			db = dbInstance.createConnector(dbName, true);
			try {
				db.getAsStream("welcome");
			} catch (DbAccessException e) {
				throw new SignInException("Invalid Username or Password!");
			}
			return true;
		}
		throw new SignInException("You are already signed in!");
	}
}

package biz.plexers.sparrow.db;

import java.net.MalformedURLException;

import org.ektorp.CouchDbConnector;
import org.ektorp.CouchDbInstance;
import org.ektorp.DbAccessException;
import org.ektorp.http.HttpClient;
import org.ektorp.http.StdHttpClient;
import org.ektorp.impl.StdCouchDbInstance;

import biz.plexers.sparrow.db.exceptions.SignInException;

public class DbManager {
	private static HttpClient client = null;
	private static CouchDbConnector db = null;
	private static String dbURL = "http://db.plexers.biz:96";
	private static String dbName = "sol";

	public static boolean signIn(String username, String password)
			throws SignInException {
		if (client == null) {
			try {
				client = new StdHttpClient.Builder().url(dbURL)
						.username(username).password(password).build();
			} catch (MalformedURLException e) {
				e.printStackTrace();
			}
			CouchDbInstance dbInstance = new StdCouchDbInstance(client);
			try {
				db = dbInstance.createConnector(dbName, true);
			} catch (DbAccessException e) {
				throw new SignInException("Invalid Username or Password!");
			}
			return true;
		}
		throw new SignInException("You are already signed in!");
	}
}

Fix db link and signIn method


package org.embulk.decoder;

import org.embulk.config.Config;
import org.embulk.config.ConfigDefault;
import org.embulk.config.ConfigInject;
import org.embulk.config.ConfigSource;
import org.embulk.config.Task;
import org.embulk.config.TaskSource;
import org.embulk.spi.BufferAllocator;
import org.embulk.spi.DecoderPlugin;
import org.embulk.spi.FileInput;
import org.embulk.spi.util.FileInputInputStream;

public class CommonsCompressDecoderPlugin
        implements DecoderPlugin
{
    public interface PluginTask
            extends Task
    {
        @Config("format")
        @ConfigDefault("\"\"")
        public String getFormat();

        @ConfigInject
        public BufferAllocator getBufferAllocator();
    }

    @Override
    public void transaction(ConfigSource config, DecoderPlugin.Control control)
    {
        PluginTask task = config.loadConfig(PluginTask.class);
        control.run(task.dump());
    }

    @Override
    public FileInput open(TaskSource taskSource, FileInput input)
    {
        PluginTask task = taskSource.loadTask(PluginTask.class);
        return new CommonsCompressFileInput(
                task.getBufferAllocator(),
                new CommonsCompressProvider(task, new FileInputInputStream(input)));
    }
}

package org.embulk.decoder;

import org.embulk.config.Config;
import org.embulk.config.ConfigDefault;
import org.embulk.config.ConfigInject;
import org.embulk.config.ConfigSource;
import org.embulk.config.Task;
import org.embulk.config.TaskSource;
import org.embulk.spi.BufferAllocator;
import org.embulk.spi.DecoderPlugin;
import org.embulk.spi.FileInput;
import org.embulk.spi.util.FileInputInputStream;

public class CommonsCompressDecoderPlugin
        implements DecoderPlugin
{
    public interface PluginTask
            extends Task
    {
        @Config("format")
        @ConfigDefault("\"\"")
        public String getFormat();

        @ConfigInject
        public BufferAllocator getBufferAllocator();
    }

    @Override
    public void transaction(ConfigSource config, DecoderPlugin.Control control)
    {
        PluginTask task = config.loadConfig(PluginTask.class);
        control.run(task.dump());
    }

    @Override
    public FileInput open(TaskSource taskSource, FileInput input)
    {
        PluginTask task = taskSource.loadTask(PluginTask.class);
        return new CommonsCompressFileInput(
                task.getBufferAllocator(),
                new CommonsCompressProvider(task, new FileInputInputStream(input) {
                    // NOTE: This is workaround code to avoid hanging issue.
                    // This issue will be fixed after merging #112.
                    // https://github.com/embulk/embulk/pull/112
                    @Override
                    public long skip(long len) {
                        long skipped = super.skip(len);
                        return skipped > 0 ? skipped : 0;
                    }
                }));
    }
}

Add workaround code to avoid hanging by skip issue


package com.deuteriumlabs.dendrite.unittest;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.junit.Ignore;
import org.junit.Test;

import com.deuteriumlabs.dendrite.model.PageId;
import com.deuteriumlabs.dendrite.model.StoryPage;

public class StoryPageTest {
    final static String IMPLEMENT_ME = "Not implemented yet";
    final static String NOT_WRITTEN = "This page has not been written yet.";

    @Test
    public void testDefaultConstructor() {
        final StoryPage storyPage = new StoryPage();
        assertNull(storyPage.getBeginning());
        assertNull(storyPage.getAncestry());
        assertNull(storyPage.getAuthorId());
        assertNull(storyPage.getAuthorName());
        assertNull(storyPage.getBeginning());
        assertNull(storyPage.getFormerlyLovingUsers());
        assertNull(storyPage.getId());
        assertNull(storyPage.getLovingUsers());
        assertNull(storyPage.getParent());
        assertTrue(storyPage.getTags().isEmpty());
        assertEquals(storyPage.getLongSummary(), NOT_WRITTEN);
    }

    @Ignore(IMPLEMENT_ME)
    @Test
    public void testConstructorWithEntity() {
        fail(IMPLEMENT_ME);
    }

    @Ignore(IMPLEMENT_ME)
    @Test
    public void testCreate() {
        fail(IMPLEMENT_ME);
    }

    @Test
    public void testGetAncestry() {
        final StoryPage storyPage = new StoryPage();
        assertNull(storyPage.getAncestry());
    }
}

package com.deuteriumlabs.dendrite.unittest;

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

import org.junit.Ignore;
import org.junit.Test;

import com.deuteriumlabs.dendrite.model.StoryPage;

public class StoryPageTest {
    final static String IMPLEMENT_ME = "Not implemented yet";
    final static String NOT_WRITTEN = "This page has not been written yet.";

    @Test
    public void testDefaultConstructor() {
        final StoryPage storyPage = new StoryPage();
        assertNull(storyPage.getBeginning());
        assertNull(storyPage.getAncestry());
        assertNull(storyPage.getAuthorId());
        assertNull(storyPage.getAuthorName());
        assertNull(storyPage.getBeginning());
        assertNull(storyPage.getFormerlyLovingUsers());
        assertNull(storyPage.getId());
        assertNull(storyPage.getLovingUsers());
        assertNull(storyPage.getParent());
        assertTrue(storyPage.getTags().isEmpty());
        assertEquals(storyPage.getLongSummary(), NOT_WRITTEN);
    }

    @Ignore(IMPLEMENT_ME)
    @Test
    public void testConstructorWithEntity() {
        fail(IMPLEMENT_ME);
    }

    @Ignore(IMPLEMENT_ME)
    @Test
    public void testCreate() {
        fail(IMPLEMENT_ME);
    }

    @Ignore(IMPLEMENT_ME)
    @Test
    public void testGetAncestry() {
        fail(IMPLEMENT_ME);
    }
}

Remove test for null result


package pg.hadoop.pig;

import org.apache.pig.EvalFunc;
import org.apache.pig.data.Tuple;

import java.io.IOException;

/**
 * Returns the hashcode of the given String or Number.
 */
public class HashCode extends EvalFunc<Integer> {

    @Override
    public Integer exec(final Tuple input) throws IOException {
        if (input.size() != 1) {
            throw new IllegalArgumentException("HashCode function requires a String or Number parameter.");
        }

        final Object obj = input.get(0);
        if (!(obj instanceof String) && !(obj instanceof Number)) {
            throw new IllegalArgumentException("HashCode only supports Strings and Numbers");
        }
        return obj.hashCode();
    }
}

package pg.hadoop.pig;

import org.apache.pig.EvalFunc;
import org.apache.pig.data.Tuple;

import java.io.IOException;

/**
 * Returns the hashcode of the given String or Number.
 */
public class HashCode extends EvalFunc<Integer> {

    @Override
    public Integer exec(final Tuple input) throws IOException {
        if (input.size() != 1) {
            throw new IllegalArgumentException("HashCode function requires a String or Number parameter.");
        }

        final Object obj = input.get(0);
        if (!(obj instanceof String) && !(obj instanceof Number)) {
            throw new IllegalArgumentException("HashCode only supports Strings and Numbers. Value=" + String.valueOf(obj));
        }
        return obj.hashCode();
    }
}

Add value to the exception for debugging.


package br.com.alura.agenda.firebase;

import android.util.Log;

import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import java.util.Map;

public class AgendaMessagingService extends FirebaseMessagingService {

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);

        Map<String, String> mensagem = remoteMessage.getData();
        Log.i("mensagem recebida", String.valueOf(mensagem));
    }
}

package br.com.alura.agenda.firebase;

import android.util.Log;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;

import java.io.IOException;
import java.util.Map;
import br.com.alura.agenda.dao.AlunoDAO;
import br.com.alura.agenda.dto.AlunoSync;

public class AgendaMessagingService extends FirebaseMessagingService {

    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        super.onMessageReceived(remoteMessage);

        Map<String, String> mensagem = remoteMessage.getData();
        Log.i("mensagem recebida", String.valueOf(mensagem));

        converteParaAluno(mensagem);
    }

    private void converteParaAluno(Map<String, String> mensagem) {
        String chaveDeAcesso = "alunoSync";
        if (mensagem.containsKey(chaveDeAcesso)) {
            String json = mensagem.get(chaveDeAcesso);
            ObjectMapper mapper = new ObjectMapper();
            try {
                AlunoSync alunoSync = mapper.readValue(json, AlunoSync.class);
                AlunoDAO alunoDAO = new AlunoDAO(this);
                alunoDAO.sincroniza(alunoSync.getAlunos());
                alunoDAO.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

Convert info send by server into student objects


package com.mattunderscore.trees.construction;

import com.mattunderscore.trees.tree.Tree;

import java.lang.reflect.ParameterizedType;

/**
 * Type key to support generics when constructing trees.
 * @author Matt Champion
 */
public abstract class TypeKey<T extends Tree<?, ?>> {
    private final Class<T> type;

    @SuppressWarnings("unchecked")
    public TypeKey() {
        final ParameterizedType concreteParameterizedType = (ParameterizedType) getClass().getGenericSuperclass();
        final ParameterizedType parameterizedType = (ParameterizedType) concreteParameterizedType.getActualTypeArguments()[0];
        type = (Class<T>) parameterizedType.getRawType();
    }

    public final Class<T> getType() {
        return type;
    }

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

        final TypeKey typeKey = (TypeKey) o;

        return type.equals(typeKey.type);
    }

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

    @Override
    public final String toString() {
        return "TypeKey:" + type.getName();
    }
}

package com.mattunderscore.trees.construction;

import com.mattunderscore.trees.tree.Tree;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

/**
 * Type key to support generics when constructing trees.
 * @author Matt Champion
 */
public abstract class TypeKey<T extends Tree<?, ?>> {
    private final Class<T> type;

    @SuppressWarnings("unchecked")
    public TypeKey() {
        final ParameterizedType concreteParameterizedType = (ParameterizedType) getClass().getGenericSuperclass();
        final Type treeType = concreteParameterizedType.getActualTypeArguments()[0];
        if (treeType instanceof ParameterizedType) {
            final ParameterizedType parameterizedType = (ParameterizedType) treeType;
            type = (Class<T>) parameterizedType.getRawType();
        }
        else if (treeType instanceof Class) {
            type = (Class<T>) treeType;
        }
        else {
            throw new IllegalStateException("Unable to identify tree class");
        }
    }

    public final Class<T> getType() {
        return type;
    }

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

        final TypeKey typeKey = (TypeKey) o;

        return type.equals(typeKey.type);
    }

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

    @Override
    public final String toString() {
        return "TypeKey:" + type.getName();
    }
}

Allow exactly specified trees to be represented by type keys


package com.jstanier.tweetscheduler.main;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan("com.jstanier")
public class Config {

}

package com.jstanier.tweetscheduler.main;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@ComponentScan("com.jstanier.tweetscheduler")
public class Config {

}

Make component scan more specific


/**
 * Copyright © 2011-2012 EMBL - European Bioinformatics Institute
 *
 * 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 uk.ac.ebi.phenotype.dao;

/**
 *
 * Organisation (institute, company) data access manager interface.
 *
 * @author Gautier Koscielny (EMBL-EBI) <koscieln@ebi.ac.uk>
 * @since February 2012
 */

import java.util.List;

import uk.ac.ebi.phenotype.pojo.Organisation;

public interface OrganisationDAO {

	/**
	 * Get all organisations
	 * @return all organisations
	 */
	public List<Organisation> getAllOrganisations();

	/**
	 * Find an organisation by its name.
	 * @param name the organisation name
	 * @return the organisation
	 */
	public Organisation getOrganisationByName(String name);
}

/**
 * Copyright © 2011-2013 EMBL - European Bioinformatics Institute
 *
 * 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 uk.ac.ebi.phenotype.dao;

/**
 *
 * Organisation (institute, company) data access manager interface.
 *
 * @author Gautier Koscielny (EMBL-EBI) <koscieln@ebi.ac.uk>
 * @since February 2012
 */

import java.util.List;

import uk.ac.ebi.phenotype.pojo.Organisation;

public interface OrganisationDAO {

	/**
	 * Get all organisations
	 * @return all organisations
	 */
	public List<Organisation> getAllOrganisations();

	/**
	 * Find an organisation by its name.
	 * @param name the organisation name
	 * @return the organisation
	 */
	public Organisation getOrganisationByName(String name);
}

Change copyright in Apache 2 license to 2013


import ch.rasc.embeddedtc.EmbeddedTomcat;

public class Spring4WSStartTomcat {
	public static void main(String[] args) throws Exception {
		EmbeddedTomcat.create().startAndWait();
	}
}

import ch.rasc.embeddedtc.EmbeddedTomcat;

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

		// -Dtwitter4j.debug=false
		// -Dtwitter4j.oauth.consumerKey=<consumerKey>
		// -Dtwitter4j.oauth.consumerSecret=<secretKey>
		// -Dtwitter4j.oauth.accessToken=<accessToken>
		// -Dtwitter4j.oauth.accessTokenSecret=<accessTokenSecret>
		// -DTAIL_GEOCITY_DAT=<path_to_GeoLiteCity.dat>   download it from here: http://dev.maxmind.com/geoip/legacy/geolite/
		// -DTAIL_ACCESS_LOG=<path_to_http_server_access_log>
		// -Dbandwidth.network.interface=<network_interface>

		EmbeddedTomcat.create().startAndWait();
	}
}

Add a list of all the system properties that the application need


package info.u_team.u_team_core.data;

import java.io.IOException;
import java.util.Arrays;

import net.minecraft.resources.*;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.fml.loading.FMLLoader;

public class ExistingFileHelperWithForge extends ExistingFileHelper {

	private final ExistingFileHelper existingFileHelper;

	public ExistingFileHelperWithForge(ExistingFileHelper helper) {
		super(Arrays.asList(FMLLoader.getForgePath()), helper.isEnabled());
		this.existingFileHelper = helper;
	}

	public boolean exists(ResourceLocation loc, ResourcePackType type, String pathSuffix, String pathPrefix) {
		final boolean exists = existingFileHelper.exists(loc, type, pathSuffix, pathPrefix);
		if (!exists) {
			return super.exists(loc, type, pathSuffix, pathPrefix);
		}
		return exists;
	}

	public IResource getResource(ResourceLocation loc, ResourcePackType type, String pathSuffix, String pathPrefix) throws IOException {
		try {
			return existingFileHelper.getResource(loc, type, pathSuffix, pathPrefix);
		} catch (IOException ex) {
			return super.getResource(loc, type, pathSuffix, pathPrefix);
		}
	}
}

package info.u_team.u_team_core.data;

import java.io.IOException;
import java.util.Arrays;

import net.minecraft.resources.*;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.fml.loading.FMLLoader;

class ExistingFileHelperWithForge extends ExistingFileHelper {

	private final ExistingFileHelper existingFileHelper;

	protected ExistingFileHelperWithForge(ExistingFileHelper helper) {
		super(Arrays.asList(FMLLoader.getForgePath()), helper.isEnabled());
		this.existingFileHelper = helper;
	}

	public boolean exists(ResourceLocation loc, ResourcePackType type, String pathSuffix, String pathPrefix) {
		final boolean exists = existingFileHelper.exists(loc, type, pathSuffix, pathPrefix);
		if (!exists) {
			return super.exists(loc, type, pathSuffix, pathPrefix);
		}
		return exists;
	}

	public IResource getResource(ResourceLocation loc, ResourcePackType type, String pathSuffix, String pathPrefix) throws IOException {
		try {
			return existingFileHelper.getResource(loc, type, pathSuffix, pathPrefix);
		} catch (IOException ex) {
			return super.getResource(loc, type, pathSuffix, pathPrefix);
		}
	}
}

Make the class package private


package google;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import google.main.ResultProcessor;

@SpringBootApplication
public class ResultCounter implements CommandLineRunner {

	static {
		System.setProperty("logFilename", "log4j2.log");
	}

	@Autowired
	private ResultProcessor resultProcessor;

	/*
	 * If you want to see the database, type '--show-db'. If you want to get sorted
	 * or remove answers, type '--sort' or '--remove', respectively, as the first
	 * argument.
	 */
	public static void main(String... args) {
		SpringApplication.run(ResultCounter.class, args);
	}

	@Override
	public void run(String... args) throws Exception {
		resultProcessor.process(args);
	}

}

package google;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import google.main.ResultProcessor;

@SpringBootApplication
public class ResultCounter implements CommandLineRunner {

	static {
		System.setProperty("logFilename", "log4j2.log");
	}

	@Autowired
	private ResultProcessor resultProcessor;

	/**
	 * The main method of the application.
	 *
	 * The first argument can be one of the following flags:
	 *

	 *
--clear-db if you want to remove all data stored in the
	 * database;

	 *
--remove if you want to remove specific data from the
	 * database;

	 *
--show-db if you want to see the whole database.

	 *

	 * By default, if no flag is passed, the app prints the number of results found
	 * by Google for the given arguments. In such a case the answer is sorted
	 * descending with respect to popularity.
	 *
	 * @param args
	 *            Arguments to be processed, the first one can a flag.
	 */
	public static void main(String... args) {
		SpringApplication.run(ResultCounter.class, args);
	}

	@Override
	public void run(String... args) throws Exception {
		resultProcessor.process(args);
	}

}

Update Java doc of the main method.


package com.deweysasser.example.webserver;

import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;

/** Serve up a basic Hello World page
 *
 * @author Dewey Sasser
 *
 */
public class GoodbyePage implements HttpHandler {

	@Override
	public void handle(HttpExchange req) throws IOException {
		String response = "
Goodbye Cruel World
What a world
What a world...";

		req.sendResponseHeaders(200, response.length());
		OutputStream os = req.getResponseBody();

		os.write(response.getBytes());
		os.close();

		System.exit(0);
	}

}

package com.deweysasser.example.webserver;

import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;

/** Serve up a basic Hello World page
 *
 * @author Dewey Sasser
 *
 */
public class GoodbyePage implements HttpHandler {

	@Override
	public void handle(HttpExchange req) throws IOException {
		String response = "
Goodbye Cruel World
What a world
What a world...";

		req.sendResponseHeaders(200, response.length());
		OutputStream os = req.getResponseBody();

		os.write(response.getBytes());
		os.close();

		req.getHttpContext().getServer().stop(0);
	}

}

Change 'goodbye' handler to use proper exit methodology.


/*
 *    Copyright 2010 The myBatis Team
 *
 *    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.mybatis.spring;

import org.apache.ibatis.session.SqlSession;
import org.springframework.transaction.support.ResourceHolderSupport;

/**
 *
 * @version $Id$
 */
public final class SqlSessionHolder extends ResourceHolderSupport {

    private final SqlSession session;

    public SqlSessionHolder(SqlSession session) {
        assert session != null;
        this.session = session;
    }

    public SqlSession getSqlSession() {
        return session;
    }

}

/*
 *    Copyright 2010 The myBatis Team
 *
 *    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.mybatis.spring;

import org.apache.ibatis.session.SqlSession;
import org.springframework.transaction.support.ResourceHolderSupport;
import org.springframework.util.Assert;

/**
 *
 * @version $Id$
 */
public final class SqlSessionHolder extends ResourceHolderSupport {

    private final SqlSession sqlSession;

    public SqlSessionHolder(SqlSession sqlSession) {
        Assert.notNull(sqlSession, "SqlSession must not be null");
        this.sqlSession = sqlSession;
    }

    public SqlSession getSqlSession() {
        return sqlSession;
    }

}

Replace 'assert session != null' with Assert.notnull(Object, String)


package uk.co.imallan.tuchongdaily.api.data;

import java.io.Serializable;
import java.util.List;

import uk.co.imallan.tuchongdaily.db.model.Post;

/**
 * Created by allan on 15/1/30.
 */
public class DataPosts extends BaseData {

	private List<Post> posts;

	public List<Post> getPosts() {
		return posts;
	}

	public void setPosts(List<Post> posts) {
		this.posts = posts;
	}
}

package uk.co.imallan.tuchongdaily.api.data;

import java.util.List;

import uk.co.imallan.tuchongdaily.db.model.Post;

/**
 * Created by allan on 15/1/30.
 */
public class DataPosts extends BaseData {

	private List<Post> posts;

	public List<Post> getPosts() {
		return posts;
	}

	public void setPosts(List<Post> posts) {
		this.posts = posts;
	}
}

Reformat Code and optimize imports


package com.bbn.bue.common;

import com.google.common.base.Function;
import com.google.common.collect.Ordering;

public final class OrderingUtils {

  private OrderingUtils() {
    throw new UnsupportedOperationException();
  }

  /**
   * Gets a function which maps any iterable to its minimum according to the supplied {@link
   * com.google.common.collect.Ordering}.  If no such minimum exists for an input, it will throw an
   * exception as specified in {@link Ordering#min(Iterable)}.
   */
  public static <T> Function<Iterable<T>, T> minFunction(final Ordering<T> ordering) {
    return new Function<Iterable<T>, T>() {
      @Override
      public T apply(Iterable<T> input) {
        return ordering.min(input);
      }
    };
  }

  /**
   * Gets a function which maps any iterable to its maximum according to the supplied {@link
   * com.google.common.collect.Ordering}.  If no such maximum exists for an input, it will throw an
   * exception as specified in {@link Ordering#max(Iterable)}.
   */
  public static <T> Function<Iterable<T>, T> maxFunction(final Ordering<T> ordering) {
    return new Function<Iterable<T>, T>() {
      @Override
      public T apply(Iterable<T> input) {
        return ordering.max(input);
      }
    };
  }

  /**
   * Orders Ts in some domain by their image under F using the onFunctionResultOrdering
   */
  public static <T,V> Ordering<T> onResultOf(final Function<T, V> F, final Ordering<V> onFunctionResult) {
    return new Ordering<T>() {
      @Override
      public int compare(final T t, final T t1) {
        return onFunctionResult.compare(F.apply(t), F.apply(t1));
      }
    };
  }
}

package com.bbn.bue.common;

import com.google.common.base.Function;
import com.google.common.collect.Ordering;

public final class OrderingUtils {

  private OrderingUtils() {
    throw new UnsupportedOperationException();
  }

  /**
   * Gets a function which maps any iterable to its minimum according to the supplied {@link
   * com.google.common.collect.Ordering}.  If no such minimum exists for an input, it will throw an
   * exception as specified in {@link Ordering#min(Iterable)}.
   */
  public static <T> Function<Iterable<T>, T> minFunction(final Ordering<T> ordering) {
    return new Function<Iterable<T>, T>() {
      @Override
      public T apply(Iterable<T> input) {
        return ordering.min(input);
      }
    };
  }

  /**
   * Gets a function which maps any iterable to its maximum according to the supplied {@link
   * com.google.common.collect.Ordering}.  If no such maximum exists for an input, it will throw an
   * exception as specified in {@link Ordering#max(Iterable)}.
   */
  public static <T> Function<Iterable<T>, T> maxFunction(final Ordering<T> ordering) {
    return new Function<Iterable<T>, T>() {
      @Override
      public T apply(Iterable<T> input) {
        return ordering.max(input);
      }
    };
  }
}

Revert "add ability to order a domain D by the result of a function F and an Ordering O on the image of F"


package com.intellij.ide;

import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.ui.popup.IdePopup;
import com.intellij.ui.popup.StackingPopupDispatcher;
import com.intellij.ui.popup.JBPopupImpl;

import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;

public final class IdePopupManager implements IdeEventQueue.EventDispatcher {
  private static final Logger LOG = Logger.getInstance("com.intellij.ide.IdePopupManager");

  private IdePopup myActivePopup;

  boolean isPopupActive() {
    if (myActivePopup != null) {
      final Component component = myActivePopup.getComponent();
      if (component == null || !component.isShowing()) {
        IdePopup activePopup = myActivePopup;
        myActivePopup = null;
        if (component == null) {
          LOG.error("Popup " + activePopup + " is set up as active but not showing (component=null)");
        }
        else if (activePopup instanceof JBPopupImpl) {
          LOG.error("Popup [JBPop upImpl] " + ((JBPopupImpl) activePopup).getContent() + " is set up as active but not showing");
        }
        else {
          LOG.error("Popup " + component + " is set up as active but not showing");
        }
      }
    }
    return myActivePopup != null;
  }

  public boolean dispatch(AWTEvent e) {
    LOG.assertTrue(isPopupActive());

    if (e instanceof KeyEvent || e instanceof MouseEvent) {
      return myActivePopup.dispatch(e);
    }

    return false;
  }

  public void setActivePopup(IdePopup popup) {
    myActivePopup = popup;
  }

  public void resetActivePopup() {
    myActivePopup = null;
  }

  public boolean closeActivePopup(){
    return myActivePopup instanceof StackingPopupDispatcher && ((StackingPopupDispatcher)myActivePopup).closeActivePopup();
  }
}

package com.intellij.ide;

import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.ui.popup.IdePopup;
import com.intellij.ui.popup.StackingPopupDispatcher;

import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;

public final class IdePopupManager implements IdeEventQueue.EventDispatcher {
  private static final Logger LOG = Logger.getInstance("com.intellij.ide.IdePopupManager");

  private IdePopup myActivePopup;

  boolean isPopupActive() {
    if (myActivePopup != null) {
      final Component component = myActivePopup.getComponent();
      if (component == null || !component.isShowing()) {
        myActivePopup = null;
      }
    }
    return myActivePopup != null;
  }

  public boolean dispatch(AWTEvent e) {
    LOG.assertTrue(isPopupActive());

    if (e instanceof KeyEvent || e instanceof MouseEvent) {
      return myActivePopup.dispatch(e);
    }

    return false;
  }

  public void setActivePopup(IdePopup popup) {
    myActivePopup = popup;
  }

  public void resetActivePopup() {
    myActivePopup = null;
  }

  public boolean closeActivePopup(){
    return myActivePopup instanceof StackingPopupDispatcher && ((StackingPopupDispatcher)myActivePopup).closeActivePopup();
  }
}

Remove assertion in favor to correct recover.


package org.pitest.cucumber;

import cucumber.api.junit.Cucumber;
import cucumber.runtime.Runtime;
import cucumber.runtime.model.CucumberScenario;
import gherkin.formatter.Formatter;
import gherkin.formatter.Reporter;
import gherkin.formatter.model.TagStatement;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.pitest.testapi.ResultCollector;

import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;

@RunWith(MockitoJUnitRunner.class)
public class ScenarioTestUnitTest {

    @Mock
    CucumberScenario scenario;

    @Mock
    private ResultCollector resultCollector;

    @Before
    public void setUp() throws Exception {
        TagStatement gherkin = mock(TagStatement.class);
        when(scenario.getGherkinModel()).thenReturn(gherkin);
    }

    @Test
    public void should_run_scenario_and_call_collector_when_ran() {
        // given
        ScenarioTestUnit testUnit = new ScenarioTestUnit(HideFromJUnit.Concombre.class, scenario);

        // when
        testUnit.execute(getClass().getClassLoader(), resultCollector);

        // then
        verify(scenario, times(1)).run(any(Formatter.class), any(Reporter.class), any(Runtime.class));
    }

    private static class HideFromJUnit {

        @RunWith(Cucumber.class)
        private static class Concombre {
        }

    }
}

package org.pitest.cucumber;

import cucumber.api.junit.Cucumber;
import cucumber.runtime.Runtime;
import cucumber.runtime.model.CucumberScenario;
import gherkin.formatter.Formatter;
import gherkin.formatter.Reporter;
import gherkin.formatter.model.TagStatement;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.pitest.testapi.ResultCollector;

import static org.mockito.Matchers.any;
import static org.mockito.Mockito.*;

@RunWith(MockitoJUnitRunner.class)
public class ScenarioTestUnitTest {

    @Mock
    CucumberScenario scenario;

    @Mock
    private ResultCollector resultCollector;

    @Before
    public void setUp() throws Exception {
        TagStatement gherkin = mock(TagStatement.class);
        when(scenario.getGherkinModel()).thenReturn(gherkin);
    }

    @Test
    public void should_run_scenario_and_call_collector_when_ran() {
        // given
        ScenarioTestUnit testUnit = new ScenarioTestUnit(HideFromJUnit.Concombre.class, scenario);

        // when
        testUnit.execute(resultCollector);

        // then
        verify(scenario, times(1)).run(any(Formatter.class), any(Reporter.class), any(Runtime.class));
    }

    private static class HideFromJUnit {

        @RunWith(Cucumber.class)
        private static class Concombre {
        }

    }
}

Update to support FIT 1.4.3-SNAPSHOT


package sleepyweasel.purplefluffernutter;

import android.widget.Button;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;

import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;

@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class)
public class EditMovieActivityTest {

    @Test
    public void shouldOnClickSaveButtonAddMovieToContentProvider() throws Exception {
        EditMovieActivity activity = Robolectric.setupActivity(EditMovieActivity.class);
        Button saveButton = (Button) activity.findViewById(R.id.button_save);
        MovieContentProvider contentProvider = MovieContentProvider.getInstance();
        contentProvider.clear();

        saveButton.performClick();

        assertThat(contentProvider.isEmpty()).isFalse();
    }

    //TODO: shouldNotSaveAMovieWithoutATitle
}

package sleepyweasel.purplefluffernutter;

import android.widget.Button;
import android.widget.TextView;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;

import butterknife.ButterKnife;
import butterknife.InjectView;

import static org.assertj.core.api.Assertions.*;
import static org.junit.Assert.*;

@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class)
public class EditMovieActivityTest {

    @InjectView(R.id.button_save) Button saveButton;

    @InjectView(R.id.movie_title_value) TextView movieTitleTextView;

    void initActivity() {
        EditMovieActivity activity = Robolectric.setupActivity(EditMovieActivity.class);
        ButterKnife.inject(this, activity);
    }

    MovieContentProvider getEmptyContentProvider() {
        MovieContentProvider contentProvider = MovieContentProvider.getInstance();
        contentProvider.clear();
        return contentProvider;
    }

    @Test
    public void shouldOnClickSaveButtonAddMovieToContentProvider() throws Exception {
        initActivity();
        String movieTitle = movieTitleTextView.getText().toString();
        MovieContentProvider contentProvider = getEmptyContentProvider();

        saveButton.performClick();

        assertThat(contentProvider.size()).isEqualTo(1);
        MovieEntry entry = contentProvider.getEntry(0);
        assertThat(entry.getTitle()).isEqualTo(movieTitle);
    }

    //TODO: shouldNotSaveAMovieWithoutATitle
}

Enhance test for adding movie on save


package com.bloatit.framework.webprocessor.annotations;

public class Message {
    public enum What {
        UNKNOWN, NOT_FOUND, CONVERSION_ERROR, MIN_ERROR, MAX_ERROR, NO_ERROR, LENGTH_ERROR, OPTIONAL_ERROR, PRECISION_ERROR
    }

    private final String message;
    private final What what;

    public Message(final String message, final What what, final String name, final String value) {
        super();
        if (what == null || message == null) {
            throw new NullPointerException();
        }
        this.message = extractErrorMessage(message, name, value);
        this.what = what;
    }

    public Message(final String message) {
        this.message = message;
        this.what = What.UNKNOWN;
    }

    private String extractErrorMessage(final String aMessage, final String name, final String value) {
        String errorMsg = aMessage.replaceAll("%param", name);
        if (!value.isEmpty()) {
            errorMsg = errorMsg.replaceAll("%value", value);
        } else {
            errorMsg = errorMsg.replaceAll("%value", "null");
        }
        return errorMsg;
    }

    public String getMessage() {
        return message;
    }

    public What getWhat() {
        return what;
    }
}

package com.bloatit.framework.webprocessor.annotations;

import java.util.regex.Matcher;

public class Message {
    public enum What {
        UNKNOWN, NOT_FOUND, CONVERSION_ERROR, MIN_ERROR, MAX_ERROR, NO_ERROR, LENGTH_ERROR, OPTIONAL_ERROR, PRECISION_ERROR
    }

    private final String message;
    private final What what;

    public Message(final String message, final What what, final String name, final String value) {
        super();
        if (what == null || message == null) {
            throw new NullPointerException();
        }
        this.message = extractErrorMessage(message, name, value);
        this.what = what;
    }

    public Message(final String message) {
        this.message = message;
        this.what = What.UNKNOWN;
    }

    private String extractErrorMessage(final String aMessage, final String name, final String value) {
        String errorMsg = aMessage.replaceAll("%param", Matcher.quoteReplacement(name));
        if (!value.isEmpty()) {
            errorMsg = errorMsg.replaceAll("%value", Matcher.quoteReplacement(value));
        } else {
            errorMsg = errorMsg.replaceAll("%value", "null");
        }
        return errorMsg;
    }

    public String getMessage() {
        return message;
    }

    public What getWhat() {
        return what;
    }
}

Fix message generation: when the value contained replacement group for regex it was crashing


package com.github.onsdigital.json.release;

import com.github.onsdigital.json.ContentType;
import com.github.onsdigital.json.Reference;
import com.github.onsdigital.json.dataset.Dataset;
import com.github.onsdigital.json.markdown.Article;
import com.github.onsdigital.json.markdown.Bulletin;

/**
 * Represents a section in a release
 */
public class ReleaseSection extends Reference {

	public ContentType type;

	/**
	 * Creates an {@link Article} reference.
	 *
	 * @param article
	 *            The item to be referenced.
	 */
	public ReleaseSection(Article article) {
		super(article);
		this.type = ContentType.article;
	}

	/**
	 * Creates a {@link Bulletin} reference.
	 *
	 * @param bulletin
	 *            The item to be referenced.
	 */
	public ReleaseSection(Bulletin bulletin) {
		super(bulletin);
		this.type = ContentType.bulletin;
	}

	/**
	 * Creates a {@link Dataset} reference.
	 *
	 * @param dataset
	 *            The item to be referenced.
	 */
	public ReleaseSection(Dataset dataset) {
		super(dataset);
		this.type = ContentType.dataset;
	}
}

package com.github.onsdigital.json.release;

import com.github.onsdigital.json.ContentType;
import com.github.onsdigital.json.Reference;
import com.github.onsdigital.json.dataset.Dataset;
import com.github.onsdigital.json.markdown.Article;
import com.github.onsdigital.json.markdown.Bulletin;

/**
 * Represents a section in a release
 */
public class ReleaseSection extends Reference {

	/**
	 * Creates an {@link Article} reference.
	 *
	 * @param article
	 *            The item to be referenced.
	 */
	public ReleaseSection(Article article) {
		super(article);
		this.type = ContentType.article;
	}

	/**
	 * Creates a {@link Bulletin} reference.
	 *
	 * @param bulletin
	 *            The item to be referenced.
	 */
	public ReleaseSection(Bulletin bulletin) {
		super(bulletin);
		this.type = ContentType.bulletin;
	}

	/**
	 * Creates a {@link Dataset} reference.
	 *
	 * @param dataset
	 *            The item to be referenced.
	 */
	public ReleaseSection(Dataset dataset) {
		super(dataset);
		this.type = ContentType.dataset;
	}
}

Fix for duplicat field in Json serialisation.


// ========================================================================
// Copyright 2010 NEXCOM Systems
// ------------------------------------------------------------------------
// 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.cipango.diameter.router;

import java.util.Hashtable;
import java.util.Map;

import org.cipango.diameter.node.DiameterRequest;
import org.cipango.diameter.node.Node;
import org.cipango.diameter.node.Peer;

public class DefaultRouter implements DiameterRouter
{

	private Map<String, Peer> _peers = new Hashtable<String, Peer>();

	public Peer getRoute(DiameterRequest request)
	{
		return _peers.get(request.getDestinationHost());
	}

	public void peerAdded(Peer peer)
	{
		_peers.put(peer.getHost(), peer);
	}

	public void peerRemoved(Peer peer)
	{
		_peers.remove(peer.getHost());
	}

}

// ========================================================================
// Copyright 2010 NEXCOM Systems
// ------------------------------------------------------------------------
// 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.cipango.diameter.router;

import java.util.Hashtable;
import java.util.Map;

import org.cipango.diameter.node.DiameterRequest;
import org.cipango.diameter.node.Peer;

public class DefaultRouter implements DiameterRouter
{

	private Map<String, Peer> _peers = new Hashtable<String, Peer>();

	public Peer getRoute(DiameterRequest request)
	{
		if (request.getDestinationHost() == null)
			return null;
		return _peers.get(request.getDestinationHost());
	}

	public void peerAdded(Peer peer)
	{
		_peers.put(peer.getHost(), peer);
	}

	public void peerRemoved(Peer peer)
	{
		_peers.remove(peer.getHost());
	}

}

Fix CIPANGO-99: Creating a DiameterServletRequest without specifying the destinationhost field leads to a null pointer exception when sending a the request


package edu.cmu.sv.trailscribe;

import android.test.ActivityInstrumentationTestCase2;

import edu.cmu.sv.trailscribe.view.MainActivity;
import android.widget.GridView;

/**
 * This is a simple framework for a test of an Application.  See
 * {@link android.test.ApplicationTestCase ApplicationTestCase} for more information on
 * how to write and extend Application tests.
 * <p/>
 * To run this test, you can type:
 * adb shell am instrument -w \
 * -e class edu.cmu.sv.trailscribe.view.MainActivityTest \
 * edu.cmu.sv.trailscribe.tests/android.test.InstrumentationTestRunner
 */
public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActivity> {

    private MainActivity tMainActivity;
    private GridView tGridView;

    public MainActivityTest() {
        super("edu.cmu.sv.trailscribe", MainActivity.class);
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        tMainActivity = getActivity();
        tGridView = (GridView) tMainActivity
            .findViewById(R.id.main_buttongrid);
    }

    public void testPreconditions() {
        assertNotNull("tMainActivity is null", tMainActivity);
        assertNotNull("tGridView is null", tGridView);
    }

    public void testGridView_viewCount() {
        final int expected = 4;
        final int actual = tGridView.getAdapter().getCount();
        assertEquals(expected, actual);
    }
}

package edu.cmu.sv.trailscribe;

import android.test.ActivityInstrumentationTestCase2;

import edu.cmu.sv.trailscribe.view.MainActivity;

import android.widget.GridView;

/**
 * This is a simple framework for a test of an Application.  See
 * {@link android.test.ApplicationTestCase ApplicationTestCase} for more information on
 * how to write and extend Application tests.
 * <p/>
 * To run this test, you can type:
 * adb shell am instrument -w \
 * -e class edu.cmu.sv.trailscribe.view.MainActivityTest \
 * edu.cmu.sv.trailscribe.tests/android.test.InstrumentationTestRunner
 */
public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActivity> {
    private static final int GRIDVIEW_ELEMENTS = 4;

    private MainActivity tMainActivity;
    private GridView tGridView;

    public MainActivityTest() {
        super("edu.cmu.sv.trailscribe", MainActivity.class);
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        tMainActivity = getActivity();
        tGridView = (GridView) tMainActivity
            .findViewById(R.id.main_buttongrid);
    }

    public void testPreconditions() {
        assertNotNull("tMainActivity is null", tMainActivity);
        assertNotNull("tGridView is null", tGridView);
    }

    public void testGridView_viewCount() {
        final int expected = GRIDVIEW_ELEMENTS;
        final int actual = tGridView.getAdapter().getCount();
        assertEquals(expected, actual);
    }
}

Put test value in a more obvious location


package com.example.octoissues;

import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;

public class EditOwnerRepoDialog extends DialogFragment implements OnEditorActionListener{

	public interface EditRepoDialogListener {
		void onFinishEditDialog(String inputText);
	}

	private EditText editOwner;
	private EditText editRepo;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_owner_repo, container);
        editOwner = (EditText) view.findViewById(R.id.owner_name);
        editRepo = (EditText) view.findViewById(R.id.repo_name);
        getDialog().setTitle("Enter Owner and Repo");

        return view;
    }

	@Override
	public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
		// TODO Auto-generated method stub
		return false;
	}

}

package com.example.octoissues;

import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;

public class EditOwnerRepoDialog extends DialogFragment implements OnEditorActionListener{

	public interface EditRepoDialogListener {
		void onFinishEditDialog(String owner, String repo);
	}

	private EditText editOwner;
	private EditText editRepo;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_owner_repo, container);
        editOwner = (EditText) view.findViewById(R.id.owner_name);
        editRepo = (EditText) view.findViewById(R.id.repo_name);
        getDialog().setTitle("Enter Owner and Repo");

        return view;
    }

	@Override
	public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
		if (EditorInfo.IME_ACTION_DONE == actionId) {
			//Send input owner name and repo name to activity
			EditRepoDialogListener activity = (EditRepoDialogListener) getActivity();
			activity.onFinishEditDialog(editOwner.getText().toString(), editRepo.getText().toString());
			this.dismiss();
			return true;
		}
		return false;
	}
}

Send owner and repo info to enclosing activity when done


class Str2 {
	public static void main (String args[]) {
		String a = "1";
		a += "2";
		System.out.println(a);
		System.out.println("abc".indexOf("", -32));
		System.out.println("abc".indexOf("", 100));
		System.out.println("abc".lastIndexOf("", -32));
		System.out.println("abc".lastIndexOf("", 100));
	}
}

/* Expected Output:
12
0
-1
-1
3
*/

class Str2 {
	public static void main (String args[]) {
		String a = "1";
		a += "2";
		System.out.println(a);
		System.out.println("abc".indexOf("", -99999999));
		System.out.println("abc".indexOf("", 99999999));
		System.out.println("".indexOf("a"));
		System.out.println("".indexOf(""));
		System.out.println("abc".lastIndexOf("", -99999999));
		System.out.println("abc".lastIndexOf("", 99999999));
		System.out.println("".lastIndexOf("a"));
		System.out.println("".lastIndexOf(""));
	}
}

/* Expected Output:
12
0
-1
-1
0
-1
3
-1
0
*/

Add a couple more tests.


package me.devsaki.hentoid.activities.sources;

import me.devsaki.hentoid.enums.Site;

public class PorncomixActivity extends BaseWebActivity {

    //    private static final String DOMAIN_FILTER = "porncomixonline.net";
    private static final String[] GALLERY_FILTER = {
            "//www.porncomixonline.net/manga/[A-Za-z0-9\\-]+/[A-Za-z0-9\\-]+$",
            "//www.porncomixonline.net/[A-Za-z0-9\\-]+/$",
            "//porncomicszone.net/[0-9]+/[A-Za-z0-9\\-]+/[0-9]+/$",
            "//porncomixinfo.com/manga-comics/[A-Za-z0-9\\-]+/[A-Za-z0-9\\-]+/$",
            "//bestporncomix.com/gallery/[A-Za-z0-9\\-]+/$"
    };

    Site getStartSite() {
        return Site.PORNCOMIX;
    }

    @Override
    protected CustomWebViewClient getWebClient() {
        return new CustomWebViewClient(GALLERY_FILTER, this);
    }
}

package me.devsaki.hentoid.activities.sources;

import me.devsaki.hentoid.enums.Site;

public class PorncomixActivity extends BaseWebActivity {

    //    private static final String DOMAIN_FILTER = "porncomixonline.net";
    private static final String[] GALLERY_FILTER = {
            "//www.porncomixonline.net/manga/[A-Za-z0-9\\-]+/[A-Za-z0-9\\-]+$",
            "//www.porncomixonline.net/[A-Za-z0-9\\-]+/$",
            "//porncomicszone.net/[0-9]+/[A-Za-z0-9\\-]+/[0-9]+/$",
            "//porncomixinfo.com/manga-comics/[A-Za-z0-9\\-]+/[A-Za-z0-9\\-]+/$",
            "//bestporncomix.com/gallery/[A-Za-z0-9\\-]+/$"
    };
    private static final String[] DIRTY_ELEMENTS = {"iframe[name^='spot']"};

    Site getStartSite() {
        return Site.PORNCOMIX;
    }

    @Override
    protected CustomWebViewClient getWebClient() {
        addDirtyElements(DIRTY_ELEMENTS);
        return new CustomWebViewClient(GALLERY_FILTER, this);
    }
}

Remove ads from porncomixonline's main page


/*
 * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.controller.cluster.notifications;

import java.io.Serializable;

/**
 * A message initiated internally from the RaftActor when some state of a leader has changed
 *
 * @author Thomas Pantelis
 */
public class LeaderStateChanged implements Serializable {
    private static final long serialVersionUID = 1L;

    private final String memberId;
    private final String leaderId;

    public LeaderStateChanged(String memberId, String leaderId) {
        this.memberId = memberId;
        this.leaderId = leaderId;
    }

    public String getMemberId() {
        return memberId;
    }

    public String getLeaderId() {
        return leaderId;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("LeaderStateChanged [memberId=").append(memberId).append(", leaderId=").append(leaderId)
                .append("]");
        return builder.toString();
    }
}

/*
 * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.controller.cluster.notifications;

import com.google.common.base.Preconditions;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
 * A local message initiated internally from the RaftActor when some state of a leader has changed.
 *
 * @author Thomas Pantelis
 */
public class LeaderStateChanged {
    private final String memberId;
    private final String leaderId;

    public LeaderStateChanged(@Nonnull String memberId, @Nullable String leaderId) {
        this.memberId = Preconditions.checkNotNull(memberId);
        this.leaderId = leaderId;
    }

    public @Nonnull String getMemberId() {
        return memberId;
    }

    public @Nullable String getLeaderId() {
        return leaderId;
    }

    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("LeaderStateChanged [memberId=").append(memberId).append(", leaderId=").append(leaderId)
                .append("]");
        return builder.toString();
    }
}

Return local shard tree from FindPrimaryShard


//@@author A0143409J

package seedu.address.logic.parser;

import static org.junit.Assert.assertEquals;
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;

import java.lang.reflect.Field;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import seedu.address.logic.commands.IncorrectCommand;
import seedu.address.logic.commands.FinishCommand;

public class FinishCommandParserTest {

    @Rule
    public ExpectedException thrown = ExpectedException.none();

    @Test
    public void nullTest() throws Exception {
        thrown.expect(NullPointerException.class);
        FinishCommandParser.parse(null);
    }

    @Test
    public void validTest() throws Exception {
        Field field = FinishCommand.class.getDeclaredField("targetIndex");
        field.setAccessible(true);

        FinishCommand finishCommand = (FinishCommand) FinishCommandParser.parse("1");
        assertEquals(field.get(finishCommand), 1);
    }

    @Test
    public void invalidTest() throws Exception {
        Field field = IncorrectCommand.class.getDeclaredField("feedbackToUser");
        field.setAccessible(true);

        IncorrectCommand incorrectCommand = (IncorrectCommand) FinishCommandParser.parse("+");
        assertEquals(field.get(incorrectCommand),
                String.format(MESSAGE_INVALID_COMMAND_FORMAT, FinishCommand.MESSAGE_USAGE));
    }
}

//@@author A0143409J

package seedu.address.logic.parser;

import static org.junit.Assert.assertEquals;
import static seedu.address.commons.core.Messages.MESSAGE_INVALID_COMMAND_FORMAT;

import java.lang.reflect.Field;

import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import seedu.address.logic.commands.FinishCommand;
import seedu.address.logic.commands.IncorrectCommand;

public class FinishCommandParserTest {

    @Rule
    public ExpectedException thrown = ExpectedException.none();

    @Test
    public void nullTest() throws Exception {
        thrown.expect(NullPointerException.class);
        FinishCommandParser.parse(null);
    }

    @Test
    public void validTest() throws Exception {
        Field field = FinishCommand.class.getDeclaredField("targetIndex");
        field.setAccessible(true);

        FinishCommand finishCommand = (FinishCommand) FinishCommandParser.parse("1");
        assertEquals(field.get(finishCommand), 1);
    }

    @Test
    public void invalidTest() throws Exception {
        Field field = IncorrectCommand.class.getDeclaredField("feedbackToUser");
        field.setAccessible(true);

        IncorrectCommand incorrectCommand = (IncorrectCommand) FinishCommandParser.parse("+");
        assertEquals(field.get(incorrectCommand),
                String.format(MESSAGE_INVALID_COMMAND_FORMAT, FinishCommand.MESSAGE_USAGE));
    }
}

Modify to match lexicographical order


package com.battlelancer.seriesguide.util;

import android.support.v4.view.ViewPager.OnPageChangeListener;

import net.simonvt.menudrawer.MenuDrawer;

/**
 * {@link OnPageChangeListener} which allows to open a {@link MenuDrawer} by
 * swiping once more to the left if displaying the first page.
 */
public class MenuOnPageChangeListener implements OnPageChangeListener {

    private MenuDrawer mMenuDrawer;

    public MenuOnPageChangeListener(MenuDrawer menuDrawer) {
        mMenuDrawer = menuDrawer;
    }

    @Override
    public void onPageScrollStateChanged(int arg0) {
    }

    @Override
    public void onPageScrolled(int arg0, float arg1, int arg2) {
    }

    @Override
    public void onPageSelected(int position) {
        mMenuDrawer.setTouchMode(position == 0
                ? MenuDrawer.TOUCH_MODE_FULLSCREEN
                : MenuDrawer.TOUCH_MODE_NONE);
    }

}

package com.battlelancer.seriesguide.util;

import android.support.v4.view.ViewPager.OnPageChangeListener;

import net.simonvt.menudrawer.MenuDrawer;

/**
 * {@link OnPageChangeListener} which allows to open a {@link MenuDrawer} by
 * swiping once more to the left if displaying the first page.
 */
public class MenuOnPageChangeListener implements OnPageChangeListener {

    private MenuDrawer mMenuDrawer;

    public MenuOnPageChangeListener(MenuDrawer menuDrawer) {
        mMenuDrawer = menuDrawer;
    }

    @Override
    public void onPageScrollStateChanged(int arg0) {
    }

    @Override
    public void onPageScrolled(int arg0, float arg1, int arg2) {
    }

    @Override
    public void onPageSelected(int position) {
        mMenuDrawer.setTouchMode(position == 0
                ? MenuDrawer.TOUCH_MODE_FULLSCREEN
                : MenuDrawer.TOUCH_MODE_BEZEL);
    }

}

Use bezel touch mode inside view pager.


package org.apache.ddlutils.platform;

/*
 * Copyright 1999-2005 The Apache Software Foundation.
 *
 * 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.
 */

import java.io.IOException;

import org.apache.ddlutils.PlatformInfo;
import org.apache.ddlutils.model.Table;

/**
 * The SQL Builder for the HsqlDb database.
 *
 * @author James Strachan
 * @author Thomas Dudziak
 * @version $Revision$
 */
public class HsqlDbBuilder extends SqlBuilder
{
    /**
     * Creates a new builder instance.
     *
     * @param info The platform info
     */
    public HsqlDbBuilder(PlatformInfo info)
    {
        super(info);
    }

    /**
     * {@inheritDoc}
     */
    public void dropTable(Table table) throws IOException
    {
        print("DROP TABLE ");
        printIdentifier(getTableName(table));
        print(" IF EXISTS");
        printEndOfStatement();
    }
}

package org.apache.ddlutils.platform;

/*
 * Copyright 1999-2005 The Apache Software Foundation.
 *
 * 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.
 */

import java.io.IOException;

import org.apache.ddlutils.PlatformInfo;
import org.apache.ddlutils.model.Table;

/**
 * The SQL Builder for the HsqlDb database.
 *
 * @author James Strachan
 * @author Thomas Dudziak
 * @version $Revision$
 */
public class HsqlDbBuilder extends SqlBuilder
{
    /**
     * Creates a new builder instance.
     *
     * @param info The platform info
     */
    public HsqlDbBuilder(PlatformInfo info)
    {
        super(info);
    }

    /**
     * {@inheritDoc}
     */
    public void dropTable(Table table) throws IOException
    {
        print("DROP TABLE ");
        printIdentifier(getTableName(table));
        print(" IF EXISTS");
        printEndOfStatement();
    }

    /**
     * @see org.apache.ddlutils.platform.SqlBuilder#getSelectLastInsertId(org.apache.ddlutils.model.Table)
     */
    public String getSelectLastInsertId(Table table)
    {
        return "CALL IDENTITY()";
    }

}

Add call identity to hsqldb.