-
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.
Added test to verify the generation contract of ScaffoldProvider
A Mock scaffold provider that scaffolds mock resources has been created.
- Loading branch information
1 parent
b0099a5
commit b2e25f7
Showing
12 changed files
with
320 additions
and
25 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
8 changes: 5 additions & 3 deletions
8
scaffold/spi/src/main/java/org/jboss/forge/addon/scaffold/spi/ResourceCollection.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
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
28 changes: 28 additions & 0 deletions
28
scaffold/tests/src/test/java/org/jboss/forge/addon/scaffold/mock/Scaffoldable.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,28 @@ | ||
package org.jboss.forge.addon.scaffold.mock; | ||
|
||
public class Scaffoldable | ||
{ | ||
|
||
private String name; | ||
|
||
public Scaffoldable(String name) | ||
{ | ||
this.name = name; | ||
} | ||
|
||
public String getName() | ||
{ | ||
return name; | ||
} | ||
|
||
public void setName(String name) | ||
{ | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public String toString() | ||
{ | ||
return name; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
scaffold/tests/src/test/java/org/jboss/forge/addon/scaffold/mock/ScaffoldableResource.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,54 @@ | ||
package org.jboss.forge.addon.scaffold.mock; | ||
|
||
import org.jboss.forge.addon.resource.Resource; | ||
import org.jboss.forge.addon.resource.ResourceFactory; | ||
import org.jboss.forge.addon.resource.VirtualResource; | ||
|
||
import java.util.List; | ||
|
||
public class ScaffoldableResource extends VirtualResource<Scaffoldable> | ||
{ | ||
|
||
private Scaffoldable value; | ||
|
||
public ScaffoldableResource(ResourceFactory factory, Scaffoldable resource) | ||
{ | ||
super(factory, null); | ||
this.value = resource; | ||
} | ||
|
||
protected ScaffoldableResource(ResourceFactory factory, Resource<?> parent) | ||
{ | ||
super(factory, parent); | ||
} | ||
|
||
@Override | ||
protected List<Resource<?>> doListResources() | ||
{ | ||
return null; | ||
} | ||
|
||
@Override | ||
public boolean delete() throws UnsupportedOperationException | ||
{ | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean delete(boolean recursive) throws UnsupportedOperationException | ||
{ | ||
return false; | ||
} | ||
|
||
@Override | ||
public String getName() | ||
{ | ||
return value.toString(); | ||
} | ||
|
||
@Override | ||
public Scaffoldable getUnderlyingResourceObject() | ||
{ | ||
return value; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...ests/src/test/java/org/jboss/forge/addon/scaffold/mock/ScaffoldableResourceGenerator.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,33 @@ | ||
package org.jboss.forge.addon.scaffold.mock; | ||
|
||
import org.jboss.forge.addon.resource.Resource; | ||
import org.jboss.forge.addon.resource.ResourceFactory; | ||
import org.jboss.forge.addon.resource.ResourceGenerator; | ||
|
||
public class ScaffoldableResourceGenerator implements ResourceGenerator<ScaffoldableResource, Scaffoldable> | ||
{ | ||
@Override | ||
public boolean handles(Class<?> type, Object resource) | ||
{ | ||
if (resource instanceof Scaffoldable) | ||
{ | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
@SuppressWarnings("unchecked") | ||
public <T extends Resource<Scaffoldable>> T getResource(ResourceFactory factory, Class<ScaffoldableResource> type, | ||
Scaffoldable resource) | ||
{ | ||
return (T) new ScaffoldableResource(factory, resource); | ||
} | ||
|
||
@Override | ||
public <T extends Resource<Scaffoldable>> Class<?> getResourceType(ResourceFactory factory, | ||
Class<ScaffoldableResource> type, Scaffoldable resource) | ||
{ | ||
return ScaffoldableResource.class; | ||
} | ||
} |
Oops, something went wrong.