-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed resource generator resolution and added mocked out test for the…
… NewProjectPlugin
- Loading branch information
1 parent
0b6d916
commit 9abbc40
Showing
12 changed files
with
307 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 0 additions & 53 deletions
53
projects/tests/src/test/java/org/jboss/forge/projects/NewProjectCommandTest.java
This file was deleted.
Oops, something went wrong.
117 changes: 117 additions & 0 deletions
117
projects/tests/src/test/java/org/jboss/forge/projects/impl/NewProjectCommandTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package org.jboss.forge.projects.impl; | ||
|
||
/* | ||
* Copyright 2012 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.forge.arquillian.Addon; | ||
import org.jboss.forge.arquillian.Dependencies; | ||
import org.jboss.forge.arquillian.archive.ForgeArchive; | ||
import org.jboss.forge.container.AddonDependency; | ||
import org.jboss.forge.container.AddonId; | ||
import org.jboss.forge.resource.DirectoryResource; | ||
import org.jboss.forge.ui.UIBuilder; | ||
import org.jboss.forge.ui.UIContext; | ||
import org.jboss.forge.ui.UIInput; | ||
import org.jboss.forge.ui.UIValidationContext; | ||
import org.jboss.shrinkwrap.api.ArchivePaths; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.EmptyAsset; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(Arquillian.class) | ||
public class NewProjectCommandTest | ||
{ | ||
@Deployment | ||
@Dependencies({ | ||
@Addon(name = "org.jboss.forge:facets", version = "2.0.0-SNAPSHOT"), | ||
@Addon(name = "org.jboss.forge:resources", version = "2.0.0-SNAPSHOT"), | ||
@Addon(name = "org.jboss.forge:ui", version = "2.0.0-SNAPSHOT"), | ||
@Addon(name = "org.jboss.forge:projects", version = "2.0.0-SNAPSHOT") | ||
}) | ||
// FIXME We should not need to explicitly list the entire dependency graph, fix addon manager | ||
public static ForgeArchive getDeployment() | ||
{ | ||
ForgeArchive archive = ShrinkWrap | ||
.create(ForgeArchive.class) | ||
.addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml")) | ||
.addAsAddonDependencies( | ||
AddonDependency.create(AddonId.from("org.jboss.forge:resources", "2.0.0-SNAPSHOT")), | ||
AddonDependency.create(AddonId.from("org.jboss.forge:projects", "2.0.0-SNAPSHOT")), | ||
AddonDependency.create(AddonId.from("org.jboss.forge:ui", "2.0.0-SNAPSHOT")) | ||
// FIXME We should not need to explicitly list the entire dependency graph, fix addon XML transitivity | ||
); | ||
|
||
return archive; | ||
} | ||
|
||
@Inject | ||
private NewProjectCommand command; | ||
|
||
@Test | ||
public void testInjectionNotNull() | ||
{ | ||
Assert.assertNotNull(command); | ||
} | ||
|
||
@Test | ||
public void testInvokeCommand() throws Exception | ||
{ | ||
final List<UIInput<?>> inputs = new ArrayList<UIInput<?>>(); | ||
|
||
final UIBuilder builder = new UIBuilder() | ||
{ | ||
@Override | ||
public UIBuilder add(UIInput<?> input) | ||
{ | ||
inputs.add(input); | ||
return this; | ||
} | ||
}; | ||
|
||
UIContext context = new UIContext() | ||
{ | ||
@Override | ||
public UIBuilder getUIBuilder() | ||
{ | ||
return builder; | ||
} | ||
}; | ||
|
||
command.initializeUI(context); | ||
command.getNamed().setValue("test"); | ||
|
||
command.validate(new UIValidationContext() | ||
{ | ||
@Override | ||
public UIBuilder getUIBuilder() | ||
{ | ||
return builder; | ||
} | ||
|
||
@Override | ||
public void addValidationError(UIInput<?> input, String errorMessage) | ||
{ | ||
// TODO implement | ||
} | ||
}); | ||
|
||
command.execute(context); | ||
|
||
DirectoryResource targetDirectory = command.getTargetDirectory().getValue(); | ||
Assert.assertTrue(targetDirectory.exists()); | ||
targetDirectory.delete(true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
resources/api/src/main/java/org/jboss/forge/resource/ResourceGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
package org.jboss.forge.resource; | ||
|
||
public interface ResourceGenerator<UNDERLYINGTYPE> | ||
public interface ResourceGenerator<RESOURCETYPE, UNDERLYINGTYPE> | ||
{ | ||
public Class<? extends Resource<UNDERLYINGTYPE>> getResourceType(UNDERLYINGTYPE resource); | ||
public boolean handles(Class<?> type, final Object resource); | ||
|
||
public <T extends Resource<UNDERLYINGTYPE>> T getResource(final ResourceFactory factory, | ||
public <T extends Resource<UNDERLYINGTYPE>> T getResource(final ResourceFactory factory, Class<RESOURCETYPE> type, | ||
final UNDERLYINGTYPE resource); | ||
|
||
public boolean handles(final Object resource); | ||
public <T extends Resource<UNDERLYINGTYPE>> Class<?> getResourceType(Class<RESOURCETYPE> type, final UNDERLYINGTYPE resource); | ||
|
||
} |
Oops, something went wrong.