package org.wildfly.swarm.examples.jaxrs.cdi;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.wildfly.swarm.cdi.ConfigValue;

/**
 * @author Heiko Braun
 */
@ApplicationScoped
@Path("/app")
public class Controller {

    @Inject
    @ConfigValue("some.string.property")
    String stringProperty;

    @Inject
    @ConfigValue("some.integer.property")
    Integer intProperty;

    @Inject
    @ConfigValue("some.boolean.property")
    Boolean boolProperty;

    @GET
    @Path("/propertyString")
    @Produces(MediaType.TEXT_PLAIN)
    public String getStringProperty() {
        if(null==stringProperty) throw new RuntimeException("config property not initialised");
        return stringProperty;
    }

    @GET
    @Path("/propertyInteger")
    @Produces(MediaType.TEXT_PLAIN)
    public String getIntegerProperty() {
        if(null==intProperty) throw new RuntimeException("config property not initialised");
        return String.valueOf(intProperty);
    }

    @GET
    @Path("/propertyBoolean")
    @Produces(MediaType.TEXT_PLAIN)
    public String getBoolProperty() {
        if(null==boolProperty) throw new RuntimeException("config property not initialised");
        return String.valueOf(boolProperty);
    }
}

package org.wildfly.swarm.examples.jaxrs.cdi;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.wildfly.swarm.spi.runtime.annotations.ConfigurationValue;

/**
 * @author Heiko Braun
 */
@ApplicationScoped
@Path("/app")
public class Controller {

    @Inject
    @ConfigurationValue("some.string.property")
    String stringProperty;

    @Inject
    @ConfigurationValue("some.integer.property")
    Integer intProperty;

    @Inject
    @ConfigurationValue("some.boolean.property")
    Boolean boolProperty;

    @GET
    @Path("/propertyString")
    @Produces(MediaType.TEXT_PLAIN)
    public String getStringProperty() {
        if (null == stringProperty) throw new RuntimeException("config property not initialised");
        return stringProperty;
    }

    @GET
    @Path("/propertyInteger")
    @Produces(MediaType.TEXT_PLAIN)
    public String getIntegerProperty() {
        if (null == intProperty) throw new RuntimeException("config property not initialised");
        return String.valueOf(intProperty);
    }

    @GET
    @Path("/propertyBoolean")
    @Produces(MediaType.TEXT_PLAIN)
    public String getBoolProperty() {
        if (null == boolProperty) throw new RuntimeException("config property not initialised");
        return String.valueOf(boolProperty);
    }
}

Modify example as @ConfigurationValue package is now different


package com.jgeppert.struts2.jquery.components;

import org.apache.struts2.conversion.StrutsTypeConverterHolder;
import org.junit.jupiter.api.BeforeEach;

import com.opensymphony.xwork2.DefaultTextProvider;
import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
import com.opensymphony.xwork2.ognl.OgnlUtil;
import com.opensymphony.xwork2.ognl.OgnlValueStack;
import com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor;
import com.opensymphony.xwork2.util.ValueStack;

public abstract class AbstractComponentBaseTest {
    protected ValueStack valueStack;

    @BeforeEach
    void setUpValueStack() {
        valueStack = new TestOgnlValueStack();
    }

    static class TestOgnlValueStack extends OgnlValueStack {
        private static final long serialVersionUID = 1L;

        protected TestOgnlValueStack() {
            super(new TestXworkConverter(), new CompoundRootAccessor(), new DefaultTextProvider(), false);
            TestXworkConverter converter = new TestXworkConverter();
            converter.setTypeConverterHolder(new StrutsTypeConverterHolder());

            setXWorkConverter(converter);
            setOgnlUtil(new OgnlUtil(null, null));
        }

    }

    static class TestXworkConverter extends XWorkConverter {
    }
}

package com.jgeppert.struts2.jquery.components;

import com.opensymphony.xwork2.DefaultTextProvider;
import com.opensymphony.xwork2.conversion.impl.XWorkConverter;
import com.opensymphony.xwork2.ognl.DefaultOgnlBeanInfoCacheFactory;
import com.opensymphony.xwork2.ognl.DefaultOgnlExpressionCacheFactory;
import com.opensymphony.xwork2.ognl.OgnlUtil;
import com.opensymphony.xwork2.ognl.OgnlValueStack;
import com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor;
import com.opensymphony.xwork2.util.ValueStack;
import org.apache.struts2.conversion.StrutsTypeConverterHolder;
import org.junit.jupiter.api.BeforeEach;

public abstract class AbstractComponentBaseTest {
    protected ValueStack valueStack;

    @BeforeEach
    void setUpValueStack() {
        valueStack = new TestOgnlValueStack();
    }

    static class TestOgnlValueStack extends OgnlValueStack {
        private static final long serialVersionUID = 1L;

        protected TestOgnlValueStack() {
            super(new TestXworkConverter(), new CompoundRootAccessor(), new DefaultTextProvider(), false);
            TestXworkConverter converter = new TestXworkConverter();
            converter.setTypeConverterHolder(new StrutsTypeConverterHolder());

            setXWorkConverter(converter);
            setOgnlUtil(new OgnlUtil(new DefaultOgnlExpressionCacheFactory<>(), new DefaultOgnlBeanInfoCacheFactory<>()));
        }

    }

    static class TestXworkConverter extends XWorkConverter {
    }
}

Set default cache factories for ognl utils in integration tests


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

import javax.portlet.ActionRequest;
import javax.portlet.PortletRequest;

/**
 * Strategy for selecting different background image sets based on some criteria such as theme, user agent, etc.
 *
 * @author James Wennmacher, jwennmacher@unicon.net
 */

public interface BackgroundSetSelectionStrategy {

    String[] getImageSet(PortletRequest req);

    String[] getImageThumbnailSet(PortletRequest req);

    String[] getImageCaptions(PortletRequest req);

    String getSelectedImage(PortletRequest req);

    String getBackgroundContainerSelector(PortletRequest req);

    void setSelectedImage(ActionRequest req, String backgroundImage);

}

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

import javax.portlet.ActionRequest;
import javax.portlet.PortletRequest;

/**
 * Strategy for selecting different background image sets based on some criteria such as theme, user agent, etc.
 *
 * @author James Wennmacher, jwennmacher@unicon.net
 */

public interface BackgroundSetSelectionStrategy {

    String[] getImageSet(PortletRequest req);

    String[] getImageThumbnailSet(PortletRequest req);

    /**
     * @since 4.3.2
     */
    String[] getImageCaptions(PortletRequest req);

    String getSelectedImage(PortletRequest req);

    String getBackgroundContainerSelector(PortletRequest req);

    void setSelectedImage(ActionRequest req, String backgroundImage);

}

UP-4802: Add since annotation to getImageCaptions


package de.espend.idea.php.annotation.doctrine.action;

import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.jetbrains.php.codeInsight.PhpCodeInsightUtil;
import com.jetbrains.php.lang.psi.elements.PhpClass;
import com.jetbrains.php.lang.psi.elements.PhpPsiElement;
import de.espend.idea.php.annotation.doctrine.util.DoctrineUtil;
import de.espend.idea.php.annotation.util.PhpDocUtil;
import de.espend.idea.php.annotation.util.PhpElementsUtil;
import org.jetbrains.annotations.NotNull;

/**
 * @author Daniel Espendiller <daniel@espendiller.net>
 */
public class DoctrineEmbeddedClassAnnotationGenerateAction extends DoctrineClassGeneratorAction {
    @NotNull
    @Override
    protected String supportedClass() {
        return "Doctrine\\ORM\\Mapping\\Embedded";
    }

    protected void execute(@NotNull Editor editor, @NotNull PhpClass phpClass, @NotNull PsiFile psiFile) {
        // insert ORM alias
        PhpPsiElement scopeForUseOperator = PhpCodeInsightUtil.findScopeForUseOperator(phpClass.getFirstChild());
        if(scopeForUseOperator != null) {
            PhpElementsUtil.insertUseIfNecessary(scopeForUseOperator, DoctrineUtil.DOCTRINE_ORM_MAPPING, "ORM");
            PsiDocumentManager.getInstance(psiFile.getProject()).doPostponedOperationsAndUnblockDocument(editor.getDocument());
        }

        PhpDocUtil.addClassEmbeddedDocs(phpClass, editor.getDocument(), psiFile);
    }
}

package de.espend.idea.php.annotation.doctrine.action;

import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import com.jetbrains.php.codeInsight.PhpCodeInsightUtil;
import com.jetbrains.php.lang.psi.elements.PhpClass;
import com.jetbrains.php.lang.psi.elements.PhpPsiElement;
import de.espend.idea.php.annotation.doctrine.util.DoctrineUtil;
import de.espend.idea.php.annotation.util.PhpDocUtil;
import de.espend.idea.php.annotation.util.PhpElementsUtil;
import org.jetbrains.annotations.NotNull;

/**
 * @author Daniel Espendiller <daniel@espendiller.net>
 */
public class DoctrineEmbeddedClassAnnotationGenerateAction extends DoctrineClassGeneratorAction {
    @NotNull
    @Override
    protected String supportedClass() {
        return "Doctrine\\ORM\\Mapping\\Embeddable";
    }

    protected void execute(@NotNull Editor editor, @NotNull PhpClass phpClass, @NotNull PsiFile psiFile) {
        // insert ORM alias
        PhpPsiElement scopeForUseOperator = PhpCodeInsightUtil.findScopeForUseOperator(phpClass.getFirstChild());
        if(scopeForUseOperator != null) {
            PhpElementsUtil.insertUseIfNecessary(scopeForUseOperator, DoctrineUtil.DOCTRINE_ORM_MAPPING, "ORM");
            PsiDocumentManager.getInstance(psiFile.getProject()).doPostponedOperationsAndUnblockDocument(editor.getDocument());
        }

        PhpDocUtil.addClassEmbeddedDocs(phpClass, editor.getDocument(), psiFile);
    }
}

Insert Embeddable instead of Embedded annotation for class


package com.semperos.screwdriver.scripting.js;

import com.semperos.screwdriver.TestUtil;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.io.ByteArrayOutputStream;
import java.io.File;

import static org.junit.Assert.assertEquals;

public class CoffeeScriptEvalIntegrationTest {
    @Before
    public void setup() throws Exception {
        TestUtil.deleteAssetDirectories();
    }

    @After
    public void tearDown() throws Exception {
        TestUtil.deleteAssetDirectories();
    }

    @Test
    public void testEvalFile() throws Exception {
        String expected = "THIS IS COFFEESCRIPT, outputDir is " + TestUtil.baseDirectoryPath();
        File f = new File(TestUtil.baseDirectoryPath(), "screwdriver_config.coffee");
        // Capture stdout and compare
        ByteArrayOutputStream baos = TestUtil.captureStdout();
        CoffeeScriptEval.evalFile(f);
        assertEquals(expected, baos.toString());
        TestUtil.restoreStdout();
    }
}

package com.semperos.screwdriver.scripting.js;

import com.semperos.screwdriver.TestUtil;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.io.ByteArrayOutputStream;
import java.io.File;

import static org.junit.Assert.assertEquals;

public class CoffeeScriptEvalIntegrationTest {
    @Before
    public void setup() throws Exception {
        TestUtil.deleteAssetDirectories();
    }

    @After
    public void tearDown() throws Exception {
        TestUtil.deleteAssetDirectories();
    }

    @Test
    public void testEvalFile() throws Exception {
        String expected = "THIS IS COFFEESCRIPT, outputDir is " + TestUtil.baseDirectoryPath();
        File f = new File(TestUtil.baseDirectoryPath(), "screwdriver_build.coffee");
        // Capture stdout and compare
        ByteArrayOutputStream baos = TestUtil.captureStdout();
        CoffeeScriptEval.evalFile(f);
        assertEquals(expected, baos.toString());
        TestUtil.restoreStdout();
    }
}

Fix name of file in test for Clojure scripting


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

import org.apache.qpid.proton4j.amqp.Symbol;

/**
 * Implements the Anonymous SASL authentication mechanism.
 */
public class AnonymousMechanism extends AbstractMechanism {

    public static final Symbol ANONYMOUS = Symbol.valueOf("ANONYMOUS");

    @Override
    public Symbol getName() {
        return ANONYMOUS;
    }
}

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

import org.apache.qpid.proton4j.amqp.Symbol;
import org.apache.qpid.proton4j.buffer.ProtonBuffer;

/**
 * Implements the Anonymous SASL authentication mechanism.
 */
public class AnonymousMechanism extends AbstractMechanism {

    public static final Symbol ANONYMOUS = Symbol.valueOf("ANONYMOUS");

    @Override
    public Symbol getName() {
        return ANONYMOUS;
    }

    @Override
    public ProtonBuffer getInitialResponse() {
        return EMPTY;
    }
}

Add back the empty initial response for ANONYMOUS


package com.mitchellbosecke.pebble.boot.autoconfigure;

import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.core.env.Environment;
import org.springframework.core.env.PropertyResolver;
import org.springframework.core.io.ResourceLoader;
import org.springframework.util.ClassUtils;

public class PebbleTemplateAvailabilityProvider implements TemplateAvailabilityProvider {

    @Override
    public boolean isTemplateAvailable(String view, Environment environment, ClassLoader classLoader,
            ResourceLoader resourceLoader) {
        if (ClassUtils.isPresent("com.mitchellbosecke.pebble.PebbleEngine", classLoader)) {
            PropertyResolver resolver = new RelaxedPropertyResolver(environment, "pebble.");
            String prefix = resolver.getProperty("prefix", PebbleProperties.DEFAULT_PREFIX);
            String suffix = resolver.getProperty("suffix", PebbleProperties.DEFAULT_SUFFIX);
            return resourceLoader.getResource(prefix + view + suffix).exists();
        } else {
            return false;
        }
    }

}

package com.mitchellbosecke.pebble.boot.autoconfigure;

import org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider;
import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.core.env.Environment;
import org.springframework.core.env.PropertyResolver;
import org.springframework.core.io.ResourceLoader;
import org.springframework.util.ClassUtils;

public class PebbleTemplateAvailabilityProvider implements TemplateAvailabilityProvider {

    @Override
    public boolean isTemplateAvailable(String view, Environment environment, ClassLoader classLoader,
            ResourceLoader resourceLoader) {
        if (ClassUtils.isPresent("com.mitchellbosecke.pebble.PebbleEngine", classLoader)) {
            PropertyResolver resolver = new RelaxedPropertyResolver(environment, "pebble.");
            String prefix = resolver.getProperty("prefix", PebbleProperties.DEFAULT_PREFIX);
            String suffix = resolver.getProperty("suffix", PebbleProperties.DEFAULT_SUFFIX);
            return resourceLoader.getResource(ResourceLoader.CLASSPATH_URL_PREFIX + prefix + view + suffix).exists();
        } else {
            return false;
        }
    }

}

Fix issue with loading error templates for specific error codes.


package uk.co.automatictester.lightning.gradle.plugin;

import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.GradleRunner;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import java.io.File;

import static org.gradle.internal.impldep.org.hamcrest.MatcherAssert.assertThat;
import static org.gradle.internal.impldep.org.hamcrest.core.Is.is;
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS;

public class GradleCompatibilityTest {

    @Test(dataProvider = "getGradleVersions")
    public void checkGradleCompatibility(String gradleVersion) {
        BuildResult result = GradleRunner.create()
                .withGradleVersion(gradleVersion)
                .withProjectDir(new File("src/integrationTest/resources/build/complete"))
                .withArguments(":report")
                .withPluginClasspath()
                .build();

        assertThat(result.task(":report").getOutcome(), is(SUCCESS));
    }

    @DataProvider
    private Object[][] getGradleVersions() {
        return new Object[][] {
                new Object[] { "2.14.1" },
                new Object[] { "3.5" },
                new Object[] { "4.0" }
        };
    }
}

package uk.co.automatictester.lightning.gradle.plugin;

import org.gradle.testkit.runner.BuildResult;
import org.gradle.testkit.runner.GradleRunner;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import java.io.File;

import static org.gradle.internal.impldep.org.hamcrest.MatcherAssert.assertThat;
import static org.gradle.internal.impldep.org.hamcrest.core.Is.is;
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS;

public class GradleCompatibilityTest {

    @Test(dataProvider = "getGradleVersions")
    public void checkGradleCompatibility(String gradleVersion) {
        BuildResult result = GradleRunner.create()
                .withGradleVersion(gradleVersion)
                .withProjectDir(new File("src/integrationTest/resources/build/complete"))
                .withArguments(":report")
                .withPluginClasspath()
                .build();

        assertThat(result.task(":report").getOutcome(), is(SUCCESS));
    }

    @DataProvider
    private Object[][] getGradleVersions() {
        return new Object[][] {
                new Object[] { "2.14.1" },
                new Object[] { "3.5" }
        };
    }
}

Drop Gradle 4.0 compatibility test - we are using Gradle 4.8 wrapper anyway


/**
 * Copyright (c) 2011 RedEngine Ltd, http://www.RedEngine.co.nz. All rights reserved.
 *
 * This program is licensed to you under the Apache License Version 2.0,
 * and you may not use this file except in compliance with the Apache License Version 2.0.
 * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the Apache License Version 2.0 is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
 */
package co.nfigured.example.helloworld.v1;

import javax.jws.WebService;

@WebService
public interface CountingWorld {

  Integer count();

}

/**
 * Copyright (c) 2011 RedEngine Ltd, http://www.RedEngine.co.nz. All rights reserved.
 *
 * This program is licensed to you under the Apache License Version 2.0,
 * and you may not use this file except in compliance with the Apache License Version 2.0.
 * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the Apache License Version 2.0 is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
 */
package co.nfigured.example.helloworld.v1;

import javax.jws.WebService;

@WebService
public interface CountingWorld {

  Integer count();

  void stop();

  void start();

}

Include a stop and start to ensure client and server are really talking to each other


package ee.tuleva.onboarding.auth.session;

import java.io.Serializable;
import java.util.Optional;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

@Component
public class GenericSessionStore {

  public <T extends Serializable> void save(T sessionAttribute) {
    session().setAttribute(sessionAttribute.getClass().getName(), sessionAttribute);
  }

  public <T extends Serializable> Optional<T> get(Class clazz) {
    @SuppressWarnings("unchecked")
    T sessionAttribute = (T) session().getAttribute(clazz.getName());

    if (sessionAttribute == null) {
      return Optional.empty();
    }

    return Optional.of(sessionAttribute);
  }

  private static HttpSession session() {
    ServletRequestAttributes attr =
        (ServletRequestAttributes) RequestContextHolder.currentRequestAttributes();
    boolean allowCreate = true;
    return attr.getRequest().getSession(allowCreate);
  }
}

package ee.tuleva.onboarding.auth.session;

import java.io.Serial;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Component;

@Component
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public class GenericSessionStore implements Serializable {

  @Serial private static final long serialVersionUID = -648103071415508424L;

  private final Map<String, Object> sessionAttributes = new HashMap<>();

  public <T extends Serializable> void save(T sessionAttribute) {
    sessionAttributes.put(sessionAttribute.getClass().getName(), sessionAttribute);
  }

  public <T extends Serializable> Optional<T> get(Class clazz) {
    @SuppressWarnings("unchecked")
    T sessionAttribute = (T) sessionAttributes.get(clazz.getName());

    if (sessionAttribute == null) {
      return Optional.empty();
    }

    return Optional.of(sessionAttribute);
  }
}

Replace manual session handling with spring session scoped bean


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

package org.vaadin.addons.locationtextfield;

import java.io.Serializable;
import java.util.Collection;

/**
 * Inteface providing {@link GeocodedLocation}s based on an address
 */
public interface LocationProvider extends Serializable {
    Collection<GeocodedLocation> geocode(String address) throws GeocodingException;
}

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

package org.vaadin.addons.locationtextfield;

import java.io.Serializable;
import java.util.Collection;

/**
 * Inteface providing {@link GeocodedLocation}s based on an address
 */
public interface LocationProvider<T extends GeocodedLocation> extends Serializable {
    Collection<T> geocode(String address) throws GeocodingException;
}

Allow for specifying a subclass of GeocodedLocation


package com.codenvy.ide.ext.datasource.client.sqllauncher;

import com.google.gwt.i18n.client.Messages;

public interface SqlRequestLauncherConstants extends Messages {

    @DefaultMessage("Open SQL editor")
    String menuEntryOpenSqlEditor();

    @DefaultMessage("SQL editor")
    String sqlEditorWindowTitle();

    @DefaultMessage("Select datasource")
    String selectDatasourceLabel();

    @DefaultMessage("Result limit")
    String resultLimitLabel();

    @DefaultMessage("Execute")
    String executeButtonLabel();

    @DefaultMessage("{0} rows.")
    String updateCountMessage(int count);
}

package com.codenvy.ide.ext.datasource.client.sqllauncher;

import com.google.gwt.i18n.client.LocalizableResource.DefaultLocale;
import com.google.gwt.i18n.client.Messages;

@DefaultLocale("en")
public interface SqlRequestLauncherConstants extends Messages {

    @DefaultMessage("Open SQL editor")
    String menuEntryOpenSqlEditor();

    @DefaultMessage("SQL editor")
    String sqlEditorWindowTitle();

    @DefaultMessage("Select datasource")
    String selectDatasourceLabel();

    @DefaultMessage("Result limit")
    String resultLimitLabel();

    @DefaultMessage("Execute")
    String executeButtonLabel();

    @DefaultMessage("{0} rows.")
    @AlternateMessage({"one", "{0} row."})
    String updateCountMessage(@PluralCount int count);
}

Fix plural form for number of rows message


package org.tkirill.teamcity.bisectPlugin;

import jetbrains.buildServer.controllers.BaseFormXmlController;
import jetbrains.buildServer.serverSide.SBuildServer;
import jetbrains.buildServer.web.openapi.WebControllerManager;
import org.jdom.Element;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class BisectController extends BaseFormXmlController {
    public BisectController(SBuildServer server, WebControllerManager manager) {
        super(server);
        manager.registerController("/bisect/run.html", this);
    }

    @Override
    protected ModelAndView doGet(HttpServletRequest request, HttpServletResponse response) {
        return null;
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response, Element xmlResponse) {
        response.setStatus(200);
//        String buildId = request.getParameter("buildId");
//        if (buildId != null) {
//            if (storage.getValue("bisect-plugin-build-" + buildId) != null) {
//                response.setStatus(400);
//                return;
//            }
//            storage.putValue("bisect-plugin-build-" + buildId, "started");
//        }
    }
}

package org.tkirill.teamcity.bisectPlugin;

import jetbrains.buildServer.controllers.BaseFormXmlController;
import jetbrains.buildServer.serverSide.CustomDataStorage;
import jetbrains.buildServer.serverSide.SBuild;
import jetbrains.buildServer.serverSide.SBuildServer;
import jetbrains.buildServer.web.openapi.WebControllerManager;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class BisectController extends BaseFormXmlController {
    public BisectController(SBuildServer server, WebControllerManager manager) {
        super(server);
        manager.registerController("/bisect/run.html", this);
    }

    @Override
    protected ModelAndView doGet(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) {
        return null;
    }

    @Override
    protected void doPost(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @NotNull Element xmlResponse) {
        long buildId = Long.parseLong(request.getParameter("buildId"));
        SBuild build = myServer.findBuildInstanceById(buildId);
        if (build == null) {
            response.setStatus(404);
            return;
        }

        CustomDataStorage storage = build.getBuildType().getCustomDataStorage("bisectPlugin");
        storage.putValue(String.valueOf(buildId), "running");
        response.setStatus(200);
//        String buildId = request.getParameter("buildId");
//        if (buildId != null) {
//            if (storage.getValue("bisect-plugin-build-" + buildId) != null) {
//                response.setStatus(400);
//                return;
//            }
//            storage.putValue("bisect-plugin-build-" + buildId, "started");
//        }
    }
}

Store the flag designating that bisect is running.


package org.edx.mobile.module.db.impl;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

class DbOperationSingleValueByRawQuery<T> extends DbOperationBase<T> {

    private String sqlQuery;
    private String[] selectionArgs;
    private Class<T> columnType;

    DbOperationSingleValueByRawQuery(String sqlQuery, String[] selectionArgs, Class<T> valueType) {
        this.sqlQuery = sqlQuery;
        this.selectionArgs = selectionArgs;
        this.columnType = valueType;
    }

    @Override
    public T execute(SQLiteDatabase db) {
        Cursor c = db.rawQuery(sqlQuery, selectionArgs);

        if (c.moveToFirst()) {
            if (columnType == Long.class) {
                Long column = c.getLong(0);
                return (T) column;
            } else if (columnType == String.class) {
                String column = c.getString(0);
                return (T) column;
            } else if (columnType == Integer.class) {
                Integer column = c.getInt(0);
                return (T) column;
            } else {
                logger.warn("Class types does NOT match for: " + columnType);
            }
        }

        c.close();

        return null;
    }

}

package org.edx.mobile.module.db.impl;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

class DbOperationSingleValueByRawQuery<T> extends DbOperationBase<T> {

    private String sqlQuery;
    private String[] selectionArgs;
    private Class<T> columnType;

    DbOperationSingleValueByRawQuery(String sqlQuery, String[] selectionArgs, Class<T> valueType) {
        this.sqlQuery = sqlQuery;
        this.selectionArgs = selectionArgs;
        this.columnType = valueType;
    }

    @Override
    public T execute(SQLiteDatabase db) {
        Cursor c = db.rawQuery(sqlQuery, selectionArgs);

        T result = null;
        if (c.moveToFirst()) {
            if (columnType == Long.class) {
                Long column = c.getLong(0);
                result = (T) column;
            } else if (columnType == String.class) {
                String column = c.getString(0);
                result = (T) column;
            } else if (columnType == Integer.class) {
                Integer column = c.getInt(0);
                result = (T) column;
            } else {
                logger.warn("Class types does NOT match for: " + columnType);
            }
        }

        c.close();

        return result;
    }

}

Fix cursor not closed in database single value query

The cursor was closed too late in DbOperationSingleValueByRawQuery,
after the value was returned. The only case where it was closed was when
there was an unsupported column type specified. This commit fixes this
issue.


package org.csstudio.platform.model;

/**
 * Interface to a control system process variable with archive data source.
 * <p>
 *
 * @see IProcessVariableName
 * @see IArchiveDataSource
 * @author Jan Hatje and Helge Rickens
 *
 */
public interface IProcessVariableWithSample extends IProcessVariable {
	/**
	 * The global type id.
	 */
	String TYPE_ID = "css:processVariableWithSample"; //$NON-NLS-1$

	/**
	 *
	 *
	 * @return
	 */
	double[] getSampleValue();
	/**
	 *
	 *
	 * @return
	 */
	double[] getTimeStamp();
	/**
	 *
	 *
	 * @return
	 */
	String[] getStatus();
	/**
	 *
	 *
	 * @return
	 */
	String[] getSeverity();
	/**
	 *
	 *
	 * @return
	 */
	int getDBRTyp();
	/**
	 *
	 *
	 * @return
	 */
	String getEGU();
	/**
	 *
	 *
	 * @return
	 */
	int getPrecision();
	/**
	 *
	 *
	 * @return
	 */
	double getLow();
	/**
	 *
	 *
	 * @return
	 */
	double getHigh();

}

package org.csstudio.platform.model;

/**
 * Interface to a control system process variable with archive data source.
 * <p>
 *
 * @see IProcessVariableName
 * @see IArchiveDataSource
 * @author Jan Hatje and Helge Rickens
 *
 * TODO It's actually ... process variable with actual data.
 * TODO This is limited to double-type samples.
 * Use either DAL, or the intermediate Value from org.csstudio.utility.pv,
 * which supports more data types as well as their MetaData.
 */
public interface IProcessVariableWithSample extends IProcessVariable {
	/**
	 * The global type id.
	 */
	String TYPE_ID = "css:processVariableWithSample"; //$NON-NLS-1$

	/**
	 *
	 * @return
	 */
	double[] getSampleValue();
	/**
	 *
	 * TODO Use the Timestamp (ITimestamp) found elsewhere in this plugin.
	 * @return
	 */
	double[] getTimeStamp();
	/**
	 *
	 *
	 * @return
	 */
	String[] getStatus();
	/**
	 *
	 *
	 * @return
	 */
	String[] getSeverity();
	/**
	 *
	 *
	 * @return
	 */
	int getDBRTyp();
	/**
	 *
	 *
	 * @return
	 */
	String getEGU();
	/**
	 *
	 *
	 * @return
	 */
	int getPrecision();
	/**
	 *
	 *
	 * @return
	 */
	double getLow();
	/**
	 *
	 *
	 * @return
	 */
	double getHigh();

}

TODO: Replace with something that handles more than just 'double' ...


package com.github.thomasfischl.aihome.controller;

import java.io.File;

import com.github.thomasfischl.aihome.communication.sensor.SensorDataGroup;
import com.github.thomasfischl.aihome.controller.rule.RuleEngine;

public class SensorDataProcessorService extends AbstractPipelineService {

  private RuleEngine engine = new RuleEngine(new File("/tmp/rule.config"));

  public SensorDataProcessorService(AbstractPipelineService nextService) {
    super(nextService);
  }

  public void process(SensorDataGroup data) {
    SensorDataGroup newData = engine.evaluate(data);
    executeNextService(newData);
  }

}

package com.github.thomasfischl.aihome.controller;

import java.io.File;

import com.github.thomasfischl.aihome.communication.sensor.SensorDataGroup;
import com.github.thomasfischl.aihome.controller.rule.RuleEngine;

public class SensorDataProcessorService extends AbstractPipelineService {

  private RuleEngine engine = new RuleEngine(new File("/home/pi/aihome/rule.config"));

  public SensorDataProcessorService(AbstractPipelineService nextService) {
    super(nextService);
  }

  public void process(SensorDataGroup data) {
    SensorDataGroup newData = engine.evaluate(data);
    executeNextService(newData);
  }

}

Use other location for rule.config file

Use other location for rule.config file


package io.github.mikesaelim.poleposition.persistence;

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

public interface ArticlePersistenceRepository extends JpaRepository<ArticlePersistence, String> {
}

package io.github.mikesaelim.poleposition.persistence;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface ArticlePersistenceRepository extends JpaRepository<ArticlePersistence, String> {
}

Make IntelliJ stop crying by adding unnecessary @Repository annotation


// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.content.cluster;

import com.yahoo.config.application.api.DeployLogger;
import com.yahoo.vespa.model.builder.xml.dom.ModelElement;
import com.yahoo.vespa.model.content.ResourceLimits;

import java.util.logging.Level;

/**
 * Builder for feed block resource limits.
 *
 * @author geirst
 */
public class DomResourceLimitsBuilder {

    public static ResourceLimits.Builder createBuilder(ModelElement contentXml, boolean hostedVespa, DeployLogger deployLogger) {
        ResourceLimits.Builder builder = new ResourceLimits.Builder();
        ModelElement resourceLimits = contentXml.child("resource-limits");
        if (resourceLimits == null) { return builder; }

        if (hostedVespa) {
            deployLogger.log(Level.WARNING, "Element " + resourceLimits + " is not allowed, default limits will be used");
            // TODO: Throw exception when we are sure nobody is using this
            //throw new IllegalArgumentException("Element " + element + " is not allowed to be set, default limits will be used");
            return builder;
        }
        if (resourceLimits.child("disk") != null) {
            builder.setDiskLimit(resourceLimits.childAsDouble("disk"));
        }
        if (resourceLimits.child("memory") != null) {
            builder.setMemoryLimit(resourceLimits.childAsDouble("memory"));
        }
        return builder;
    }

}

// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.content.cluster;

import com.yahoo.config.application.api.DeployLogger;
import com.yahoo.vespa.model.builder.xml.dom.ModelElement;
import com.yahoo.vespa.model.content.ResourceLimits;

import java.util.logging.Level;

/**
 * Builder for feed block resource limits.
 *
 * @author geirst
 */
public class DomResourceLimitsBuilder {

    public static ResourceLimits.Builder createBuilder(ModelElement contentXml, boolean hostedVespa, DeployLogger deployLogger) {
        ResourceLimits.Builder builder = new ResourceLimits.Builder();
        ModelElement resourceLimits = contentXml.child("resource-limits");
        if (resourceLimits == null) { return builder; }

        if (hostedVespa) {
            deployLogger.logApplicationPackage(Level.WARNING, "Element " + resourceLimits +
                                                              " is not allowed, default limits will be used");
            // TODO: Throw exception when we are sure nobody is using this
            //throw new IllegalArgumentException("Element " + element + " is not allowed to be set, default limits will be used");
            return builder;
        }
        if (resourceLimits.child("disk") != null) {
            builder.setDiskLimit(resourceLimits.childAsDouble("disk"));
        }
        if (resourceLimits.child("memory") != null) {
            builder.setMemoryLimit(resourceLimits.childAsDouble("memory"));
        }
        return builder;
    }

}

Use logApplicationPackage so users might get a notification


package com.indeed.proctor.groups;

import junit.framework.Assert;
import org.junit.Test;

import static com.indeed.proctor.groups.UppercaseFirstCharacterGroups.Test.UPPERCASE_FIRST_CHARACTER_TEST;

/**
 *
 */
public class TestUppercaseFirstCharacterGroups {

    @Test
    public void testUppercaseFirstCharacter() {
        Assert.assertEquals("Uppercase_first_character_test", UPPERCASE_FIRST_CHARACTER_TEST.getName());
    }
}

package com.indeed.proctor.groups;

import junit.framework.Assert;
import org.junit.Test;

import static com.indeed.proctor.groups.UppercaseFirstCharacterGroups.Test.UPPERCASE_FIRST_CHARACTER_TEST;

/**
 * Test to ensure that Proctor tests that start with an uppercase character retain an unnormalized name in the
 * generated groups class.
 */
public class TestUppercaseFirstCharacterGroups {

    @Test
    public void testUppercaseFirstCharacter() {
        Assert.assertEquals("Uppercase_first_character_test", UPPERCASE_FIRST_CHARACTER_TEST.getName());
    }
}

Add a comment to explain the test

PROC-235: Add a comment to explain the test


package com.mgaetan89.showsrage.fragment;

import com.google.gson.Gson;
import com.mgaetan89.showsrage.R;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.Arrays;
import java.util.Collection;

import static org.assertj.core.api.Assertions.assertThat;

@RunWith(Parameterized.class)
public class ShowsSectionFragment_GetAdapterLayoutResourceTest {
	@Parameterized.Parameter(1)
	public int layoutId;

	@Parameterized.Parameter(0)
	public String preferedShowLayout;

	@Test
	public void getAdapterLayoutResource() {
		assertThat(ShowsSectionFragment.getAdapterLayoutResource(this.preferedShowLayout)).isEqualTo(this.layoutId);
	}

	@Parameterized.Parameters
	public static Collection<Object[]> data() {
		Gson gson = new Gson();

		return Arrays.asList(new Object[][]{
				{null, R.layout.adapter_shows_list_content_poster},
				{"", R.layout.adapter_shows_list_content_poster},
				{"banner", R.layout.adapter_shows_list_content_banner},
				{"fan_art", R.layout.adapter_shows_list_content_poster},
				{"poster", R.layout.adapter_shows_list_content_poster},
		});
	}
}

package com.mgaetan89.showsrage.fragment;

import com.mgaetan89.showsrage.R;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.Arrays;
import java.util.Collection;

import static org.assertj.core.api.Assertions.assertThat;

@RunWith(Parameterized.class)
public class ShowsSectionFragment_GetAdapterLayoutResourceTest {
	@Parameterized.Parameter(1)
	public int layoutId;

	@Parameterized.Parameter(0)
	public String preferredShowLayout;

	@Test
	public void getAdapterLayoutResource() {
		assertThat(ShowsSectionFragment.getAdapterLayoutResource(this.preferredShowLayout)).isEqualTo(this.layoutId);
	}

	@Parameterized.Parameters
	public static Collection<Object[]> data() {
		return Arrays.asList(new Object[][]{
				{null, R.layout.adapter_shows_list_content_poster},
				{"", R.layout.adapter_shows_list_content_poster},
				{"banner", R.layout.adapter_shows_list_content_banner},
				{"fan_art", R.layout.adapter_shows_list_content_poster},
				{"poster", R.layout.adapter_shows_list_content_poster},
		});
	}
}

Remove unused variable and fix typo

Remove unused variable and fix typo


package org.gemoc.sample.tfsm.design.services;

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

import org.gemoc.gemoc_language_workbench.extensions.sirius.services.AbstractGemocAnimatorServices;

public class TFSMAnimatorServices extends AbstractGemocAnimatorServices {

	@Override
	protected List<StringCouple> getRepresentationRefreshList() {
		final List<StringCouple> res = new ArrayList<StringCouple>();

		res.add(new StringCouple("TFSM", "Animator"));

		return res;
	}

}

package org.gemoc.sample.tfsm.design.services;

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

import org.gemoc.gemoc_language_workbench.extensions.sirius.services.AbstractGemocAnimatorServices;
import org.gemoc.gemoc_modeling_workbench.ui.debug.sirius.services.AbstractGemocDebuggerServices.StringCouple;

public class TFSMAnimatorServices extends AbstractGemocAnimatorServices {

	@Override
	protected List<StringCouple> getRepresentationRefreshList() {
		final List<StringCouple> res = new ArrayList<StringCouple>();

		res.add(new StringCouple("TrafficControl","Debug"));
		res.add(new StringCouple("Semaphore","Debug"));

		res.add(new StringCouple("TrafficControl","Animation"));
		res.add(new StringCouple("Semaphore","Animation"));

		//res.add(new StringCouple("TFSM","Animator"));

		return res;
	}

}

Fix content of the map.

Fix content of the map.


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

import org.json.JSONException;
import org.json.JSONObject;

import uk.ac.bolton.spaws.model.impl.Actor;

public class ActorFactory {

	public static Actor createActor(JSONObject document) throws JSONException{

		if (document.has("resource_data")){
			if (document.getJSONObject("resource_data").has("activity")){
				JSONObject activity = document.getJSONObject("resource_data").getJSONObject("activity");
				if (activity.has("actor")){
					Actor actor = new Actor();
					actor.setName(activity.getJSONObject("actor").getString("displayName"));
					actor.setUrl(activity.getJSONObject("actor").getString("url"));
					return actor;
				}
			}
		}
		return null;

	}

}

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

import org.json.JSONException;
import org.json.JSONObject;

import uk.ac.bolton.spaws.model.impl.Actor;

public class ActorFactory {

	public static Actor createActor(JSONObject document) throws JSONException{

		if (document.has("resource_data")){
			if (document.getJSONObject("resource_data").has("activity")){
				JSONObject activity = document.getJSONObject("resource_data").getJSONObject("activity");
				if (activity.has("actor")){
					Actor actor = new Actor();
					JSONObject jsonActor = activity.getJSONObject("actor");
					actor.setName(jsonActor.getString("displayName"));
					if(jsonActor.has("url")){
						actor.setUrl(jsonActor.getString("url"));
					}
					return actor;
				}
			}
		}
		return null;

	}

}

Check for existence of URL when parsing actor info


package org.ovirt.engine.api.restapi.utils;

import org.ovirt.engine.core.compat.Guid;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class GuidUtils {

    private static final String MD5_SECURITY_ALGORITHM = "MD5";

    public static Guid asGuid(String id) {
        try {
            return new Guid(id);
        }catch (IllegalArgumentException e) {
            throw new MalformedIdException(e);
        }
    }

    /**
     * There are some business entities in the API, which are not regarded as business entities in the engine, and
     * therefore they don't have IDs. The API generates uniqute GUIDs for them, according to their attributes. This
     * method accepts one or more string attributes, concatenates them, and using Md5 hash to generate a unique Guid for
     * them.
     *
     * @param args
     *            one or more strings, guid will be generated from them
     * @return unique Guid generated from the given strings.
     */
    public static Guid generateGuidUsingMd5(String... args) {
        String id = "";
        for (String arg : args) {
            id = id + arg;
        }
        byte[] hash;
        try {
            hash = MessageDigest.getInstance(MD5_SECURITY_ALGORITHM).digest(id.getBytes());
        } catch (NoSuchAlgorithmException e) {
            throw new IllegalStateException(e); // never happens, MD5 algorithm exists
        }
        return new Guid(hash, true);
    }
}

package org.ovirt.engine.api.restapi.utils;

import org.ovirt.engine.core.compat.Guid;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class GuidUtils {

    private static final String MD5_SECURITY_ALGORITHM = "MD5";

    public static Guid asGuid(String id) {
        try {
            return new Guid(id);
        }catch (IllegalArgumentException e) {
            throw new MalformedIdException(e);
        }
    }

    /**
     * There are some business entities in the API, which are not regarded as business entities in the engine, and
     * therefore they don't have IDs. The API generates uniqute GUIDs for them, according to their attributes. This
     * method accepts one or more string attributes, concatenates them, and using Md5 hash to generate a unique Guid for
     * them.
     *
     * @param args
     *            one or more strings, guid will be generated from them
     * @return unique Guid generated from the given strings.
     */
    public static Guid generateGuidUsingMd5(String... args) {
        StringBuilder builder = new StringBuilder();
        for (String arg : args) {
            builder.append(arg);
        }
        byte[] hash;
        try {
            hash = MessageDigest.getInstance(MD5_SECURITY_ALGORITHM).digest(builder.toString().getBytes());
        } catch (NoSuchAlgorithmException e) {
            throw new IllegalStateException(e); // never happens, MD5 algorithm exists
        }
        return new Guid(hash, true);
    }
}

restapi: Use StringBuilder for String concatenation

Change-Id: Iee94056b785ef76cffafd4b2d07ae001dfab7674
Signed-off-by: Ori Liel <4fcecd40a9c0dad06aec9ecf8a7829d6470e6321@redhat.com>


/**
 * Copyright (c) 2010 IBM Corporation
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *
 * $Id$
 */
package org.openhealthtools.mdht.uml.hl7.datatypes.operations;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;

/**
 * This class represents a suite of Junit 4 test cases for HL7 Datatypes.
 */
@RunWith(Suite.class)
@Suite.SuiteClasses( { ADOperationsTest.class, BNOperationsTest.class,
	EDOperationsTest.class, ENOperationsTest.class, ONOperationsTest.class,
	PNOperationsTest.class, TNOperationsTest.class })
	public class ALLDatatypeOperationsTests {
	// Nothing
} // ALLDatatypeOperationsTests

/**
 * Copyright (c) 2010 IBM Corporation
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *
 * $Id$
 */
package org.openhealthtools.mdht.uml.hl7.datatypes.operations;

import junit.framework.JUnit4TestAdapter;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
/**
 * This class represents a suite of Junit 4 test cases for HL7 Datatypes.
 */
@RunWith(Suite.class)
@Suite.SuiteClasses( { ADOperationsTest.class, BNOperationsTest.class,
	EDOperationsTest.class, ENOperationsTest.class, ONOperationsTest.class,
	PNOperationsTest.class, TNOperationsTest.class })
	public class ALLDatatypeOperationsTests {

	public static junit.framework.Test suite() {
	    return new JUnit4TestAdapter(ALLDatatypeOperationsTests.class);
	}
	// Nothing
} // ALLDatatypeOperationsTests

Add junit ant task support

Add junit ant task support


package com.google.sps.tests;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public final class AuthInfoTest {
  @Test
  public void example() {
    Assert.assertEquals(1 + 1, 2);
  }
}

package com.google.sps.tests;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public final class AuthInfoTest {

  @Test
  public void example() {
    // placeholder test to show that tests are evaluated
    Assert.assertEquals(1 + 1, 2);
    Assert.assertEquals(2 * 2, 4);
    Assert.assertEquals(1337, 1500 - 163);
  }
}

Add example tests to show build success

Add example tests to show build success


package gov.nih.nci.calab.dto.workflow;

public class AssayBean {

	private String assayId;
	private String assayName;
	private String assayType;

	public AssayBean(String assayId, String assayName, String assayType) {
		super();
		// TODO Auto-generated constructor stub
		this.assayId = assayId;
		this.assayName = assayName;
		this.assayType = assayType;
	}
	public String getAssayId() {
		return assayId;
	}
	public void setAssayId(String assayId) {
		this.assayId = assayId;
	}
	public String getAssayName() {
		return assayName;
	}
	public void setAssayName(String assayName) {
		this.assayName = assayName;
	}
	public String getAssayType() {
		return assayType;
	}
	public void setAssayType(String assayType) {
		this.assayType = assayType;
	}

}

package gov.nih.nci.calab.dto.workflow;

public class AssayBean {

	private String assayId;
	private String assayName;
	private String assayType;
	private String assayStr;

	public AssayBean(String assayId, String assayName, String assayType) {
		super();
		// TODO Auto-generated constructor stub
		this.assayId = assayId;
		this.assayName = assayName;
		this.assayType = assayType;
	}
	public String getAssayId() {
		return assayId;
	}
	public void setAssayId(String assayId) {
		this.assayId = assayId;
	}
	public String getAssayName() {
		return assayName;
	}
	public void setAssayName(String assayName) {
		this.assayName = assayName;
	}
	public String getAssayType() {
		return assayType;
	}
	public void setAssayType(String assayType) {
		this.assayType = assayType;
	}
	public String getAssayStr() {
		return this.assayType + " : " + this.assayName;
	}
//	public void setAssayStr(String assayStr) {
//		this.assayStr = assayStr;
//	}

}

Add an additional property assayStr

Add an additional property assayStr

SVN-Revision: 7349


package io.elssa.net;

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

public abstract class MessageRouterBase {

    private List<MessageListener> listeners
        = Collections.synchronizedList(new ArrayList<>());

    /**
     * Adds a message listener (consumer) to this MessageRouter.  Listeners
     * receive messages that are published by this MessageRouter.
     *
     * @param listener {@link MessageListener} that will consume messages
     * published by this MessageRouter.
     */
    public void addListener(MessageListener listener) {
        listeners.add(listener);
    }

    public void removeListener(MessageListener listener) {
        listeners.remove(listener);
    }

    public void onConnnect(NetworkEndpoint endpoint) {
        for (MessageListener listener : listeners) {
            listener.onConnect(endpoint);
        }
    }

    public void onDisconnect(NetworkEndpoint endpoint) {
        for (MessageListener listener : listeners) {
            listener.onDisconnect(endpoint);
        }
    }

    public void onMessage(ElssaMessage msg) {
        for (MessageListener listener : listeners) {
            listener.onMessage(msg);
        }
    }
}

package io.elssa.net;

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

public abstract class MessageRouterBase {

    private List<MessageListener> listeners
        = Collections.synchronizedList(new ArrayList<>());

    /**
     * Adds a message listener (consumer) to this MessageRouter.  Listeners
     * receive messages that are published by this MessageRouter.
     *
     * @param listener {@link MessageListener} that will consume messages
     * published by this MessageRouter.
     */
    public void addListener(MessageListener listener) {
        listeners.add(listener);
    }

    public void removeListener(MessageListener listener) {
        listeners.remove(listener);
    }

    protected void onConnnect(NetworkEndpoint endpoint) {
        for (MessageListener listener : listeners) {
            listener.onConnect(endpoint);
        }
    }

    protected void onDisconnect(NetworkEndpoint endpoint) {
        for (MessageListener listener : listeners) {
            listener.onDisconnect(endpoint);
        }
    }

    protected void onMessage(ElssaMessage msg) {
        for (MessageListener listener : listeners) {
            listener.onMessage(msg);
        }
    }
}

Update message passing method visibility


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

package co.phoenixlab.discord.api.exceptions;

public class RateLimitExceededException extends ApiException {

    private long retryIn;

    public RateLimitExceededException() {
        super();
    }

    public RateLimitExceededException(String msg) {
        super(msg);
    }

    public RateLimitExceededException(long retryIn) {
        super("Retry in " + retryIn);
        this.retryIn = retryIn;
    }

    public RateLimitExceededException(String msg, long retryIn) {
        super("Retry in " + retryIn + ": " + msg);
        this.retryIn = retryIn;
    }

}

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

package co.phoenixlab.discord.api.exceptions;

import lombok.Getter;

public class RateLimitExceededException extends ApiException {

    @Getter
    private long retryIn;

    public RateLimitExceededException() {
        super();
    }

    public RateLimitExceededException(String msg) {
        super(msg);
    }

    public RateLimitExceededException(long retryIn) {
        super("Retry in " + retryIn);
        this.retryIn = retryIn;
    }

    public RateLimitExceededException(String msg, long retryIn) {
        super("Retry in " + retryIn + ": " + msg);
        this.retryIn = retryIn;
    }
}

Add getter for retry in

Add getter for retry in


/*
 * Copyright 2020 The Bazel Authors. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.idea.blaze.android.run.binary.mobileinstall;

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

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

  /** Returns whether mobile install deployments should happen via the studio deployer. */
  public static boolean isEnabled() {
    if (!SystemInfo.isLinux) {
      // TODO(b/197761450): Enable this for Macs after mdproxy related issues are sorted out.
      return false;
    }
    return useStudioDeployer.isEnabled();
  }

  private StudioDeployerExperiment() {}
}

/*
 * Copyright 2020 The Bazel Authors. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.google.idea.blaze.android.run.binary.mobileinstall;

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

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

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

  private StudioDeployerExperiment() {}
}

Build android_binary targets on rabbit

BlazeApkBuildStep: Build android_binary targets on rabbit

This CL implements an alternate flow for building android_binary
targets that is specific to Google3/Blaze. In this iteration, it
only supports building on rabbit and then deploying locally via
Studio. It is only enabled in a very limited set of conditions:
the IDE is running off corp, and mdproxy is running w/o sshfs
enabled.

Other types of build (blaze and rabbit via mdproxy) will be
supported once b/225936997 is fixed.

Tests will be added in a follow up CL.

PiperOrigin-RevId: 436469354


/*
 * Copyright (C) 2012 Archie L. Cobbs. All rights reserved.
 *
 * $Id$
 */

package org.dellroad.stuff.pobj;

import java.util.Set;

import javax.validation.ConstraintViolation;

/**
 * Runtime exception thrown during {@link PersistentObject} operations.
 */
@SuppressWarnings("serial")
public class PersistentObjectValidationException extends PersistentObjectException {

    private final Set<ConstraintViolation<?>> violations;

    /**
     * Constructor.
     *
     * @param violations set of violations
     * @throws IllegalArgumentException if {@code violations} is null
     */
    public PersistentObjectValidationException(Set<ConstraintViolation<?>> violations) {
        super("object failed to validate: " + violations);
        if (violations == null)
            throw new IllegalArgumentException("null violations");
        this.violations = violations;
    }

    /**
     * Get the set of constraint violations.
     */
    public Set<ConstraintViolation<?>> getViolations() {
        return this.violations;
    }
}

/*
 * Copyright (C) 2012 Archie L. Cobbs. All rights reserved.
 *
 * $Id$
 */

package org.dellroad.stuff.pobj;

import java.util.Set;

import javax.validation.ConstraintViolation;

/**
 * Runtime exception thrown during {@link PersistentObject} operations.
 */
@SuppressWarnings("serial")
public class PersistentObjectValidationException extends PersistentObjectException {

    private final Set<ConstraintViolation<?>> violations;

    /**
     * Constructor.
     *
     * @param violations set of violations
     * @throws IllegalArgumentException if {@code violations} is null
     */
    public PersistentObjectValidationException(Set<ConstraintViolation<?>> violations) {
        this.violations = violations;
    }

    /**
     * Get the set of constraint violations.
     */
    public Set<ConstraintViolation<?>> getViolations() {
        return this.violations;
    }

    private static String generateMessage(Set<ConstraintViolation<?>> violations) {
        if (violations == null)
            throw new IllegalArgumentException("null violations");
        StringBuilder buf = new StringBuilder("object failed to validate with " + violations.size() + " violation(s): ");
        boolean first = true;
        for (ConstraintViolation<?> violation : violations) {
            if (first)
                first = false;
            else
                buf.append("; ");
            buf.append("[" + violation.getPropertyPath() + "]: " + violation.getMessage());
        }
        return buf.toString();
    }
}

Improve exception message from previous commit.


/*
 * Copyright (c) 2012 Evolveum
 *
 * The contents of this file are subject to the terms
 * of the Common Development and Distribution License
 * (the License). You may not use this file except in
 * compliance with the License.
 *
 * You can obtain a copy of the License at
 * http://www.opensource.org/licenses/cddl1 or
 * CDDLv1.0.txt file in the source code distribution.
 * See the License for the specific language governing
 * permission and limitations under the License.
 *
 * If applicable, add the following below the CDDL Header,
 * with the fields enclosed by brackets [] replaced by
 * your own identifying information:
 *
 * Portions Copyrighted 2012 [name of copyright owner]
 */

package com.evolveum.midpoint.web.page.admin.configuration.dto;

import java.io.Serializable;

/**
 * @author lazyman
 */
public class ObjectViewDto implements Serializable {

    private String oid;
    private String name;
    private String xml;

    public ObjectViewDto() {
    }

    public ObjectViewDto(String name, String oid, String xml) {
        this.name = name;
        this.oid = oid;
        this.xml = xml;
    }

    public String getName() {
        return name;
    }

    public String getOid() {
        return oid;
    }

    public String getXml() {
        return xml;
    }

    public void setXml(String xml) {
        this.xml = xml;
    }
}

/*
 * Copyright (c) 2012 Evolveum
 *
 * The contents of this file are subject to the terms
 * of the Common Development and Distribution License
 * (the License). You may not use this file except in
 * compliance with the License.
 *
 * You can obtain a copy of the License at
 * http://www.opensource.org/licenses/cddl1 or
 * CDDLv1.0.txt file in the source code distribution.
 * See the License for the specific language governing
 * permission and limitations under the License.
 *
 * If applicable, add the following below the CDDL Header,
 * with the fields enclosed by brackets [] replaced by
 * your own identifying information:
 *
 * Portions Copyrighted 2012 [name of copyright owner]
 */

package com.evolveum.midpoint.web.page.admin.configuration.dto;

import java.io.Serializable;

/**
 * @author lazyman
 */
public class ObjectViewDto implements Serializable {

    private String oid;
    private String name;
    private String xml;

    public ObjectViewDto() {
    }

    public ObjectViewDto(String oid, String name, String xml) {
        this.name = name;
        this.oid = oid;
        this.xml = xml;
    }

    public String getName() {
        return name;
    }

    public String getOid() {
        return oid;
    }

    public String getXml() {
        return xml;
    }

    public void setXml(String xml) {
        this.xml = xml;
    }
}

Change the position parameter in the constructor


/*
 IntentDConnectMessage.java
 Copyright (c) 2014 NTT DOCOMO,INC.
 Released under the MIT license
 http://opensource.org/licenses/mit-license.php
 */
package org.deviceconnect.message.intent.message;

import org.deviceconnect.message.DConnectMessage;

/**
 * メッセージ.
 * @author NTT DOCOMO, INC.
 */
public interface IntentDConnectMessage extends DConnectMessage {

    /**
     * アクション:GET.
     */
    String ACTION_GET = "org.deviceconnect.action.GET";

    /**
     * アクション:PUT.
     */
    String ACTION_PUT = "org.deviceconnect.action.PUT";

    /**
     * アクション:POST.
     */
    String ACTION_POST = "org.deviceconnect.action.POST";

    /**
     * アクション:DELETE.
     */
    String ACTION_DELETE = "org.deviceconnect.action.DELETE";

    /**
     * アクション:RESPONSE.
     */
    String ACTION_RESPONSE = "org.deviceconnect.action.RESPONSE";

    /**
     * アクション:EVENT.
     */
    String ACTION_EVENT = "org.deviceconnect.action.EVENT";

    /**
     * アクションを取得する.
     * @return アクション
     */
    String getAction();

}

/*
 IntentDConnectMessage.java
 Copyright (c) 2014 NTT DOCOMO,INC.
 Released under the MIT license
 http://opensource.org/licenses/mit-license.php
 */
package org.deviceconnect.message.intent.message;

import org.deviceconnect.message.DConnectMessage;

/**
 * メッセージ.
 * @author NTT DOCOMO, INC.
 */
public interface IntentDConnectMessage extends DConnectMessage {

    /**
     * アクション:GET.
     */
    String ACTION_GET = "org.deviceconnect.action.GET";

    /**
     * アクション:PUT.
     */
    String ACTION_PUT = "org.deviceconnect.action.PUT";

    /**
     * アクション:POST.
     */
    String ACTION_POST = "org.deviceconnect.action.POST";

    /**
     * アクション:DELETE.
     */
    String ACTION_DELETE = "org.deviceconnect.action.DELETE";

    /**
     * アクション:RESPONSE.
     */
    String ACTION_RESPONSE = "org.deviceconnect.action.RESPONSE";

    /**
     * アクション:EVENT.
     */
    String ACTION_EVENT = "org.deviceconnect.action.EVENT";

    /**
     * パラメータ: {@value} .
     */
    String EXTRA_ORIGIN = "origin";

    /**
     * パラメータ: {@value} .
     */
    String EXTRA_KEY = "key";

    /**
     * パラメータ: {@value} .
     */
    String EXTRA_NONCE = "nonce";

    /**
     * パラメータ: {@value} .
     */
    String EXTRA_HMAC = "hmac";

    /**
     * アクションを取得する.
     * @return アクション
     */
    String getAction();

}

Define new request parameters for server anti-spoofing.


package uk.gov.register.core;

import org.junit.Test;
import java.time.Instant;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

public class EntryTest {
    @Test
    public void getTimestampAsISOFormat_returnsTheFormattedTimestamp() {
        Entry entry = new Entry(123, "abc", Instant.ofEpochSecond(1470403440));
        assertThat(entry.getTimestampAsISOFormat(), equalTo("2016-08-05T13:24:00Z"));
    }

    @Test
    public void getItemHash_returnsSha256AsItemHash() {
        Entry entry = new Entry(123, "abc", Instant.ofEpochSecond(1470403440));
        assertThat(entry.getItemHash(), equalTo("sha-256:abc"));
    }
}

package uk.gov.register.core;

import org.junit.Test;
import java.time.Instant;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

public class EntryTest {
    @Test
    public void getTimestampAsISOFormat_returnsTheFormattedTimestamp() {
        Entry entry = new Entry(123, "abc", Instant.ofEpochSecond(1470403440));
        assertThat(entry.getTimestampAsISOFormat(), equalTo("2016-08-05T13:24:00Z"));
    }

    @Test
    public void getSha256hex_returnsTheSha256HexOfItem() {
        Entry entry = new Entry(123, "abc", Instant.ofEpochSecond(1470403440));
        assertThat(entry.getSha256hex(), equalTo("abc"));
    }

    @Test
    public void getItemHash_returnsSha256AsItemHash() {
        Entry entry = new Entry(123, "abc", Instant.ofEpochSecond(1470403440));
        assertThat(entry.getItemHash(), equalTo("sha-256:abc"));
    }
}

Add additional Entry test to show distinction between sha and itemhash


package de.fu_berlin.imp.apiua.groundedtheory.handlers;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

import org.apache.log4j.Logger;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.handlers.HandlerUtil;

import com.bkahlert.nebula.utils.selection.retriever.SelectionRetrieverFactory;

import de.fu_berlin.imp.apiua.groundedtheory.model.ICode;
import de.fu_berlin.imp.apiua.groundedtheory.ui.Utils;
import de.fu_berlin.imp.apiua.groundedtheory.ui.wizards.WizardUtils;

public class CreateCodeHandler extends AbstractHandler {

	@SuppressWarnings("unused")
	private static final Logger LOGGER = Logger
			.getLogger(CreateCodeHandler.class);

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {

		Collection<?> menus = HandlerUtil.getActiveMenus(event);

		List<ICode> codes = menus.size() > 0 ? SelectionRetrieverFactory
				.getSelectionRetriever(ICode.class).getSelection()
				: new LinkedList<ICode>();
		assert codes.size() < 2;

		WizardUtils.openNewCodeWizard(codes.size() == 1 ? codes.get(0) : null,
				Utils.getFancyCodeColor());

		return null;
	}

}

package de.fu_berlin.imp.apiua.groundedtheory.handlers;

import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

import org.apache.log4j.Logger;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.handlers.HandlerUtil;

import com.bkahlert.nebula.utils.selection.retriever.SelectionRetrieverFactory;

import de.fu_berlin.imp.apiua.groundedtheory.model.ICode;
import de.fu_berlin.imp.apiua.groundedtheory.ui.Utils;
import de.fu_berlin.imp.apiua.groundedtheory.ui.wizards.WizardUtils;

public class CreateCodeHandler extends AbstractHandler {

	@SuppressWarnings("unused")
	private static final Logger LOGGER = Logger
			.getLogger(CreateCodeHandler.class);

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {

		Collection<?> menus = HandlerUtil.getActiveMenus(event);

		List<ICode> codes = menus != null && menus.size() > 0 ? SelectionRetrieverFactory
				.getSelectionRetriever(ICode.class).getSelection()
				: new LinkedList<ICode>();
		assert codes.size() < 2;

		WizardUtils.openNewCodeWizard(codes.size() == 1 ? codes.get(0) : null,
				Utils.getFancyCodeColor());

		return null;
	}

}

Create Code Toolbar Action repaired

[FIX] Create Code Toolbar Action repaired


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

package org.wso2.carbon.apimgt.api.model.policy;

import java.util.List;

public class Pipeline {

    private QuotaPolicy quotaPolicy;

    private List<Condition> conditions;

    public List<Condition> getConditions() {
        return conditions;
    }

    public void setConditions(List<Condition> condition) {
        this.conditions = condition;
    }

    public QuotaPolicy getQuotaPolicy() {
        return quotaPolicy;
    }

    public void setQuotaPolicy(QuotaPolicy quotaPolicy) {
        this.quotaPolicy = quotaPolicy;
    }

    @Override
    public String toString() {
        return "Pipeline [quotaPolicy=" + quotaPolicy + ", conditions=" + conditions + "]";
    }

}

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

package org.wso2.carbon.apimgt.api.model.policy;

import java.util.List;

public class Pipeline {

    private QuotaPolicy quotaPolicy;
    private List<Condition> conditions;
    private boolean enabled;

    public boolean isEnabled() {
        return enabled;
    }

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

    public List<Condition> getConditions() {
        return conditions;
    }

    public void setConditions(List<Condition> condition) {
        this.conditions = condition;
    }

    public QuotaPolicy getQuotaPolicy() {
        return quotaPolicy;
    }

    public void setQuotaPolicy(QuotaPolicy quotaPolicy) {
        this.quotaPolicy = quotaPolicy;
    }

    @Override
    public String toString() {
        return "Pipeline [quotaPolicy=" + quotaPolicy + ", conditions=" + conditions + "]";
    }

}

Add enabled property to pipeline

Add enabled property to pipeline


package main;

import approximation.Lagrange;

/**
 * Main class
 * @author Pavel_Verkhovtsov
 */
public class Main {

	private static double[] y = {2.02, 1.98, 1.67, 1.65, 1.57, 1.42, 1.37, 1.07, 0.85, 0.48, 0.35, -0.30, -0.61, -1.2, -1.39, -1.76, -2.28, -2.81, -3.57, -4.06};
	private static double[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};

	/**
	 * Main method.
	 * @param args console parameters
	 */
	public static void main(final String[] args){
		Lagrange lagrange = new Lagrange(x, y);
		System.out.println(lagrange.approximazeFunction(2));
	}
}

package main;

import java.util.Scanner;

import approximation.Lagrange;

/**
 * Main class
 * @author Pavel_Verkhovtsov
 */
public class Main {

	private static double[] y = {2.02, 1.98, 1.67, 1.65, 1.57, 1.42, 1.37, 1.07, 0.85, 0.48, 0.35, -0.30, -0.61, -1.2, -1.39, -1.76, -2.28, -2.81, -3.57, -4.06};
	private static double[] x = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};

	/**
	 * Main method.
	 * @param args console parameters
	 */
	@SuppressWarnings("resource")
	public static void main(final String[] args){
		Lagrange lagrange = new Lagrange(x, y);
		System.out.print("Input approximation point: ");
		double point = new Scanner(System.in).nextDouble();
		System.out.println(lagrange.approximazeFunction(point));
	}
}

Add console input approximation point

Add console input approximation point


package org.assertj.android.api.bluetooth;

import android.bluetooth.BluetoothGattCharacteristic;
import android.support.annotation.IntDef;
import java.lang.annotation.Retention;

import static java.lang.annotation.RetentionPolicy.SOURCE;

@IntDef(
    flag = true,
    value = {
        BluetoothGattCharacteristic.PERMISSION_READ,
        BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED,
        BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED_MITM,
        BluetoothGattCharacteristic.PERMISSION_WRITE,
        BluetoothGattCharacteristic.PERMISSION_WRITE_ENCRYPTED,
        BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED_MITM,
        BluetoothGattCharacteristic.PERMISSION_WRITE_SIGNED,
        BluetoothGattCharacteristic.PERMISSION_WRITE_SIGNED_MITM
    }
)
@Retention(SOURCE)
@interface BluetoothGattCharacteristicPermissions {
}

package org.assertj.android.api.bluetooth;

import android.bluetooth.BluetoothGattCharacteristic;
import android.support.annotation.IntDef;
import java.lang.annotation.Retention;

import static java.lang.annotation.RetentionPolicy.SOURCE;

@IntDef(
    flag = true,
    value = {
        BluetoothGattCharacteristic.PERMISSION_READ,
        BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED,
        BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED_MITM,
        BluetoothGattCharacteristic.PERMISSION_WRITE,
        BluetoothGattCharacteristic.PERMISSION_WRITE_ENCRYPTED,
        BluetoothGattCharacteristic.PERMISSION_WRITE_ENCRYPTED_MITM,
        BluetoothGattCharacteristic.PERMISSION_WRITE_SIGNED,
        BluetoothGattCharacteristic.PERMISSION_WRITE_SIGNED_MITM
    }
)
@Retention(SOURCE)
@interface BluetoothGattCharacteristicPermissions {
}

Fix bluetooth characteristic intdef copy-paste typo.

PERMISSION_READ_ENCRYPTED_MITM was duplicated and
PERMISSION_WRITE_ENCRYPTED_MITM was missing.
Full list of available values:
https://developer.android.com/reference/android/bluetooth/BluetoothGattCharacteristic.html


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

import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;

import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;
import org.springframework.social.twitter.api.Trend;

/**
 * Holder of a list of daily trends.
 * @author Craig Walls
 */
@JsonIgnoreProperties(ignoreUnknown=true)
class DailyTrendsList extends AbstractTrendsList {

	@JsonCreator
	public DailyTrendsList(@JsonProperty("trends") Map<String, List<Trend>> trends) {
		super(trends, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
	}

}

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

import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;

import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonProperty;
import org.springframework.social.twitter.api.Trend;

/**
 * Holder of a list of daily trends.
 * @author Craig Walls
 */
@JsonIgnoreProperties(ignoreUnknown=true)
class DailyTrendsList extends AbstractTrendsList {

	@JsonCreator
	public DailyTrendsList(@JsonProperty("trends") Map<String, List<Trend>> trends) {
		super(trends, new SimpleDateFormat("yyyy-MM-dd HH:mm"));
	}

}

Change the date format for daily trends (SOCIALTW-14).


package ${package}.server;

import java.io.IOException;
import java.net.URI;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
import org.glassfish.jersey.server.ResourceConfig;

/** Starts REST server based on Jersey.
 */
final class Main implements ContainerResponseFilter {
    public static void main(String... args) throws Exception {
        ResourceConfig rc = new ResourceConfig(
            ContactsResource.class, Main.class
        );
        URI u = new URI("http://localhost:8080/");
        HttpServer server = GrizzlyHttpServerFactory.createHttpServer(u, rc);
        System.err.println("Press Enter to shutdown the server");
        System.in.read();
        server.stop();
    }

    @Override
    public void filter(
        ContainerRequestContext requestContext,
        ContainerResponseContext r
    ) throws IOException {
        r.getHeaders().add("Access-Control-Allow-Origin", "*");
        r.getHeaders().add("Access-Control-Allow-Credentials", "true");
        r.getHeaders().add("Access-Control-Allow-Headers", "Content-Type");
        r.getHeaders().add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
    }
}

package ${package}.server;

import java.io.IOException;
import java.net.URI;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
import org.glassfish.grizzly.http.server.HttpServer;
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory;
import org.glassfish.jersey.server.ResourceConfig;

/** Starts REST server based on Jersey.
 */
final class Main implements ContainerResponseFilter {
    public static void main(String... args) throws Exception {
        ResourceConfig rc = new ResourceConfig(
            ContactsResource.class, Main.class
        );
        URI u = new URI("http://0.0.0.0:8080/");
        HttpServer server = GrizzlyHttpServerFactory.createHttpServer(u, rc);
        System.err.println("Press Enter to shutdown the server");
        System.in.read();
        server.stop();
    }

    @Override
    public void filter(
        ContainerRequestContext requestContext,
        ContainerResponseContext r
    ) throws IOException {
        r.getHeaders().add("Access-Control-Allow-Origin", "*");
        r.getHeaders().add("Access-Control-Allow-Credentials", "true");
        r.getHeaders().add("Access-Control-Allow-Headers", "Content-Type");
        r.getHeaders().add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
    }
}

Allow connection from any host

Allow connection from any host


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

package org.apache.maven.shell.core.impl.command;

import org.apache.maven.shell.cli.Option;
import org.apache.maven.shell.i18n.MessageSource;
import org.apache.maven.shell.i18n.ResourceBundleMessageSource;

/**
 * Helper to inject <tt>--help<tt> support.
 *
 * @version $Rev$ $Date$
 */
public class CommandHelpSupport
{
    @Option(name="-h", aliases={"--help"}, requireOverride=true)
    public boolean displayHelp;

    private MessageSource messages;

    public MessageSource getMessages() {
        if (messages == null) {
            messages = new ResourceBundleMessageSource(getClass());
        }

        return messages;
    }
}

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

package org.apache.maven.shell.core.impl.command;

import org.apache.maven.shell.cli.Option;
import org.apache.maven.shell.i18n.MessageSource;
import org.apache.maven.shell.i18n.ResourceBundleMessageSource;

/**
 * Helper to inject <tt>--help<tt> support.
 *
 * @version $Rev$ $Date$
 */
public class CommandHelpSupport
{
    //CLOVER: OFF

    @Option(name="-h", aliases={"--help"}, requireOverride=true)
    public boolean displayHelp;

    private MessageSource messages;

    public MessageSource getMessages() {
        if (messages == null) {
            messages = new ResourceBundleMessageSource(getClass());
        }

        return messages;
    }
}

Disable clover for help support

Disable clover for help support


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

package com.googlesource.gerrit.plugins.reviewersbyblame;

import com.google.gerrit.common.ChangeListener;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.server.config.FactoryModule;

public class ReviewersByBlameModule extends FactoryModule {
  @Override
  protected void configure() {
    DynamicSet.bind(binder(), ChangeListener.class).to(
        ChangeUpdatedListener.class);
    factory(ReviewersByBlame.Factory.class);
  }
}

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

package com.googlesource.gerrit.plugins.reviewersbyblame;

import com.google.gerrit.common.ChangeListener;
import com.google.gerrit.extensions.annotations.Exports;
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.server.config.FactoryModule;
import com.google.gerrit.server.config.ProjectConfigEntry;

public class ReviewersByBlameModule extends FactoryModule {
  @Override
  protected void configure() {
    DynamicSet.bind(binder(), ChangeListener.class).to(
        ChangeUpdatedListener.class);
    factory(ReviewersByBlame.Factory.class);
    bind(ProjectConfigEntry.class)
        .annotatedWith(Exports.named("maxReviewers"))
        .toInstance(new ProjectConfigEntry("Max Reviewers", 3, true,
            "The maximum number of reviewers that should be automatically added"
            + " to a change based on the git blame computation on the changed files."));
  }
}

Allow to set maxReviewers on a project from the WebUI

Change-Id: I8c3d9d7659b935652004fad29c22b23a6326d2d0
Signed-off-by: Edwin Kempin <b444e279ad95fdef4fbdd82c813b624595df204a@sap.com>


package org.biojava.nbio.structure.align.quaternary;

/**
 * The parameter bean for the {@link QsAlign} algorithm.
 *
 * @author Aleix Lafita
 * @since 5.0.0
 *
 */
public class QsAlignParameters {

	private double dCutoff = 10.0;

	/**
	 * The maximum allowed distance between the centroids of two equivalent
	 * Subunits, in A.
	 *
	 * @return dCutoff
	 */
	public double getdCutoff() {
		return dCutoff;
	}

	/**
	 * The maximum allowed distance between the centroids of two equivalent
	 * Subunits, in A.
	 *
	 * @param dCutoff
	 */
	public void setdCutoff(double dCutoff) {
		this.dCutoff = dCutoff;
	}

}

package org.biojava.nbio.structure.align.quaternary;

/**
 * The parameter bean for the {@link QsAlign} algorithm.
 *
 * @author Aleix Lafita
 * @since 5.0.0
 *
 */
public class QsAlignParameters {

	private double dCutoff = 10.0;
	private double maxRmsd = 7.0;
	private double minOrientationMetric = Math.PI / 8; // 45 degree

	/**
	 * The maximum allowed distance between the centroids of two equivalent
	 * Subunits, in A.
	 *
	 * @return dCutoff
	 */
	public double getdCutoff() {
		return dCutoff;
	}

	/**
	 * The maximum allowed distance between the centroids of two equivalent
	 * Subunits, in A.
	 *
	 * @param dCutoff
	 */
	public void setdCutoff(double dCutoff) {
		this.dCutoff = dCutoff;
	}

	public double getMaxRmsd() {
		return maxRmsd;
	}

	public void setMaxRmsd(double maxRmsd) {
		this.maxRmsd = maxRmsd;
	}

	public double getMinOrientationMetric() {
		return minOrientationMetric;
	}

	public void setMinOrientationMetric(double minOrientationMetric) {
		this.minOrientationMetric = minOrientationMetric;
	}

}

Add more parameters for QsAlign

Add more parameters for QsAlign