Skip to content

Commit

Permalink
Minor improvements (#6)
Browse files Browse the repository at this point in the history
* Updates jboss-parent to latest released one

* Updates Forge to latest release

* Code improvements (mainly JDK 8 related)
  • Loading branch information
bartoszmajsak authored and gastaldi committed Dec 21, 2016
1 parent da73d75 commit 73cc7ae
Show file tree
Hide file tree
Showing 22 changed files with 155 additions and 323 deletions.
6 changes: 2 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@
<parent>
<groupId>org.jboss</groupId>
<artifactId>jboss-parent</artifactId>
<version>19</version>
<version>21</version>
</parent>
<groupId>org.arquillian.forge</groupId>
<artifactId>arquillian-addon</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Arquillian Forge Addon</name>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<version.arquillian_core>1.1.11.Final</version.arquillian_core>
<version.forge>3.0.0.Beta4</version.forge>
<version.forge>3.4.0.Final</version.forge>
<version.jackson>1.9.1</version.jackson>
<version.junit>4.12</version.junit>
<version.velocity>1.7</version.velocity>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
package org.jboss.forge.arquillian.api;

import java.util.Collection;

import javax.inject.Inject;

import org.jboss.forge.addon.dependencies.Coordinate;
import org.jboss.forge.addon.facets.AbstractFacet;
import org.jboss.forge.addon.facets.constraints.FacetConstraint;
import org.jboss.forge.addon.facets.constraints.FacetConstraints;
import org.jboss.forge.addon.projects.Project;
import org.jboss.forge.addon.projects.ProjectFacet;
import org.jboss.forge.addon.projects.facets.DependencyFacet;
import org.jboss.forge.addon.projects.facets.MetadataFacet;
import org.jboss.forge.arquillian.extension.ExtensionResolver;

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

@FacetConstraints({
@FacetConstraint(DependencyFacet.class),
@FacetConstraint(MetadataFacet.class),
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jboss/forge/arquillian/api/Extension.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

public class Extension {

private String name;
private Dependency dependency;
private final String name;
private final Dependency dependency;

public Extension(Dependency dependency) {
this(dependency.getCoordinate().getArtifactId(), dependency);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,8 @@ public UICommandMetadata getMetadata(UIContext context) {
public void initializeUI(UIBuilder builder) throws Exception {
builder.add(arquillianVersion);

arquillianVersion.setDefaultValue(new Callable<String>() {
@Override
public String call() throws Exception {
return facet.getDefaultVersion();
}
});
arquillianVersion.setValueChoices(new Callable<Iterable<String>>() {
@Override
public Iterable<String> call() throws Exception {
return facet.getAvailableVersions();
}
});
arquillianVersion.setDefaultValue(() -> facet.getDefaultVersion());
arquillianVersion.setValueChoices(() -> facet.getAvailableVersions());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@

package org.jboss.forge.arquillian.command;

import java.util.concurrent.Callable;

import javax.inject.Inject;

import org.jboss.forge.addon.convert.Converter;
import org.jboss.forge.addon.facets.FacetFactory;
import org.jboss.forge.addon.projects.ProjectFactory;
import org.jboss.forge.addon.projects.ui.AbstractProjectCommand;
Expand All @@ -26,6 +21,8 @@
import org.jboss.forge.arquillian.api.Extension;
import org.jboss.forge.arquillian.extension.ExtensionResolver;

import javax.inject.Inject;

public class AddArquillianExtensionCommand extends AbstractProjectCommand implements UICommand {

@Inject
Expand Down Expand Up @@ -56,18 +53,8 @@ public UICommandMetadata getMetadata(UIContext context) {
public void initializeUI(UIBuilder builder) throws Exception {
builder.add(arquillianExtension);

arquillianExtension.setValueChoices(new Callable<Iterable<Extension>>() {
@Override
public Iterable<Extension> call() throws Exception {
return resolver.getAvailableExtensions(getSelectedProject(builder.getUIContext()));
}
});
arquillianExtension.setItemLabelConverter(new Converter<Extension, String>() {
@Override
public String convert(Extension source) {
return source.getName();
}
});
arquillianExtension.setValueChoices(() -> resolver.getAvailableExtensions(getSelectedProject(builder.getUIContext())));
arquillianExtension.setItemLabelConverter(Extension::getName);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,10 @@ public void initializeUI(final UIBuilder builder) throws Exception {
.getCoordinate());

dependencyVersion.setEnabled(true);
dependencyVersion.setValueChoices(new Callable<Iterable<String>>() {
@Override
public Iterable<String> call() throws Exception {
return DependencyUtil.toVersionString(
resolver.resolveVersions(dependencyCoordinate));
}
});
dependencyVersion.setDefaultValue(new Callable<String>() {
@Override
public String call() throws Exception {
return DependencyUtil.getLatestNonSnapshotVersionCoordinate(
resolver.resolveVersions(dependencyCoordinate));
}
});
dependencyVersion.setValueChoices(() -> DependencyUtil.toVersionString(
resolver.resolveVersions(dependencyCoordinate)));
dependencyVersion.setDefaultValue(() -> DependencyUtil.getLatestNonSnapshotVersionCoordinate(
resolver.resolveVersions(dependencyCoordinate)));

}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
package org.jboss.forge.arquillian.command;

import java.util.Collections;
import java.util.concurrent.Callable;

import javax.enterprise.event.Event;
import javax.enterprise.inject.Any;
import javax.inject.Inject;

import org.jboss.forge.addon.convert.Converter;
import org.jboss.forge.addon.facets.FacetFactory;
import org.jboss.forge.addon.projects.ProjectFactory;
import org.jboss.forge.addon.projects.ui.AbstractProjectCommand;
Expand All @@ -27,6 +19,11 @@
import org.jboss.forge.arquillian.api.TestFrameworkFacet;
import org.jboss.forge.arquillian.api.TestFrameworkInstallEvent;

import javax.enterprise.event.Event;
import javax.enterprise.inject.Any;
import javax.inject.Inject;
import java.util.Collections;

public class AddTestFrameworkCommand extends AbstractProjectCommand implements UICommand {

@Inject
Expand All @@ -52,7 +49,7 @@ public UICommandMetadata getMetadata(UIContext context) {
return Metadata.from(super.getMetadata(context), getClass())
.category(Categories.create("Arquillian"))
.name("Arquillian: Add TestFramework")
.description("This addon will help you setup a testframework for Arquillian");
.description("This addon will help you setup a Test Framework for Arquillian");
}

@Override
Expand All @@ -61,54 +58,30 @@ public void initializeUI(final UIBuilder builder) throws Exception {
.add(testFrameworkVersion);

testFramework.setEnabled(true);
testFramework.setItemLabelConverter(new Converter<TestFrameworkFacet, String>() {
@Override
public String convert(TestFrameworkFacet source) {
if(source == null) {
return null;
}
if(builder.getUIContext().getProvider().isGUI()) {
return source.getFrameworkName();
}
return source.getFrameworkName().toLowerCase();
testFramework.setItemLabelConverter(source -> {
if(source == null) {
return null;
}
});
testFramework.setRequired(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return true; // check if already installed
if(builder.getUIContext().getProvider().isGUI()) {
return source.getFrameworkName();
}
return source.getFrameworkName().toLowerCase();
});
testFramework.setRequired(() -> true); // check if already installed

testFrameworkVersion.setRequired(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return true;
testFrameworkVersion.setRequired(() -> true);
testFrameworkVersion.setEnabled(() -> testFramework.hasValue());
testFrameworkVersion.setValueChoices(() -> {
if(testFrameworkVersion.isEnabled()) {
return testFramework.getValue().getAvailableVersions();
}
return Collections.emptyList();
});
testFrameworkVersion.setEnabled(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return testFramework.hasValue();
}
});
testFrameworkVersion.setValueChoices(new Callable<Iterable<String>>() {
@Override
public Iterable<String> call() throws Exception {
if(testFrameworkVersion.isEnabled()) {
return testFramework.getValue().getAvailableVersions();
}
return Collections.emptyList();
}
});
testFrameworkVersion.setDefaultValue(new Callable<String>() {
@Override
public String call() throws Exception {
if(testFrameworkVersion.isEnabled()) {
return testFrameworkVersion.isEnabled() ? testFramework.getValue().getDefaultVersion():null;
}
return null;
testFrameworkVersion.setDefaultValue(() -> {
if(testFrameworkVersion.isEnabled()) {
return testFrameworkVersion.isEnabled() ? testFramework.getValue().getDefaultVersion():null;
}
return null;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public enum ArchiveType
private final String simpleClassName;
private final String beansXmlLocationAdder;

private ArchiveType(String className,String beansXmlLocationAdder)
ArchiveType(String className, String beansXmlLocationAdder)
{
this.className = className;
this.simpleClassName = Types.toSimpleName(className);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,94 +65,48 @@ public void initializeUI(final UIBuilder builder) throws Exception
.add(containerOption)
.add(containerValue);

container.setValueChoices(new Callable<Iterable<String>>()
{
@Override
public Iterable<String> call() throws Exception
container.setValueChoices(() -> profileManager.getArquillianProfiles(getSelectedProject(builder.getUIContext())));
container.setDefaultValue(() -> {
Iterable<String> profiles = container.getValueChoices();
if (profiles != null && profiles.iterator().hasNext())
{
return profileManager.getArquillianProfiles(getSelectedProject(builder.getUIContext()));
return profiles.iterator().next();
}
return null;
});
container.setDefaultValue(new Callable<String>()
{
@Override
public String call() throws Exception
containerOption.setEnabled(() -> container.hasValue());
containerOption.setItemLabelConverter(source -> {
if (source == null)
{
Iterable<String> profiles = container.getValueChoices();
if (profiles != null && profiles.iterator().hasNext())
{
return profiles.iterator().next();
}
return null;
}
return source.getName();
});
containerOption.setEnabled(new Callable<Boolean>()
{
@Override
public Boolean call() throws Exception
{
return container.hasValue();
}
});
containerOption.setItemLabelConverter(new Converter<Configuration, String>()
{
@Override
public String convert(Configuration source)
{
if (source == null)
{
return null;
}
return source.getName();
}
});
containerOption.setValueChoices(new Callable<Iterable<Configuration>>()
{
@Override
public Iterable<Configuration> call() throws Exception
containerOption.setValueChoices(() -> {
if (containerOption.isEnabled())
{
if (containerOption.isEnabled())
Iterable<Configuration> config = profileManager.getContainer(container.getValue()).getConfigurations();
if (config != null)
{
Iterable<Configuration> config = profileManager.getContainer(container.getValue()).getConfigurations();
if (config != null)
{
return config;
}
return config;
}
return Collections.emptyList();
}
return Collections.emptyList();
});
containerValue.setEnabled(new Callable<Boolean>()
{
@Override
public Boolean call() throws Exception
containerValue.setEnabled(() -> containerOption.hasValue());
containerValue.setDefaultValue(() -> {
if (containerValue.isEnabled())
{
return containerOption.hasValue();
return containerOption.getValue().getDefault();
}
return null;
});
containerValue.setDefaultValue(new Callable<String>()
{
@Override
public String call() throws Exception
containerValue.setRequired(() -> {
if (containerValue.isEnabled())
{
if (containerValue.isEnabled())
{
return containerOption.getValue().getDefault();
}
return null;
}
});
containerValue.setRequired(new Callable<Boolean>()
{
@Override
public Boolean call() throws Exception
{
if (containerValue.isEnabled())
{
return containerOption.getValue().getDefault() != null;
}
return true;
return containerOption.getValue().getDefault() != null;
}
return true;
});
}

Expand Down
Loading

0 comments on commit 73cc7ae

Please sign in to comment.