Skip to content

Commit

Permalink
Make the GraphTypeManagerTest independent of real types.
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraZizka committed Jun 21, 2014
1 parent 4ae058e commit d49334d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.jboss.windup.graph.typedgraph;

import com.tinkerpop.frames.modules.typedgraph.TypeValue;
import org.jboss.windup.graph.model.resource.ResourceModel;

/**
*
* @author Ondrej Zizka, ozizka at redhat.com
*/
@TypeValue("Foo")
interface FooModel extends ResourceModel {



}// class
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.jboss.windup.graph.typedgraph;

import com.tinkerpop.frames.modules.typedgraph.TypeValue;
import org.jboss.windup.graph.model.resource.ResourceModel;

/**
*
* @author Ondrej Zizka, ozizka at redhat.com
*/
@TypeValue("FooSub")
interface FooSubModel extends FooModel {



}// class
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import org.jboss.windup.graph.GraphContext;
import org.jboss.windup.graph.GraphUtil;
import org.jboss.windup.graph.model.WindupVertexFrame;
import org.jboss.windup.graph.model.meta.xml.MavenFacetModel;
import org.jboss.windup.graph.model.resource.XmlResourceModel;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -27,17 +25,17 @@ public class GraphTypeManagerTest
{
@Deployment
@Dependencies({
@AddonDependency(name = "org.jboss.windup.graph:windup-graph"),
@AddonDependency(name = "org.jboss.forge.furnace.container:cdi")
@AddonDependency(name = "org.jboss.windup.graph:windup-graph"),
@AddonDependency(name = "org.jboss.forge.furnace.container:cdi")
})
public static ForgeArchive getDeployment()
{
ForgeArchive archive = ShrinkWrap.create(ForgeArchive.class)
.addBeansXML()
.addAsAddonDependencies(
AddonDependencyEntry.create("org.jboss.windup.graph:windup-graph"),
AddonDependencyEntry.create("org.jboss.forge.furnace.container:cdi")
);
.addBeansXML()
.addAsAddonDependencies(
AddonDependencyEntry.create("org.jboss.windup.graph:windup-graph"),
AddonDependencyEntry.create("org.jboss.forge.furnace.container:cdi")
);
return archive;
}

Expand All @@ -50,26 +48,26 @@ public void testGraphTypeHandling() throws Exception
Assert.assertNotNull(context);

// First, create a base object
XmlResourceModel initialModelType = context.getFramed().addVertex(null, XmlResourceModel.class);
FooModel initialModelType = context.getFramed().addVertex(null, FooModel.class);

// Now cast it to an xml object
GraphUtil.addTypeToModel(context, initialModelType, MavenFacetModel.class);
GraphUtil.addTypeToModel(context, initialModelType, FooSubModel.class);

// Now reload it as a base meta object (this returns an iterable, but there should only be one result)
Iterable<Vertex> vertices = context.getFramed().query()
.has("type", Text.CONTAINS, XmlResourceModel.class.getAnnotation(TypeValue.class).value())
.vertices();
.has("type", Text.CONTAINS, FooModel.class.getAnnotation(TypeValue.class).value())
.vertices();
int numberFound = 0;
for (Vertex v : vertices)
{
numberFound++;
WindupVertexFrame framed = context.getFramed().frame(v, WindupVertexFrame.class);

// because the type information is stored in the Vertex, this should include at least the following types:
// - BaseMetaModel
// - XmlResourceModel
Assert.assertTrue(framed instanceof XmlResourceModel);
Assert.assertTrue(framed instanceof MavenFacetModel);
// - FooModel
// - FooSubModel
Assert.assertTrue(framed instanceof FooModel);
Assert.assertTrue(framed instanceof FooSubModel);
}
Assert.assertEquals(1, numberFound);
}
Expand Down

0 comments on commit d49334d

Please sign in to comment.