package com.nguyenmp.starclient.test;

import com.nguyenmp.starclient.STAR;
import org.junit.Assert;
import org.junit.Test;

import java.io.IOException;

public class STAR_Test {
	@Test
	public void login_Test() throws IOException {
		Assert.assertEquals(STAR.login("mpnasf8", "asoidfu"), null);
	}
}

package com.nguyenmp.starclient.test;

import com.nguyenmp.starclient.STAR;
import org.junit.Assert;
import org.junit.Test;

import java.io.IOException;

public class STAR_Test {
	@Test
	public void login_Test() throws IOException {
		//TODO: Write realistic test for logging in
		Assert.assertEquals(STAR.login("mpnasf8", "asoidfu"), null);
	}
}

Write realistic test for logging in


package com.github.sherter.googlejavaformatgradleplugin;

import org.gradle.api.tasks.SourceTask;

abstract class FormatTask extends SourceTask {

  protected SharedContext sharedContext;

  abstract void accept(TaskConfigurator configurator);

  boolean hasSources() {
    return !source.isEmpty();
  }
}

package com.github.sherter.googlejavaformatgradleplugin;

import org.gradle.api.tasks.SourceTask;

abstract class FormatTask extends SourceTask {

  protected SharedContext sharedContext;

  abstract void accept(TaskConfigurator configurator);

  boolean hasSources() {
    return !getSource().isEmpty();
  }
}

Use getSource to access SourceTask source


package org.bds.test;

import org.bds.Config;
import org.bds.util.Gpr;
import org.junit.Before;
import org.junit.Test;

/**
 * Quick test cases when creating a new feature...
 *
 * @author pcingola
 *
 */
public class TestCasesZzz extends TestCasesBase {

	@Before
	public void beforeEachTest() {
		Config.reset();
		Config.get().load();
	}

	@Test
	public void test223_switch_case_return() {
		Gpr.debug("Test");
		runAndCheck("test/z.bds", "res", "1");
	}

}

package org.bds.test;

import org.bds.Config;
import org.bds.util.Gpr;
import org.junit.Before;
import org.junit.Test;

/**
 * Quick test cases when creating a new feature...
 *
 * @author pcingola
 *
 */
public class TestCasesZzz extends TestCasesBase {

	@Before
	public void beforeEachTest() {
		Config.reset();
		Config.get().load();
	}

	@Test
	public void test166_switch_case_return() {
		Gpr.debug("Test");
		runAndCheck("test/run_166.bds", "res", "1");
	}

}

Switch + case + return was leaving values on the vm stack. Fixed


package org.bouncycastle.crypto.tls;

public class SecurityParameters
{
    int entity = -1;
    int prfAlgorithm = -1;
    short compressionAlgorithm = -1;
    int verifyDataLength = -1;
    byte[] masterSecret = null;
    byte[] clientRandom = null;
    byte[] serverRandom = null;

    // TODO Keep this internal, since it's not the ideal place for it
    boolean truncatedHMac = false;

    /**
     * @return {@link ConnectionEnd}
     */
    public int getEntity()
    {
        return entity;
    }

    /**
     * @return {@link PRFAlgorithm}
     */
    public int getPrfAlgorithm()
    {
        return prfAlgorithm;
    }

    /**
     * @return {@link CompressionMethod}
     */
    public short getCompressionAlgorithm()
    {
        return compressionAlgorithm;
    }

    public int getVerifyDataLength()
    {
        return verifyDataLength;
    }

    public byte[] getMasterSecret()
    {
        return masterSecret;
    }

    public byte[] getClientRandom()
    {
        return clientRandom;
    }

    public byte[] getServerRandom()
    {
        return serverRandom;
    }
}

package org.bouncycastle.crypto.tls;

import org.bouncycastle.util.Arrays;

public class SecurityParameters
{
    int entity = -1;
    int cipherSuite = -1;
    short compressionAlgorithm = -1;
    int prfAlgorithm = -1;
    int verifyDataLength = -1;
    byte[] masterSecret = null;
    byte[] clientRandom = null;
    byte[] serverRandom = null;

    // TODO Keep this internal, since it's not the ideal place for it
    boolean truncatedHMac = false;

    void copySessionParametersFrom(SecurityParameters other)
    {
        this.entity = other.entity;
        this.cipherSuite = other.cipherSuite;
        this.compressionAlgorithm = other.compressionAlgorithm;
        this.prfAlgorithm = other.prfAlgorithm;
        this.verifyDataLength = other.verifyDataLength;
        this.masterSecret = Arrays.clone(other.masterSecret);
    }

    void clear()
    {
        if (this.masterSecret != null)
        {
            Arrays.fill(this.masterSecret, (byte)0);
            this.masterSecret = null;
        }
    }

    /**
     * @return {@link ConnectionEnd}
     */
    public int getEntity()
    {
        return entity;
    }

    /**
     * @return {@link CipherSuite}
     */
    public int getCipherSuite()
    {
        return cipherSuite;
    }

    /**
     * @return {@link CompressionMethod}
     */
    public short getCompressionAlgorithm()
    {
        return compressionAlgorithm;
    }

    /**
     * @return {@link PRFAlgorithm}
     */
    public int getPrfAlgorithm()
    {
        return prfAlgorithm;
    }

    public int getVerifyDataLength()
    {
        return verifyDataLength;
    }

    public byte[] getMasterSecret()
    {
        return masterSecret;
    }

    public byte[] getClientRandom()
    {
        return clientRandom;
    }

    public byte[] getServerRandom()
    {
        return serverRandom;
    }
}

Add new fields to support session resumption


package play.test;

import java.util.List;

import play.Play;
import play.modules.morphia.Model;
import play.modules.morphia.MorphiaPlugin;
import play.test.Fixtures;

import com.google.code.morphia.Datastore;

public class MorphiaFixtures extends Fixtures {

	private static Datastore ds() {
        return MorphiaPlugin.ds();
    }

    public static void deleteAll() {
        Datastore ds = ds();
        for (Class<Model> clz: Play.classloader.getAssignableClasses(Model.class)) {
            ds.getCollection(clz).drop();
        }
    }

    public static void delete(Class<? extends Model> ... types) {
        for (Class<? extends Model> type: types) {
            ds().getCollection(type).drop();
        }
    }

    public static void delete(List<Class<? extends Model>> classes) {
        for (Class<? extends Model> type: classes) {
            ds().getCollection(type).drop();
        }
    }

    public static void deleteAllModels() {
        deleteAll();
    }
}

package play.test;

import java.util.List;

import play.Play;
import play.modules.morphia.Model;
import play.modules.morphia.MorphiaPlugin;
import play.test.Fixtures;

import com.google.code.morphia.Datastore;

public class MorphiaFixtures extends Fixtures {

	private static Datastore ds() {
        return MorphiaPlugin.ds();
    }

    public static void deleteAll() {
    	idCache.clear();
        Datastore ds = ds();
        for (Class<Model> clz: Play.classloader.getAssignableClasses(Model.class)) {
            ds.getCollection(clz).drop();
        }
    }

    public static void delete(Class<? extends Model> ... types) {
    	idCache.clear();
        for (Class<? extends Model> type: types) {
            ds().getCollection(type).drop();
        }
    }

    public static void delete(List<Class<? extends Model>> classes) {
    	idCache.clear();
        for (Class<? extends Model> type: classes) {
            ds().getCollection(type).drop();
        }
    }

    public static void deleteAllModels() {
        deleteAll();
    }
}

Revert "reverse changes to MorhiaFixtures which is specific to 1.2.1"

This reverts commit 4e00685568a7eb9edcf39bd20d2c5272f5d365aa.


package com.google.cloud.anviltop.hbase.adapters;

import com.google.bigtable.anviltop.AnviltopServices;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.client.Result;

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

/**
 * Adapt an AppendRowResponse from Anviltop to an HBase Result
 */
public class AppendResponseAdapter implements ResponseAdapter<AnviltopServices.AppendRowResponse, Result> {
  protected final RowAdapter rowAdapter;

  public AppendResponseAdapter(RowAdapter rowAdapter) {
    this.rowAdapter = rowAdapter;
  }

  @Override
  public Result adaptResponse(AnviltopServices.AppendRowResponse response) {
    List<Cell> cells = new ArrayList<Cell>();
    if (response.hasRow()) {
      return rowAdapter.adaptResponse(response.getRow());
    }
    return new Result();
  }
}

package com.google.cloud.anviltop.hbase.adapters;

import com.google.bigtable.anviltop.AnviltopServices;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.client.Result;

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

/**
 * Adapt an AppendRowResponse from Anviltop to an HBase Result
 */
public class AppendResponseAdapter implements ResponseAdapter<AnviltopServices.AppendRowResponse, Result> {
  protected final RowAdapter rowAdapter;

  public AppendResponseAdapter(RowAdapter rowAdapter) {
    this.rowAdapter = rowAdapter;
  }

  @Override
  public Result adaptResponse(AnviltopServices.AppendRowResponse response) {
    List<Cell> cells = new ArrayList<Cell>();
    if (response.hasRow()) {
      return rowAdapter.adaptResponse(response.getRow());
    }
    return null;
  }
}

Fix Appends when no results were asked.

Fix Appends when no results were asked.


package com.antonyt.coveredimageview.example;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;

import com.antonyt.coveredimageview.CoveredImageView;
import com.antonyt.coveredimageview.R;

/**
 * Example activity to demonstrate the {@link CoveredImageView}. Click on the
 * image to repeat the reveal animation.
 */
public class CoveredImageViewActivity extends Activity {

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

        final CoveredImageView image = (CoveredImageView) findViewById(R.id.image);
        image.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                image.reveal(2000);
            }
        });
    }
}

package com.antonyt.coveredimageview.example;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView.ScaleType;

import com.antonyt.coveredimageview.CoveredImageView;
import com.antonyt.coveredimageview.R;

/**
 * Example activity to demonstrate the {@link CoveredImageView}. Click on the
 * image to repeat the reveal animation.
 */
public class CoveredImageViewActivity extends Activity {

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

        final CoveredImageView image = (CoveredImageView) findViewById(R.id.image);
        image.setScaleType(ScaleType.FIT_START);
        image.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                image.reveal(2000);
            }
        });
    }
}

Use ScaleType.FIT_START to align graph and plot better.


/*
 * LapisCommons
 * Copyright (c) 2014, LapisDev <https://github.com/LapisDev>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package blue.lapis.common.economy;

public interface EconomyAccount {

    String getAccountName();

    double getBalance();

    void setBalance();

    boolean hasCashFlow();

    TransactionHistory getCashFlow();

    String getCurrencyNameSingular();

    String getCurrencyNamePlural();
}

/*
 * LapisCommons
 * Copyright (c) 2014, LapisDev <https://github.com/LapisDev>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package blue.lapis.common.economy;

public interface EconomyAccount {

    String getAccountName();

    double getBalance();
    void setBalance();

    boolean hasHistory();
    TransactionHistory getHistory();

    String getCurrencyNameSingular();
    String getCurrencyNamePlural();
}

Rename cash flow getter to getHistory

Rename cash flow getter to getHistory


package org.apache.lucene.spatial.base.context;

import org.apache.lucene.spatial.base.context.simple.SimpleSpatialContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * TODO -- i think there is a more standard way to approach this problem
 */
public class SpatialContextProvider {
  static final Logger log = LoggerFactory.getLogger(SpatialContextProvider.class);

  private static SpatialContext instance = null;

  private SpatialContextProvider() {
  }

  @SuppressWarnings("unchecked")
  public static synchronized SpatialContext getContext() {
    if (instance != null) {
      return instance;
    }

    String cname = System.getProperty("SpatialContextProvider");
    if (cname != null) {
      try {
        Class<? extends SpatialContext> clazz = (Class<? extends SpatialContext>) Class.forName(cname);
        instance = clazz.newInstance();
        return instance;
      } catch (Exception e) {
        //don't log full stack trace
        log.warn("Using default SpatialContext because: " + e.toString());
      }
    }
    instance = new SimpleSpatialContext();
    return instance;
  }

  static void clear() {
    instance = null;
  }
}

package org.apache.lucene.spatial.base.context;

import org.apache.lucene.spatial.base.context.simple.SimpleSpatialContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * TODO -- i think there is a more standard way to approach this problem
 */
public class SpatialContextProvider {
  static final Logger log = LoggerFactory.getLogger(SpatialContextProvider.class);

  private static SpatialContext instance = null;

  private SpatialContextProvider() {
  }

  @SuppressWarnings("unchecked")
  public static synchronized SpatialContext getContext() {
    if (instance != null) {
      return instance;
    }

    String cname = System.getProperty("SpatialContextProvider");
    if (cname != null) {
      try {
        Class<? extends SpatialContext> clazz = (Class<? extends SpatialContext>) Class.forName(cname);
        instance = clazz.newInstance();
        return instance;
      } catch (Exception e) {
        //don't log full stack trace
        log.warn("Using default SpatialContext because: " + e.toString());
      }
    }
    instance = new SimpleSpatialContext();
    return instance;
  }

  static synchronized void clear() {
    instance = null;
  }
}

Synchronize access to static instance in clear()


package com.paritytrading.parity.reporter;

import com.paritytrading.parity.net.pmr.PMR;
import com.paritytrading.parity.net.pmr.PMRListener;
import java.util.Locale;

abstract class MarketReportListener implements PMRListener {

    protected static final double PRICE_FACTOR = 10000.0;

    protected static final long NANOS_PER_MILLI = 1000 * 1000;

    @Override
    public void order(PMR.Order message) {
    }

    @Override
    public void cancel(PMR.Cancel message) {
    }

    protected void printf(String format, Object... args) {
        System.out.printf(Locale.US, format, args);
    }

}

package com.paritytrading.parity.reporter;

import com.paritytrading.parity.net.pmr.PMR;
import com.paritytrading.parity.net.pmr.PMRListener;
import java.util.Locale;

abstract class MarketReportListener implements PMRListener {

    protected static final double PRICE_FACTOR = 10000.0;

    protected static final long NANOS_PER_MILLI = 1_000_000;

    @Override
    public void order(PMR.Order message) {
    }

    @Override
    public void cancel(PMR.Cancel message) {
    }

    protected void printf(String format, Object... args) {
        System.out.printf(Locale.US, format, args);
    }

}

Clean up integer literals in trade reporter


package cc.blynk.common.handlers.common.encoders;

import cc.blynk.common.enums.Command;
import cc.blynk.common.model.messages.Message;
import cc.blynk.common.model.messages.MessageBase;
import cc.blynk.common.utils.Config;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * Encodes java message into a bytes array.
 *
 * The Blynk Project.
 * Created by Dmitriy Dumanskiy.
 * Created on 2/1/2015.
 */
public class MessageEncoder extends MessageToByteEncoder<MessageBase> {

    @Override
    protected void encode(ChannelHandlerContext ctx, MessageBase message, ByteBuf out) throws Exception {
        out.writeByte(message.command);
        out.writeShort(message.id);
        out.writeShort(message.length);

        if (message.command != Command.RESPONSE && message.length > 0) {
            out.writeBytes(((Message) message).body.getBytes(Config.DEFAULT_CHARSET));
        }
    }
}

package cc.blynk.common.handlers.common.encoders;

import cc.blynk.common.enums.Command;
import cc.blynk.common.model.messages.Message;
import cc.blynk.common.model.messages.MessageBase;
import cc.blynk.common.utils.Config;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * Encodes java message into a bytes array.
 *
 * The Blynk Project.
 * Created by Dmitriy Dumanskiy.
 * Created on 2/1/2015.
 */
public class MessageEncoder extends MessageToByteEncoder<MessageBase> {

    @Override
    protected void encode(ChannelHandlerContext ctx, MessageBase message, ByteBuf out) throws Exception {
        out.writeByte(message.command);
        out.writeShort(message.id);

        if (message.command == Command.RESPONSE) {
            out.writeShort(message.length);
        } else {
            byte[] body = ((Message) message).body.getBytes(Config.DEFAULT_CHARSET);
            out.writeShort(body.length);
            if (body.length > 0) {
                out.writeBytes(body);
            }
        }
    }
}

Correct message body length for unicode chars.


// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInsight.completion;

import com.intellij.lang.Language;
import com.intellij.lang.LanguageExtension;
import com.intellij.lang.MetaLanguage;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;

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

class CompletionExtension<T> extends LanguageExtension<T> {

  CompletionExtension(String epName) {
    super(epName);
  }

  @NotNull
  @Override
  protected List<T> buildExtensions(@NotNull String stringKey, @NotNull Language key) {
    return buildExtensions(getAllBaseLanguageIdsWithAny(key));
  }

  @NotNull
  private Set<String> getAllBaseLanguageIdsWithAny(@NotNull Language key) {
    Set<String> allowed = new THashSet<>();
    while (key != null) {
      allowed.add(keyToString(key));
      key = key.getBaseLanguage();
    }
    allowed.add("any");
    for (MetaLanguage metaLanguage : MetaLanguage.all()) {
      allowed.add(metaLanguage.getID());
    }
    return allowed;
  }
}

// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.codeInsight.completion;

import com.intellij.lang.Language;
import com.intellij.lang.LanguageExtension;
import com.intellij.lang.MetaLanguage;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NotNull;

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

class CompletionExtension<T> extends LanguageExtension<T> {

  CompletionExtension(String epName) {
    super(epName);
  }

  @NotNull
  @Override
  protected List<T> buildExtensions(@NotNull String stringKey, @NotNull Language key) {
    return buildExtensions(getAllBaseLanguageIdsWithAny(key));
  }

  @NotNull
  private Set<String> getAllBaseLanguageIdsWithAny(@NotNull Language key) {
    Set<String> allowed = new THashSet<>();
    while (key != null) {
      allowed.add(keyToString(key));
      for (MetaLanguage metaLanguage : MetaLanguage.all()) {
        if (metaLanguage.matchesLanguage(key))
          allowed.add(metaLanguage.getID());
      }
      key = key.getBaseLanguage();
    }
    allowed.add("any");
    return allowed;
  }
}

Check metalanguage applicability in getAllBaseLanguageIdsWithAny()

GitOrigin-RevId: f76645e6ba0672f74059aa8b4ec97855d6a5527c


package org.dataportabilityproject.job;

import static com.google.common.truth.Truth.assertThat;

import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import org.junit.Test;

public class CrypterImplTest {
  @Test
  public void testRoundTripSecretKey() throws Exception {
    KeyGenerator generator = KeyGenerator.getInstance("AES");
    SecretKey key = generator.generateKey();
    CrypterImpl impl = new CrypterImpl(key);
    String data = "The lazy dog didn't jump over anything";
    assertThat(impl.decrypt(impl.encrypt(data))).isEqualTo(data);
  }
}

package org.dataportabilityproject.job;

import static com.google.common.truth.Truth.assertThat;

import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import org.junit.Test;

public class CrypterImplTest {
  @Test
  public void testRoundTripSecretKey() throws Exception {
    KeyGenerator generator = KeyGenerator.getInstance("AES");
    SecretKey key = generator.generateKey();
    CrypterImpl impl = new CrypterImpl(key);
    String data = "The lazy dog didn't jump over anything except \u2614, and a \u26F5";
    assertThat(impl.decrypt(impl.encrypt(data))).isEqualTo(data);
  }
}

Add special charecters to the test as per chuy's request


package com.avairebot.orion.database.transformers;

import com.avairebot.orion.contracts.database.transformers.Transformer;
import com.avairebot.orion.database.collection.DataRow;
import com.google.gson.Gson;

public class GuildTypeTransformer extends Transformer {

    private static final Gson GSON = new Gson();

    private String name = "Default";
    private GuildTypeLimits limits = new GuildTypeLimits();

    GuildTypeTransformer(DataRow data) {
        super(data);

        if (hasData()) {
            if (data.getString("type_name", null) != null) {
                name = data.getString("type_name");
            }

            if (data.getString("type_limits", null) != null) {
                GuildTypeLimits typeLimits = GSON.fromJson(data.getString("type_limits"), GuildTypeLimits.class);
                if (typeLimits != null) {
                    limits = typeLimits;
                }
            }
        }
    }

    public String getName() {
        return name;
    }

    public GuildTypeLimits getLimits() {
        return limits;
    }

    public class GuildTypeLimits {
        private GuildTypePlaylist playlist = new GuildTypePlaylist();
        private int aliases = 20;

        public int getAliases() {
            return aliases;
        }

        public GuildTypePlaylist getPlaylist() {
            return playlist;
        }

        public class GuildTypePlaylist {
            private int lists;
            private int songs;

            public int getPlaylists() {
                return lists;
            }

            public int getSongs() {
                return songs;
            }
        }
    }
}

package com.avairebot.orion.database.transformers;

import com.avairebot.orion.contracts.database.transformers.Transformer;
import com.avairebot.orion.database.collection.DataRow;
import com.google.gson.Gson;

public class GuildTypeTransformer extends Transformer {

    private static final Gson GSON = new Gson();

    private String name = "Default";
    private GuildTypeLimits limits = new GuildTypeLimits();

    GuildTypeTransformer(DataRow data) {
        super(data);

        if (hasData()) {
            if (data.getString("type_name", null) != null) {
                name = data.getString("type_name");
            }

            if (data.getString("type_limits", null) != null) {
                GuildTypeLimits typeLimits = GSON.fromJson(data.getString("type_limits"), GuildTypeLimits.class);
                if (typeLimits != null) {
                    limits = typeLimits;
                }
            }
        }
    }

    public String getName() {
        return name;
    }

    public GuildTypeLimits getLimits() {
        return limits;
    }

    public class GuildTypeLimits {
        private GuildTypePlaylist playlist = new GuildTypePlaylist();
        private int aliases = 20;

        public int getAliases() {
            return aliases;
        }

        public GuildTypePlaylist getPlaylist() {
            return playlist;
        }

        public class GuildTypePlaylist {
            private int lists = 5;
            private int songs = 30;

            public int getPlaylists() {
                return lists;
            }

            public int getSongs() {
                return songs;
            }
        }
    }
}

Add defaults to guild type playlist settings


package org.openmhealth.shim.fitbit.mapper;

import com.fasterxml.jackson.databind.JsonNode;
import org.openmhealth.schema.domain.omh.BodyWeight;
import org.openmhealth.schema.domain.omh.DataPoint;
import org.openmhealth.schema.domain.omh.MassUnit;
import org.openmhealth.schema.domain.omh.MassUnitValue;

import java.time.*;
import java.util.Optional;

import static org.openmhealth.shim.common.mapper.JsonNodeMappingSupport.*;

/**
 * Created by Chris Schaefbauer on 6/10/15.
 */
public class FitbitBodyWeightDataPointMapper extends FitbitDataPointMapper<BodyWeight>{

    @Override
    protected Optional<DataPoint<BodyWeight>> asDataPoint(JsonNode node, int offsetInMilliseconds) {
        MassUnitValue bodyWeight = new MassUnitValue(MassUnit.KILOGRAM,asRequiredDouble(node,"weight"));
        BodyWeight.Builder builder = new BodyWeight.Builder(bodyWeight);

        Optional<LocalDateTime> dateTime = asOptionalLocalDateTime(node,"date","time");

        if(dateTime.isPresent()){
            OffsetDateTime offsetDateTime = OffsetDateTime.of(dateTime.get(), ZoneOffset.ofTotalSeconds(offsetInMilliseconds / 1000));
            builder.setEffectiveTimeFrame(offsetDateTime);
        }

        Optional<Long> externalId = asOptionalLong(node, "logId");
        BodyWeight measure = builder.build();

        return Optional.of(newDataPoint(measure, externalId.orElse(null)));

    }

    @Override
    protected String getListNodeName() {
        return "weight";
    }
}

package org.openmhealth.shim.fitbit.mapper;

import com.fasterxml.jackson.databind.JsonNode;
import org.openmhealth.schema.domain.omh.BodyWeight;
import org.openmhealth.schema.domain.omh.DataPoint;
import org.openmhealth.schema.domain.omh.MassUnit;
import org.openmhealth.schema.domain.omh.MassUnitValue;

import java.time.*;
import java.util.Optional;

import static org.openmhealth.shim.common.mapper.JsonNodeMappingSupport.*;

/**
 * Created by Chris Schaefbauer on 6/10/15.
 */
public class FitbitBodyWeightDataPointMapper extends FitbitDataPointMapper<BodyWeight>{

    @Override
    protected Optional<DataPoint<BodyWeight>> asDataPoint(JsonNode node, int UTCOffsetInMilliseconds) {
        MassUnitValue bodyWeight = new MassUnitValue(MassUnit.KILOGRAM,asRequiredDouble(node,"weight"));
        BodyWeight.Builder builder = new BodyWeight.Builder(bodyWeight);

        Optional<LocalDateTime> dateTime = asOptionalLocalDateTime(node,"date","time");

        if(dateTime.isPresent()){
            OffsetDateTime offsetDateTime = OffsetDateTime.of(dateTime.get(), ZoneOffset.ofTotalSeconds(UTCOffsetInMilliseconds / 1000));
            builder.setEffectiveTimeFrame(offsetDateTime);
        }

        Optional<Long> externalId = asOptionalLong(node, "logId");
        BodyWeight measure = builder.build();

        return Optional.of(newDataPoint(measure, externalId.orElse(null)));

    }

    @Override
    protected String getListNodeName() {
        return "weight";
    }
}

Rename offset in body weight mapper with UTC


package codechicken.lib.world;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.ChunkEvent;

public class TileChunkLoadHook
{
    private static boolean init;
    public static void init() {
        if(init) return;
        init = true;

        MinecraftForge.EVENT_BUS.register(new TileChunkLoadHook());
    }

    @SubscribeEvent
    public void onChunkLoad(ChunkEvent.Load event) {
        for(TileEntity t : ((Iterable<TileEntity>)event.getChunk().chunkTileEntityMap.values()))
            if(t instanceof IChunkLoadTile)
                ((IChunkLoadTile)t).onChunkLoad();
    }
}

package codechicken.lib.world;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.world.ChunkEvent;

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

public class TileChunkLoadHook
{
    private static boolean init;
    public static void init() {
        if(init) return;
        init = true;

        MinecraftForge.EVENT_BUS.register(new TileChunkLoadHook());
    }

    @SubscribeEvent
    public void onChunkLoad(ChunkEvent.Load event) {
        List<TileEntity> list = new ArrayList<TileEntity>(event.getChunk().chunkTileEntityMap.values());
        for(TileEntity t : list)
            if(t instanceof IChunkLoadTile)
                ((IChunkLoadTile)t).onChunkLoad();
    }
}

Fix ConcurrentModificationException in tile chunk load hook


package org.robockets.runqueue.client;

import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import org.robockets.runqueue.client.controllers.Controllers;

public class Main {

	public static void main(String args[]) {
        try { // Nimbus theme
            for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (Exception e) {
        	System.out.println(e);
        }

		SwingUtilities.invokeLater(new Runnable () {
			public void run () {
				Controllers.main.show();
			}
		});
	}
}

package org.robockets.runqueue.client;

import javax.swing.SwingUtilities;
import javax.swing.UIManager;

import org.robockets.runqueue.client.controllers.Controllers;

public class Main {

	public static void main(String args[]) {
        try { // Nimbus theme
            for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (Exception e) {
        	e.printStackTrace();
        }

		SwingUtilities.invokeLater(new Runnable () {
			public void run () {
				Controllers.main.show();
			}
		});
	}
}

Print stack trace if Nimbus is not avaible


/*
 * Copyright 2020 The Bazel Authors. All rights reserved.
 *
 * 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.idea.blaze.android.run.binary.mobileinstall;

import com.google.idea.common.experiments.FeatureRolloutExperiment;

/**
 * A utility class that manages the experiment to use studio's built in deployer for deploying apks
 * instead of using the one present in mobile-install.
 */
public class StudioDeployerExperiment {
  /** Indicates if we should deploy via Studio or via MI. */
  private static final FeatureRolloutExperiment useStudioDeployer =
      new FeatureRolloutExperiment("aswb.use.studio.deployer");

  /** Returns whether mobile install deployments should happen via the studio deployer. */
  public static boolean isEnabled() {
    return useStudioDeployer.isEnabled();
  }

  private StudioDeployerExperiment() {}
}

/*
 * Copyright 2020 The Bazel Authors. All rights reserved.
 *
 * 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.idea.blaze.android.run.binary.mobileinstall;

import com.google.idea.common.experiments.FeatureRolloutExperiment;
import com.intellij.openapi.util.SystemInfo;

/**
 * A utility class that manages the experiment to use studio's built in deployer for deploying apks
 * instead of using the one present in mobile-install.
 */
public class StudioDeployerExperiment {
  /** Indicates if we should deploy via Studio or via MI. */
  private static final FeatureRolloutExperiment useStudioDeployer =
      new FeatureRolloutExperiment("aswb.use.studio.deployer");

  /** Returns whether mobile install deployments should happen via the studio deployer. */
  public static boolean isEnabled() {
    // The Studio deployer experiment is specific to local builds on Linux. For other platforms,
    // we'll rely entirely on the new Blaze specific deployment flow.
    if (!SystemInfo.isLinux) {
      return false;
    }

    return useStudioDeployer.isEnabled();
  }

  private StudioDeployerExperiment() {}
}

Make Studio deployer specific to workstations

(cherry picked from commit 5c3291237d53cce00f68a6f209136951fc2a66fe)


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

import com.facebook.nifty.core.NettyServerConfig;
import com.facebook.nifty.core.NettyServerConfigBuilder;
import com.google.inject.Provider;

public class LoadTesterNettyConfigProvider implements Provider<NettyServerConfig> {
    private final NiftyLoadTester.LoadTesterConfig config;

    @Inject
    public LoadTesterNettyConfigProvider(NiftyLoadTester.LoadTesterConfig config)
    {
        this.config = config;
    }

    @Override
    public NettyServerConfig get() {
        NettyServerConfigBuilder configBuilder = new NettyServerConfigBuilder();
        configBuilder.getServerSocketChannelConfig().setBacklog(config.getAcceptBacklog());
        return configBuilder.build();
    }
}

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

import com.facebook.nifty.core.NettyServerConfig;
import com.facebook.nifty.core.NettyServerConfigBuilder;
import com.google.inject.Inject;
import com.google.inject.Provider;

public class LoadTesterNettyConfigProvider implements Provider<NettyServerConfig> {
    private final NiftyLoadTester.LoadTesterConfig config;

    @Inject
    public LoadTesterNettyConfigProvider(NiftyLoadTester.LoadTesterConfig config)
    {
        this.config = config;
    }

    @Override
    public NettyServerConfig get() {
        NettyServerConfigBuilder configBuilder = new NettyServerConfigBuilder();
        configBuilder.getServerSocketChannelConfig().setBacklog(config.getAcceptBacklog());
        return configBuilder.build();
    }
}

Add missing import to fix build

Add missing import to fix build


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

package org.gradle.api.internal.tasks.testing;

import org.gradle.api.Task;
import org.gradle.api.reporting.ConfigureableReport;
import org.gradle.api.reporting.DirectoryReport;
import org.gradle.api.reporting.internal.TaskGeneratedSingleDirectoryReport;
import org.gradle.api.reporting.internal.TaskReportContainer;
import org.gradle.api.tasks.testing.TestReports;

public class DefaultTestReports extends TaskReportContainer<ConfigureableReport> implements TestReports {

    public DefaultTestReports(Task task) {
        super(ConfigureableReport.class, task);

        add(TaskGeneratedSingleDirectoryReport.class, "junitXml", task, null);
        add(TaskGeneratedSingleDirectoryReport.class, "html", task, "index.html");
    }

    public DirectoryReport getHtml() {
        return (DirectoryReport) getByName("html");
    }

    public DirectoryReport getJunitXml() {
        return (DirectoryReport) getByName("junitXml");
    }

}

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

package org.gradle.api.internal.tasks.testing;

import org.gradle.api.Task;
import org.gradle.api.reporting.ConfigurableReport;
import org.gradle.api.reporting.DirectoryReport;
import org.gradle.api.reporting.internal.TaskGeneratedSingleDirectoryReport;
import org.gradle.api.reporting.internal.TaskReportContainer;
import org.gradle.api.tasks.testing.TestReports;

public class DefaultTestReports extends TaskReportContainer<ConfigurableReport> implements TestReports {

    public DefaultTestReports(Task task) {
        super(ConfigurableReport.class, task);

        add(TaskGeneratedSingleDirectoryReport.class, "junitXml", task, null);
        add(TaskGeneratedSingleDirectoryReport.class, "html", task, "index.html");
    }

    public DirectoryReport getHtml() {
        return (DirectoryReport) getByName("html");
    }

    public DirectoryReport getJunitXml() {
        return (DirectoryReport) getByName("junitXml");
    }

}

Fix compile error due to class rename.

Fix compile error due to class rename.


package com.shc.silenceengine.core.gameloops;

import com.shc.silenceengine.core.IGameLoop;
import com.shc.silenceengine.core.SilenceEngine;
import com.shc.silenceengine.graphics.opengl.GLContext;
import com.shc.silenceengine.utils.TimeUtils;

import static com.shc.silenceengine.graphics.IGraphicsDevice.Constants.*;

/**
 * @author Sri Harsha Chilakapati
 */
public class VariableTimeSteppedLoop implements IGameLoop
{
    private float prevTime = (int) TimeUtils.currentTime();

    @Override
    public void performLoopFrame()
    {
        float currTime = (float) TimeUtils.currentTime();
        float elapsedTime = currTime - prevTime;

        prevTime = currTime;

        SilenceEngine.eventManager.raiseUpdateEvent(elapsedTime);

        GLContext.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        SilenceEngine.eventManager.raiseRenderEvent(elapsedTime);
    }
}

package com.shc.silenceengine.core.gameloops;

import com.shc.silenceengine.core.IGameLoop;
import com.shc.silenceengine.core.SilenceEngine;
import com.shc.silenceengine.graphics.opengl.GLContext;
import com.shc.silenceengine.utils.TimeUtils;

import static com.shc.silenceengine.graphics.IGraphicsDevice.Constants.*;

/**
 * @author Sri Harsha Chilakapati
 */
public class VariableTimeSteppedLoop implements IGameLoop
{
    private float prevTime;

    @Override
    public void performLoopFrame()
    {
        if (prevTime == 0)
            prevTime = (int) TimeUtils.currentTime();

        float currTime = (float) TimeUtils.currentTime();
        float elapsedTime = currTime - prevTime;

        prevTime = currTime;

        SilenceEngine.eventManager.raiseUpdateEvent(elapsedTime);

        GLContext.clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        SilenceEngine.eventManager.raiseRenderEvent(elapsedTime);
    }
}

Fix exception in initialization error in GameLoop


/**
 * See {@link org.cojen.tupl.Database} to get started with Tupl.
 */
module org.cojen.tupl {
    exports org.cojen.tupl;
    exports org.cojen.tupl.ext;
    exports org.cojen.tupl.io;
    exports org.cojen.tupl.repl;
    exports org.cojen.tupl.tools;
    exports org.cojen.tupl.util;

    requires transitive java.logging;

    requires transitive jdk.unsupported;

    requires transitive com.sun.jna;
    requires transitive com.sun.jna.platform;

    requires transitive org.cojen.maker;

    requires static java.management;

    requires static org.lz4.java;

    requires static org.slf4j;
}

/**
 * See {@link org.cojen.tupl.Database} to get started with Tupl.
 */
module org.cojen.tupl {
    exports org.cojen.tupl;
    exports org.cojen.tupl.ext;
    exports org.cojen.tupl.io;
    exports org.cojen.tupl.repl;
    exports org.cojen.tupl.tools;
    exports org.cojen.tupl.util;

    requires jdk.unsupported;

    requires com.sun.jna;
    requires com.sun.jna.platform;

    requires org.cojen.maker;

    // Could be transitive because it's part of the public API, but only in EventListener.
    // I doubt that the java.logging module is used much.
    requires static java.logging;

    requires static java.management;

    requires static org.lz4.java;

    requires static org.slf4j;
}

Remove transitive modifier from dependencies.


/*
 * Copyright 2015 Hewlett-Packard Development Company, L.P.
 * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
 */

package com.hp.autonomy.types.requests.idol.actions.answer.params;

@SuppressWarnings({"WeakerAccess", "unused"})
public enum GetResourcesSortParam {
    ID("id"),
    CREATED_TIME("createdTime"),
    METADATA("metadata"),
    MODIFIED_TIME("modifiedTime"),
    POPULARITY("popularity"),
    RANDOM("random"),
    STATUS("status");

    private final String value;

    GetResourcesSortParam(final String value) {
        this.value = value;
    }

    public String value() {
        return value;
    }
}

/*
 * Copyright 2015 Hewlett-Packard Development Company, L.P.
 * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
 */

package com.hp.autonomy.types.requests.idol.actions.answer.params;

@SuppressWarnings({"WeakerAccess", "unused"})
public enum GetResourcesSortParam {
    ID("id"),
    CREATED_TIME("createdTime"),
    LIKELIHOOD("likelihood"),
    METADATA("metadata"),
    MODIFIED_TIME("modifiedTime"),
    POPULARITY("popularity"),
    RANDOM("random"),
    STATUS("status");

    private final String value;

    GetResourcesSortParam(final String value) {
        this.value = value;
    }

    public String value() {
        return value;
    }
}

Add support for AnswerServer likelihood

Add support for AnswerServer likelihood

[rev. matthew.gordon]


package com.jonasgerdes.schauburgr.usecase.home.movies.movie_list;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.jonasgerdes.schauburgr.R;
import com.jonasgerdes.schauburgr.model.Movie;

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

/**
 * Created by jonas on 05.03.2017.
 */

public class MovieListAdapter extends RecyclerView.Adapter<MovieHolder> {

    private List<Movie> mMovies = new ArrayList<>();

    @Override
    public MovieHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.home_movies_item_movie, parent, false);
        return new MovieHolder(view);
    }

    @Override
    public void onBindViewHolder(MovieHolder holder, int position) {
        Movie movie = mMovies.get(position);
        holder.onBind(movie);
    }

    @Override
    public int getItemCount() {
        return mMovies.size();
    }

    public void setMovies(List<Movie> movies) {
        mMovies = movies;
        notifyDataSetChanged();
    }
}

package com.jonasgerdes.schauburgr.usecase.home.movies.movie_list;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.jonasgerdes.schauburgr.R;
import com.jonasgerdes.schauburgr.model.Movie;

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

import io.realm.RealmChangeListener;
import io.realm.RealmResults;

/**
 * Created by jonas on 05.03.2017.
 */

public class MovieListAdapter extends RecyclerView.Adapter<MovieHolder> {

    private List<Movie> mMovies = new ArrayList<>();

    @Override
    public MovieHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.home_movies_item_movie, parent, false);
        return new MovieHolder(view);
    }

    @Override
    public void onBindViewHolder(MovieHolder holder, int position) {
        Movie movie = mMovies.get(position);
        holder.onBind(movie);
    }

    @Override
    public int getItemCount() {
        return mMovies.size();
    }

    public void setMovies(RealmResults<Movie> movies) {
        mMovies = movies;
        notifyDataSetChanged();
        movies.addChangeListener(new RealmChangeListener<RealmResults<Movie>>() {
            @Override
            public void onChange(RealmResults<Movie> element) {
                notifyDataSetChanged();
            }
        });
    }
}

Add automatic refresh of movies when new data is available


package org.motechproject.server.pillreminder.util;

import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Util {

    public static DateTime currentDateTime() {
        return new DateTime(DateTimeZone.UTC);
    }

    public static Date newDate(int year, int month, int day) {
        Calendar cal = Calendar.getInstance();
        cal.set(year, month, day);
        return cal.getTime();
    }

    public static boolean areDatesSame(Date date1, Date date2) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd");
        return dateFormat.format(date1).equals(dateFormat.format(date2));
    }

    public static Date getDateAfter(Date date, int numOfMonth) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.add(Calendar.MONTH, numOfMonth);
        return cal.getTime();
    }
}

package org.motechproject.server.pillreminder.util;

import org.joda.time.DateTime;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Util {

    public static DateTime currentDateTime() {
        return new DateTime();
    }

    public static Date newDate(int year, int month, int day) {
        Calendar cal = Calendar.getInstance();
        cal.set(year, month, day);
        return cal.getTime();
    }

    public static boolean areDatesSame(Date date1, Date date2) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd");
        return dateFormat.format(date1).equals(dateFormat.format(date2));
    }

    public static Date getDateAfter(Date date, int numOfMonth) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.add(Calendar.MONTH, numOfMonth);
        return cal.getTime();
    }
}

Remove UTC from time util<Manohar/Shruthi>


/**
 * $$\\ToureNPlaner\\$$
 */
package algorithms;

import com.carrotsearch.hppc.IntArrayList;

public class Points {
	private IntArrayList points;

	public Points() {
		points = new IntArrayList();
	}

	public void addPoint(int lat, int lon) {
		points.add(lat);
		points.add(lon);
	}

	public void addEmptyPoints(int num) {
		points.resize(this.size() + num*2);
	}

	public int getPointLat(int index) {
		return points.get(index * 2);
	}

	public int getPointLon(int index) {
		return points.get(index * 2 + 1);
	}

	public void setPointLat(int index, int lat) {
		points.set(index * 2, lat);
	}

	public void setPointLon(int index, int lon) {
		points.set(index * 2 + 1, lon);
	}

	public int size() {
		return points.size() / 2;
	}

}

/**
 * $$\\ToureNPlaner\\$$
 */
package algorithms;

import com.carrotsearch.hppc.IntArrayList;

public class Points {
	private IntArrayList points;

	public Points() {
		points = new IntArrayList();
	}

	public void addPoint(int lat, int lon) {
		points.add(lat);
		points.add(lon);
	}

	public void addEmptyPoints(int num) {
		points.resize(points.size() + num*2);
	}

	public int getPointLat(int index) {
		return points.get(index * 2);
	}

	public int getPointLon(int index) {
		return points.get(index * 2 + 1);
	}

	public void setPointLat(int index, int lat) {
		points.set(index * 2, lat);
	}

	public void setPointLon(int index, int lon) {
		points.set(index * 2 + 1, lon);
	}

	public int size() {
		return points.size() / 2;
	}

}

Fix allocation of points array for real

Fix allocation of points array for real


package com.alexrnl.subtitlecorrector.correctionstrategy;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.logging.Logger;

import com.alexrnl.subtitlecorrector.service.SessionParameters;

/**
 * Abstract strategy implementation.<br />
 * Provide a basic body for the actual strategies. There is no logic in this class.
 * @author Alex
 */
public abstract class AbstractStrategy implements Strategy {
	/** Logger */
	private static final Logger	LG	= Logger.getLogger(AbstractStrategy.class.getName());

	@Override
	public void startSession (final SessionParameters parameters) {
		// Nothing to do here, override if strategy depends on session state
	}

	@Override
	public void stopSession () {
		// Nothing to do here, override if strategy depends on session state
	}

	@Override
	public List<Parameter<?>> getParameters () {
		return new ArrayList<>(0);
	}

	@Override
	public Parameter<?> getParameterByName (final String name) {
		Objects.requireNonNull(name);
		for (final Parameter<?> parameter : getParameters()) {
			if (parameter.getDescription().equals(name)) {
				return parameter;
			}
		}
		LG.info("No parameter with name " + name + " found");
		return null;
	}

}

package com.alexrnl.subtitlecorrector.correctionstrategy;

import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.logging.Logger;

import com.alexrnl.subtitlecorrector.service.SessionParameters;

/**
 * Abstract strategy implementation.<br />
 * Provide a basic body for the actual strategies. There is no logic in this class.
 * @author Alex
 */
public abstract class AbstractStrategy implements Strategy {
	/** Logger */
	private static final Logger	LG	= Logger.getLogger(AbstractStrategy.class.getName());

	@Override
	public void startSession (final SessionParameters parameters) {
		// Nothing to do here, override if strategy depends on session state
	}

	@Override
	public void stopSession () {
		// Nothing to do here, override if strategy depends on session state
	}

	@Override
	public List<Parameter<?>> getParameters () {
		return Collections.emptyList();
	}

	@Override
	public Parameter<?> getParameterByName (final String name) {
		Objects.requireNonNull(name);
		for (final Parameter<?> parameter : getParameters()) {
			if (parameter.getDescription().equals(name)) {
				return parameter;
			}
		}
		LG.info("No parameter with name " + name + " found");
		return null;
	}

}

Replace empty list creation with Collections.emptyList()


/*
 * This file is part of Nucleus, licensed under the MIT License (MIT). See the LICENSE.txt file
 * at the root of this project for more details.
 */
package io.github.nucleuspowered.nucleus.modules.admin.config;

import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;

@ConfigSerializable
public class AdminConfig {

    @Setting(value = "broadcast-message-template", comment = "config.broadcast.template")
    private BroadcastConfig broadcastMessage = new BroadcastConfig();

    // TODO: Make the default true in future versions?
    @Setting(value = "separate-gamemode-permissions", comment = "config.gamemode.separate")
    private boolean separateGamemodePermission = false;

    public BroadcastConfig getBroadcastMessage() {
        return broadcastMessage;
    }

    public boolean isSeparateGamemodePermission() {
        return separateGamemodePermission;
    }
}

/*
 * This file is part of Nucleus, licensed under the MIT License (MIT). See the LICENSE.txt file
 * at the root of this project for more details.
 */
package io.github.nucleuspowered.nucleus.modules.admin.config;

import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;

@ConfigSerializable
public class AdminConfig {

    @Setting(value = "broadcast-message-template", comment = "config.broadcast.template")
    private BroadcastConfig broadcastMessage = new BroadcastConfig();

    @Setting(value = "separate-gamemode-permissions", comment = "config.gamemode.separate")
    private boolean separateGamemodePermission = true;

    public BroadcastConfig getBroadcastMessage() {
        return broadcastMessage;
    }

    public boolean isSeparateGamemodePermission() {
        return separateGamemodePermission;
    }
}

Set separate game mode permissions default to true.

I meant to do this ages ago.


package com.theaccountant.accountabilityhack.processor;

import com.theaccountant.accountabilityhack.data.SchoolEntry;
import com.theaccountant.accountabilityhack.data.SchoolRegistry;

import java.io.IOException;

public final class FteAantalProcessor implements Processor {

    public void process(final SchoolRegistry registry) throws IOException {
        final CsvReader reader = new CsvReader("02.-po-fte-owtype-bestuur-brin-functie.csv");
        while (reader.next()) {
            final String brin = reader.get("BRIN_NUMMER");
            final SchoolEntry entry;
            if (registry.isSchoolPresent(brin)) {
                entry = registry.getSchoolByBrin(brin);
            } else {
                entry = new SchoolEntry(brin);
                registry.addSchool(entry);
            }
            final String functie = reader.get("FUNCTIEGROEP");
            final String fte = reader.get("FTE'S 2016");
            switch (functie) {
            case "Directie":
                entry.setFteDirectie(fte);
                break;
            case "Onderwijsgevend personeel":
                entry.setFteLeerkrachten(fte);
                break;
            case "Onderwijsondersteunend personeel (OOP/OBP)":
                entry.setFteOndersteunend(fte);
                break;
            default:
                System.err.println("Unknown functie: " + functie);
                break;
            }
        }
    }
}

package com.theaccountant.accountabilityhack.processor;

import com.theaccountant.accountabilityhack.data.SchoolEntry;
import com.theaccountant.accountabilityhack.data.SchoolRegistry;

import java.io.IOException;

public final class FteAantalProcessor implements Processor {

    public void process(final SchoolRegistry registry) throws IOException {
        final CsvReader reader = new CsvReader("02.-po-fte-owtype-bestuur-brin-functie.csv");
        while (reader.next()) {
            final String brin = reader.get("BRIN_NUMMER");
            final SchoolEntry entry;
            if (registry.isSchoolPresent(brin)) {
                entry = registry.getSchoolByBrin(brin);
            } else {
                entry = SchoolEntry.builder().brin(brin).build();
                registry.addSchool(entry);
            }
            final String functie = reader.get("FUNCTIEGROEP");
            final String fte = reader.get("FTE'S 2016");
            switch (functie) {
            case "Directie":
                entry.setFteDirectie(fte);
                break;
            case "Onderwijsgevend personeel":
                entry.setFteLeerkrachten(fte);
                break;
            case "Onderwijsondersteunend personeel (OOP/OBP)":
                entry.setFteOndersteunend(fte);
                break;
            default:
                System.err.println("Unknown functie: " + functie);
                break;
            }
        }
    }
}

Use builder to create object.

Use builder to create object.


/*******************************************************************************
 * Copyright (c) 2014 Codenvy, S.A.
 * 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
 *
 * Contributors:
 *   Codenvy, S.A. - initial API and implementation
 *******************************************************************************/
package com.codenvy.flux.watcher.core.spi;

import java.nio.file.Path;

/**
 * @author Kevin Pollet
 */
public interface RepositoryWatchingService {
    void watch(String projectId, Path path);

    void unwatch(String projectId);

    boolean addRepositoryListener(RepositoryListener listener);

    boolean removeRepositoryListener(RepositoryListener listener);
}

/*******************************************************************************
 * Copyright (c) 2014 Codenvy, S.A.
 * 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
 *
 * Contributors:
 *   Codenvy, S.A. - initial API and implementation
 *******************************************************************************/
package com.codenvy.flux.watcher.core.spi;

import java.nio.file.Path;

/**
 * @author Kevin Pollet
 */
public interface RepositoryWatchingService {
    void watch(Path path);

    void unwatch(Path path);

    boolean addRepositoryListener(RepositoryListener listener);

    boolean removeRepositoryListener(RepositoryListener listener);
}

Remove project parameter from watching service


package dk.in2isoft.onlineobjects.apps.reader.perspective;

public class StatementPerspective {
	private String text;
	private long id;
	private boolean found;

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public long getId() {
		return id;
	}

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

	public boolean isFound() {
		return found;
	}

	public void setFound(boolean found) {
		this.found = found;
	}
}

package dk.in2isoft.onlineobjects.apps.reader.perspective;

public class StatementPerspective {
	private String text;
	private long id;
	private boolean found;
	private int firstPosition;

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public long getId() {
		return id;
	}

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

	public boolean isFound() {
		return found;
	}

	public void setFound(boolean found) {
		this.found = found;
	}

	public int getFirstPosition() {
		return firstPosition;
	}

	public void setFirstPosition(int firstPosition) {
		this.firstPosition = firstPosition;
	}
}

Store first position of statements

Store first position of statements


/*
 * Copyright (C) 2013 Matija Mazi
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is furnished to do
 * so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package si.mazi.rescu;

/**
 * @author Matija Mazi <br>
 */
public enum HttpMethod {
    GET, POST, PUT, DELETE, HEAD
}

/*
 * Copyright (C) 2013 Matija Mazi
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is furnished to do
 * so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package si.mazi.rescu;

/**
 * @author Matija Mazi <br>
 */
public enum HttpMethod {
    GET, POST, PUT, DELETE, HEAD, OPTIONS
}

Add support for the OPTIONS method

Add support for the OPTIONS method


package com.github.javiersantos.materialstyleddialogs;

import android.content.Context;
import android.os.Build;
import android.support.annotation.ColorRes;
import android.util.TypedValue;

class UtilsLibrary {

    static int getPrimaryColor(Context context) {
        TypedValue typedValue = new TypedValue();

        context.getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true);

        return typedValue.data;
    }

    static int dpToPixels(Context context, int dp) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dp * scale + 0.5f);
    }

    /**
     * Returns a color associated with a particular resource ID
     * <p/>
     * Starting in {@link android.os.Build.VERSION_CODES#M}, the returned
     * color will be styled for the specified Context's theme.
     *
     * @param colorId The desired resource identifier, as generated by the aapt
     *                tool. This integer encodes the package, type, and resource
     *                entry. The value 0 is an invalid identifier.
     * @return A single color value in the form 0xAARRGGBB.
     */
    static int getColor(Context context, @ColorRes int colorId) {
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP_MR1) {
            // Noinspection deprecation
            return context.getResources().getColor(colorId);
        } else {
            return context.getColor(colorId);
        }
    }

    static boolean checkApiGreaterThan(int api) {
        return Build.VERSION.SDK_INT >= api;
    }

}

package com.github.javiersantos.materialstyleddialogs;

import android.content.Context;
import android.os.Build;
import android.support.annotation.ColorRes;
import android.support.v4.content.ContextCompat;
import android.util.TypedValue;

class UtilsLibrary {

    static int getPrimaryColor(Context context) {
        TypedValue typedValue = new TypedValue();

        context.getTheme().resolveAttribute(R.attr.colorPrimary, typedValue, true);

        return typedValue.data;
    }

    static int dpToPixels(Context context, int dp) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dp * scale + 0.5f);
    }

    static int getColor(Context context, @ColorRes int colorId) {
        return ContextCompat.getColor(context, colorId);
    }

    static boolean checkApiGreaterThan(int api) {
        return Build.VERSION.SDK_INT >= api;
    }

}

Update method to get color

Update method to get color


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

package org.uma.jmetal.util.solutionattribute.impl;

import org.junit.Test;
import org.uma.jmetal.solution.DoubleSolution;

import static org.junit.Assert.*;

/**
 * @author Antonio J. Nebro <antonio@lcc.uma.es>
 */
public class GenericSolutionAttributeTest {
  @Test
  public void shouldDefaultConstructorCreateASolutionAttributedWithAnIdentifierEqualToTheClassName() {

    GenericSolutionAttribute<DoubleSolution, Integer> genericSolutionAttribute ;
    genericSolutionAttribute = new GenericSolutionAttribute<>() ;

    assertEquals(genericSolutionAttribute.getClass(), genericSolutionAttribute.getAttributeID());
  }

}

Add copyrigth comments to some classes

Add copyrigth comments to some classes


/**
 * Copyright (C) 2015 android10.org. All rights reserved.
 * @author Fernando Cejas (the android10 coder)
 */
package com.fernandocejas.android10.rx.sample.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import butterknife.ButterKnife;
import com.fernandocejas.android10.rx.sample.R;
import rx.Subscription;
import rx.subscriptions.Subscriptions;

public class SampleActivityObservableTransfor extends Activity {

  private Subscription subscription;

  public static Intent getCallingIntent(Context context) {
    return new Intent(context, SampleActivityObservableTransfor.class);
  }

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

    ButterKnife.inject(this);
    initialize();
  }

  @Override
  protected void onDestroy() {
    this.subscription.unsubscribe();
    super.onDestroy();
  }

  private void initialize() {
    this.subscription = Subscriptions.empty();
  }
}

/**
 * Copyright (C) 2015 android10.org. All rights reserved.
 * @author Fernando Cejas (the android10 coder)
 */
package com.fernandocejas.android10.rx.sample.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;
import com.fernandocejas.android10.rx.sample.R;
import com.fernandocejas.android10.rx.sample.data.DataManager;
import rx.Subscription;
import rx.subscriptions.Subscriptions;

public class SampleActivityObservableTransfor extends Activity {

  @InjectView(R.id.btn_flatMap) Button btn_flatMap;
  @InjectView(R.id.btn_concatMap) Button btn_concatMap;

  private DataManager dataManager;

  private Subscription subscription;

  public static Intent getCallingIntent(Context context) {
    return new Intent(context, SampleActivityObservableTransfor.class);
  }

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

    ButterKnife.inject(this);
    initialize();
  }

  @Override
  protected void onDestroy() {
    this.subscription.unsubscribe();
    super.onDestroy();
  }

  private void initialize() {
    this.subscription = Subscriptions.empty();
  }

  @OnClick(R.id.btn_flatMap) void onFlatMapClick() {

  }

  @OnClick(R.id.btn_concatMap) void onConcatMapClick() {

  }
}

Add click events for buttons.

Add click events for buttons.


/*
 * Copyright 2016 SEARCH-The National Consortium for Justice Information and Statistics
 *
 * 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.search.nibrs.route;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

@RunWith(SpringRunner.class)
@SpringBootTest
public class NibrsRouteApplicationTests {

	@Test
	public void contextLoads() {
	}

}

/*
 * Copyright 2016 SEARCH-The National Consortium for Justice Information and Statistics
 *
 * 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.search.nibrs.route;

import org.apache.camel.CamelContext;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.search.nibrs.fbi.service.NibrsFbiServiceApplication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.Assert;

@RunWith(SpringRunner.class)
@SpringBootTest(classes = NibrsFbiServiceApplication.class)
public class NibrsRouteApplicationTests {

	@Autowired
	CamelContext context;
	@Test
	public void contextLoads() {
		Assert.notNull(context, "the camel context should not be null");
	}

}

Test the Autowired bean of context.

Test the Autowired bean of context.


package com.yuzhouwan.site.service.rpc.core;

import com.yuzhouwan.site.api.rpc.service.IRPCService;
import com.yuzhouwan.site.api.rpc.service.Server;
import com.yuzhouwan.site.service.rpc.service.RPCServiceImpl;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * Copyright @ 2017 yuzhouwan.com
 * All right reserved.
 * Function: RPC Tester
 *
 * @author Benedict Jin
 * @since 2016/9/1
 */
public class RPCTest {

    @Test
    public void rpc() throws Exception {

        Server server = new RPC.RPCServer();
        server.register(IRPCService.class, RPCServiceImpl.class);
        server.start();
        Thread.sleep(100);

        IRPCService testServiceImpl = RPC.getProxy(IRPCService.class, "localhost", server.getPort());
        assertEquals("Hello, Benedict!", testServiceImpl.printHello("Benedict"));
        server.stop();  // System.exit(0);
    }
}

package com.yuzhouwan.site.service.rpc.core;

import com.yuzhouwan.site.api.rpc.service.IRPCService;
import com.yuzhouwan.site.api.rpc.service.Server;
import com.yuzhouwan.site.service.rpc.service.RPCServiceImpl;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * Copyright @ 2017 yuzhouwan.com
 * All right reserved.
 * Function: RPC Tester
 *
 * @author Benedict Jin
 * @since 2016/9/1
 */
public class RPCTest {

    @Test
    public void rpc() throws Exception {

        Server server = new RPC.RPCServer();
        server.register(IRPCService.class, RPCServiceImpl.class);
        server.start();

        int count = 0, max = 5;
        while (!server.isRunning() && count < max) {
            Thread.sleep(10);
            count++;
        }
        IRPCService testServiceImpl = RPC.getProxy(IRPCService.class, "localhost", server.getPort());
        assertEquals("Hello, Benedict!", testServiceImpl.printHello("Benedict"));
        server.stop();  // System.exit(0);
    }
}

Add retry strategy for RPC server

Add retry strategy for RPC server


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

import org.apache.camel.Exchange;
import org.apache.camel.Message;

public final class AwsExchangeUtil {

    private AwsExchangeUtil() {
    }

    public static Message getMessageForResponse(final Exchange exchange) {
        if (exchange.getPattern().isOutCapable()) {
            return exchange.getOut();
        }
        return exchange.getIn();
    }
}

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

import org.apache.camel.Exchange;
import org.apache.camel.Message;

public final class AwsExchangeUtil {

    private AwsExchangeUtil() {
    }

    public static Message getMessageForResponse(final Exchange exchange) {
        if (exchange.getPattern().isOutCapable()) {
            Message out = exchange.getOut();
            out.copyFrom(exchange.getIn());
            return out;
        }
        return exchange.getIn();
    }
}

Revert "Fix over writing previous addToResult calls"

This reverts commit 45c375c38e1a02347c17d172a6bd7dc68aebcdd4.


package org.demyo.dao;

import org.demyo.model.IModel;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.NoRepositoryBean;

/**
 * Base interface for manipulation of models.
 *
 * @param <M> The model type (an {@link IModel}).
 */
@NoRepositoryBean
public interface IModelRepo<M extends IModel> extends JpaRepository<M, Long> {
	// TODO: figure out how to return slices. We can't override JpaRepository's findAll to return a slice
	//Slice<M> findAll(Pageable pageable);
}

package org.demyo.dao;

import java.util.List;

import org.demyo.model.IModel;

import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.NoRepositoryBean;

/**
 * Base interface for manipulation of models. This doesn't inherit from JpaRepository, in order to be free to
 * define exactly what we need.
 *
 * @param <M> The model type (an {@link IModel}).
 */
@NoRepositoryBean
public interface IModelRepo<M extends IModel> extends CrudRepository<M, Long> {
	@Override
	List<M> findAll();

	/**
	 * Returns a {@link Slice} of entities meeting the paging restriction provided in the {@code Pageable} object.
	 *
	 * @param pageable
	 * @return a page of entities
	 */
	Slice<M> findAll(Pageable pageable);
}

Return Slices rather than Pages.

Return Slices rather than Pages.


package io.appium.android.bootstrap.utils;

import java.nio.charset.Charset;

public class UnicodeEncoder {
  private static final Charset M_UTF7 = Charset.forName("x-IMAP-mailbox-name");
  private static final Charset ASCII  = Charset.forName("US-ASCII");

  public static String encode(final String text) {
    byte[] encoded = text.getBytes(M_UTF7);
    return new String(encoded, ASCII);
  }

  public static boolean needsEncoding(final String text) {
    char[] chars = text.toCharArray();
    for (int i = 0; i < chars.length; i++) {
      int cp = Character.codePointAt(chars, i);
      if (cp > 0x7F || cp == '&') {
        // Selenium uses a Unicode PUA to cover certain special characters
        // see https://code.google.com/p/selenium/source/browse/java/client/src/org/openqa/selenium/Keys.java
        // these should juse be passed through as is.
        return !(cp >= 0xE000 && cp <= 0xE040);
      }
    }
    return false;
  }
}

package io.appium.android.bootstrap.utils;

import java.nio.charset.Charset;

import io.appium.android.bootstrap.Logger;

public class UnicodeEncoder {
  private static final Charset M_UTF7 = Charset.forName("x-IMAP-mailbox-name");
  private static final Charset ASCII  = Charset.forName("US-ASCII");

  public static String encode(final String text) {
    byte[] encoded = text.getBytes(M_UTF7);
    String ret = new String(encoded, ASCII);
    if (ret.charAt(ret.length()-1) != text.charAt(text.length()-1) && !ret.endsWith("-")) {
      // in some cases there is a problem and the closing tag is not added
      // to the encoded text (for instance, with `ü`)
      Logger.debug("Closing tag missing. Adding.");
      ret = ret + "-";
    }
    return ret;
  }

  public static boolean needsEncoding(final String text) {
    char[] chars = text.toCharArray();
    for (int i = 0; i < chars.length; i++) {
      int cp = Character.codePointAt(chars, i);
      if (cp > 0x7F || cp == '&') {
        // Selenium uses a Unicode PUA to cover certain special characters
        // see https://code.google.com/p/selenium/source/browse/java/client/src/org/openqa/selenium/Keys.java
        // these should juse be passed through as is.
        return !(cp >= 0xE000 && cp <= 0xE040);
      }
    }
    return false;
  }
}

Make sure encoding closes correctly

Make sure encoding closes correctly


/*
 * Zed Attack Proxy (ZAP) and its related class files.
 *
 * ZAP is an HTTP/HTTPS proxy for assessing web application security.
 *
 * Copyright 2019 The ZAP Development 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.zaproxy.zap.extension.wappalyzer;

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

import java.io.IOException;
import org.junit.jupiter.api.Test;

public class WappalyzerAppsJsonParseUnitTest {

    @Test
    public void test() throws IOException {
        // When - there's a parse exception, fail
        WappalyzerJsonParser parser =
                new WappalyzerJsonParser(
                        (pattern, e) -> fail("Regular expression with errors: " + e));
        parser.parseDefaultAppsJson();
    }
}

/*
 * Zed Attack Proxy (ZAP) and its related class files.
 *
 * ZAP is an HTTP/HTTPS proxy for assessing web application security.
 *
 * Copyright 2019 The ZAP Development 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.zaproxy.zap.extension.wappalyzer;

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

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.junit.jupiter.api.Test;

public class WappalyzerAppsJsonParseUnitTest {

    @Test
    public void test() throws IOException {
        // Given
        List<String> errs = new ArrayList<>();
        // When
        WappalyzerJsonParser parser =
                new WappalyzerJsonParser((pattern, e) -> errs.add(e.toString()));
        parser.parseDefaultAppsJson();
        // Then
        assertEquals(Collections.emptyList(), errs);
    }
}

wappalyzer: Tweak UnitTest to collect all failing patterns

Signed-off-by: kingthorin <83ea41af2b636790c02743e48206546e1fa891e4@users.noreply.github.com>


package eu.europa.esig.dss.validation.process.qmatrix;

import java.util.Date;

import javax.xml.bind.DatatypeConverter;

public final class EIDASUtils {

	private EIDASUtils() {
	}

	/**
	 * Start date of the eIDAS regulation
	 */
	private final static Date EIDAS_DATE = DatatypeConverter.parseDateTime("2016-07-01T00:00:00.000Z").getTime();

	/**
	 * End of the grace period for eIDAS regulation
	 */
	private final static Date EIDAS_GRACE_DATE = DatatypeConverter.parseDateTime("2017-07-01T00:00:00.000Z").getTime();

	public static boolean isPostEIDAS(Date date) {
		return date != null && date.compareTo(EIDAS_DATE) >= 0;
	}

	public static boolean isPreEIDAS(Date date) {
		return date != null && date.compareTo(EIDAS_DATE) < 0;
	}

	public static boolean isPostGracePeriod(Date date) {
		return date != null && date.compareTo(EIDAS_GRACE_DATE) >= 0;
	}

}

package eu.europa.esig.dss.validation.process.qmatrix;

import java.util.Date;

import javax.xml.bind.DatatypeConverter;

public final class EIDASUtils {

	private EIDASUtils() {
	}

	/**
	 * Start date of the eIDAS regulation
	 *
	 * Regulation was signed in Brussels : 1st of July 00:00 Brussels = 30th of June 22:00 UTC
	 */
	private final static Date EIDAS_DATE = DatatypeConverter.parseDateTime("2016-06-30T22:00:00.000Z").getTime();

	/**
	 * End of the grace period for eIDAS regulation
	 */
	private final static Date EIDAS_GRACE_DATE = DatatypeConverter.parseDateTime("2017-06-30T22:00:00.000Z").getTime();

	public static boolean isPostEIDAS(Date date) {
		return date != null && date.compareTo(EIDAS_DATE) >= 0;
	}

	public static boolean isPreEIDAS(Date date) {
		return date != null && date.compareTo(EIDAS_DATE) < 0;
	}

	public static boolean isPostGracePeriod(Date date) {
		return date != null && date.compareTo(EIDAS_GRACE_DATE) >= 0;
	}

}

Fix eIDAS date (Brussels date is used)

Fix eIDAS date (Brussels date is used)


/*
 * (C) Copyright 2015 Boni Garcia (http://bonigarcia.github.io/)
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 2.1 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl-2.1.html
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 */
package io.github.bonigarcia.wdm.test;

import org.junit.Before;
import org.junit.Ignore;
import org.openqa.selenium.firefox.FirefoxDriver;

import io.github.bonigarcia.wdm.base.BaseBrowserTst;

/**
 * Test with Firefox browser.
 *
 * @author Boni Garcia (boni.gg@gmail.com)
 * @since 1.0.0
 */
@Ignore
public class FirefoxTest extends BaseBrowserTst {

	@Before
	public void setup() {
		driver = new FirefoxDriver();
	}

}

/*
 * (C) Copyright 2015 Boni Garcia (http://bonigarcia.github.io/)
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 2.1 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl-2.1.html
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 */
package io.github.bonigarcia.wdm.test;

import org.junit.Before;
import org.openqa.selenium.firefox.FirefoxDriver;

import io.github.bonigarcia.wdm.base.BaseBrowserTst;

/**
 * Test with Firefox browser.
 *
 * @author Boni Garcia (boni.gg@gmail.com)
 * @since 1.0.0
 */
public class FirefoxTest extends BaseBrowserTst {

	@Before
	public void setup() {
		driver = new FirefoxDriver();
	}

}

Enable FirefoxText (WebDriver 2.53.1 is working again with Firefox 47.0.1)


package it.cosenonjaviste.daggermock.realworldapp;

import android.app.Activity;

import dagger.Binds;
import dagger.Module;
import dagger.android.ActivityKey;
import dagger.android.AndroidInjector;
import dagger.multibindings.IntoMap;
import it.cosenonjaviste.daggermock.realworldapp.main.MainActivity;
import it.cosenonjaviste.daggermock.realworldapp.main.MainActivityComponent;

@Module(subcomponents = {
        MainActivityComponent.class
})
abstract public class MainActivityBindingModule {

    @Binds
    @IntoMap
    @ActivityKey(MainActivity.class)
    abstract AndroidInjector.Factory<? extends Activity> mainActivityInjectorFactory(
            MainActivityComponent.Builder builder);
}

package it.cosenonjaviste.daggermock.realworldapp;

import dagger.Binds;
import dagger.Module;
import dagger.android.AndroidInjector;
import dagger.multibindings.ClassKey;
import dagger.multibindings.IntoMap;
import it.cosenonjaviste.daggermock.realworldapp.main.MainActivity;
import it.cosenonjaviste.daggermock.realworldapp.main.MainActivityComponent;

@Module(subcomponents = {
        MainActivityComponent.class
})
abstract public class MainActivityBindingModule {

    @Binds
    @IntoMap
    @ClassKey(MainActivity.class)
    abstract AndroidInjector.Factory<?> mainActivityInjectorFactory(
            MainActivityComponent.Builder builder);
}

Fix compilation error in RealWorldAppInjector


package uk.ac.ic.wlgitbridge.bridge.db.sqlite.query;

import uk.ac.ic.wlgitbridge.bridge.db.sqlite.SQLQuery;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Created by winston on 23/08/2016.
 */
public class GetOldestProjectName implements SQLQuery<String> {

    private static final String GET_OLDEST_PROJECT_NAME =
            "SELECT `name`, MIN(`last_accessed`)\n" +
            "    FROM `projects`";

    @Override
    public String getSQL() {
        return GET_OLDEST_PROJECT_NAME;
    }

    @Override
    public String processResultSet(ResultSet resultSet) throws SQLException {
        while (resultSet.next()) {
            return resultSet.getString("name");
        }
        return null;
    }

}

package uk.ac.ic.wlgitbridge.bridge.db.sqlite.query;

import uk.ac.ic.wlgitbridge.bridge.db.sqlite.SQLQuery;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Created by winston on 23/08/2016.
 */
public class GetOldestProjectName implements SQLQuery<String> {

    private static final String GET_OLDEST_PROJECT_NAME =
            "SELECT `name`, MIN(`last_accessed`)\n" +
            "    FROM `projects` \n" +
            "    WHERE `last_accessed` IS NOT NULL;";

    @Override
    public String getSQL() {
        return GET_OLDEST_PROJECT_NAME;
    }

    @Override
    public String processResultSet(ResultSet resultSet) throws SQLException {
        while (resultSet.next()) {
            return resultSet.getString("name");
        }
        return null;
    }

}

Fix query for oldest (un-swapped) project


package com.orientechnologies.orient.test.server.network.http;

import com.orientechnologies.orient.core.record.impl.ODocument;
import org.apache.http.HttpResponse;
import org.junit.Assert;
import org.junit.Test;

public class HttpServerTest extends BaseHttpDatabaseTest {
  @Test
  public void testGetServer() throws Exception {
    HttpResponse res = get("server").getResponse();
    Assert.assertEquals(res.getStatusLine().getStatusCode(), 200);

    ODocument payload = new ODocument().fromJSON(res.getEntity().getContent());

    Assert.assertTrue(payload.containsField("connections"));
  }

  @Test
  public void testGetConnections() throws Exception {
    HttpResponse res =
        setUserName("root").setUserPassword("root").get("connections/").getResponse();
    Assert.assertEquals(res.getStatusLine().getStatusCode(), 200);

    ODocument payload = new ODocument().fromJSON(res.getEntity().getContent());

    Assert.assertTrue(payload.containsField("connections"));
  }

  @Override
  protected String getDatabaseName() {
    return "server";
  }
}

package com.orientechnologies.orient.test.server.network.http;

import com.orientechnologies.orient.core.record.impl.ODocument;
import org.apache.http.HttpResponse;
import org.junit.Assert;
import org.junit.Test;

import java.io.IOException;

public class HttpServerTest extends BaseHttpDatabaseTest {
  @Test
  public void testGetServer() throws Exception {
    HttpResponse res = get("server").getResponse();
    Assert.assertEquals(res.getStatusLine().getStatusCode(), 200);

    ODocument payload = new ODocument().fromJSON(res.getEntity().getContent());

    Assert.assertTrue(payload.containsField("connections"));
  }

  @Test
  public void testGetConnections() throws Exception {
    HttpResponse res =
        setUserName("root").setUserPassword("root").get("connections/").getResponse();
    Assert.assertEquals(res.getStatusLine().getStatusCode(), 200);

    ODocument payload = new ODocument().fromJSON(res.getEntity().getContent());

    Assert.assertTrue(payload.containsField("connections"));
  }

  @Test
  public void testCreateDatabase() throws IOException {
    String dbName = getClass().getSimpleName()+"testCreateDatabase";
    HttpResponse res =
            setUserName("root")
                    .setUserPassword("root")
                    .post("servercommand")
                    .payload("{\"command\":\"create database "+dbName+" plocal\" }", CONTENT.JSON)
                    .getResponse();
    System.out.println(res.getStatusLine().getReasonPhrase());
    Assert.assertEquals(res.getStatusLine().getStatusCode(), 200);

    Assert.assertTrue(getServer().getContext().exists(dbName));
    getServer().getContext().drop(dbName);
  }

  @Override
  protected String getDatabaseName() {
    return "server";
  }
}

Add test cases for HTTP server-level commands


/*-
 * Copyright 2015 Diamond Light Source Ltd.
 *
 * 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.eclipse.dawnsci.analysis.api;

public interface EventTracker {

	/**
	 * This method is used to track events (log, action, exception etc) in the application.
	 *
	 * @param name
	 *            Name of event to be tracked
	 * @throws Exception
	 */
	public void track(String name) throws Exception;

	/**
	 * This method is used to track events from extension points given by their id and label
	 *
	 * @param id
	 *            Unique id
	 * @param label
	 *            Name
	 */
	public void track(String id, String label) throws Exception;
}

/*-
 * Copyright 2015 Diamond Light Source Ltd.
 *
 * 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.eclipse.dawnsci.analysis.api;

public interface EventTracker {

	/**
	 * This method is used to track events (log, action, exception etc) in the application.
	 *
	 * @param name
	 *            Name of event to be tracked
	 * @throws Exception
	 */
	public void track(String name) throws Exception;

	/**
	 * This method is used to track events from extension points given by their id and label
	 *
	 * @param id
	 *            Unique id
	 * @param label
	 *            Name
	 */
	public void track(String id, String label) throws Exception;

	/**
	 * This method is used to track tool creation events given a tool name. It will track the event name with the prefix
	 * "/Tool/"
	 *
	 * @param name
	 * @throws Exception
	 */
	public void trackToolEvent(String name) throws Exception;

	/**
	 * This method is used to track perspective launch events given a perspective name. It will track the event name
	 * with the prefix "/perspective/".
	 *
	 * @param name
	 * @throws Exception
	 */
	public void trackPerspectiveEvent(String name) throws Exception;

	/**
	 * This method is used to track action events like a user click on a "run" button given the action's name. It will
	 * track the event name with the prefix "/Action/".
	 *
	 * @param name
	 * @throws Exception
	 */
	public void trackActionEvent(String name) throws Exception;
}

Add new tracking methods to API

Add new tracking methods to API