package org.graphwalker.io.factory;

/*
 * #%L
 * GraphWalker Input/Output
 * %%
 * Copyright (C) 2011 - 2014 GraphWalker
 * %%
 * 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.
 * #L%
 */

/**
 * Created by krikar on 8/20/14.
 */
public class YEdParsingException extends RuntimeException {

  public YEdParsingException(Throwable throwable) {
    super(throwable);
  }

  public YEdParsingException(String message) {
    super(message);
  }
}

Fix git mvn problem with white space


package org.littleshoot.proxy.mitm;

import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSession;

import org.littleshoot.proxy.MitmManager;

/**
 * {@link MitmManager} that uses the given host name to create a dynamic
 * certificate for. If a port is given, it will be truncated.
 */
public class HostNameMitmManager implements MitmManager {

    private BouncyCastleSslEngineSource sslEngineSource;

    public HostNameMitmManager() throws RootCertificateException {
        this(new Authority());
    }

    public HostNameMitmManager(Authority authority)
            throws RootCertificateException {
        try {
            sslEngineSource = new BouncyCastleSslEngineSource(authority, true,
                    true);
        } catch (final Exception e) {
            throw new RootCertificateException(
                    "Errors during assembling root CA.", e);
        }
    }

    public SSLEngine serverSslEngine() {
        return sslEngineSource.newSslEngine();
    }

    public SSLEngine clientSslEngineFor(SSLSession serverSslSession,
            String serverHostAndPort) {
        try {
            String serverName = serverHostAndPort.split(":")[0];
            SubjectAlternativeNameHolder san = new SubjectAlternativeNameHolder();
            return sslEngineSource.createCertForHost(serverName, san);
        } catch (Exception e) {
            throw new FakeCertificateException(
                    "Creation dynamic certificate failed for "
                            + serverHostAndPort, e);
        }
    }
}

package org.littleshoot.proxy.mitm;

import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSession;

import org.littleshoot.proxy.MitmManager;

/**
 * {@link MitmManager} that uses the given host name to create a dynamic
 * certificate for. If a port is given, it will be truncated.
 */
public class HostNameMitmManager implements MitmManager {

    private BouncyCastleSslEngineSource sslEngineSource;

    public HostNameMitmManager() throws RootCertificateException {
        this(new Authority());
    }

    public HostNameMitmManager(Authority authority)
            throws RootCertificateException {
        try {
            boolean trustAllServers = false;
            boolean sendCerts = true;
            sslEngineSource = new BouncyCastleSslEngineSource(authority,
                    trustAllServers, sendCerts);
        } catch (final Exception e) {
            throw new RootCertificateException(
                    "Errors during assembling root CA.", e);
        }
    }

    public SSLEngine serverSslEngine() {
        return sslEngineSource.newSslEngine();
    }

    public SSLEngine clientSslEngineFor(SSLSession serverSslSession,
            String serverHostAndPort) {
        try {
            String serverName = serverHostAndPort.split(":")[0];
            SubjectAlternativeNameHolder san = new SubjectAlternativeNameHolder();
            return sslEngineSource.createCertForHost(serverName, san);
        } catch (Exception e) {
            throw new FakeCertificateException(
                    "Creation dynamic certificate failed for "
                            + serverHostAndPort, e);
        }
    }
}

Disable trust all servers by default.


package org.synyx.urlaubsverwaltung;

import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.testcontainers.containers.MariaDBContainer;

import static org.testcontainers.containers.MariaDBContainer.IMAGE;

@DirtiesContext
public abstract class TestContainersBase {

    static MariaDBContainer<?> mariaDB = new MariaDBContainer<>(IMAGE + ":10.5");

    @DynamicPropertySource
    static void mariaDBProperties(DynamicPropertyRegistry registry) {
        mariaDB.start();
        registry.add("spring.datasource.url", mariaDB::getJdbcUrl);
        registry.add("spring.datasource.username", mariaDB::getUsername);
        registry.add("spring.datasource.password", mariaDB::getPassword);
    }
}

package org.synyx.urlaubsverwaltung;

import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.DynamicPropertyRegistry;
import org.springframework.test.context.DynamicPropertySource;
import org.testcontainers.containers.MariaDBContainer;

import static org.testcontainers.containers.MariaDBContainer.NAME;

@DirtiesContext
public abstract class TestContainersBase {

    static MariaDBContainer<?> mariaDB = new MariaDBContainer<>(NAME + ":10.5");

    @DynamicPropertySource
    static void mariaDBProperties(DynamicPropertyRegistry registry) {
        mariaDB.start();
        registry.add("spring.datasource.url", mariaDB::getJdbcUrl);
        registry.add("spring.datasource.username", mariaDB::getUsername);
        registry.add("spring.datasource.password", mariaDB::getPassword);
    }
}

Replace testcontainers deprecated image constant with name


/*
 * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
 *
 * 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.traccar.api;

import com.fasterxml.jackson.databind.ObjectMapper;

import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
import java.text.SimpleDateFormat;

@Provider
public class ObjectMapperProvider implements ContextResolver<ObjectMapper> {

    private ObjectMapper mapper = new ObjectMapper();

    public ObjectMapperProvider() {
        mapper.setConfig(mapper.getSerializationConfig().with(
                new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")));
    }

    @Override
    public ObjectMapper getContext(Class<?> type) {
        return mapper;
    }

}

/*
 * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
 *
 * 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.traccar.api;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
import java.text.SimpleDateFormat;

@Provider
public class ObjectMapperProvider implements ContextResolver<ObjectMapper> {

    private ObjectMapper mapper = new ObjectMapper();

    public ObjectMapperProvider() {
        mapper.setConfig(mapper.getSerializationConfig().without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS));
    }

    @Override
    public ObjectMapper getContext(Class<?> type) {
        return mapper;
    }

}

Change serialization date format again


package com.elmakers.mine.bukkit.magic;

import javax.annotation.Nonnull;

import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;

import com.elmakers.mine.bukkit.api.magic.Mage;
import com.elmakers.mine.bukkit.api.magic.MageController;

public class MobTrigger extends CustomTrigger {
    boolean requiresTarget = false;

    public MobTrigger(@Nonnull MageController controller, @Nonnull String key, @Nonnull ConfigurationSection configuration) {
        super(controller, key, configuration);
        requiresTarget = configuration.getBoolean("requires_target");
    }

    public boolean isValid(Mage mage) {
        if (!isValid(mage)) return false;
        if (requiresTarget) {
            Entity entity = mage.getEntity();
            if (entity instanceof Creature) {
                return ((Creature)entity).getTarget() != null;
            }
        }
        return true;
    }
}

package com.elmakers.mine.bukkit.magic;

import javax.annotation.Nonnull;

import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;

import com.elmakers.mine.bukkit.api.magic.Mage;
import com.elmakers.mine.bukkit.api.magic.MageController;

public class MobTrigger extends CustomTrigger {
    boolean requiresTarget = false;

    public MobTrigger(@Nonnull MageController controller, @Nonnull String key, @Nonnull ConfigurationSection configuration) {
        super(controller, key, configuration);
        requiresTarget = configuration.getBoolean("requires_target");
    }

    @Override
    public boolean isValid(Mage mage) {
        if (!super.isValid(mage)) return false;
        if (requiresTarget) {
            Entity entity = mage.getEntity();
            if (entity instanceof Creature) {
                return ((Creature)entity).getTarget() != null;
            }
        }
        return true;
    }
}

Fix mob trigger infinite recursion


/**
 * Copyright (c) 2020 Bosch.IO GmbH and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
package org.eclipse.hawkbit.repository;

import java.io.Serializable;

public interface Identifiable<T extends Serializable> {

    T getId();
}

/**
 * Copyright (c) 2020 Bosch.IO GmbH and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
package org.eclipse.hawkbit.repository;

import java.io.Serializable;

@FunctionalInterface
public interface Identifiable<T extends Serializable> {

    T getId();
}

Use best practise annotation for SAM interfaces in Java 8


class Node {
    String getType() { return ""; }

    String foo(Node left, Node right) {
        String leftType = left.getType().substring(1);
<selection>        String rightType = right.getType().substring(1);
</selection>
        String type = "A".substring(1);
        return leftType + rightType + type;
    }
}

class Node {
    String getType() { return ""; }

    String foo(Node left, Node right) {
        String leftType = left.getType().substring(1);
<selection>        String rightType = right.getType().substring(1); //line comment
</selection>
        String type = "A".substring(1);
        return leftType + rightType + type;
    }
}

Trim surrounding whitespaces because they don't survive in the refactoring - test data fixed (IDEA-191738)


/*
 * Copyright (C) 2017 EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */

package org.lttng.scope.lttng.kernel.core.activator.internal;

import java.io.IOException;

import org.lttng.scope.common.core.ScopeCoreActivator;
import org.lttng.scope.lami.core.module.LamiAnalysisFactoryException;

/**
 * Plugin activator
 *
 * @noreference This class should not be accessed outside of this plugin.
 */
public class Activator extends ScopeCoreActivator {

    /**
     * Return the singleton instance of this activator.
     *
     * @return The singleton instance
     */
    public static Activator instance() {
        return ScopeCoreActivator.getInstance(Activator.class);
    }

    @Override
    protected void startActions() {
        try {
            LttngAnalysesLoader.load();
        } catch (LamiAnalysisFactoryException | IOException e) {
            // Not the end of the world if the analyses are not available
            logWarning("Cannot find LTTng analyses configuration files: " + e.getMessage()); //$NON-NLS-1$
        }
    }

    @Override
    protected void stopActions() {
    }

}

/*
 * Copyright (C) 2017 EfficiOS Inc., Alexandre Montplaisir <alexmonthy@efficios.com>
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */

package org.lttng.scope.lttng.kernel.core.activator.internal;

import org.lttng.scope.common.core.ScopeCoreActivator;

/**
 * Plugin activator
 *
 * @noreference This class should not be accessed outside of this plugin.
 */
public class Activator extends ScopeCoreActivator {

    /**
     * Return the singleton instance of this activator.
     *
     * @return The singleton instance
     */
    public static Activator instance() {
        return ScopeCoreActivator.getInstance(Activator.class);
    }

    @Override
    protected void startActions() {
//        try {
//            LttngAnalysesLoader.load();
//        } catch (LamiAnalysisFactoryException | IOException e) {
//            // Not the end of the world if the analyses are not available
//            logWarning("Cannot find LTTng analyses configuration files: " + e.getMessage()); //$NON-NLS-1$
//        }
    }

    @Override
    protected void stopActions() {
    }

}

Disable the built-in LTTng-Analyses connectors


package org.zstack.storage.primary.smp;

import org.zstack.header.core.Completion;

/**
 * Created by xing5 on 2016/3/27.
 */
public abstract class BackupStorageKvmUploader {
    public abstract void uploadBits(String bsPath, String psPath, Completion completion);
}

package org.zstack.storage.primary.smp;

import org.zstack.header.core.ReturnValueCompletion;

/**
 * Created by xing5 on 2016/3/27.
 */
public abstract class BackupStorageKvmUploader {
    // When uploading an image from 'psPath' to backup storage, the 'bsPath'
    // might be allocated by the backup storage and returned by the completion,
    // instead of being known ahead of time.
    public abstract void uploadBits(String bsPath, String psPath, ReturnValueCompletion<String> completion);
}

Update the method signature of 'uploadBits()'


package com.hubspot.baragon.service.edgecache.cloudflare.client;

public class CloudflareClientException extends Exception {

  public CloudflareClientException(String message, Throwable t) {
    super(message, t);
  }

}

package com.hubspot.baragon.service.edgecache.cloudflare.client;

public class CloudflareClientException extends Exception {

  public CloudflareClientException(String message, Throwable t) {
    super(message, t);
  }

  public CloudflareClientException(String message) {
    super(message);
  }

}

Add exception class for Cloudflare interactions.


/*
 * Created on 11-Jan-2006
 */
package uk.org.ponder.rsf.test.sitemap;

import java.util.HashMap;

import uk.org.ponder.rsf.bare.junit.PlainRSFTests;
import uk.org.ponder.rsf.viewstate.EntityCentredViewParameters;
import uk.org.ponder.rsf.viewstate.support.BasicViewParametersParser;

public class TestSiteMap extends PlainRSFTests {
  public void testParseECVP() {
    BasicViewParametersParser bvpp = (BasicViewParametersParser) applicationContext.getBean("viewParametersParser");
    HashMap attrmap = new HashMap();
    attrmap.put("flowtoken", "ec38f0");
    EntityCentredViewParameters ecvp = (EntityCentredViewParameters) bvpp.parse("/recipe/3652/", attrmap);
    System.out.println("ECVP for entity " + ecvp.entity.ID + " of type " + ecvp.entity.entityname);
  }

}

/*
 * Created on 11-Jan-2006
 */
package uk.org.ponder.rsf.test.sitemap;

import java.util.HashMap;

import uk.org.ponder.rsf.bare.junit.PlainRSFTests;
import uk.org.ponder.rsf.viewstate.EntityCentredViewParameters;
import uk.org.ponder.rsf.viewstate.support.BasicViewParametersParser;

public class TestSiteMap extends PlainRSFTests {
  public TestSiteMap() {
    contributeConfigLocation("classpath:uk/org/ponder/rsf/test/sitemap/sitemap-context.xml");
  }

  public void testParseECVP() {
    BasicViewParametersParser bvpp = (BasicViewParametersParser) applicationContext.getBean("viewParametersParser");
    HashMap attrmap = new HashMap();
    attrmap.put("flowtoken", "ec38f0");
    EntityCentredViewParameters ecvp = (EntityCentredViewParameters) bvpp.parse("/recipe/3652/", attrmap);
    System.out.println("ECVP for entity " + ecvp.entity.ID + " of type " + ecvp.entity.entityname);
  }

}

Fix for loading SiteMap entry on Spring 2.x


package coffee;

import dagger.Component;
import javax.inject.Singleton;

public class CoffeeApp {
  @Singleton
  @Component(modules = { DripCoffeeModule.class })
  public interface Coffee {
    CoffeeMaker maker();
  }

  public static void main(String[] args) {
    Coffee coffee = DaggerCoffeeApp_Coffee.builder().build();
    coffee.maker().brew();
  }
}

package coffee;

import dagger.Component;
import javax.inject.Singleton;

public class CoffeeApp {
  @Singleton
  @Component(modules = { DripCoffeeModule.class })
  public interface CoffeeShop {
    CoffeeMaker maker();
  }

  public static void main(String[] args) {
    CoffeeShop coffeeShop = DaggerCoffeeApp_CoffeeShop.builder().build();
    coffeeShop.maker().brew();
  }
}

Align the user's guide's usage of CoffeeShop with the sample code


package eve.corp.manager;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

package eve.corp.manager;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.AbstractJsonpResponseBodyAdvice;

@SpringBootApplication
public class Application {

    @ControllerAdvice
    static class JsonpAdvice extends AbstractJsonpResponseBodyAdvice {
        public JsonpAdvice() {
            super("callback");
        }
    }

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

Add JSONP support which is now included in Spring 4.1


package org.scenarioo.pizza.pageObjects;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

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

public class SelectPizzaPage extends BasePage {

    public static void assertPageIsShown() {
        assertTrue(getStepElement().isDisplayed(), "Expected page to be displayed");
    }

    public static void selectPizzaVerdura() {
        getWebDriver().findElement(By.id("v")).click();
    }

    public static void clickNextButton() {
        getStepElement().findElement(By.className("next")).click();
    }

    private static WebElement getStepElement() {
        return getWebDriver().findElement(By.id("step-selectPizza"));
    }

}

package org.scenarioo.pizza.pageObjects;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;

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

public class SelectPizzaPage extends BasePage {

    public static void assertPageIsShown() {
        assertTrue(getStepElement().isDisplayed(), "Expected page to be displayed");
    }

    public static void selectPizzaVerdura() {
        getWebDriver().findElement(By.id("pizza-verdura")).click();
    }

    public static void clickNextButton() {
        getStepElement().findElement(By.className("next")).click();
    }

    private static WebElement getStepElement() {
        return getWebDriver().findElement(By.id("step-selectPizza"));
    }

}

Adjust tests to new pizza ids


package atg.tools.ant.types;

import atg.tools.ant.util.ModuleUtils;
import org.apache.tools.ant.types.resources.FileResource;

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

/**
 * @author msicker
 * @version 2.0
 */
public class AtgInstallation
        extends FileResource {

    private final Map<String, Module> modules = new ConcurrentHashMap<String, Module>();

    /**
     * Sets the base ATG installation directory. For example, one might have ATG installed in
     * {@code $HOME/ATG/ATG11.0}, so you would use the following:
     * <pre>
     *     {@code <atg:atg id="atg.installation" home="${user.home}/ATG/ATG11.0"/>}
     * </pre>
     *
     * @param home
     *         directory where ATG is installed.
     */
    public void setHome(final File home) {
        setFile(home);
    }

    public File getHome() {
        return getFile();
    }

    protected Module getModule(final String name) {
        final Module cached = modules.get(name);
        if (cached != null) {
            return cached;
        }
        final Module module = new Module();
        module.setAtg(this);
        module.setModule(ModuleUtils.moduleNameToPath(name));
        modules.put(name, module);
        return module;
    }
}

package atg.tools.ant.types;

import org.apache.tools.ant.types.resources.FileResource;

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

/**
 * @author msicker
 * @version 2.0
 */
public class AtgInstallation
        extends FileResource {

    private final Map<String, Module> modules = new ConcurrentHashMap<String, Module>();

    /**
     * Sets the base ATG installation directory. For example, one might have ATG installed in
     * {@code $HOME/ATG/ATG11.0}, so you would use the following:
     * <pre>
     *     {@code <atg:atg id="atg.installation" home="${user.home}/ATG/ATG11.0"/>}
     * </pre>
     *
     * @param home
     *         directory where ATG is installed.
     */
    public void setHome(final File home) {
        setFile(home);
    }

    public File getHome() {
        return getFile();
    }

    protected Module getModule(final String name) {
        final Module cached = modules.get(name);
        if (cached != null) {
            return cached;
        }
        final Module module = new Module();
        module.setAtg(this);
        module.setModule(name);
        modules.put(name, module);
        return module;
    }
}

Fix bug in module name.


package de.springbootbuch.webmvc;

import java.io.IOException;
import javax.inject.Provider;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * Part of springbootbuch.de.
 *
 * @author Michael J. Simons
 * @author @rotnroll666
 */
@Component
public class DemoFilter implements Filter {
	private static final Logger LOG = LoggerFactory
		.getLogger(DemoFilter.class);

	private final Provider<ShoppingCart> shoppingCart;

	public DemoFilter(
		Provider<ShoppingCart> shoppingCart) {
		this.shoppingCart = shoppingCart;
	}

	// Init und Destroy der Übersicht
	// halber nicht gezeigt

	@Override
	public void init(
		FilterConfig filterConfig) throws ServletException {
	}

	@Override
	public void doFilter(
		ServletRequest request,
		ServletResponse response,
		FilterChain chain
	) throws IOException, ServletException {
		chain.doFilter(request, response);
		LOG.info(
			"Shopping cart is {} empty",
			shoppingCart.get()
				.getContent().isEmpty() ? "" : "not"
		);
	}

	@Override
	public void destroy() {
	}
}

package de.springbootbuch.webmvc;

import java.io.IOException;
import javax.inject.Provider;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * Part of springbootbuch.de.
 *
 * @author Michael J. Simons
 * @author @rotnroll666
 */
@Component
public class DemoFilter implements Filter {
	private static final Logger LOG = LoggerFactory
		.getLogger(DemoFilter.class);

	private final Provider<ShoppingCart> shoppingCart;

	public DemoFilter(
		Provider<ShoppingCart> shoppingCart) {
		this.shoppingCart = shoppingCart;
	}

	// Init und Destroy der Übersicht
	// halber nicht gezeigt

	@Override
	public void init(
		FilterConfig filterConfig) throws ServletException {
	}

	@Override
	public void doFilter(
		ServletRequest request,
		ServletResponse response,
		FilterChain chain
	) throws IOException, ServletException {
		chain.doFilter(request, response);
		if(request instanceof HttpServletRequest && ((HttpServletRequest)request).getSession(false) != null) {
			LOG.info(
				"Request from {}",
				shoppingCart.get()
					.getContent().isEmpty() ? "" : "not"
			);
		}
	}

	@Override
	public void destroy() {
	}
}

Fix bug when no session scope


package io.quarkus.container.image.deployment;

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

import java.util.Optional;

import org.junit.jupiter.api.Test;

class ContainerImageConfigEffectiveGroupTest {

    public static final String USER_NAME_SYSTEM_PROPERTY = "user.name";

    private ContainerImageConfig sut = new ContainerImageConfig();

    @Test
    void testFromLowercaseUsername() {
        testWithNewUsername("test", () -> {
            sut.group = Optional.of(System.getProperty(USER_NAME_SYSTEM_PROPERTY));
            assertEquals(sut.getEffectiveGroup(), Optional.of("test"));
        });
    }

    @Test
    void testFromUppercaseUsername() {
        testWithNewUsername("TEST", () -> {
            sut.group = Optional.of(System.getProperty(USER_NAME_SYSTEM_PROPERTY));
            assertEquals(sut.getEffectiveGroup(), Optional.of("test"));
        });
    }

    @Test
    void testFromOther() {
        testWithNewUsername("WhateveR", () -> {
            sut.group = Optional.of("OtheR");
            assertEquals(sut.getEffectiveGroup(), Optional.of("OtheR"));
        });
    }

    private void testWithNewUsername(String newUserName, Runnable test) {
        String previousUsernameValue = System.getProperty(USER_NAME_SYSTEM_PROPERTY);
        System.setProperty(USER_NAME_SYSTEM_PROPERTY, newUserName);

        test.run();

        System.setProperty(USER_NAME_SYSTEM_PROPERTY, previousUsernameValue);
    }
}

package io.quarkus.container.image.deployment;

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

import java.util.Optional;

import org.junit.jupiter.api.Test;

class ContainerImageConfigEffectiveGroupTest {

    public static final String USER_NAME_SYSTEM_PROPERTY = "user.name";

    private ContainerImageConfig sut = new ContainerImageConfig();

    @Test
    void testFromLowercaseUsername() {
        testWithNewUsername("test", () -> {
            sut.group = Optional.of(System.getProperty(USER_NAME_SYSTEM_PROPERTY));
            assertEquals(sut.getEffectiveGroup(), Optional.of("test"));
        });
    }

    @Test
    void testFromUppercaseUsername() {
        testWithNewUsername("TEST", () -> {
            sut.group = Optional.of(System.getProperty(USER_NAME_SYSTEM_PROPERTY));
            assertEquals(sut.getEffectiveGroup(), Optional.of("test"));
        });
    }

    @Test
    void testFromSpaceInUsername() {
        testWithNewUsername("user name", () -> {
            sut.group = Optional.of(System.getProperty(USER_NAME_SYSTEM_PROPERTY));
            assertEquals(sut.getEffectiveGroup(), Optional.of("user-name"));
        });
    }

    @Test
    void testFromOther() {
        testWithNewUsername("WhateveR", () -> {
            sut.group = Optional.of("OtheR");
            assertEquals(sut.getEffectiveGroup(), Optional.of("OtheR"));
        });
    }

    private void testWithNewUsername(String newUserName, Runnable test) {
        String previousUsernameValue = System.getProperty(USER_NAME_SYSTEM_PROPERTY);
        System.setProperty(USER_NAME_SYSTEM_PROPERTY, newUserName);

        test.run();

        System.setProperty(USER_NAME_SYSTEM_PROPERTY, previousUsernameValue);
    }
}

Test for spaces removal from quarkus.container-image.group when it's set to the username


package seedu.doit.logic;

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

import java.time.LocalDateTime;
import java.util.Optional;

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

import seedu.doit.logic.parser.DateTimeParser;

/**
 * Tests if DateTimeParser is parsing the date correctly
 **/

public class DateTimeParserTest {

    @Rule
    public ExpectedException thrown = ExpectedException.none();
    private void assertSameDate(LocalDateTime time1, LocalDateTime time2) {
        LocalDateTime diff = time1.minusHours(time2.getHour()).minusMinutes(time2.getMinute()).minusSeconds(time2.getSecond());
        assertEquals(time1, diff);
    }

    @Test
    public void check_ifDateParsedCorrectly() throws Exception {
        Optional<LocalDateTime> t = DateTimeParser.parseDateTime("03/20/17");
        assertSameDate(t.get(), LocalDateTime.of(2017, 3, 20, 0, 0));
    }

    @Test
    public void parseEmptyString() {
        Optional<LocalDateTime> dateParsed = DateTimeParser.parseDateTime("");
        assertFalse(dateParsed.isPresent());
    }

    @Test
    public void parseNullString() throws Exception {
        thrown.expect(NullPointerException.class);
        DateTimeParser.parseDateTime(null);
    }

    @Test
    public void parseRubbishString() {
        Optional<LocalDateTime> dateParsed = DateTimeParser.parseDateTime("jsadf");
        assertFalse(dateParsed.isPresent());
    }

}

package seedu.doit.logic;

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

import java.time.LocalDateTime;
import java.util.Optional;

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

import seedu.doit.logic.parser.DateTimeParser;

/**
 * Tests if DateTimeParser is parsing the date correctly
 **/

public class DateTimeParserTest {

    @Rule
    public ExpectedException thrown = ExpectedException.none();
    private void assertSameDate(LocalDateTime time1, LocalDateTime time2) {
        LocalDateTime diff = time1.minusHours(time2.getHour()).minusMinutes(time2.getMinute())
            .minusSeconds(time2.getSecond());
        assertEquals(time1, diff);
    }

    @Test
    public void check_ifDateParsedCorrectly() throws Exception {
        Optional<LocalDateTime> t = DateTimeParser.parseDateTime("03/20/17");
        assertSameDate(t.get(), LocalDateTime.of(2017, 3, 20, 0, 0));
    }

    @Test
    public void parseEmptyString() {
        Optional<LocalDateTime> dateParsed = DateTimeParser.parseDateTime("");
        assertFalse(dateParsed.isPresent());
    }

    @Test
    public void parseNullString() throws Exception {
        thrown.expect(NullPointerException.class);
        DateTimeParser.parseDateTime(null);
    }

    @Test
    public void parseRubbishString() {
        Optional<LocalDateTime> dateParsed = DateTimeParser.parseDateTime("jsadf");
        assertFalse(dateParsed.isPresent());
    }

}

Fix line longer than 120 characters error


/*
 * Copyright 2012-2021 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
 *
 *      https://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.boot.deployment;

import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;

/**
 * Deployment tests for Wildfly.
 *
 * @author Christoph Dreis
 * @author Scott Frederick
 */
@Testcontainers(disabledWithoutDocker = true)
class WildflyDeploymentTests extends AbstractDeploymentTests {

	@Container
	static WarDeploymentContainer container = new WarDeploymentContainer("jboss/wildfly:latest",
			"/opt/jboss/wildfly/standalone/deployments", DEFAULT_PORT);

	@Override
	WarDeploymentContainer getContainer() {
		return container;
	}

}

/*
 * Copyright 2012-2021 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
 *
 *      https://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.boot.deployment;

import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;

/**
 * Deployment tests for Wildfly.
 *
 * @author Christoph Dreis
 * @author Scott Frederick
 */
@Testcontainers(disabledWithoutDocker = true)
class WildflyDeploymentTests extends AbstractDeploymentTests {

	@Container
	static WarDeploymentContainer container = new WarDeploymentContainer("jboss/wildfly:24.0.0.Final",
			"/opt/jboss/wildfly/standalone/deployments", DEFAULT_PORT);

	@Override
	WarDeploymentContainer getContainer() {
		return container;
	}

}

Downgrade Wildfly to work around basic auth bug


//@@author A0142102E
package guitests;

import seedu.tasklist.testutil.TypicalTestTasks;

import org.junit.Test;

import static org.junit.Assert.assertTrue;

public class ClearCommandTest extends TaskListGuiTest {

    @Test
    public void clear() {

        //verify a non-empty list can be cleared
        assertTrue(taskListPanel.isListMatching(td.getTypicalTasks()));
        assertClearCommandSuccess();

        //verify other commands can work after a clear command
        commandBox.runCommand(TypicalTestTasks.task8.getAddCommand());
        assertTrue(taskListPanel.isListMatching(TypicalTestTasks.task8));
        commandBox.runCommand("delete 1");
        assertListSize(0);

        //verify clear command works when the list is empty
        assertClearCommandSuccess();
    }

    private void assertClearCommandSuccess() {
        commandBox.runCommand("clear");
        assertListSize(0);
        assertResultMessage("Your Smart Scheduler has been cleared!");
    }
}

//@@author A0142102E
package guitests;

import seedu.tasklist.testutil.TypicalTestTasks;

import org.junit.Test;

import static org.junit.Assert.assertTrue;

public class ClearCommandTest extends TaskListGuiTest {

    @Test
    public void clear() {

        //verify a non-empty list can be cleared
        assertClearCommandSuccess();

        //verify other commands can work after a clear command
        commandBox.runCommand(TypicalTestTasks.task8.getAddCommand());
        commandBox.runCommand("delete 1");
        assertListSize(0);

        //verify clear command works when the list is empty
        assertClearCommandSuccess();
    }

    private void assertClearCommandSuccess() {
        commandBox.runCommand("clear");
        assertListSize(0);
        assertResultMessage("Your Smart Scheduler has been cleared!");
    }
}

Fix tests for clear command


package fr.utc.assos.uvweb.util;

/**
 * A helper class containing a few parameters for the application's animations.
 */
public class AnimationUtils {
	public static final long CARD_ANIMATION_DELAY_MILLIS = 50;
	public static final long CARD_ANIMATION_DURATION_MILLIS = 750;
}

package fr.utc.assos.uvweb.util;

/**
 * A helper class containing a few parameters for the application's animations.
 */
public class AnimationUtils {
	public static final long CARD_ANIMATION_DELAY_MILLIS = 100;
	public static final long CARD_ANIMATION_DURATION_MILLIS = 800;
}

Tweak CardAnimation values a bit


package tars.model.task;

import tars.commons.exceptions.IllegalValueException;

/**
 * Represents a Task's priority in tars.
 */
public class Priority {
    public static final String MESSAGE_PRIORITY_CONSTRAINTS = "Task priority should be h / m / l";
    public static final String PRIORITY_VALIDATION_REGEX = "[\\p{Lower} ]+";

    public static final String PRIORITY_HIGH = "high";
    public static final String PRIORITY_MEDIUM = "medium";
    public static final String PRIORITY_LOW = "low";

    public static final String PRIORITY_H = "h";
    public static final String PRIORITY_M = "m";
    public static final String PRIORITY_L = "l";

    private String priorityLevel;

    /**
     * Validates given task priority level.
     *
     * @throws IllegalValueException
     *             if given priority level string is invalid.
     */
    public Priority(String priorityLevel) throws IllegalValueException {
        assert priorityLevel != null;
        priorityLevel = priorityLevel.trim();
        if (!isValidPriorityLevel(priorityLevel)) {
            throw new IllegalValueException(MESSAGE_PRIORITY_CONSTRAINTS);
        }
        this.priorityLevel = priorityLevel;
    }

    /**
     * Returns true if a given string is a valid task priority level.
     */
    public static boolean isValidPriorityLevel(String level) {
        return level.matches(PRIORITY_VALIDATION_REGEX);
    }

    @Override
    public String toString() {
        String level = "";

        switch (priorityLevel) {
        case PRIORITY_H:
            level = PRIORITY_HIGH;
            break;
        case PRIORITY_M:
            level = PRIORITY_MEDIUM;
            break;
        case PRIORITY_L:
            level = PRIORITY_LOW;
            break;
        }

        return level;
    }

    public void setLevel(String priorityLevel) {
        this.priorityLevel = priorityLevel;
    }

}

package tars.model.task;

import tars.commons.exceptions.IllegalValueException;

/**
 * Represents a Task's priority in tars.
 */
public class Priority {
    public static final String MESSAGE_PRIORITY_CONSTRAINTS = "Task priority should be h / m / l";
    public static final String PRIORITY_VALIDATION_REGEX = "[\\p{Lower} ]+";

    public String priorityLevel;

    /**
     * Validates given task priority level.
     *
     * @throws IllegalValueException
     *             if given priority level string is invalid.
     */
    public Priority(String priorityLevel) throws IllegalValueException {
        assert priorityLevel != null;
        priorityLevel = priorityLevel.trim();
        if (!isValidPriorityLevel(priorityLevel)) {
            throw new IllegalValueException(MESSAGE_PRIORITY_CONSTRAINTS);
        }
        this.priorityLevel = priorityLevel;
    }

    /**
     * Returns true if a given string is a valid task priority level.
     */
    public static boolean isValidPriorityLevel(String level) {
        return level.matches(PRIORITY_VALIDATION_REGEX);
    }

    @Override
    public String toString() {
        return priorityLevel;
    }

    public void setLevel(String priorityLevel) {
        this.priorityLevel = priorityLevel;
    }

}

Move format priority to ReadOnlyTars.java


import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.text.Text;
import javafx.scene.control.Button;
import javafx.geometry.Pos;

public class SudokuGUI extends BorderPane {

  public SudokuGUI() {
    drawGUI();
  }

  private void drawGUI() {
    Text tMessage = new Text();
    SudokuPane sPane = new SudokuPane();
    Button btSolve = new Button("Solve");
    Button btClear = new Button("Clear");

    btSolve.setOnAction(e -> solve(sPane, tMessage));
    btClear.setOnAction(e -> clear(sPane, tMessage));

    HBox hbControl = new HBox(10);
    hbControl.getChildren().addAll(btSolve, btClear);
    hbControl.setAlignment(Pos.CENTER);

    setTop(tMessage);
    setCenter(sPane);
    setBottom(hbControl);
    setAlignment(tMessage, Pos.CENTER);
  }

  private void solve(SudokuPane sPane, Text tMessage) {
    try {
      if (!sPane.solve()) {
        tMessage.setText("Only 1-9 or empty spaces allowed");
      }
    } catch (IllegalArgumentException ex) {
      tMessage.setText("Invalid Sudoku Grid");
    }
  }

  private void clear(SudokuPane sPane, Text tMessage) {
    sPane.clear();
    tMessage.setText("");
  }
}

import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.text.Text;
import javafx.scene.control.Button;
import javafx.geometry.Pos;

public class SudokuGUI extends BorderPane {

  public SudokuGUI() {
    drawGUI();
  }

  private void drawGUI() {
    Text tMessage = new Text();
    SudokuPane sPane = new SudokuPane();
    Button btSolve = new Button("Solve");
    Button btClear = new Button("Clear");

    btSolve.setOnAction(e -> solve(sPane, tMessage, btSolve));
    btClear.setOnAction(e -> clear(sPane, tMessage, btSolve));

    HBox hbControl = new HBox(10);
    hbControl.getChildren().addAll(btSolve, btClear);
    hbControl.setAlignment(Pos.CENTER);

    setTop(tMessage);
    setCenter(sPane);
    setBottom(hbControl);
    setAlignment(tMessage, Pos.CENTER);
  }

  private void solve(SudokuPane sPane, Text tMessage, Button btSolve) {
    try {
      if (!sPane.solve()) {
        tMessage.setText("Only 1-9 or empty spaces allowed");
      } else {
        btSolve.setDisable(true);
      }
    } catch (IllegalArgumentException ex) {
      tMessage.setText("Invalid Sudoku Grid");
    }
  }

  private void clear(SudokuPane sPane, Text tMessage, Button btSolve) {
    sPane.clear();
    tMessage.setText("");
    btSolve.setDisable(false);
  }
}

Disable Solve button after a valid solution is found


/*
 * Copyright 2016-2017 Red Hat, Inc, and individual contributors.
 *
 * 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 io.openshift.booster;

import java.net.URL;

import com.jayway.restassured.RestAssured;
import io.openshift.booster.service.GreetingProperties;
import org.arquillian.cube.openshift.impl.enricher.RouteURL;
import org.jboss.arquillian.junit.Arquillian;
import org.junit.Before;
import org.junit.runner.RunWith;

@RunWith(Arquillian.class)
public class OpenShiftIT extends AbstractBoosterApplicationTest {

    @RouteURL("${app.name}")
    private URL baseURL;

    @Before
    public void setup() throws Exception {
        RestAssured.baseURI = baseURL + "api/greeting";
    }

    protected GreetingProperties getProperties() {
        return new GreetingProperties();
    }

}

/*
 * Copyright 2016-2017 Red Hat, Inc, and individual contributors.
 *
 * 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 io.openshift.booster;

import java.net.URL;

import com.jayway.restassured.RestAssured;
import io.openshift.booster.service.GreetingProperties;
import org.arquillian.cube.openshift.impl.enricher.AwaitRoute;
import org.arquillian.cube.openshift.impl.enricher.RouteURL;
import org.jboss.arquillian.junit.Arquillian;
import org.junit.Before;
import org.junit.runner.RunWith;

@RunWith(Arquillian.class)
public class OpenShiftIT extends AbstractBoosterApplicationTest {

    @AwaitRoute(path = "/health")
    @RouteURL("${app.name}")
    private URL baseURL;

    @Before
    public void setup() throws Exception {
        RestAssured.baseURI = baseURL + "api/greeting";
    }

    protected GreetingProperties getProperties() {
        return new GreetingProperties();
    }

}

Add @AwaitRule to integration test


/*
 * Copyright 2016 Attribyte, LLC
 *
 * 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.attribyte.wp.model;

/**
 * Metadata associated with a post, user, or
 * other object.
 */
public class Meta {

   /**
    * Creates metadata.
    * @param id The id.
    * @param key The key.
    * @param value The value.
    */
   public Meta(final long id, final String key, final String value) {
      this.id = id;
      this.key = key;
      this.value = value;
   }

   /**
    * The unique id.
    */
   public final long id;

   /**
    * The key.
    */
   public final String key;

   /**
    * The value.
    */
   public final String value;
}

/*
 * Copyright 2016 Attribyte, LLC
 *
 * 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.attribyte.wp.model;

/**
 * Metadata associated with a post, user, or
 * other object.
 */
public class Meta {

   /**
    * Creates metadata with no assigned id.
    * @param key The key.
    * @param value The value.
    */
   public Meta(final String key, final String value) {
      this(0L, key, value);
   }

   /**
    * Creates metadata.
    * @param id The id.
    * @param key The key.
    * @param value The value.
    */
   public Meta(final long id, final String key, final String value) {
      this.id = id;
      this.key = key;
      this.value = value;
   }

   /**
    * The unique id.
    */
   public final long id;

   /**
    * The key.
    */
   public final String key;

   /**
    * The value.
    */
   public final String value;
}

Add constructor that does not require id.


package pl.koszela.jan.domain;

import java.util.Objects;

/**
 * Created on 12.08.2017.
 *
 * @author Jan Koszela
 */
public class Order {

  private String productName;
  private int quantity;

  public Order(String productName, int quantity) {
    this.productName = productName;
    this.quantity = quantity;
  }

  public String getProductName() {
    return this.productName;
  }

  public int getQuantity() {
    return this.quantity;
  }

  public void setProductName(String productName) {
    this.productName = productName;
  }

  public void setQuantity(int quantity) {
    this.quantity = quantity;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    Order order = (Order) o;
    return Objects.equals(productName, order.productName);
  }

  @Override
  public int hashCode() {
    return Objects.hash(productName, quantity);
  }
}

package pl.koszela.jan.domain;

import java.util.Objects;

/**
 * Created on 12.08.2017.
 *
 * @author Jan Koszela
 */
public class Order {

  private Product product;
  private int quantity;

  public Order(String productName, int quantity) {
    this.product = Product.builder()
        .item(productName)
        .build();
    this.quantity = quantity;
  }

  public Product getProduct() {
    return this.product;
  }

  public int getQuantity() {
    return this.quantity;
  }

  public void setProduct(Product productName) {
    this.product = productName;
  }

  public void setQuantity(int quantity) {
    this.quantity = quantity;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    Order order = (Order) o;
    return Objects.equals(product, order.product);
  }

  @Override
  public int hashCode() {
    return Objects.hash(product, quantity);
  }

  @Override
  public String toString() {
    return "Order{" +
        "productName='" + product + '\'' +
        ", quantity=" + quantity +
        '}';
  }
}

Add toString method for debuging purposes


package year2014;

import java.util.Scanner;
import java.util.stream.IntStream;

/**
 *
Digital Root

 *
The digital root of a number is obtained by summing its individual digits,
 * summing those individual digits, and continuing the process until the final sum
 * is a single digit (that is, less than 10). For example, the digital root of 1234 is 1

 *
 * @author John Cameron
 * @see Problem Descrption and Requirements
 */
public class DigitalRoot {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        System.out.println("Enter a non-negative integer number: ");

        final int input = Math.abs(scanner.nextInt());

        scanner.close();

        int digitalRoot = input;

        while (digitalRoot > 9)
            digitalRoot = sumIndividualDigits(digitalRoot);

        System.out.println("The digital root of " + input + " is " + digitalRoot);

    }

    private static int sumIndividualDigits(int input) {
        if (input < 0)
            throw new IllegalArgumentException("Input must be positive");

        char[] chars = String.valueOf(input).toCharArray();

        return IntStream.range(0, chars.length)
                .map(i -> Character.getNumericValue(chars[i])).sum();
    }

}

package year2014;

import java.util.Scanner;

/**
 *
Digital Root

 *
The digital root of a number is obtained by summing its individual digits,
 * summing those individual digits, and continuing the process until the final sum
 * is a single digit (that is, less than 10). For example, the digital root of 1234 is 1

 *
 * @author John Cameron
 * @see Problem Descrption and Requirements
 */
public class DigitalRoot {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        System.out.println("Enter a non-negative integer number: ");

        final int input = Math.abs(scanner.nextInt());

        scanner.close();

        int digitalRoot = input;

        while (digitalRoot > 9)
            digitalRoot = sumIndividualDigits(digitalRoot);

        System.out.println("The digital root of " + input + " is " + digitalRoot);

    }

    private static int sumIndividualDigits(int input) {
        if (input < 0)
            throw new IllegalArgumentException("Input must be positive");

        int sum = 0;

        while (input > 0) {

            sum += input % 10;
            input /= 10;

        }

        return sum;

        //String approach method

        /*char[] chars = String.valueOf(input).toCharArray();

        return IntStream.range(0, chars.length)
                .map(i -> Character.getNumericValue(chars[i])).sum();*/
    }

}

Use Integer approach in summing digits


import static java.lang.reflect.Modifier.*;
import static org.junit.Assert.*;

import org.junit.Test;

public class SuperTest {
  @Test
  public void isNotPublic() {
    int modifiers = Super.class.getModifiers();
    boolean isPublic = isPublic(modifiers);
    assertFalse(isPublic);
  }
}

import static java.lang.reflect.Modifier.*;
import static org.junit.Assert.*;

import org.junit.Test;

public class SuperTest {
  @Test
  public void isNotPublic() {
    int modifiers = Super.class.getModifiers();
    boolean isPublic = isPublic(modifiers);
    assertFalse("Super is public (modifiers: " + modifiers + ").", isPublic);     }
}

Add value of modifiers to assertion message.


package controller;

import java.io.File;
import java.util.List;
import javafx.application.Application;
import javafx.stage.Stage;

public class MainController extends Application {
    private UserInterface userInterface;

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

	Parser.parserXml("gridInput.xml");

	launch(args);
    }

    @Override
    public void start(Stage s) throws Exception {
	// create our UI
	userInterface = new UserInterface(s, this);
    }

    public void initializeSimulationWithData(File XMLData) {
	try {
	    List<TestCell> cellList = Parser.parserXml(XMLData
		    .getAbsolutePath());

	} catch (Exception e) {
	    System.out.println("Error processing file, make sure it's XML.");
	}
    }

    public void startSimulation() {
	// TODO Auto-generated method stub

    }

    public void stopSimulation() {
	// TODO Auto-generated method stub

    }

    public void stepSimulation() {
	// TODO Auto-generated method stub

    }

}

package controller;

import java.io.File;
import java.util.List;
import javafx.application.Application;
import javafx.stage.Stage;

public class MainController extends Application {
    private UserInterface userInterface;

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

	Parser.parserXml("gridInput.xml");

	launch(args);
    }

    @Override
    public void start(Stage s) throws Exception {
	// create our UI
	userInterface = new UserInterface(s, this);
    }

    public void initializeSimulationWithData(File XMLData) {
	try {
	    @SuppressWarnings("unchecked")
        List<TestCell> cellList = Parser.parserXml(XMLData
		    .getAbsolutePath());
	    initializeSimulationObjects(cellList);
	} catch (Exception e) {
	    System.out.println("Error processing file, make sure it's XML.");
	}
    }

    private void initializeSimulationObjects(List<TestCell> cellList){
        for (TestCell c : cellList){
            try {
                //create a patch object at the x and y location

                //create a cell object
                String classPathAndName = "simulationObjects."+c.cellType;
                Class<?> cellClass = Class.forName(classPathAndName);
                System.out.println(cellClass);
                Object cell = cellClass.newInstance();
                //assign the cell to the patch
                //add the patch to grid manager

            }
            catch (ClassNotFoundException e) {
                System.out.println("One or more cell classes from your XML file could not be found.");
            }
            catch (InstantiationException e) {
                System.out.println("One or more paramaters could not be applied to the simulation.");
            }
            catch (IllegalAccessException e) {
                System.out.println("Couldn't create a class from the XML file: illegal access.");
            }
        }
    }

    public void startSimulation() {
	// TODO Auto-generated method stub

    }

    public void stopSimulation() {
	// TODO Auto-generated method stub

    }

    public void stepSimulation() {
	// TODO Auto-generated method stub

    }

}

Use the parser and initialize cell classes using reflection.


package com.africastalking;

import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Body;

interface IToken {

    @FormUrlEncoded
    @POST("checkout/token/create")
    Call<String> createCheckoutToken(@Field("phoneNumber") String phoneNumber);

    @Headers("Content-Type: application-json")
    @POST("auth-token/generate")
    Call<String> generateAuthToken(@Body String body);
}

package com.africastalking;

import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Body;

interface IToken {

    @FormUrlEncoded
    @POST("checkout/token/create")
    Call<String> createCheckoutToken(@Field("phoneNumber") String phoneNumber);

    @Headers("Content-Type: application/json")
    @POST("auth-token/generate")
    Call<String> generateAuthToken(@Body String body);
}

Fix content type on auth token service


package io.bitsquare.http;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

// TODO route over tor
public class HttpClient {

    private final String baseUrl;

    public HttpClient(String baseUrl) {
        this.baseUrl = baseUrl;
    }

    public String requestWithGET(String param) throws IOException, HttpException {
        HttpURLConnection connection = null;
        try {
            URL url = new URL(baseUrl + param);
            connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.setConnectTimeout(10000);
            connection.setReadTimeout(10000);

            if (connection.getResponseCode() == 200) {
                return convertInputStreamToString(connection.getInputStream());
            } else {
                connection.getErrorStream().close();
                throw new HttpException(convertInputStreamToString(connection.getErrorStream()));
            }
        } finally {
            if (connection != null)
                connection.getInputStream().close();
        }
    }

    private String convertInputStreamToString(InputStream inputStream) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        StringBuilder stringBuilder = new StringBuilder();
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            stringBuilder.append(line);
        }
        return stringBuilder.toString();
    }

    @Override
    public String toString() {
        return "HttpClient{" +
                "baseUrl='" + baseUrl + '\'' +
                '}';
    }
}

package io.bitsquare.http;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

// TODO route over tor
public class HttpClient {

    private final String baseUrl;

    public HttpClient(String baseUrl) {
        this.baseUrl = baseUrl;
    }

    public String requestWithGET(String param) throws IOException, HttpException {
        HttpURLConnection connection = null;
        try {
            URL url = new URL(baseUrl + param);
            connection = (HttpURLConnection) url.openConnection();
            connection.setRequestMethod("GET");
            connection.setConnectTimeout(10_000);
            connection.setReadTimeout(10_000);

            if (connection.getResponseCode() == 200) {
                return convertInputStreamToString(connection.getInputStream());
            } else {
                String error = convertInputStreamToString(connection.getErrorStream());
                connection.getErrorStream().close();
                throw new HttpException(error);
            }
        } finally {
            if (connection != null)
                connection.getInputStream().close();
        }
    }

    private String convertInputStreamToString(InputStream inputStream) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        StringBuilder stringBuilder = new StringBuilder();
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            stringBuilder.append(line);
        }
        return stringBuilder.toString();
    }

    @Override
    public String toString() {
        return "HttpClient{" +
                "baseUrl='" + baseUrl + '\'' +
                '}';
    }
}

Read HTTP error stream before closing it


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

/**
 * Generalizes Mask functionality for masking Aliquot, File, etc.
 * @author doswellj
 * @param strType Type of Mask (e.g., aliquot, file, run, etc.)
 * @param strId	  The id associated to the type
 * @param strDescription The mask description associated to the mask type and Id.
 *
 */
public class MaskService
{
    public void setMask(String strType, String strId, String strDescription)
    {
        if (strType.equals("aliquot"))
        {
            //TODO Find Aliquot record based on the its id and set the status to "Masked" and its Description
        }
        if (strType.equals("file"))
        {
        	//TODO Find File record based on the its id and set the status to "Masked" and its Description
        }

    }

}

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

/**
 * Generalizes Mask functionality for masking Aliquot, File, etc.
 * @author doswellj
 * @param strType Type of Mask (e.g., aliquot, file, run, etc.)
 * @param strId	  The id associated to the type
 * @param strDescription The mask description associated to the mask type and Id.
 *
 */
public class MaskService
{

	//This functionality is pending the completed Object Model
	public void setMask(String strType, String strId, String strDescription)
    {
        if (strType.equals("aliquot"))
        {
            //TODO Find Aliquot record based on the strID

        	//TODO Set File Status record to "Masked".

        }
        if (strType.equals("file"))
        {
        	//TODO Find File record based on the its strID

        	//TODO Set File Status record to "Masked".
        }

    }

}

Mask Service is pending the completed object model


package org.jboss.as.remoting;

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

import org.jboss.dmr.ModelNode;

/**
 * Protocols that can be used for a remoting connection
 *
 * @author Stuart Douglas
 */
public enum Protocol {

    REMOTE("remote"),
    HTTP_REMOTING("http-remoting"),
    HTTPS_REMOTING("https-remoting");

    private static final Map<String, Protocol> MAP;

    static {
        final Map<String, Protocol> map = new HashMap<String, Protocol>();
        for (Protocol value : values()) {
            map.put(value.localName, value);
        }
        MAP = map;
    }

    public static Protocol forName(String localName) {
        final Protocol value = localName != null ? MAP.get(localName.toLowerCase()) : null;
        return value == null ? Protocol.valueOf(localName.toUpperCase(Locale.ENGLISH)) : value;
    }

    private final String localName;

    Protocol(final String localName) {
        this.localName = localName;
    }

    @Override
    public String toString() {
        return localName;
    }

    public ModelNode toModelNode() {
        return new ModelNode().set(toString());
    }
}

package org.jboss.as.remoting;

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

import org.jboss.dmr.ModelNode;

/**
 * Protocols that can be used for a remoting connection
 *
 * @author Stuart Douglas
 */
public enum Protocol {

    REMOTE("remote"),
    HTTP_REMOTING("http-remoting"),
    HTTPS_REMOTING("https-remoting");

    private static final Map<String, Protocol> MAP;

    static {
        final Map<String, Protocol> map = new HashMap<String, Protocol>();
        for (Protocol value : values()) {
            map.put(value.localName, value);
        }
        MAP = map;
    }

    public static Protocol forName(String localName) {
        final Protocol value = localName != null ? MAP.get(localName.toLowerCase(Locale.ENGLISH)) : null;
        return value == null && localName != null ? Protocol.valueOf(localName.toUpperCase(Locale.ENGLISH)) : value;
    }

    private final String localName;

    Protocol(final String localName) {
        this.localName = localName;
    }

    @Override
    public String toString() {
        return localName;
    }

    public ModelNode toModelNode() {
        return new ModelNode().set(toString());
    }
}

Fix NPE warning; use locale for toLowerCase


package com.vtence.molecule.http;

public final class HeaderNames {
    public static final String ACCEPT_ENCODING = "Accept-Encoding";
    public static final String ACCEPT_LANGUAGE = "Accept-Language";
    public static final String ALLOW = "Allow";
    public static final String CACHE_CONTROL = "Cache-Control";
    public static final String CONTENT_ENCODING = "Content-Encoding";
    public static final String CONTENT_LANGUAGE = "Content-Language";
    public static final String CONTENT_LENGTH = "Content-Length";
    public static final String CONTENT_TYPE = "Content-Type";
    public static final String DATE = "Date";
    public static final String ETAG = "ETag";
    public static final String IF_MODIFIED_SINCE = "If-Modified-Since";
    public static final String IF_NONE_MATCH = "If-None-Match";
    public static final String LAST_MODIFIED = "Last-Modified";
    public static final String LOCATION = "Location";
    public static final String SERVER = "Server";
    public static final String TRANSFER_ENCODING = "Transfer-Encoding";

    private HeaderNames() {}

    public final class Response {
    }
}

package com.vtence.molecule.http;

public interface HeaderNames {
    static final String ACCEPT_ENCODING = "Accept-Encoding";
    static final String ACCEPT_LANGUAGE = "Accept-Language";
    static final String ALLOW = "Allow";
    static final String CACHE_CONTROL = "Cache-Control";
    static final String CONTENT_ENCODING = "Content-Encoding";
    static final String CONTENT_LANGUAGE = "Content-Language";
    static final String CONTENT_LENGTH = "Content-Length";
    static final String CONTENT_TYPE = "Content-Type";
    static final String DATE = "Date";
    static final String ETAG = "ETag";
    static final String IF_MODIFIED_SINCE = "If-Modified-Since";
    static final String IF_NONE_MATCH = "If-None-Match";
    static final String LAST_MODIFIED = "Last-Modified";
    static final String LOCATION = "Location";
    static final String SERVER = "Server";
    static final String TRANSFER_ENCODING = "Transfer-Encoding";
}

Make header names an interface with constants


package ee.shy.cli.command;

import ee.shy.cli.Command;
import ee.shy.cli.SuperCommand;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

public class CompletionCommand implements Command {
    private final Command rootCommand;

    public CompletionCommand(Command rootCommand) {
        this.rootCommand = rootCommand;
    }

    @Override
    public void execute(String[] args) throws IOException {
        List<String> argsList = new ArrayList<>(Arrays.asList(args));
        argsList.add(null);

        Command command = rootCommand;
        for (String arg : argsList) {
            if (command instanceof SuperCommand) {
                Map<String, Command> subCommands = ((SuperCommand) command).getSubCommands();
                Command subCommand = subCommands.get(arg);
                if (subCommand != null) {
                    command = subCommand;
                }
                else {
                    System.out.println(String.join(" ", subCommands.keySet()));
                    break;
                }
            }
            else if (command instanceof HelpCommand) {
                command = ((HelpCommand) command).getRootCommand();
            }
        }
    }

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

package ee.shy.cli.command;

import ee.shy.cli.Command;
import ee.shy.cli.SuperCommand;

import java.io.IOException;
import java.util.Map;

public class CompletionCommand implements Command {
    private final Command rootCommand;

    public CompletionCommand(Command rootCommand) {
        this.rootCommand = rootCommand;
    }

    @Override
    public void execute(String[] args) throws IOException {
        Command command = rootCommand;
        for (int i = 0; i <= args.length; i++) { // loop for one extra time for supercommands without arguments
            if (command instanceof SuperCommand) {
                Map<String, Command> subCommands = ((SuperCommand) command).getSubCommands();
                Command subCommand;
                if ((i < args.length - 1) // complete subcommand even if fully typed (don't nest yet)
                        && ((subCommand = subCommands.get(args[i])) != null)) {
                    command = subCommand;
                }
                else {
                    System.out.println(String.join(" ", subCommands.keySet()));
                    break;
                }
            }
            else if (command instanceof HelpCommand) {
                command = ((HelpCommand) command).getRootCommand(); // changed command point without parsing extra argument
                i--; // step back for that extra argument
            }
        }
    }

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

Fix bash completion for HelpCommand and fully typed subcommands


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

package org.optaplanner.core.score.holder;

import java.io.Serializable;

import org.drools.common.AgendaItem;
import org.kie.event.rule.ActivationUnMatchListener;
import org.kie.runtime.rule.RuleContext;
import org.kie.runtime.rule.Session;

/**
 * Abstract superclass for {@link ScoreHolder}.
 */
public abstract class AbstractScoreHolder implements ScoreHolder, Serializable {

    protected void registerUndoListener(RuleContext kcontext, ActivationUnMatchListener undoListener) {
        AgendaItem agendaItem = (AgendaItem) kcontext.getMatch();
        if (agendaItem.getActivationUnMatchListener() != null) {
            Session workingMemory = null; // Should not be used by the undoListener anyway
            agendaItem.getActivationUnMatchListener().unMatch(workingMemory, agendaItem);
        }
        agendaItem.setActivationUnMatchListener(undoListener);
    }

}

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

package org.optaplanner.core.score.holder;

import java.io.Serializable;

import org.drools.core.common.AgendaItem;
import org.kie.event.rule.ActivationUnMatchListener;
import org.kie.runtime.rule.RuleContext;
import org.kie.runtime.rule.Session;

/**
 * Abstract superclass for {@link ScoreHolder}.
 */
public abstract class AbstractScoreHolder implements ScoreHolder, Serializable {

    protected void registerUndoListener(RuleContext kcontext, ActivationUnMatchListener undoListener) {
        AgendaItem agendaItem = (AgendaItem) kcontext.getMatch();
        if (agendaItem.getActivationUnMatchListener() != null) {
            Session workingMemory = null; // Should not be used by the undoListener anyway
            agendaItem.getActivationUnMatchListener().unMatch(workingMemory, agendaItem);
        }
        agendaItem.setActivationUnMatchListener(undoListener);
    }

}

Resolve split-packages: move everything from drools-core under org.drools.core: move org.drools.common


/*-
 * Copyright 2015 Diamond Light Source Ltd.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */

package org.eclipse.dawnsci.analysis.api.tree;

public class TreeUtils {

	/**
	 * Get the path
	 * @param tree
	 * @param node
	 * @return path to node, return null if not found
	 */
	public static String getPath(Tree tree, Node node) {
		return getPathDepthFirst(tree.getGroupNode(), node);
	}

	private static String getPathDepthFirst(final GroupNode group, final Node node) {
		for (NodeLink l : group) {
			if (l.getDestination() == node) {
				return l.getFullName();
			} else if (l.isDestinationGroup()) {
				String p = getPathDepthFirst((GroupNode) l.getDestination(), node);
				if (p != null)
					return p;
			}
		}
		return null;
	}
}

/*-
 * Copyright 2015 Diamond Light Source Ltd.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */

package org.eclipse.dawnsci.analysis.api.tree;

public class TreeUtils {

	/**
	 * Get the path
	 * @param tree
	 * @param node
	 * @return path to node, return null if not found
	 */
	public static String getPath(Tree tree, Node node) {
		GroupNode g = tree.getGroupNode();
		if (g == node) {
			return tree.getNodeLink().getFullName();
		}
		return getPathDepthFirst(tree.getGroupNode(), node);
	}

	private static String getPathDepthFirst(final GroupNode group, final Node node) {
		for (NodeLink l : group) {
			if (l.getDestination() == node) {
				return l.getFullName();
			} else if (l.isDestinationGroup()) {
				String p = getPathDepthFirst((GroupNode) l.getDestination(), node);
				if (p != null)
					return p;
			}
		}
		return null;
	}
}

Fix case of finding the top of tree node


package model.transform.tasks;

import model.transform.base.ImageTransformTask;

public class StoreOptions extends ImageTransformTask {

    public StoreOptions() {
        super("store");
    }

    public static class Builder {
        private StoreOptions storeOptions;

        public Builder() {
            this.storeOptions = new StoreOptions();
        }

        public Builder filename(String filename) {
            storeOptions.addOption("filename", filename);
            return this;
        }

        public Builder location(String location) {
            storeOptions.addOption("location", location);
            return this;
        }

        public Builder path(String path) {
            storeOptions.addOption("path", path);
            return this;
        }

        public Builder container(String container) {
            storeOptions.addOption("container", container);
            return this;
        }

        public Builder region(String region) {
            storeOptions.addOption("region", region);
            return this;
        }

        public Builder access(String access) {
            storeOptions.addOption("access", access);
            return this;
        }

        public Builder base64Decode(boolean base64Decode) {
            storeOptions.addOption("base64decode", base64Decode);
            return this;
        }

        public StoreOptions build() {
            return storeOptions;
        }
    }
}

package model.transform.tasks;

import model.transform.base.ImageTransformTask;

public class StoreOptions extends ImageTransformTask {

    // Constructor left public because this task can be used with default options
    public StoreOptions() {
        super("store");
    }

    public static class Builder {
        private StoreOptions storeOptions;

        public Builder() {
            this.storeOptions = new StoreOptions();
        }

        public Builder filename(String filename) {
            storeOptions.addOption("filename", filename);
            return this;
        }

        public Builder location(String location) {
            storeOptions.addOption("location", location);
            return this;
        }

        public Builder path(String path) {
            storeOptions.addOption("path", path);
            return this;
        }

        public Builder container(String container) {
            storeOptions.addOption("container", container);
            return this;
        }

        public Builder region(String region) {
            storeOptions.addOption("region", region);
            return this;
        }

        public Builder access(String access) {
            storeOptions.addOption("access", access);
            return this;
        }

        public Builder base64Decode(boolean base64Decode) {
            storeOptions.addOption("base64decode", base64Decode);
            return this;
        }

        public StoreOptions build() {
            return storeOptions;
        }
    }
}

Add comment to clarify constructor access


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

import junit.framework.*;

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

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

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

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

	    return suite;
	}
}

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

import junit.framework.*;

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

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

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

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

	    return suite;
	}
}

Integrate the hashtable Unit testcases.


/*
 * Copyright 2013-2019 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.cloudfoundry.client.v3.builds;

import org.cloudfoundry.client.v3.FilterParameter;
import org.cloudfoundry.client.v3.PaginatedRequest;
import org.immutables.value.Value;

import java.util.List;

/**
 * The request payload for the List Builds operation
 */
@Value.Immutable
abstract class _ListBuildsRequest extends PaginatedRequest {

    /**
     * The application ids
     */
    @FilterParameter("app_guids")
    abstract List<String> getApplicationIds();

    /**
     * The build states
     */
    @FilterParameter("states")
    abstract List<String> getStates();

}

/*
 * Copyright 2013-2019 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.cloudfoundry.client.v3.builds;

import org.cloudfoundry.client.v3.FilterParameter;
import org.cloudfoundry.client.v3.PaginatedRequest;
import org.immutables.value.Value;

import java.util.List;

/**
 * The request payload for the List Builds operation
 */
@Value.Immutable
abstract class _ListBuildsRequest extends PaginatedRequest {

    /**
     * The application ids
     */
    @FilterParameter("app_guids")
    abstract List<String> getApplicationIds();

    /**
     * The package ids
     */
    @FilterParameter("package_guids")
    abstract List<String> getPackageIds();

    /**
     * The build states
     */
    @FilterParameter("states")
    abstract List<String> getStates();

}

Implement filtering of builds based on package IDs


package seedu.ezdo.model;

import java.util.EmptyStackException;

/*
 * Array-based implementation for a stack with fixed size. Used for undo & redo stacks.
 * If stack goes past max capacity, the oldest item to be pushed is replaced.
 */
public class FixedStack<T> {
    private int index;
    private T[] array;

    public FixedStack(int capacity) {
        array = (T[]) new Object[capacity];
        index = -1;
    }

    public void push(T item) {
        index = (index + 1) % 5; // wraps around
        array[index] = item;
        System.out.println("item added at index: " + index);
    }

    public T pop() throws EmptyStackException {
        if (index == -1 || array[index] == null) {
            throw new EmptyStackException();
        }
        T item = array[index];
        array[index] = null;
        System.out.println(item + " at index " + index + " removed");
        if (index == 0) {
            index = array.length - 1;
            System.out.println("index now: " + index);
        } else {
            index = index - 1;
            System.out.println("index now: " + index);
        }
        return item;
    }

    public boolean isEmpty() {
        for (int i = 0; i < array.length; i++) {
            if (array[i] != null) {
                return false;
            }
        }
        return true;
    }

    public void clear() {
        for (int i = 0; i < array.length; i++) {
            array[i] = null;
        }
        index = -1;
    }
}

package seedu.ezdo.model;

import java.util.EmptyStackException;

/*
 * Array-based implementation for a stack with fixed size. Used for undo & redo stacks.
 * If stack goes past max capacity, the oldest item to be pushed is replaced.
 */
public class FixedStack<T> {
    private int index;
    private T[] array;

    public FixedStack(int capacity) {
        array = (T[]) new Object[capacity];
        index = -1;
    }

    public void push(T item) {
        index = (index + 1) % ModelManager.STACK_CAPACITY; // wraps around
        array[index] = item;
    }

    public T pop() throws EmptyStackException {
        if (index == -1 || array[index] == null) {
            throw new EmptyStackException();
        }
        T item = array[index];
        array[index] = null;
        if (index == 0) {
            index = array.length - 1;
        } else {
            index = index - 1;
        }
        return item;
    }

    public boolean isEmpty() {
        for (int i = 0; i < array.length; i++) {
            if (array[i] != null) {
                return false;
            }
        }
        return true;
    }

    public void clear() {
        for (int i = 0; i < array.length; i++) {
            array[i] = null;
        }
        index = -1;
    }
}

Remove magic numbers and print statements


package tc.oc.projectares.api;

import java.util.Collection;
import java.util.Set;
import java.util.UUID;

import javax.annotation.Nonnull;

import org.bukkit.World;

public interface Match {
    @Nonnull World getWorld();

    @Nonnull UUID getUUID();

    @Nonnull boolean isRunning();

    @Nonnull boolean start();

    @Nonnull boolean end();

    @Nonnull boolean end(@Nonnull Team winningTeam);

    @Nonnull Collection<Player> getPlayers();

    @Nonnull Set<Player> getParticipatingPlayers();

    @Nonnull Set<Player> getObservingPlayers();

    Player getPlayer(org.bukkit.entity.Player player);

    @Nonnull Player addPlayer(org.bukkit.entity.Player player);

    void removePlayer(org.bukkit.entity.Player player);

    void removeAllPlayers();

    void broadcast(String message);

    @Nonnull Set<Team> getTeams();

    @Nonnull Set<Team> getParticipatingTeams();

    @Nonnull Set<Team> getObservingTeams();

    Team getFirstOther(Team exclude);
}

package tc.oc.projectares.api;

import java.util.Collection;
import java.util.Set;
import java.util.UUID;

import javax.annotation.Nonnull;

import org.bukkit.World;

public interface Match {
    @Nonnull World getWorld();

    @Nonnull UUID getUUID();

    @Nonnull boolean isRunning();

    @Nonnull boolean start();

    @Nonnull boolean end();

    @Nonnull boolean end(@Nonnull Team winningTeam);

    @Nonnull Collection<Player> getPlayers();

    @Nonnull Set<Player> getParticipatingPlayers();

    @Nonnull Set<Player> getObservingPlayers();

    void broadcast(String message);

    @Nonnull Set<Team> getTeams();

    @Nonnull Set<Team> getParticipatingTeams();

    @Nonnull Set<Team> getObservingTeams();

    Team getFirstOther(Team exclude);
}

Remove some methods that shouldn't have been exposed


// Copyright 2019 Google LLC
//
// 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
//
//     https://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.sps;

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

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

}

Add new line at EOF


package edu.stuy.starlorn.entities;

import edu.stuy.starlorn.upgrades.GunUpgrade;

import java.util.LinkedList;

public class Ship extends Entity {
    protected LinkedList<GunUpgrade> _gunupgrades;
    protected int _baseDamage, _baseShotSpeed, _health;
    protected double _baseAim;

    public Ship() {
        super();
        _gunupgrades = new LinkedList<GunUpgrade>();
        _baseDamage = 1;
        _baseShotSpeed = 1;
        _health = 10;
        _baseAim = Math.PI/2; //Aim up by default
    }

    public void addUpgrade(GunUpgrade upgrade) {
        _gunupgrades.add(upgrade);
    }

    /*
     * Create the shots based on the available GunUpgrades
     */
    public void shoot() {
        GunUpgrade topShot = _gunupgrades.get(0);
        int damage = _baseDamage;
        int shotSpeed = _baseShotSpeed;
        for (GunUpgrade up : _gunupgrades) {
            if (up.getNumShots() > topShot.getNumShots())
                topShot = up;
            damage = up.getDamage(damage);
            shotSpeed = up.getShotSpeed(shotSpeed);
        }
        // Create new shots, based on dem vars
        int numShots = topShot.getNumShots();
        for (int i = 0; i < numShots; i++) {
            new Bullet(_baseAim + topShot.getAimAngle(), damage, shotSpeed);
        }
    }
}

package edu.stuy.starlorn.entities;

import edu.stuy.starlorn.upgrades.GunUpgrade;

import java.util.LinkedList;

public class Ship extends Entity {
    protected LinkedList<GunUpgrade> _gunupgrades;
    protected int _baseDamage, _baseShotSpeed, _health;
    protected double _baseAim;

    public Ship() {
        super();
        _gunupgrades = new LinkedList<GunUpgrade>();
        _baseDamage = 1;
        _baseShotSpeed = 1;
        _health = 10;
        _baseAim = Math.PI/2; //Aim up by default
    }

    public void addUpgrade(GunUpgrade upgrade) {
        _gunupgrades.add(upgrade);
    }

    /*
     * Create the shots based on the available GunUpgrades
     */
    public void shoot() {
        GunUpgrade topShot = _gunupgrades.get(0);
        int damage = _baseDamage;
        int shotSpeed = _baseShotSpeed;
        for (GunUpgrade up : _gunupgrades) {
            if (up.getNumShots() > topShot.getNumShots())
                topShot = up;
            damage = up.getDamage(damage);
            shotSpeed = up.getShotSpeed(shotSpeed);
        }
        // Create new shots, based on dem vars
        int numShots = topShot.getNumShots();
        for (int i = 0; i < numShots; i++) {
            Bullet b = new Bullet(_baseAim + topShot.getAimAngle(), damage, shotSpeed);
            b.setWorld(this.getWorld());
        }
    }
}

Add bullet to world when it's created


package io.khasang.wlogs.controller;

import io.khasang.wlogs.model.InsertDataTable;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class AppController {
    @RequestMapping("/")
    public String welcome(Model model) {
        model.addAttribute("greeting", "Welcome to our best wLogs!");
        model.addAttribute("tagline", "The one and only amazing logs system!");
        return "welcome";
    }

    @RequestMapping("/backup")
    public String backup(Model model) {
        model.addAttribute("backup", "Success");
        return "backup";
    }

    @RequestMapping("/admin")
    public String admin(Model model) {
        model.addAttribute("admin", "You are number 1!");
        return "admin";
    }

    @RequestMapping("/createtable")
    public String crateTable(Model model) {
        InsertDataTable sql = new InsertDataTable();
        model.addAttribute("createtable", sql.sqlInsertCheck());
        return "createtable";
    }
}

package io.khasang.wlogs.controller;

import io.khasang.wlogs.model.InsertDataTable;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class AppController {
    @RequestMapping("/")
    public String welcome(Model model) {
        model.addAttribute("greeting", "Welcome to our best wLogs!");
        model.addAttribute("tagline", "The one and only amazing logs system!");
        return "welcome";
    }

    @RequestMapping("/backup")
    public String backup(Model model) {
        model.addAttribute("backup", "Success");
        return "backup";
    }

    @RequestMapping("/admin")
    public String admin(Model model) {
        model.addAttribute("admin", "You are number 1!");
        return "admin";
    }

    @RequestMapping("/createtable")
    public String crateTable(Model model) {
        InsertDataTable sql = new InsertDataTable();
        model.addAttribute("createtable", sql.sqlInsertCheck());
        return "createtable";
    }

    @RequestMapping("/mainmenu")
    public String mainMenu(Model model) {
        return "mainmenu";
    }
}

Add menu jsp and controller function


package eu.nerro.wolappla.model;

public class Device {
  private String name;
  private String macAddress;
  private String ipAddress;
  private int port;
  private String ssid;
}

package eu.nerro.wolappla.model;

public class Device {
  private String name;
  private String macAddress;
  private String ipAddress;
  private int port;
}

Remove currently not used 'ssid' field in device model


package org.nwapw.abacus.tests;

import org.nwapw.abacus.lexing.Lexer;
import org.nwapw.abacus.tree.TokenType;

public class LexerTests {

    Lexer<TokenType> lexer = new Lexer<TokenType>(){{

    }};

}

package org.nwapw.abacus.tests;

import org.junit.Assert;
import org.junit.Test;
import org.nwapw.abacus.lexing.Lexer;
import org.nwapw.abacus.lexing.pattern.Match;

import java.util.List;

public class LexerTests {

    @Test
    public void testBasicSuccess(){
        Lexer<Integer> lexer = new Lexer<>();
        lexer.register("abc", 0);
        lexer.register("def", 1);
        List<Match<Integer>> matchedIntegers = lexer.lexAll("abcdefabc", 0, Integer::compare);
        Assert.assertEquals(matchedIntegers.get(0).getType(), Integer.valueOf(0));
        Assert.assertEquals(matchedIntegers.get(1).getType(), Integer.valueOf(1));
        Assert.assertEquals(matchedIntegers.get(2).getType(), Integer.valueOf(0));
    }

    @Test
    public void testBasicFailure(){
        Lexer<Integer> lexer = new Lexer<>();
        lexer.register("abc", 0);
        lexer.register("def", 1);
        Assert.assertNull(lexer.lexAll("abcdefabcz", 0, Integer::compare));
    }

}

Write basic tests for string matching.


package kawa.standard;
import kawa.lang.*;

/**
 * The Syntax transformer that re-writes the "define" Scheme primitive.
 * Currently, only handles top-level definitions.
 * @author	Per Bothner
 */

public class define extends Syntax implements Printable
{
  public Expression rewrite (Object obj, Interpreter interp)
       throws kawa.lang.WrongArguments
  {
    if (obj instanceof Pair)
      {
	Pair p1 = (Pair) obj;
	if (p1.car instanceof Symbol && p1.cdr instanceof Pair)
	  {
	    Pair p2 = (Pair) p1.cdr;
	    if (p2.cdr == List.Empty)
	      {
		SetExp result = new SetExp ((Symbol)p1.car,
					    interp.rewrite (p2.car));
		result.setDefining (true);
		return result;
	      }
	  }
	else if (p1.car instanceof Pair)
	  {
	    Pair p2 = (Pair) p1.car;
	    if (p2.car instanceof Symbol)
	      {
		Symbol name = (Symbol) p2.car;
		LambdaExp lexp = new LambdaExp (p2.cdr, p1.cdr, interp);
		lexp.setName (name.toString ());
		SetExp result = new SetExp (name, lexp);
		result.setDefining (true);
		return result;
	      }
	  }
      }
    return interp.syntaxError ("invalid syntax for define");
  }

  public void print(java.io.PrintStream ps)
  {
    ps.print("#<builtin define>");
  }
}

package kawa.standard;
import kawa.lang.*;

/**
 * The Syntax transformer that re-writes the "define" Scheme primitive.
 * Currently, only handles top-level definitions.
 * @author	Per Bothner
 */

public class define extends Syntax implements Printable
{
  public Expression rewrite (Object obj, Interpreter interp)
       throws kawa.lang.WrongArguments
  {
    if (obj instanceof Pair)
      {
	Pair p1 = (Pair) obj;
	if (p1.car instanceof Symbol && p1.cdr instanceof Pair)
	  {
	    Pair p2 = (Pair) p1.cdr;
	    if (p2.cdr == List.Empty)
	      {
		SetExp result = new SetExp ((Symbol)p1.car,
					    interp.rewrite (p2.car));
		result.setDefining (true);
		return result;
	      }
	  }
	else if (p1.car instanceof Pair)
	  {
	    Pair p2 = (Pair) p1.car;
	    if (p2.car instanceof Symbol)
	      {
		Symbol name = (Symbol) p2.car;
		LambdaExp lexp = new LambdaExp (p2.cdr, p1.cdr, interp);
		lexp.setName (name.toString ());
		SetExp result = new SetExp (name, lexp);
		result.setDefining (true);
		return result;
	      }
	  }
      }
    return interp.syntaxError ("invalid syntax for define");
  }
}

Remove print method. No longer needed.