package org.xdi.service.cdi.event;

import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Qualifier;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

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

/**
 * @author Yuriy Movchan Date: 04/13/2017
 */
@Qualifier
@Retention(RUNTIME)
@Target({ METHOD, FIELD, PARAMETER, TYPE })
@Documented
public @interface ApplicationInitialized {

    public static final class Literal extends AnnotationLiteral<ApplicationInitialized> implements ApplicationInitialized {

        private static final long serialVersionUID = 4891987789146132930L;

        public static final Literal INSTANCE = new Literal();
    }

}

package org.xdi.service.cdi.event;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.Initialized.Literal;
import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Qualifier;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

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

import java.lang.annotation.Annotation;

/**
 * @author Yuriy Movchan Date: 04/13/2017
 */
@Qualifier
@Retention(RUNTIME)
@Target({ METHOD, FIELD, PARAMETER, TYPE })
@Documented
public @interface ApplicationInitialized {

    /**
     * The scope for which to observe initialization
     */
    Class<? extends Annotation> value();

    public static final class Literal extends AnnotationLiteral<ApplicationInitialized> implements ApplicationInitialized {

        public static final Literal APPLICATION = of(ApplicationScoped.class);

        private static final long serialVersionUID = 1L;

        private final Class<? extends Annotation> value;

        public static Literal of(Class<? extends Annotation> value) {
            return new Literal(value);
        }

        private Literal(Class<? extends Annotation> value) {
            this.value = value;
        }

        @Override
        public Class<? extends Annotation> value() {
            // TODO Auto-generated method stub
            return null;
        }
    }

}

Add event to notify plugins about finish application initialization


package com.yahoo.vespa.hosted.node.admin.task.util.network;

/**
 * Strong type IPv4 and IPv6 with the respective iptables executable.
 *
 * @author smorgrav
 */
public enum IPVersion {

    IPv6("ip6tables"),
    IPv4("iptables");

    IPVersion(String exec) {
        this.exec = exec;
    }

    private String exec;

    String exec() {
        return exec;
    }
}

package com.yahoo.vespa.hosted.node.admin.task.util.network;

/**
 * Strong type IPv4 and IPv6 with common executables for ip related commands.
 *
 * @author smorgrav
 */
public enum IPVersion {

    IPv6("ip6tables", "ip -6"),
    IPv4("iptables", "ip");

    IPVersion(String iptablesCmd, String ipCmd) {
        this.ipCmd = ipCmd;
        this.iptablesCmd = iptablesCmd;
    }

    private String iptablesCmd;
    private String ipCmd;

    public String iptablesCmd() {
        return iptablesCmd;
    }
    public String ipCmd() {
        return ipCmd;
    }
}

Rename exec to iptablesCmd and add ipCmd


package gov.nih.nci.cabig.caaers.service;

import com.semanticbits.aenotification.AENotification;

import gov.nih.nci.cabig.caaers.CaaersSystemException;
import gov.nih.nci.cabig.caaers.domain.AdverseEventReport;
import gov.nih.nci.cabig.caaers.esb.client.MessageBroadcastService;
import gov.nih.nci.cabig.caaers.utils.XMLUtil;

/**
 *
 * @author Sujith Vellat Thayyilthodi
 * */
public class InteroperationServiceImpl implements InteroperationService {

	private MessageBroadcastService messageBroadcastService;

	public void pushToStudyCalendar(AdverseEventReport aeReport) throws CaaersSystemException {
		AENotification aeNotification = new AENotification();
		aeNotification.setRegistrationGridId(
				aeReport.getAssignment().getGridId());
		aeNotification.setDetectionDate(
				new java.sql.Date(aeReport.getPrimaryAdverseEvent().getDetectionDate().getTime()));
		aeNotification.setDescription(aeReport.getPrimaryAdverseEvent().getDetailsForOther());
		getMessageBroadcastService().broadcast(XMLUtil.getXML(aeNotification));
	}

	public MessageBroadcastService getMessageBroadcastService() {
		return messageBroadcastService;
	}

	public void setMessageBroadcastService(
			MessageBroadcastService messageBroadcastService) {
		this.messageBroadcastService = messageBroadcastService;
	}

}

package gov.nih.nci.cabig.caaers.service;

import com.semanticbits.aenotification.AENotification;

import gov.nih.nci.cabig.caaers.CaaersSystemException;
import gov.nih.nci.cabig.caaers.domain.AdverseEventReport;
import gov.nih.nci.cabig.caaers.esb.client.MessageBroadcastService;
import gov.nih.nci.cabig.caaers.utils.XMLUtil;

/**
 *
 * @author Sujith Vellat Thayyilthodi
 * */
public class InteroperationServiceImpl implements InteroperationService {

	private MessageBroadcastService messageBroadcastService;

	public void pushToStudyCalendar(AdverseEventReport aeReport) throws CaaersSystemException {
		AENotification aeNotification = new AENotification();
		aeNotification.setRegistrationGridId(
				aeReport.getAssignment().getGridId());
		aeNotification.setDetectionDate(
				new java.sql.Date(aeReport.getPrimaryAdverseEvent().getDetectionDate().getTime()));
        // TODO: verify that this is sufficient
        aeNotification.setDescription(aeReport.getPrimaryAdverseEvent().getCtcTerm().getFullName());
		getMessageBroadcastService().broadcast(XMLUtil.getXML(aeNotification));
	}

	public MessageBroadcastService getMessageBroadcastService() {
		return messageBroadcastService;
	}

	public void setMessageBroadcastService(
			MessageBroadcastService messageBroadcastService) {
		this.messageBroadcastService = messageBroadcastService;
	}

}

Use CTC term for notification description

SVN-Revision: 428


package com.thoughtworks.acceptance;

import com.thoughtworks.acceptance.objects.SampleDynamicProxy;

public class DynamicProxyTest extends AbstractAcceptanceTest {

    public void testDynamicProxy() {
        assertBothWays(SampleDynamicProxy.newInstance(),
                "<dynamic-proxy>\n" +
                "  <interface>com.thoughtworks.acceptance.objects.SampleDynamicProxy$InterfaceOne</interface>\n" +
                "  <interface>com.thoughtworks.acceptance.objects.SampleDynamicProxy$InterfaceTwo</interface>\n" +
                "  <handler class=\"com.thoughtworks.acceptance.objects.SampleDynamicProxy\">\n" +
                "    <aField>hello</aField>\n" +
                "  </handler>\n" +
                "</dynamic-proxy>");
    }

}

package com.thoughtworks.acceptance;

import com.thoughtworks.acceptance.objects.SampleDynamicProxy;

public class DynamicProxyTest extends AbstractAcceptanceTest {
    public static class ClassWithProxyMember {
        SampleDynamicProxy.InterfaceOne one;
        SampleDynamicProxy.InterfaceTwo two;
    };

    public void testDynamicProxy() {
        assertBothWays(SampleDynamicProxy.newInstance(), ""
                + "<dynamic-proxy>\n"
                + "  <interface>com.thoughtworks.acceptance.objects.SampleDynamicProxy$InterfaceOne</interface>\n"
                + "  <interface>com.thoughtworks.acceptance.objects.SampleDynamicProxy$InterfaceTwo</interface>\n"
                + "  <handler class=\"com.thoughtworks.acceptance.objects.SampleDynamicProxy\">\n"
                + "    <aField>hello</aField>\n"
                + "  </handler>\n"
                + "</dynamic-proxy>");
    }

    public void TODOtestDynamicProxyAsFieldMember() {
        ClassWithProxyMember expected = new ClassWithProxyMember();
        expected.one = (SampleDynamicProxy.InterfaceOne)SampleDynamicProxy.newInstance();
        expected.two = (SampleDynamicProxy.InterfaceTwo)expected.one;
        xstream.alias("with-proxy", ClassWithProxyMember.class);
        assertBothWays(expected, ""
                + "<with-proxy>\n"
                + "  <one class=\"dynamic-proxy\">\n"
                + "    <interface>com.thoughtworks.acceptance.objects.SampleDynamicProxy$InterfaceOne</interface>\n"
                + "    <interface>com.thoughtworks.acceptance.objects.SampleDynamicProxy$InterfaceTwo</interface>\n"
                + "    <handler class=\"com.thoughtworks.acceptance.objects.SampleDynamicProxy\">\n"
                + "      <aField>hello</aField>\n"
                + "    </handler>\n"
                + "  </one>\n"
                + "  <two class=\"dynamic-proxy\" reference=\"../one\"/>\n"
                + "</with-proxy>");
    }

}

Add test case for proxy bug.

Add test case for proxy bug.

git-svn-id: fe6d842192ccfb78748eb71580d1ce65f168b559@969 9830eeb5-ddf4-0310-9ef7-f4b9a3e3227e


package org.eobjects.build;

import java.io.File;
import java.util.Map;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.Parameter;

public abstract class AbstractDotnetMojo extends AbstractMojo {

    @Parameter(defaultValue = PluginHelper.PROPERTY_BASEDIR, readonly = true)
    private File basedir;

    @Parameter(property = "environment", required = false)
    private Map<String, String> environment;

    @Parameter(required = false, defaultValue = "false")
    private boolean skip;

    @Parameter(property = "dotnet.pack.output", required = false)
    private File packOutput;

    @Parameter(property = "dotnet.configuration", required = false, defaultValue = "Release")
    private String buildConfiguration;

    @Parameter(property = "dotnet.build.framework", required = false, defaultValue = "")
    private String buildTargetFramework;

    public PluginHelper getPluginHelper() {
        return PluginHelper.get(getLog(), basedir, environment, packOutput, buildConfiguration, buildTargetFramework, skip);
    }
}

package org.eobjects.build;

import java.io.File;
import java.util.Map;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.Parameter;

public abstract class AbstractDotnetMojo extends AbstractMojo {

    @Parameter(defaultValue = PluginHelper.PROPERTY_BASEDIR, readonly = true)
    private File basedir;

    @Parameter(property = "environment", required = false)
    private Map<String, String> environment;

    @Parameter(required = false, defaultValue = "false")
    private boolean skip;

    @Parameter(property = "dotnet.pack.output", required = false)
    private File packOutput;

    @Parameter(property = "dotnet.configuration", required = false, defaultValue = "Release")
    private String buildConfiguration;

    @Parameter(property = PluginHelper.PROPERTY_TARGET_FRAMEWORK, required = false, defaultValue = "")
    private String buildTargetFramework;

    public PluginHelper getPluginHelper() {
        return PluginHelper.get(getLog(), basedir, environment, packOutput, buildConfiguration, buildTargetFramework, skip);
    }
}

Use central definition of property.

Use central definition of property.


package gov.nasa.arc.mct.scenario;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Activator implements BundleActivator {

	/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
	 */
	public void start(BundleContext context) throws Exception {
		// register the service
	}

	/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
	 */
	public void stop(BundleContext context) throws Exception {
	}

}

package gov.nasa.arc.mct.scenario;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Activator implements BundleActivator {

	/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
	 */
	public void start(BundleContext context) throws Exception {
		System.setProperty("mct.menu.this", "File");
	}

	/*
	 * (non-Javadoc)
	 * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
	 */
	public void stop(BundleContext context) throws Exception {
	}

}

Change 'This' menu to 'File' (depends on platform recognition of System property 'mct.menu.this')


package com.github.aureliano.achmed.os.pkg;

import com.github.aureliano.achmed.command.CommandResponse;
import com.github.aureliano.achmed.resources.properties.PackageProperties;

public class DpkgPackageManager implements IPackageManager {

	private PackageProperties properties;

	public DpkgPackageManager() {
		super();
	}

	public CommandResponse install() {
		throw new UnsupportedOperationException("Method not implemented yet.");
	}

	public CommandResponse uninstall() {
		throw new UnsupportedOperationException("Method not implemented yet.");
	}

	public String latest() {
		throw new UnsupportedOperationException("Method not implemented yet.");
	}

	public void setPackageProperties(PackageProperties properties) {
		this.properties = properties;
	}

	public PackageProperties getPackageProperties() {
		return this.properties;
	}
}

package com.github.aureliano.achmed.os.pkg;

import com.github.aureliano.achmed.command.CommandFacade;
import com.github.aureliano.achmed.command.CommandResponse;
import com.github.aureliano.achmed.exception.PackageResourceException;
import com.github.aureliano.achmed.helper.StringHelper;
import com.github.aureliano.achmed.resources.properties.PackageProperties;

public class DpkgPackageManager implements IPackageManager {

	private static final String DPKG_QUERY = "/usr/bin/dpkg-query";
	private static final String QUERY_FORMAT = "'${status} ${version}\\n'";

	private PackageProperties properties;

	public DpkgPackageManager() {
		super();
	}

	public CommandResponse install() {
		throw new UnsupportedOperationException("Method not implemented yet.");
	}

	public CommandResponse uninstall() {
		throw new UnsupportedOperationException("Method not implemented yet.");
	}

	public String latest() {
		throw new UnsupportedOperationException("Method not implemented yet.");
	}

	public boolean isInstalled() {
		final String desiredStatus = "installed";
		CommandResponse res = CommandFacade.executeCommand(
			DPKG_QUERY, "-W", "-f", QUERY_FORMAT, this.properties.getName()
		);

		if (!res.isOK()) {
			throw new PackageResourceException(res);
		}

		String[] match = StringHelper.match("^(\\S+)\\s+(\\S+)\\s+(\\S+)\\s+(\\S*)$", res.getOutput());
		if (match == null) {
			throw new PackageResourceException("Failed to match dpkg-query " + res.getCommand());
		}

		return desiredStatus.equalsIgnoreCase(match[3]);
	}

	public void setPackageProperties(PackageProperties properties) {
		this.properties = properties;
	}

	public PackageProperties getPackageProperties() {
		return this.properties;
	}
}

Implement methodo to check wheter package is installed.


package me.williamhester.reddit.ui.activities;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.Fragment;

import me.williamhester.reddit.R;
import me.williamhester.reddit.models.Submission;
import me.williamhester.reddit.ui.fragments.CommentsFragment;

/** Activity that holds basic content. */
public class ContentActivity extends BaseActivity {

  public static final String TYPE_EXTRA = "type";
  public static final String VOTABLE_EXTRA = "votable";
  public static final String PERMALINK_EXTRA = "permalink";

  public static final String COMMENTS = "comments";

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

    Fragment f = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
    if (f == null) {
      getSupportFragmentManager().beginTransaction()
          .add(R.id.fragment_container, createContentFragment())
          .commit();
    }

    SharedPreferences prefs = getSharedPreferences("default", MODE_PRIVATE);
    prefs.edit().putBoolean("test", true).apply();
  }

  @Override
  protected int getLayoutId() {
    return R.layout.activity_content;
  }

  protected Fragment createContentFragment() {
    Bundle args = getIntent().getExtras();
    String type = args.getString(TYPE_EXTRA);
    if (type == null) {
      return null;
    }
    switch (type) {
      case COMMENTS:
        String permalink = args.getString(PERMALINK_EXTRA);
        Submission s = args.getParcelable(VOTABLE_EXTRA);
        return CommentsFragment.newInstance(permalink, s);
      default:
        return null;
    }
  }
}

package me.williamhester.reddit.ui.activities;

import android.os.Bundle;
import android.support.v4.app.Fragment;

import me.williamhester.reddit.R;
import me.williamhester.reddit.models.Submission;
import me.williamhester.reddit.ui.fragments.CommentsFragment;

/** Activity that holds basic content. */
public class ContentActivity extends BaseActivity {

  public static final String TYPE_EXTRA = "type";
  public static final String VOTABLE_EXTRA = "votable";
  public static final String PERMALINK_EXTRA = "permalink";

  public static final String COMMENTS = "comments";

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

    Fragment f = getSupportFragmentManager().findFragmentById(R.id.fragment_container);
    if (f == null) {
      getSupportFragmentManager().beginTransaction()
          .add(R.id.fragment_container, createContentFragment())
          .commit();
    }
  }

  @Override
  protected int getLayoutId() {
    return R.layout.activity_content;
  }

  protected Fragment createContentFragment() {
    Bundle args = getIntent().getExtras();
    String type = args.getString(TYPE_EXTRA);
    if (type == null) {
      return null;
    }
    switch (type) {
      case COMMENTS:
        String permalink = args.getString(PERMALINK_EXTRA);
        Submission s = args.getParcelable(VOTABLE_EXTRA);
        return CommentsFragment.newInstance(permalink, s);
      default:
        return null;
    }
  }
}

Remove accidentally committed test code

Remove accidentally committed test code


package br.com.bloder.blormlib.validation.validations;

import android.widget.EditText;

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

/**
 * Created by bloder on 05/06/16.
 */
public class Filled extends Validation {

  public EditText editText;

  @Override
  public Validate validate() {
    return new Validate() {
      @Override
      public boolean validate() {
        editText = (EditText) field;
        return !String.valueOf(editText.getText()).trim().isEmpty();
      }

      @Override
      public void onError() {
        editText.setError(errorMessage != null && !errorMessage.isEmpty() ? errorMessage : "This field can't be blank");
      }

      @Override public void onSuccess() {
        editText.setError(null);
      }
    };
  }
}

package br.com.bloder.blormlib.validation.validations;

import android.widget.EditText;

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

/**
 * Created by bloder on 05/06/16.
 */
public class Filled extends Validation {

  public EditText editText;
  private int maxSize = -1;
  private int minSize = -1;

  public Filled withMaxSize(int maxSize) {
    this.maxSize = maxSize;
    return this;
  }

  public Filed withMinimumSize(int minSize) {
    this.minSize = minSize;
    return this;
  }

  @Override public Validate validate() {
    return new Validate() {
      @Override public boolean validate() {
        editText = (EditText) field;
        String text = String.valueOf(editText.getText()).trim();
        int textLength = text.length();
        if (!text.isEmpty()) {
          if (maxSize != -1) {
            if (textLength > maxSize) {
              return false;
            }
          }
          if (minSize != -1) {
            if (textLength < minSize) {
              return false;
            }
          }
          return true;
        }
        return false;
      }

      @Override
      public void onError() {
        editText.setError(errorMessage != null && !errorMessage.isEmpty() ? errorMessage : "This field can't be blank");
      }

      @Override public void onSuccess() {
        editText.setError(null);
      }
    };
  }
}

Update with min max for text input validation


package org.robockets.stronghold.robot.commands;

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

/**
 *
 */
public class MeasureLatency extends Command {

	NetworkTable table;
	double starttime;
	int i = 0;

    public MeasureLatency() {
    }

    protected void initialize() {
    	table = NetworkTable.getTable("vision");
    	starttime = System.nanoTime();
    }

    protected void execute() {
    	if(table.getNumber("heartbeat", 0)==1){
    		System.out.println("i," + (System.nanoTime() - starttime));
    		starttime = System.nanoTime();
    		table.putNumber("heartbeat", 0);
    	}
    }

    protected boolean isFinished() {
        return false;
    }

    protected void end() {
    }

    protected void interrupted() {
    }
}

package org.robockets.stronghold.robot.commands;

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

/**
 *
 */
public class MeasureLatency extends Command {

	NetworkTable table;
	double starttime;
	int i = 0;

    public MeasureLatency() {
    }

    protected void initialize() {
    	table = NetworkTable.getTable("vision");
    	starttime = System.nanoTime();
    }

    protected void execute() {
    	if (table.getNumber("heartbeat", 0) == 1) {
    		System.out.println("i," + (System.nanoTime() - starttime));
    		starttime = System.nanoTime();
    		table.putNumber("heartbeat", 0);
    	}
    }

    protected boolean isFinished() {
        return false;
    }

    protected void end() {
    }

    protected void interrupted() {
    }
}

Add spaces to an if statement

Add spaces to an if statement


/*
 * Copyright 2017, TeamDev Ltd. All rights reserved.
 *
 * Redistribution and use in source and/or binary forms, with or without
 * modification, must retain the above copyright notice and the following
 * disclaimer.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *
 * Base classes and interfaces for Spine Gradle plugins.
 *
 * @author Alex Tymchenko
 */
package io.spine.gradle;

/*
 * Copyright 2017, TeamDev Ltd. All rights reserved.
 *
 * Redistribution and use in source and/or binary forms, with or without
 * modification, must retain the above copyright notice and the following
 * disclaimer.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/**
 * Base classes and interfaces for Spine Gradle plugins.
 *
 * @author Alex Tymchenko
 */

@ParametersAreNonnullByDefault
package io.spine.gradle;

import javax.annotation.ParametersAreNonnullByDefault;

Add a missing annotation for a package and fix structure of comments


package DataReader;

import DataModel.Attribute;
import DataModel.EntityProfile;
import DataReader.EntityReader.EntityCSVReader;
import java.util.List;

/**
 *
 * @author G.A.P. II
 */

public class TestEntityCSVReader {
    public static void main(String[] args) {
        String filePath = "C:\\Users\\G.A.P. II\\Downloads\\cd.csv";
        EntityCSVReader csvReader = new EntityCSVReader(filePath);
        csvReader.setAttributeNamesInFirstRow(true);
        csvReader.setSeparator(';');
        csvReader.setAttributesToExclude(new int[]{1});
        csvReader.setIdIndex(0);
        List<EntityProfile> profiles = csvReader.getEntityProfiles();
//        for (EntityProfile profile : profiles) {
//            System.out.println("\n\n" + profile.getEntityUrl());
//            for (Attribute attribute : profile.getAttributes()) {
//                System.out.println(attribute.toString());
//            }
//        }
        csvReader.storeSerializedObject(profiles, "C:\\Users\\G.A.P. II\\Downloads\\cddbProfiles");
    }
}

package DataReader;

import DataModel.Attribute;
import DataModel.EntityProfile;
import DataReader.EntityReader.EntityCSVReader;
import java.util.List;

/**
 *
 * @author G.A.P. II
 */

public class TestEntityCSVReader {
    public static void main(String[] args) {
        String filePath = "C:/Users/Manos/workspaceMars/JedAIgitFinal/JedAIgitFinal/datasets/converter/DBLP2.csv";
        EntityCSVReader csvReader = new EntityCSVReader(filePath);
        csvReader.setAttributeNamesInFirstRow(true);
        csvReader.setSeparator(';');
        csvReader.setAttributesToExclude(new int[]{1});
        csvReader.setIdIndex(0);
        List<EntityProfile> profiles = csvReader.getEntityProfiles();
        for (EntityProfile profile : profiles) {
            System.out.println("\n\n" + profile.getEntityUrl());
            for (Attribute attribute : profile.getAttributes()) {
                System.out.println(attribute.toString());
            }
        }
        csvReader.storeSerializedObject(profiles, "C:/Users/Manos/workspaceMars/JedAIgitFinal/JedAIgitFinal/datasets/converter/DBLP2prof");
        csvReader.convertToRDFfile(profiles, "C:/Users/Manos/workspaceMars/JedAIgitFinal/JedAIgitFinal/datasets/converter/DBLP2toRDFxml.xml");

    }
}

Update Test for csv to RDF converter

Update Test for csv to RDF converter


package com.xamoom.android.mapping;

import com.google.gson.annotations.SerializedName;
import com.xamoom.android.APICallback;
import com.xamoom.android.mapping.ContentBlocks.MenuItem;

import java.util.List;

/**
 * Used for mapping menu responses from the xamoom-cloud-api.
 * Menu will have only a list of MenuItems.
 *
 * @author Raphael Seher
 *
 * @see MenuItem
 * @see com.xamoom.android.XamoomEndUserApi#getContentbyIdFull(String, boolean, boolean, String, boolean, APICallback)
 * @see com.xamoom.android.XamoomEndUserApi#getContentByLocationIdentifier(String, String, boolean, boolean, String, APICallback)
 */
public class Menu {

    private List<MenuItem> items;

    @Override
    public String toString() {
        String output = "items: ";

        for (MenuItem item : items) {
            output += item.toString();
        }

        return output;
    }

    public List<MenuItem> getItems() {
        return items;
    }
}

package com.xamoom.android.mapping;

import com.xamoom.android.APICallback;

import java.util.List;

/**
 * Used for mapping menu responses from the xamoom-cloud-api.
 * Menu will have only a list of MenuItems.
 *
 * @author Raphael Seher
 *
 * @see MenuItem
 * @see com.xamoom.android.XamoomEndUserApi#getContentbyId(String, boolean, boolean, String, boolean, boolean, APICallback)
 * @see com.xamoom.android.XamoomEndUserApi#getContentByLocationIdentifier(String, String, boolean, boolean, String, APICallback)
 */
public class Menu {

    private List<MenuItem> items;

    @Override
    public String toString() {
        String output = "items: ";

        for (MenuItem item : items) {
            output += item.toString();
        }

        return output;
    }

    public List<MenuItem> getItems() {
        return items;
    }
}

Change category from String to int

Change category from String to int


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

package android.support.v4.view;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.view.PointerIcon;

class PointerIconCompatApi24 {
    public static Object getSystemIcon(Context context, int style) {
        return PointerIcon.getSystemIcon(context, style);
    }

    public static Object createCustomIcon(Bitmap bitmap, float hotSpotX, float hotSpotY) {
        return PointerIcon.createCustomIcon(bitmap, hotSpotX, hotSpotY);
    }

    public static Object loadCustomIcon(Resources resources, int resourceId) {
        return PointerIcon.loadCustomIcon(resources, resourceId);
    }
}

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

package android.support.v4.view;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.view.PointerIcon;

class PointerIconCompatApi24 {
    public static Object getSystemIcon(Context context, int style) {
        return PointerIcon.getSystemIcon(context, style);
    }

    public static Object createCustomIcon(Bitmap bitmap, float hotSpotX, float hotSpotY) {
        return null;
    }

    public static Object loadCustomIcon(Resources resources, int resourceId) {
        return null;
    }
}

Remove references to framework PointerIcon API.

This is an intermediate step to renaming all of the PointerIcon APIs.

Change-Id: I2fed4f41fc873ab9301b11e3b551362ecdab8736


package org.wikipedia.page.gallery;

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

public class GalleryPagerTransformer implements ViewPager.PageTransformer {
    private static final float MIN_SCALE = 0.5f;
    private static final float ROTATION_DEGREES = 30.0f;

    @Override
    public void transformPage(View view, float position) {
        if (position < -1) { // [-Infinity,-1)
            // This page is way off-screen to the left.
        } else if (position <= 0) { // [-1,0]
            float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
            view.setScaleX(scaleFactor);
            view.setScaleY(scaleFactor);
            // fade out
            view.setAlpha(1 + position);
            // give it a bit of a rotation
            view.setRotationY(-position * ROTATION_DEGREES);
        } else if (position <= 1) { // (0,1]
            float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
            view.setScaleX(scaleFactor);
            view.setScaleY(scaleFactor);
            // fade out
            view.setAlpha(1 - position);
            // give it a bit of a rotation
            view.setRotationY(-position * ROTATION_DEGREES);
        } else { // (1,+Infinity]
            // This page is way off-screen to the right.
        }
    }
}

package org.wikipedia.page.gallery;

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

public class GalleryPagerTransformer implements ViewPager.PageTransformer {
    private static final float MIN_SCALE = 0.9f;

    @Override
    public void transformPage(View view, float position) {
        if (position < -1) { // [-Infinity,-1)
            // This page is way off-screen to the left.
            view.setTranslationX(0);
        } else if (position <= 0) { // [-1,0]
            float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position));
            view.setScaleX(scaleFactor);
            view.setScaleY(scaleFactor);
            // fade out
            view.setAlpha(1 + position);
            // keep it in place (undo the default translation)
            view.setTranslationX(-(view.getWidth() * position));
        } else if (position <= 1) { // (0,1]
            // don't do anything to it when it's sliding in.
        } else { // (1,+Infinity]
            // This page is way off-screen to the right.
            view.setTranslationX(0);
        }
    }
}

[Hackathon] Improve transition between gallery images.

Change-Id: I2edb2195e507d20b31e49637dc19bc751aaee40f


package com.forerunnergames.tools.common;

public final class DefaultMessage implements Message
{
  private final String text;

  public DefaultMessage (final String text)
  {
    Arguments.checkIsNotNull (text, "text");

    this.text = text;
  }

  // Required for network serialization
  protected DefaultMessage ()
  {
    text = null;
  }

  @Override
  public String getText ()
  {
    return text;
  }

  @Override
  public String toString ()
  {
    return String.format ("%1$s: Text: %2$s", getClass ().getSimpleName (), text);
  }
}

package com.forerunnergames.tools.common;

public final class DefaultMessage implements Message
{
  private final String text;

  public DefaultMessage (final String text)
  {
    Arguments.checkIsNotNull (text, "text");

    this.text = text;
  }

  protected DefaultMessage ()
  {
    text = null;
  }

  @Override
  public String getText ()
  {
    return text;
  }

  @Override
  public String toString ()
  {
    return String.format ("%1$s: Text: %2$s", getClass ().getSimpleName (), text);
  }
}

Remove "Required for network serialization".

Remove "Required for network serialization" comment from DefaultMessage
class' protected constructor. Although network serialization is the only
reason for this protected constructor, the classes are not in the net
package, and don't have access to the @RequiredForNetworkSerialization
annotation. Any classes in the common package should not have anything
to do with networking. If there is a need for a class to be
network-related, it should probably be renamed and moved to the net
package.


package com.marcosbarbero.zuul.filters.pre.ratelimit.config.redis;

import com.marcosbarbero.zuul.filters.pre.ratelimit.config.Policy;
import com.marcosbarbero.zuul.filters.pre.ratelimit.config.Rate;
import com.marcosbarbero.zuul.filters.pre.ratelimit.config.RateLimiter;

import org.springframework.data.redis.core.RedisTemplate;

import static java.util.concurrent.TimeUnit.SECONDS;

/**
 * @author Marcos Barbero
 */
public class RedisRateLimiter implements RateLimiter {
    private RedisTemplate template;

    public RedisRateLimiter(RedisTemplate template) {
        this.template = template;
    }

    @Override
    @SuppressWarnings("unchecked")
    public Rate consume(final Policy policy, final String key) {
        final Long limit = policy.getLimit();
        final Long refreshInterval = policy.getRefreshInterval();
        final Long current = this.template.boundValueOps(key).increment(1L);
        Long expire = this.template.getExpire(key);
        if (expire == null || expire == -1) {
            this.template.expire(key, refreshInterval, SECONDS);
            expire = refreshInterval;
        }
        return new Rate(limit, Math.max(-1, limit - current), SECONDS.toMillis(expire));
    }
}

package com.marcosbarbero.zuul.filters.pre.ratelimit.config.redis;

import com.marcosbarbero.zuul.filters.pre.ratelimit.config.Policy;
import com.marcosbarbero.zuul.filters.pre.ratelimit.config.Rate;
import com.marcosbarbero.zuul.filters.pre.ratelimit.config.RateLimiter;

import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.Assert;

import static java.util.concurrent.TimeUnit.SECONDS;

/**
 * @author Marcos Barbero
 */
public class RedisRateLimiter implements RateLimiter {
    private final RedisTemplate template;

    public RedisRateLimiter(final RedisTemplate template) {
        Assert.notNull(template, "RedisTemplate cannot be null");
        this.template = template;
    }

    @Override
    @SuppressWarnings("unchecked")
    public Rate consume(final Policy policy, final String key) {
        final Long limit = policy.getLimit();
        final Long refreshInterval = policy.getRefreshInterval();
        final Long current = this.template.boundValueOps(key).increment(1L);
        Long expire = this.template.getExpire(key);
        if (expire == null || expire == -1) {
            this.template.expire(key, refreshInterval, SECONDS);
            expire = refreshInterval;
        }
        return new Rate(limit, Math.max(-1, limit - current), SECONDS.toMillis(expire));
    }
}

Make RedisTemplate final and validate not null construction


// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.maintenance;

import com.yahoo.vespa.config.server.ApplicationRepository;
import com.yahoo.vespa.curator.Curator;

import java.time.Duration;

/**
 * Removes inactive sessions
 * <p>
 * Note: Unit test is in ApplicationRepositoryTest
 *
 * @author hmusum
 */
public class SessionsMaintainer extends ConfigServerMaintainer {
    private final boolean hostedVespa;

    SessionsMaintainer(ApplicationRepository applicationRepository, Curator curator, Duration interval) {
        // Start this maintainer immediately. It frees disk space, so if disk goes full and config server
        // restarts this makes sure that cleanup will happen as early as possible
        super(applicationRepository, curator, Duration.ZERO, interval);
        this.hostedVespa = applicationRepository.configserverConfig().hostedVespa();
    }

    @Override
    protected void maintain() {
        applicationRepository.deleteExpiredLocalSessions();

        // Expired remote sessions are not expected to exist, they should have been deleted when
        // a deployment happened or when the application was deleted. We still see them from time to time,
        // probably due to some race or another bug
        if (hostedVespa) {
            Duration expiryTime = Duration.ofDays(30);
            applicationRepository.deleteExpiredRemoteSessions(expiryTime);
        }
    }
}

// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.maintenance;

import com.yahoo.vespa.config.server.ApplicationRepository;
import com.yahoo.vespa.curator.Curator;

import java.time.Duration;

/**
 * Removes inactive sessions
 * <p>
 * Note: Unit test is in ApplicationRepositoryTest
 *
 * @author hmusum
 */
public class SessionsMaintainer extends ConfigServerMaintainer {
    private final boolean hostedVespa;

    SessionsMaintainer(ApplicationRepository applicationRepository, Curator curator, Duration interval) {
        // Start this maintainer immediately. It frees disk space, so if disk goes full and config server
        // restarts this makes sure that cleanup will happen as early as possible
        super(applicationRepository, curator, Duration.ZERO, interval);
        this.hostedVespa = applicationRepository.configserverConfig().hostedVespa();
    }

    @Override
    protected void maintain() {
        applicationRepository.deleteExpiredLocalSessions();

        // Expired remote sessions are sessions that belong to an application that have external deployments that
        // are no longer active
        if (hostedVespa) {
            Duration expiryTime = Duration.ofDays(7);
            applicationRepository.deleteExpiredRemoteSessions(expiryTime);
        }
    }
}

Revert "Revert "Reduce the time we keep expired remotes sessions and fix comment""


package net.openhft.chronicle.wire;

import net.openhft.chronicle.bytes.NativeBytes;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

import static org.junit.Assert.assertEquals;

public class LongArrayDirectReferenceTest {

    @Test
    public void getSetValues() throws Exception {
        int length = 1024 + 8;
        try (NativeBytes bytes = NativeBytes.nativeBytes(length + 8)) {
            LongArrayDirectReference.write(bytes, 128);

            LongArrayDirectReference array = new LongArrayDirectReference();
            array.bytesStore(bytes, 0, length);

            assertEquals(128, array.getCapacity());
            for (int i = 0; i < 128; i++)
                array.setValueAt(i, i + 1);

            for (int i = 0; i < 128; i++)
                assertEquals(i + 1, array.getValueAt(i));
        }
    }

}

package net.openhft.chronicle.wire;

import net.openhft.chronicle.bytes.NativeBytes;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class LongArrayDirectReferenceTest {

    @Test
    public void getSetValues() {
        int length = 1024 + 8;
        try (NativeBytes bytes = NativeBytes.nativeBytes(length + 8)) {
            LongArrayDirectReference.write(bytes, 128);

            LongArrayDirectReference array = new LongArrayDirectReference();
            array.bytesStore(bytes, 0, length);

            assertEquals(128, array.getCapacity());
            for (int i = 0; i < 128; i++)
                array.setValueAt(i, i + 1);

            for (int i = 0; i < 128; i++)
                assertEquals(i + 1, array.getValueAt(i));
        }
    }

}

Remove "throws IOException" when "close()" doesn't actually throw it.


package uk.ac.ebi.quickgo.rest.search.filter;

import com.google.common.base.Preconditions;
import java.util.Arrays;
import java.util.stream.Stream;

/**
 * Data structure that holds the field name and values of a filter requested by a REST service endpoint.
 *
 * @author Tony Wardell
 * Date: 03/05/2016
 * Time: 10:25
 */
public class RequestFilter {
    private String field;
    private String[] values;

    public RequestFilter(String field, String... values) {
        Preconditions.checkArgument(field != null && !field.trim().isEmpty(), "Filter field cannot be null or empty");
        Preconditions.checkArgument(values != null && values.length > 0, "Filter values cannot be null or empty");

        this.field = field;
        this.values = values;
    }

    /**
     * Provides the field (column) the filter will be applied to.
     *
     * @return the field
     */
    public String getField() {
        return field;
    }

    /**
     * Provides the field (column) the filter will be applied to.
     *
     * @return the field
     */
    public Stream<String> getValues() {
        return Arrays.stream(values);
    }
}

package uk.ac.ebi.quickgo.rest.search.filter;

import com.google.common.base.Preconditions;
import java.util.Arrays;
import java.util.stream.Stream;

/**
 * Data structure that holds the field name and values of a filter requested by a REST service endpoint.
 *
 * @author Tony Wardell
 * Date: 03/05/2016
 * Time: 10:25
 */
public class RequestFilter {
    private final String field;
    private final String[] values;

    public RequestFilter(String field, String... values) {
        Preconditions.checkArgument(field != null && !field.trim().isEmpty(), "Filter field cannot be null or empty");
        Preconditions.checkArgument(values != null && values.length > 0, "Filter values cannot be null or empty");

        this.field = field;
        this.values = values;
    }

    /**
     * Provides the field (column) the filter will be applied to.
     *
     * @return the field
     */
    public String getField() {
        return field;
    }

    /**
     * Provides the field (column) the filter will be applied to.
     *
     * @return the field
     */
    public Stream<String> getValues() {
        return Arrays.stream(values);
    }
}

Make state variables final, seeing as these are initialized in the constructor.


package fr.alecharp.picshare.http;

import fr.alecharp.picshare.domain.Event;
import fr.alecharp.picshare.service.EventService;
import net.codestory.http.annotations.Post;
import net.codestory.http.annotations.Prefix;
import net.codestory.http.payload.Payload;

import javax.inject.Inject;
import java.util.Optional;

/**
 * @author Adrien Lecharpentier
 */
@Prefix("/api/event")
public class EventController {
    private final EventService eventService;

    @Inject
    public EventController(EventService eventService) {
        this.eventService = eventService;
    }

    @Post
    public Payload create(Event event) {
        Optional<Event> save = eventService.save(event);
        return save.isPresent() ? Payload.created("/api/event/" + save.get().id()) :
                Payload.badRequest();
    }
}

package fr.alecharp.picshare.http;

import fr.alecharp.picshare.domain.Event;
import fr.alecharp.picshare.domain.Picture;
import fr.alecharp.picshare.service.EventService;
import fr.alecharp.picshare.service.PictureService;
import net.codestory.http.Request;
import net.codestory.http.annotations.Post;
import net.codestory.http.annotations.Prefix;
import net.codestory.http.annotations.Put;
import net.codestory.http.payload.Payload;

import javax.inject.Inject;
import java.util.Optional;
import java.util.Set;

import static java.util.stream.Collectors.toSet;

/**
 * @author Adrien Lecharpentier
 */
@Prefix("/api/event")
public class EventController {
    private final EventService eventService;
    private final PictureService pictureService;

    @Inject
    public EventController(EventService eventService, PictureService pictureService) {
        this.eventService = eventService;
        this.pictureService = pictureService;
    }

    @Post
    public Payload create(Event event) {
        Optional<Event> save = eventService.save(event);
        return save.isPresent() ? Payload.created("/api/event/" + save.get().id()) :
                Payload.badRequest();
    }

    @Put("/:id/pictures")
    public Payload attachPicture(String id, Request req) {
        Set<Picture> pictures = req.parts().stream()
                .filter(part -> part.name().equals("picture"))
                .map(part -> pictureService.upload(id, part))
                .filter(Optional::isPresent).map(Optional::get)
                .collect(toSet());
        Optional<Event> event = eventService.attachPictures(id, pictures);
        if (!event.isPresent()) {
            return Payload.notFound();
        }
        return Payload.ok().withHeader("Location", "/api/event/" + event.get().id());
    }
}

Update even HTTP API to upload images into events


package com.github.legioth.propertysource.rebind;

import com.google.gwt.user.rebind.StringSourceWriter;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.testng.Assert.*;

public class StringTypeHandlerTest
{
  @DataProvider( name = "writeValues" )
  public Object[][] actionDescriptions()
  {
    return new Object[][]{
      new Object[]{ "hi", "\"hi\"" },
      new Object[]{ "1\n2", "\"1\\n2\"" },
      new Object[]{ "&", "\"&\"" },
      new Object[]{ "Å", "\"Å\"" },
    };
  }

  @Test( dataProvider = "writeValues" )
  public void writeValues( final String input, final String output )
  {
    final StringSourceWriter writer = new StringSourceWriter();
    StringTypeHandler.INSTANCE.writeValue( null, writer, input );
    assertEquals( writer.toString(), output );
  }
}

package com.github.legioth.propertysource.rebind;

import com.google.gwt.core.ext.TreeLogger;
import com.google.gwt.core.ext.TreeLogger.Type;
import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.core.ext.typeinfo.JMethod;
import com.google.gwt.user.rebind.StringSourceWriter;
import java.util.Arrays;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.mockito.Mockito.*;
import static org.testng.Assert.*;

public class StringTypeHandlerTest
{
  @DataProvider( name = "writeValues" )
  public Object[][] actionDescriptions()
  {
    return new Object[][]{
      new Object[]{ "hi", "\"hi\"" },
      new Object[]{ "1\n2", "\"1\\n2\"" },
      new Object[]{ "&", "\"&\"" },
      new Object[]{ "Å", "\"Å\"" },
    };
  }

  @Test( dataProvider = "writeValues" )
  public void writeValues( final String input, final String output )
  {
    final StringSourceWriter writer = new StringSourceWriter();
    StringTypeHandler.INSTANCE.writeValue( null, writer, input );
    assertEquals( writer.toString(), output );
  }

  @Test
  public void getStaticReturnValue()
    throws Exception
  {
    final String result =
      StringTypeHandler.INSTANCE.getStaticReturnValue( mock( TreeLogger.class ),
                                                       Arrays.asList( "A" ),
                                                       mock( JMethod.class ) );

    assertEquals( result, "A" );
  }

  @Test
  public void getStaticReturnValue_whenMultipleValues()
    throws Exception
  {
      final TreeLogger logger = mock( TreeLogger.class );
    try
    {
      StringTypeHandler.INSTANCE.getStaticReturnValue( logger,
                                                       Arrays.asList( "A", "B" ),
                                                       mock( JMethod.class ) );
      fail( "Should have raised an exception" );
    }
    catch ( final UnableToCompleteException utce )
    {
      verify( logger ).log( Type.ERROR, "String only supported for properties with only one value" );
    }
  }
}

Add some more basic tests

Add some more basic tests


package de.pentasys.SilverPen.util.test;

import javax.mail.MessagingException;

import org.junit.BeforeClass;
import org.junit.Test;

import de.pentasys.SilverPen.util.Email;

public class EmailTest {
    private static String mailHost = "172.30.2.29";
    private static Email email;

    @BeforeClass
    public static void setUp() throws Exception {
                email = new Email(mailHost, 25, "root", "SilverPen2016");
    }

    @Test
    public void testSendRegistrationConfirmationMail() {
        try {
            email.sendRegistrationConfirmationMail("test", "tobias.johannes.endres@pentasys.de");
        } catch (MessagingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}

package de.pentasys.SilverPen.util.test;

import javax.mail.MessagingException;

import org.junit.BeforeClass;
import org.junit.Test;

import de.pentasys.SilverPen.util.Email;

public class EmailTest {
    private static String mailHost = "127.0.0.1";
    private static Email email;

    @BeforeClass
    public static void setUp() throws Exception {
                email = new Email(mailHost, 25, "root", "SilverPen2016");
    }

    @Test
    public void testSendRegistrationConfirmationMail() {
        try {
            email.sendRegistrationConfirmationMail("JUnit-TestMail", "thomas.bankiel@pentasys.de");
        } catch (MessagingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

}

Test für den Email-Versand angepasst

Jenkins: Test für den Email-Versand angepasst


package org.stagemonitor.eum;

import org.springframework.boot.Banner;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.stagemonitor.core.Stagemonitor;

@SpringBootApplication
public class EumApplication extends SpringBootServletInitializer {

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
		return configureApplication(builder);
	}

	public static void main(String[] args) {
		configureApplication(new SpringApplicationBuilder()).run(args);
	}

	private static SpringApplicationBuilder configureApplication(SpringApplicationBuilder builder) {
		Stagemonitor.init();
		return builder.sources(EumApplication.class).bannerMode(Banner.Mode.OFF);
	}

}

package org.stagemonitor.eum;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.stagemonitor.core.Stagemonitor;

@SpringBootApplication
public class EumApplication extends SpringBootServletInitializer {

	@Override
	protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
		return configureApplication(builder);
	}

	public static void main(String[] args) {
		configureApplication(new SpringApplicationBuilder()).run(args);
	}

	private static SpringApplicationBuilder configureApplication(SpringApplicationBuilder builder) {
		Stagemonitor.init();
		return builder.sources(EumApplication.class);
	}

}

Enable banner for eum server

Enable banner for eum server


package org.buddycloud.channelserver.channel.node.configuration.field;

public class Affiliation extends Field
{
	public static final String FIELD_NAME    = "pubsub#default_affiliation";
	public static final String DEFAULT_VALUE = Affiliation.models.MEMBER.toString();

	public enum models {
		FOLLOWER_AND_POST("publisher"), MEMBER("follower");
		String model = null;
		private models(String model) {
			this.model = model;
		}
		public String toString() {
	        return model;
	    }
	}

	public Affiliation()
	{
		name = FIELD_NAME;
	}

	public boolean isValid()
	{
		return (getValue().equals(Affiliation.models.FOLLOWER_AND_POST.toString())
			|| getValue().equals(Affiliation.models.MEMBER.toString())
		);
	}
}

package org.buddycloud.channelserver.channel.node.configuration.field;

public class Affiliation extends Field {
	public static final String FIELD_NAME = "pubsub#default_affiliation";
	public static final String DEFAULT_VALUE = Affiliation.models.MEMBER
			.toString();

	public enum models {
		FOLLOWER_AND_POST("publisher"), MEMBER("follower"), OWNER("owner"), MODERATOR(
				"moderator");
		String model = null;

		private models(String model) {
			this.model = model;
		}

		public String toString() {
			return model;
		}
	}

	public Affiliation() {
		name = FIELD_NAME;
	}

	public boolean isValid() {
		return (getValue().equals(
				Affiliation.models.FOLLOWER_AND_POST.toString())
		    || getValue().equals(Affiliation.models.MEMBER.toString())
		    || getValue().equals(Affiliation.models.OWNER.toString())
		    || getValue().equals(Affiliation.models.MODERATOR.toString())
	    );
	}
}

Fix for default_affiliation valid values


package org.jetbrains.kotlin.core;

import static org.eclipse.core.resources.ResourcesPlugin.getWorkspace;

import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.jetbrains.kotlin.core.builder.ResourceChangeListener;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Activator implements BundleActivator {
	private static BundleContext context;

	private final IResourceChangeListener resourceChangeListener = new ResourceChangeListener();

	public static final String PLUGIN_ID = "org.jetbrains.kotlin.core";

	static BundleContext getContext() {
		return context;
	}

	@Override
    public void start(BundleContext bundleContext) throws Exception {
		Activator.context = bundleContext;

		getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE);
	}

	@Override
    public void stop(BundleContext bundleContext) throws Exception {
		Activator.context = null;

		getWorkspace().removeResourceChangeListener(resourceChangeListener);
	}
}

package org.jetbrains.kotlin.core;

import static org.eclipse.core.resources.ResourcesPlugin.getWorkspace;

import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.runtime.Plugin;
import org.jetbrains.kotlin.core.builder.ResourceChangeListener;
import org.osgi.framework.BundleContext;

public class Activator extends Plugin {

	private static Activator plugin;

	private final IResourceChangeListener resourceChangeListener = new ResourceChangeListener();

	public static final String PLUGIN_ID = "org.jetbrains.kotlin.core";

	public Activator() {
	    plugin = this;
	}

	public static Activator getDefault() {
		return plugin;
	}

	@Override
    public void start(BundleContext bundleContext) throws Exception {
		getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE);

		super.start(bundleContext);
	}

	@Override
    public void stop(BundleContext bundleContext) throws Exception {
		getWorkspace().removeResourceChangeListener(resourceChangeListener);

		plugin = null;
	}
}

Make core activator extendable of Plugin class


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

import java.util.Random;

public class RandomStringGenerator {

  private static final int DEFAULT_STRING_LENGHT = 10;
  private static final char[] symbols;

  static {
    StringBuilder tmpSymbols = new StringBuilder();
    for (char ch = 'a'; ch <= 'z'; ch++) {
      tmpSymbols.append(ch);
    }
    symbols = tmpSymbols.toString().toCharArray();
  }

  private final int stringLenght;
  private final char[] charArray;
  private final Random random;

  public RandomStringGenerator() {
    this(DEFAULT_STRING_LENGHT);
  }

  public RandomStringGenerator(int stringLength) {
    this.stringLenght = stringLength;
    this.charArray = new char[this.stringLenght];
    this.random = new Random();
  }

  public String nextString() {
    for (int i = 0; i < charArray.length; i++) {
      charArray[i] = symbols[random.nextInt(symbols.length)];
    }
    return String.valueOf(charArray);
  }
}

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

import java.util.Random;

public class RandomStringGenerator {

  private static final int DEFAULT_STRING_LENGHT = 12;
  private static final char[] symbols;

  static {
    StringBuilder tmpSymbols = new StringBuilder();
    for (char numberChar = '0'; numberChar <= '9'; numberChar++) {
      tmpSymbols.append(numberChar);
    }
    for (char letterChar = 'a'; letterChar <= 'z'; letterChar++) {
      tmpSymbols.append(letterChar);
    }
    symbols = tmpSymbols.toString().toCharArray();
  }

  private final int stringLenght;
  private final char[] charArray;
  private final Random random;

  public RandomStringGenerator() {
    this(DEFAULT_STRING_LENGHT);
  }

  public RandomStringGenerator(int stringLength) {
    this.stringLenght = stringLength;
    this.charArray = new char[this.stringLenght];
    this.random = new Random();
  }

  public String nextString() {
    for (int i = 0; i < charArray.length; i++) {
      charArray[i] = symbols[random.nextInt(symbols.length)];
    }
    return String.valueOf(charArray);
  }
}

Add numeric char to random string generator.


package co.phoenixlab.common.lang;

import java.util.ListIterator;

/**
 * Provides a reversed view of a ListIterator, starting from the last element.
 * @param <E>
 */
public class ReverseListIterator<E> implements ListIterator<E> {

    private final ListIterator<E> parent;

    public ReverseListIterator(ListIterator<E> parent) {
        this.parent = parent;
        //  Wind the iterator to the end
        while (parent.hasNext()) {
            parent.next();
        }
    }

    @Override
    public boolean hasNext() {
        return parent.hasPrevious();
    }

    @Override
    public E next() {
        return parent.previous();
    }

    @Override
    public boolean hasPrevious() {
        return parent.hasNext();
    }

    @Override
    public E previous() {
        return parent.next();
    }

    @Override
    public int nextIndex() {
        return parent.previousIndex();
    }

    @Override
    public int previousIndex() {
        return parent.nextIndex();
    }

    @Override
    public void remove() {
        parent.remove();
    }

    @Override
    public void set(E e) {
        parent.set(e);
    }

    @Override
    public void add(E e) {
        parent.add(e);
    }
}

package co.phoenixlab.common.lang;

import java.util.Iterator;
import java.util.ListIterator;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.function.Consumer;

/**
 * Provides a reversed view of a ListIterator, starting from the last element.
 * @param <E>
 */
public class ReverseListIterator<E> implements ListIterator<E>, Iterable<E> {

    private final ListIterator<E> parent;

    public ReverseListIterator(ListIterator<E> parent) {
        this.parent = parent;
        //  Wind the iterator to the end
        while (parent.hasNext()) {
            parent.next();
        }
    }

    @Override
    public boolean hasNext() {
        return parent.hasPrevious();
    }

    @Override
    public E next() {
        return parent.previous();
    }

    @Override
    public boolean hasPrevious() {
        return parent.hasNext();
    }

    @Override
    public E previous() {
        return parent.next();
    }

    @Override
    public int nextIndex() {
        return parent.previousIndex();
    }

    @Override
    public int previousIndex() {
        return parent.nextIndex();
    }

    @Override
    public void remove() {
        parent.remove();
    }

    @Override
    public void set(E e) {
        parent.set(e);
    }

    @Override
    public void add(E e) {
        parent.add(e);
    }

    @Override
    public Iterator<E> iterator() {
        return this;
    }

    @Override
    public void forEach(Consumer<? super E> action) {
        while (hasNext()) {
            action.accept(next());
        }
    }

    @Override
    public Spliterator<E> spliterator() {
        return Spliterators.spliteratorUnknownSize(this, 0);
    }
}

Implement iterable for use in efor loops


/*
 * 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.presto.hive;

import com.facebook.presto.tests.AbstractTestDistributedQueries;

import static com.facebook.presto.hive.HiveQueryRunner.createQueryRunner;
import static com.facebook.presto.hive.HiveQueryRunner.createSampledSession;
import static io.airlift.tpch.TpchTable.getTables;

public class TestHiveDistributedQueries
        extends AbstractTestDistributedQueries
{
    public TestHiveDistributedQueries()
            throws Exception
    {
        super(createQueryRunner(getTables()), createSampledSession());
    }

    @Override
    public void testDelete()
            throws Exception
    {
        // Hive connector currently does not support delete
    }
}

/*
 * 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.presto.hive;

import com.facebook.presto.tests.AbstractTestDistributedQueries;

import static com.facebook.presto.hive.HiveQueryRunner.createQueryRunner;
import static com.facebook.presto.hive.HiveQueryRunner.createSampledSession;
import static io.airlift.tpch.TpchTable.getTables;

public class TestHiveDistributedQueries
        extends AbstractTestDistributedQueries
{
    public TestHiveDistributedQueries()
            throws Exception
    {
        super(createQueryRunner(getTables()), createSampledSession());
    }

    @Override
    public void testDelete()
            throws Exception
    {
        // Hive connector currently does not support row-by-row delete
    }

    @Override
    public void testAddColumn()
            throws Exception
    {
        // Hive connector currently does not support schema change
    }

    @Override
    public void testRenameColumn()
            throws Exception
    {
        // Hive connector currently does not support schema change
    }

    @Override
    public void testRenameTable()
            throws Exception
    {
        // Hive connector currently does not support table rename
    }
}

Disable schema change tests in Hive distributed test


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

import android.content.Context;
import android.util.Log;

import com.getpebble.android.kit.PebbleKit;

import ca.joshuatacoma.bluesky.BlueSkyConstants;

public class PebbleAckReceiver extends PebbleKit.PebbleAckReceiver
{
    static final String TAG = "BlueSky";

    public PebbleAckReceiver() {
        super(BlueSkyConstants.APP_UUID);
    }

    @Override
    public void receiveAck(
            Context context,
            int transactionId)
    {
        Log.d(TAG, "receiveAck(" + String.valueOf(transactionId) + ")");
        PebbleState.recordNack(context, transactionId);
    }
};

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

import android.content.Context;
import android.util.Log;

import com.getpebble.android.kit.PebbleKit;

import ca.joshuatacoma.bluesky.BlueSkyConstants;

public class PebbleAckReceiver extends PebbleKit.PebbleAckReceiver
{
    static final String TAG = "BlueSky";

    public PebbleAckReceiver() {
        super(BlueSkyConstants.APP_UUID);
    }

    @Override
    public void receiveAck(
            Context context,
            int transactionId)
    {
        Log.d(TAG, "receiveAck(" + String.valueOf(transactionId) + ")");
        PebbleState.recordAck(context, transactionId);
    }
};

Fix bad typo (doesn't fix bug)

Fix bad typo (doesn't fix bug)


package org.buddycloud.channelserver.pubsub.model.impl;

import nl.jqno.equalsverifier.EqualsVerifier;

import org.junit.Test;

public class NodeAffiliationImplTest {

    @Test
    public void testEquals() {
        EqualsVerifier.forClass(NodeAffiliationImpl.class).verify();
    }

}

package org.buddycloud.channelserver.pubsub.model.impl;

import java.util.Date;

import junit.framework.Assert;
import nl.jqno.equalsverifier.EqualsVerifier;

import org.buddycloud.channelserver.pubsub.affiliation.Affiliations;
import org.junit.Test;
import org.xmpp.packet.JID;

public class NodeAffiliationImplTest {

  private String node = "/user/test@example.com/posts";
  private JID fullJid = new JID("test@example.com/resource");

  @Test
  public void testEquals() {
    EqualsVerifier.forClass(NodeAffiliationImpl.class).verify();
  }

  @Test
  public void providingFullJidSetsAsAsBareJid() throws Exception {
    NodeAffiliationImpl affiliation =
        new NodeAffiliationImpl(node, fullJid, Affiliations.member, new Date());
    Assert.assertEquals(fullJid.toBareJID(), affiliation.getUser().toString());
  }

}

Increase coverage of NodeAffiliationImpl to 100%


package org.dummy.load;

/**
 * Created by baardl on 26.07.15.
 */
public class LoadThread implements Runnable {

    private final int sleepMillis;

    public LoadThread(int sleepMillis) {
        this.sleepMillis = sleepMillis;
    }

    @Override
    public void run() {
        do {
            System.out.println("Hello You at " + System.currentTimeMillis());
            try {
                Thread.sleep(sleepMillis);
            } catch (InterruptedException e) {
                //sleep interupted
            }
        } while (true);
    }
}

package org.dummy.load;

/**
 * Created by baardl on 26.07.15.
 */
public class LoadThread implements Runnable {

    private final int sleepMillis;

    public LoadThread(int sleepMillis) {
        this.sleepMillis = sleepMillis;
    }

    @Override
    public void run() {
        do {
            performVisibleLoad();
            try {
                Thread.sleep(sleepMillis);
            } catch (InterruptedException e) {
                //sleep interupted
            }
        } while (true);
    }

    public void performVisibleLoad() {
        System.out.println("Hello You at " + System.currentTimeMillis());
    }
}

Load is picked up by Valuereporter-agent.


package org.alien4cloud.secret.services;

import java.util.List;

import com.google.common.collect.Lists;
import org.springframework.stereotype.Component;

import alien4cloud.plugin.AbstractPluginLinker;
import alien4cloud.plugin.model.PluginUsage;
import org.alien4cloud.secret.ISecretProvider;

@Component
public class SecretProviderRegistry extends AbstractPluginLinker<ISecretProvider> {

    @Override
    public List<PluginUsage> usage(String pluginId) {
        // TODO how to determine plugin usage
        return null;
    }
}

package org.alien4cloud.secret.services;

import alien4cloud.dao.IGenericSearchDAO;
import alien4cloud.dao.model.GetMultipleDataResult;
import alien4cloud.model.orchestrators.locations.Location;
import alien4cloud.model.secret.SecretProviderConfiguration;
import alien4cloud.plugin.AbstractPluginLinker;
import alien4cloud.plugin.model.PluginUsage;
import com.google.common.collect.Lists;
import org.alien4cloud.secret.ISecretProvider;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class SecretProviderRegistry extends AbstractPluginLinker<ISecretProvider> {
    @Resource(name = "alien-es-dao")
    private IGenericSearchDAO alienDAO;

    @Override
    public List<PluginUsage> usage(String pluginId) {
        GetMultipleDataResult<Location> locationData = alienDAO.buildQuery(Location.class).prepareSearch().search(0, Integer.MAX_VALUE);

        List<PluginUsage> usages = Lists.newArrayList();
        for (Location location : locationData.getData()) {
            SecretProviderConfiguration locationSecretProviderConfiguration = location.getSecretProviderConfiguration();
            if (locationSecretProviderConfiguration != null && locationSecretProviderConfiguration.getPluginName().equals(pluginId)) {
                usages.add(new PluginUsage(location.getId(), location.getName(), Location.class.getSimpleName()));

            }
        }

        return usages;
    }
}

ALIEN-2807: Check vault plugins usage before delete/disable it


package de.holisticon.util.tracee.configuration;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
import java.util.Properties;

/**
 * @author Daniel Wegener (Holisticon AG)
 */
public final class TraceePropertiesFileLoader {

	public static final String TRACEE_PROPERTIES_FILE = "tracee.properties";

	public Properties loadTraceeProperties() throws IOException {
		final Properties propertiesFromFile = new Properties();
		final ClassLoader loader = Thread.currentThread().getContextClassLoader();

		final Enumeration<URL> traceePropertyFiles = loader.getResources(TRACEE_PROPERTIES_FILE);

		while (traceePropertyFiles.hasMoreElements()) {
			final URL url = traceePropertyFiles.nextElement();
			InputStream stream = null;
			try {
				stream = url.openStream();
				propertiesFromFile.load(stream);
			} catch (IOException e) {
				throw e;
			} finally {
				try {
					if (stream != null)
						stream.close();
				} catch (IOException ignored) {}
			}
		}

		return propertiesFromFile;
	}

}

package de.holisticon.util.tracee.configuration;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
import java.util.Properties;

/**
 * @author Daniel Wegener (Holisticon AG)
 */
public final class TraceePropertiesFileLoader {

	public static final String TRACEE_PROPERTIES_FILE = "tracee.properties";

	public Properties loadTraceeProperties() throws IOException {
		final Properties propertiesFromFile = new Properties();
		final ClassLoader loader = Thread.currentThread().getContextClassLoader();

		final Enumeration<URL> traceePropertyFiles = loader.getResources(TRACEE_PROPERTIES_FILE);

		while (traceePropertyFiles.hasMoreElements()) {
			final URL url = traceePropertyFiles.nextElement();
			InputStream stream = null;
			try {
				stream = url.openStream();
				propertiesFromFile.load(stream);
			} finally {
				try {
					if (stream != null)
						stream.close();
				} catch (IOException ignored) {}
			}
		}

		return propertiesFromFile;
	}

}

Remove not necessary catch-rethrow because exception is not handled


package io.github.web.springtest;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import io.github.bonigarcia.SeleniumExtension;

@ExtendWith({ SeleniumExtension.class, SpringExtension.class })
@SpringBootTest(classes = SpringTestDemoApp.class, webEnvironment = RANDOM_PORT)
public class SpringChromeJupiterTest {

    @LocalServerPort
    int serverPort;

    @Test
    public void test(ChromeDriver driver) {
        // Open system under test
        driver.get("http://localhost:" + serverPort);

        // Verify first page title
        String firstPageTitle = driver.getTitle();
        String expectedFirstPageTitle = "Spring Boot Test - Page 1";
        assertEquals(expectedFirstPageTitle, firstPageTitle);

        // Click on link
        driver.findElement(By.linkText("another")).click();

        // Verify second page caption
        String secondPageCaption = driver.findElement(By.id("caption"))
                .getText();
        String expectedSecondPageTitle = "Other page";
        assertEquals(expectedSecondPageTitle, secondPageCaption);
    }

}

package io.github.web.springtest;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import io.github.bonigarcia.SeleniumExtension;

@ExtendWith({ SeleniumExtension.class, SpringExtension.class })
@SpringBootTest(webEnvironment = RANDOM_PORT)
public class SpringChromeJupiterTest {

    @LocalServerPort
    int serverPort;

    @Test
    public void test(ChromeDriver driver) {
        // Open system under test
        driver.get("http://localhost:" + serverPort);

        // Verify first page title
        String firstPageTitle = driver.getTitle();
        String expectedFirstPageTitle = "Spring Boot Test - Page 1";
        assertEquals(expectedFirstPageTitle, firstPageTitle);

        // Click on link
        driver.findElement(By.linkText("another")).click();

        // Verify second page caption
        String secondPageCaption = driver.findElement(By.id("caption"))
                .getText();
        String expectedSecondPageTitle = "Other page";
        assertEquals(expectedSecondPageTitle, secondPageCaption);
    }

}

Remove class in SpringBooTest annotation


package lt.inventi.wicket.component.bootstrap.form;

import org.apache.wicket.util.string.AppendingStringBuffer;

abstract class ChoiceUtils {

    public enum InputPosition {
        BEFORE_LABEL, AFTER_LABEL
    }

    private ChoiceUtils() {
        // static utils
    }

    static void moveInputInsideLabel(AppendingStringBuffer buffer, String cssClass, InputPosition position) {
        int inputIdx = buffer.lastIndexOf("<input");
        if (inputIdx == -1) {
            throw new IllegalStateException("Must contain an input!");
        }
        int labelIdx = buffer.indexOf("<label", inputIdx);
        if (labelIdx == -1) {
            throw new IllegalStateException("Must contain a label!");
        }
        int labelEndIdx = buffer.indexOf("", labelIdx);
        if (labelEndIdx == -1) {
            throw new IllegalStateException("Must contain label's end!");
        }

        String label = buffer.substring(labelIdx, labelEndIdx);
        String labelClass = "class=\"" + cssClass + "\" ";
        String labelWithClass = label.substring(0, 7) + labelClass + label.substring(7, label.length());
        String input = buffer.substring(inputIdx, labelIdx);

        buffer.replace(inputIdx, labelEndIdx, position == InputPosition.BEFORE_LABEL ? "
" + input + labelWithClass + "
" : labelWithClass + input);
    }
}

package lt.inventi.wicket.component.bootstrap.form;

import org.apache.wicket.util.string.AppendingStringBuffer;

abstract class ChoiceUtils {

    public enum InputPosition {
        BEFORE_LABEL, AFTER_LABEL
    }

    private ChoiceUtils() {
        // static utils
    }

    static void moveInputInsideLabel(AppendingStringBuffer buffer, String cssClass, InputPosition position) {
        int inputIdx = buffer.lastIndexOf("<input");
        if (inputIdx == -1) {
            throw new IllegalStateException("Must contain an input!");
        }
        int labelIdx = buffer.indexOf("<label", inputIdx);
        if (labelIdx == -1) {
            throw new IllegalStateException("Must contain a label!");
        }
        int labelEndIdx = buffer.indexOf("", labelIdx);
        if (labelEndIdx == -1) {
            throw new IllegalStateException("Must contain label's end!");
        }

        String label = buffer.substring(labelIdx, labelEndIdx);
        String labelClass = "class=\"" + cssClass + "\" ";
        String labelWithClass = label.substring(0, 7) + labelClass + label.substring(7, label.length());
        String input = buffer.substring(inputIdx, labelIdx);

        buffer.replace(inputIdx, labelEndIdx, position == InputPosition.BEFORE_LABEL ? "
" + input + label + "
" : labelWithClass + input);
    }
}

Move cssClass from label to div

refact(checkbox): Move cssClass from label to div


package org.jboss.pnc.jenkinsbuilddriver;

import org.jboss.pnc.core.spi.builddriver.BuildDriver;
import org.jboss.pnc.core.spi.repositorymanager.Repository;
import org.jboss.pnc.model.BuildResult;
import org.jboss.pnc.model.BuildType;
import org.jboss.pnc.model.Project;

import java.util.function.Consumer;

/**
 * Created by Matej Lazar on 2014-11-23.
 */
//TODO implement me
public class JenkinsBuildDriver implements BuildDriver {
    @Override
    public String getDriverId() {
        return null;
    }

    @Override
    public void setDeployRepository(Repository deployRepository) {

    }

    @Override
    public void setSourceRepository(Repository repositoryProxy) {

    }

    @Override
    public void buildProject(Project project, Consumer<BuildResult> onBuildComplete) {
        //TODO implement me

        //notify build complete
        onBuildComplete.accept(new BuildResult());
    }

    @Override
    public BuildType getBuildType() {
        return BuildType.JAVA;
    }

}

package org.jboss.pnc.jenkinsbuilddriver;

import org.jboss.pnc.core.spi.builddriver.BuildDriver;
import org.jboss.pnc.core.spi.repositorymanager.Repository;
import org.jboss.pnc.model.BuildResult;
import org.jboss.pnc.model.BuildType;
import org.jboss.pnc.model.Project;

import java.util.function.Consumer;

/**
 * Created by Matej Lazar on 2014-11-23.
 */
//TODO implement me
public class JenkinsBuildDriver implements BuildDriver {
    private Consumer<BuildResult> onBuildComplete;

    @Override
    public String getDriverId() {
        return null;
    }

    @Override
    public void setDeployRepository(Repository deployRepository) {

    }

    @Override
    public void setSourceRepository(Repository repositoryProxy) {

    }

    @Override
    public void buildProject(Project project, Consumer<BuildResult> onBuildComplete) {
        this.onBuildComplete = onBuildComplete;
        //TODO implement me

        return;
    }

    @Override
    public BuildType getBuildType() {
        return BuildType.JAVA;
    }

    //TODO
    private void notifyBuildComplete() {
        //notify build complete

        onBuildComplete.accept(new BuildResult());
    }

}

Move callback notification 'after' return.


package org.sculptor.generator.util;

public abstract class ChainLink<T extends ChainLink<?>> {
	private T nextLink;

	public ChainLink(T next) {
		// TODO check for NULL
		// can be null only when created from templates and extension in generator-core
		nextLink = next;
	}

	public T getNext() {
		return nextLink;
	}
}

package org.sculptor.generator.util;

public abstract class ChainLink<T extends ChainLink<?>> {
	private T nextLink;

	public ChainLink(T next) {
		// TODO check for NULL
		// can be null only when created from templates and extension in generator-core
		nextLink = next;
	}

	public ChainLink() {

	}

	public void setNext(ChainLink<?> next) {
		nextLink = (T) next;
	}

	public T getNext() {
		return nextLink;
	}
}

SupportChainOverriding: Add default constructor to generated class


package uk.gov.dvla.services.enquiry;

import uk.gov.dvla.domain.Driver;
import uk.gov.dvla.domain.Person;
import uk.gov.dvla.services.ManagedService;

public interface DriverEnquiry extends ManagedService
{
    public static final String DRIVER_URI = "/driver/";
    public static final String CUSTOMER_PORTAL = "customer.portal";
    public static final String MIB = "mib";

    public static final String DLN_PARAM = "dln";
    public static final String ENQUIRY_ID_PARAM = "id";

    public static final String FORENAME_PARAM = "fn";
    public static final String SURNAME_PARAM = "sn";
    public static final String DOB_PARAM = "d";
    public static final String GENDER_PARAM = "g";
    public static final String POSTCODE_PARAM = "p";

	public Driver get(String dln);

	public Driver get(Person person);

    public Driver get(String forename, String surname, String dob,
                      String gender, String postCode);
}

package uk.gov.dvla.services.enquiry;

import uk.gov.dvla.domain.Driver;
import uk.gov.dvla.domain.Person;
import uk.gov.dvla.services.ManagedService;

public interface DriverEnquiry extends ManagedService
{
    public static final String EXTERNAL_DRIVER_URI = "/external/driver/";
    public static final String DRIVER_URI = "/driver/";
    public static final String CUSTOMER_PORTAL = "customer.portal";
    public static final String MIB = "mib";

    public static final String DLN_PARAM = "dln";
    public static final String ENQUIRY_ID_PARAM = "id";

    public static final String FORENAME_PARAM = "fn";
    public static final String SURNAME_PARAM = "sn";
    public static final String DOB_PARAM = "d";
    public static final String GENDER_PARAM = "g";
    public static final String POSTCODE_PARAM = "p";

	public Driver get(String dln);

	public Driver get(Person person);

    public Driver get(String forename, String surname, String dob,
                      String gender, String postCode);
}

Introduce integration tests using DropWizards ResourceTest. Include ability to return an Invalid Request message when the DLN or EnquiryId are missing.


package com.bbn.bue.common.diff;

import com.bbn.bue.common.evaluation.FMeasureCounts;
import com.google.common.collect.ImmutableMap;
import org.junit.Test;

import java.util.Map;

import static org.junit.Assert.assertEquals;

public class FMeasureTableRendererTest {
    @Test
    public void testFMeasureTableRenderer() {
        final FMeasureTableRenderer renderer = FMeasureTableRenderer.create();

        final Map<String, FMeasureCounts> data = ImmutableMap.of(
                "foo", FMeasureCounts.from(1, 2, 3),
                "bar", FMeasureCounts.from(4, 5, 6));

        final String expected=
                "Name                            TP       FP       FN        P        R       F1\n"+
                "===============================================================================\n"+
                "foo                            1.0      2.0      3.0    33.33    25.00    28.57\n"+
                "bar                            4.0      5.0      6.0    44.44    40.00    42.11\n";
        final String result = renderer.render(data);
        assertEquals(expected, result);
    }
}

package com.bbn.bue.common.diff;

import com.bbn.bue.common.evaluation.FMeasureCounts;
import com.google.common.collect.ImmutableMap;
import org.junit.Test;

import java.util.Map;

import static org.junit.Assert.assertEquals;

public class FMeasureTableRendererTest {
    @Test
    public void testFMeasureTableRenderer() {
        final FMeasureTableRenderer renderer = FMeasureTableRenderer.create();

        final Map<String, FMeasureCounts> data = ImmutableMap.of(
                "foo", FMeasureCounts.from(1, 2, 3),
                "bar", FMeasureCounts.from(4, 5, 6));

        final String expected=
                "Name                            TP       FP       FN        P        R       F1\n"+
                "===============================================================================\n"+
                "bar                            4.0      5.0      6.0    44.44    40.00    42.11\n"+
                "foo                            1.0      2.0      3.0    33.33    25.00    28.57\n";

        final String result = renderer.render(data);
        assertEquals(expected, result);
    }
}

Change test due to change in default sort order.


package lv.ctco.cukesrest.internal.matchers;

import org.hamcrest.*;

import java.math.*;

public class EqualToIgnoringTypeMatcher {

    public static Matcher<String> equalToIgnoringType(final String value) {
        return new BaseMatcher<String>() {

            @Override
            public void describeTo(Description description) {
                description.appendText("equal to ignoring type " + value);
            }

            @Override
            public boolean matches(Object item) {
                String toString = item.toString();
                if (toString.equals(value)) return true;

                if (item instanceof Number) {
                    BigDecimal observedValue = item instanceof BigDecimal ?
                            (BigDecimal) item : new BigDecimal(toString);
                    return new BigDecimal(value).compareTo(observedValue) == 0;
                }

                return false;
            }
        };
    }

    public static Matcher<String> notEqualToIgnoringType(final String value) {
        return new BaseMatcher<String>() {

            @Override
            public void describeTo(Description description) {
                description.appendText("not equal to ignoring type " + value);
            }

            @Override
            public boolean matches(Object item) {
                String toString = item.toString();
                if (!toString.equals(value)) return true;

                if (item instanceof Number) {
                    BigDecimal observedValue = item instanceof BigDecimal ? (BigDecimal) item : new BigDecimal(toString);
                    return new BigDecimal(value).compareTo(observedValue) != 0;
                }
                return false;
            }
        };
    }
}

package lv.ctco.cukesrest.internal.matchers;

import org.hamcrest.*;

import java.math.*;

public class EqualToIgnoringTypeMatcher {

    public static Matcher<String> equalToIgnoringType(final String value) {
        return new BaseMatcher<String>() {

            @Override
            public void describeTo(Description description) {
                description.appendText("equal to ignoring type " + value);
            }

            @Override
            public boolean matches(Object item) {
                if (item == null) {
                    return value.equalsIgnoreCase("null");
                }

                String toString = item.toString();
                if (toString.equals(value)) return true;

                if (item instanceof Number) {
                    BigDecimal observedValue = item instanceof BigDecimal ?
                            (BigDecimal) item : new BigDecimal(toString);
                    return new BigDecimal(value).compareTo(observedValue) == 0;
                }

                return false;
            }
        };
    }

    public static Matcher<String> notEqualToIgnoringType(final String value) {
        return new BaseMatcher<String>() {

            @Override
            public void describeTo(Description description) {
                description.appendText("not equal to ignoring type " + value);
            }

            @Override
            public boolean matches(Object item) {
                String toString = item.toString();
                if (!toString.equals(value)) return true;

                if (item instanceof Number) {
                    BigDecimal observedValue = item instanceof BigDecimal ? (BigDecimal) item : new BigDecimal(toString);
                    return new BigDecimal(value).compareTo(observedValue) != 0;
                }
                return false;
            }
        };
    }
}

Support of comparison null values in object properties


package com.github.triceo.splitlog;

import java.util.concurrent.TimeUnit;

import org.junit.Rule;
import org.junit.rules.TestRule;
import org.junit.rules.TestWatcher;
import org.junit.rules.Timeout;
import org.junit.runner.Description;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Base class for all Splitlog tests. Will enforce a default timeout and add
 * some useful test execution logging.
 */
public abstract class AbstractSplitlogTest {

    private static final Logger LOGGER = LoggerFactory.getLogger(AbstractSplitlogTest.class);

    @Rule
    public Timeout globalTimeout = new Timeout((int) TimeUnit.MINUTES.toMillis(2));

    @Rule
    public TestRule watchman = new TestWatcher() {

        @Override
        protected void finished(final Description d) {
            AbstractSplitlogTest.LOGGER.info("----- Finished test: {}\n", d);
        }

        @Override
        protected void starting(final Description d) {
            AbstractSplitlogTest.LOGGER.info("----- Starting test: {}", d);
        }
    };

}

package com.github.triceo.splitlog;

import java.util.concurrent.TimeUnit;

import org.junit.Rule;
import org.junit.rules.TestRule;
import org.junit.rules.TestWatcher;
import org.junit.rules.Timeout;
import org.junit.runner.Description;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Base class for all Splitlog tests. Will enforce a default timeout and add
 * some useful test execution logging.
 */
public abstract class AbstractSplitlogTest {

    private static final Logger LOGGER = LoggerFactory.getLogger(AbstractSplitlogTest.class);

    @Rule
    public Timeout globalTimeout = new Timeout((int) TimeUnit.MINUTES.toMillis(1));

    @Rule
    public TestRule watchman = new TestWatcher() {

        @Override
        protected void finished(final Description d) {
            AbstractSplitlogTest.LOGGER.info("----- Finished test: {}\n", d);
        }

        @Override
        protected void starting(final Description d) {
            AbstractSplitlogTest.LOGGER.info("----- Starting test: {}", d);
        }
    };

}

Reduce test timeout to 60 seconds

Reduce test timeout to 60 seconds

Tests have been split into smaller units


package no.uio.ifi.trackfind.rest.controllers;

import no.uio.ifi.trackfind.services.TrackFindService;
import org.apache.lucene.queryparser.classic.ParseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
public class TrackFindController {

    private final TrackFindService trackFindService;

    @Autowired
    public TrackFindController(TrackFindService trackFindService) {
        this.trackFindService = trackFindService;
    }

    @GetMapping(path = "/reinit", produces = "application/json")
    public void reinit() throws Exception {
        trackFindService.updateIndex();
    }

    @GetMapping(path = "/metamodel", produces = "application/json")
    public Object getMetamodel() throws IOException, ParseException {
        return trackFindService.getMetamodel().asMap();
    }

    @GetMapping(path = "/search", produces = "application/json")
    public Object search(@RequestParam String query) throws IOException, ParseException {
        return trackFindService.search(query);
    }

}

package no.uio.ifi.trackfind.rest.controllers;

import no.uio.ifi.trackfind.services.TrackFindService;
import org.apache.lucene.queryparser.classic.ParseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.Set;
import java.util.stream.Collectors;

@RestController
public class TrackFindController {

    private final TrackFindService trackFindService;

    @Autowired
    public TrackFindController(TrackFindService trackFindService) {
        this.trackFindService = trackFindService;
    }

    @GetMapping(path = "/reinit", produces = "application/json")
    public void reinit() throws Exception {
        trackFindService.updateIndex();
    }

    @GetMapping(path = "/metamodel", produces = "application/json")
    public Object getMetamodel() throws IOException, ParseException {
        return trackFindService.getMetamodel().asMap();
    }

    @GetMapping(path = "/attributes", produces = "application/json")
    public Object getAttributes(@RequestParam(required = false) String expression) throws IOException, ParseException {
        Set<String> attributes = trackFindService.getMetamodel().asMap().keySet();
        if (StringUtils.isEmpty(expression)) {
            return attributes;
        } else {
            return attributes.stream().filter(a -> a.contains(expression)).collect(Collectors.toSet());
        }
    }

    @GetMapping(path = "/values", produces = "application/json")
    public Object getValues(@RequestParam String attribute) throws IOException, ParseException {
        return trackFindService.getMetamodel().get(attribute);
    }

    @GetMapping(path = "/search", produces = "application/json")
    public Object search(@RequestParam String query) throws IOException, ParseException {
        return trackFindService.search(query);
    }

}

Add separate methods for getting attributes and values.


/*
 * * Copyright (C) 2013-2015 Matt Baxter http://kitteh.org
 *
 * 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.
 */
/**
 * Internally used classes, no javadocs.
 */
package org.kitteh.irc.client.library.implementation;

Add missing LICENSE to unnecessary file

Add missing LICENSE to unnecessary file