Search in sources :

Example 71 with WritableGraph

use of au.gov.asd.tac.constellation.graph.WritableGraph in project constellation by constellation-app.

the class ModCountNGTest method setShortValueModCounts.

/**
 * Tests that the mod counts on the two graphs in a DualGraph match after a
 * short value is set on a graph with a single vertex.
 *
 * Note that this test currently uses an integer attribute as there is no
 * ShortAttributeDescription class.
 */
@Test
public void setShortValueModCounts() {
    final DualGraph g = new DualGraph(null);
    try {
        long modCount;
        WritableGraph wg = g.getWritableGraph("", true);
        int attribute, vertex;
        final short value = 1, defaultValue = 0;
        try {
            vertex = wg.addVertex();
            attribute = wg.addAttribute(GraphElementType.VERTEX, IntegerAttributeDescription.ATTRIBUTE_NAME, "name", "description", defaultValue, null);
            modCount = wg.getGlobalModificationCounter();
        } finally {
            wg.commit();
        }
        wg = g.getWritableGraph("", true);
        try {
            assertEquals(defaultValue, wg.getShortValue(attribute, vertex));
            assertEquals(modCount, wg.getGlobalModificationCounter());
        } finally {
            wg.commit();
        }
        wg = g.getWritableGraph("", true);
        try {
            wg.setShortValue(attribute, vertex, value);
            modCount = wg.getGlobalModificationCounter();
        } finally {
            wg.commit();
        }
        wg = g.getWritableGraph("", true);
        try {
            assertEquals(value, wg.getShortValue(attribute, vertex));
            assertEquals(modCount, wg.getGlobalModificationCounter());
        } finally {
            wg.commit();
        }
    } catch (InterruptedException ex) {
        assertTrue(ex.toString(), false);
    }
}
Also used : WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Test(org.testng.annotations.Test)

Example 72 with WritableGraph

use of au.gov.asd.tac.constellation.graph.WritableGraph in project constellation by constellation-app.

the class ModCountNGTest method setTransactionSourceToDestinationModCounts.

/**
 * Tests that the mod counts on the two graphs in a DualGraph match after a
 * transactions is added between two vertices and then its source vertex is
 * set to its destination vertex to create a loop.
 */
@Test
public void setTransactionSourceToDestinationModCounts() {
    final DualGraph g = new DualGraph(null);
    try {
        long modCount;
        WritableGraph wg = g.getWritableGraph("", true);
        int vertex0, vertex1;
        int trans;
        try {
            vertex0 = wg.addVertex();
            vertex1 = wg.addVertex();
            trans = wg.addTransaction(vertex0, vertex1, true);
            modCount = wg.getGlobalModificationCounter();
        } finally {
            wg.commit();
        }
        wg = g.getWritableGraph("", true);
        try {
            assertEquals(wg.getVertexCount(), 2);
            assertEquals(wg.getTransactionCount(), 1);
            assertEquals(wg.getTransactionSourceVertex(trans), vertex0);
            assertEquals(wg.getTransactionDestinationVertex(trans), vertex1);
            assertEquals(modCount, wg.getGlobalModificationCounter());
        } finally {
            wg.commit();
        }
        wg = g.getWritableGraph("", true);
        try {
            wg.setTransactionSourceVertex(trans, vertex1);
            modCount = wg.getGlobalModificationCounter();
        } finally {
            wg.commit();
        }
        wg = g.getWritableGraph("", true);
        try {
            assertEquals(wg.getVertexCount(), 2);
            assertEquals(wg.getTransactionCount(), 1);
            assertEquals(wg.getTransactionSourceVertex(trans), vertex1);
            assertEquals(wg.getTransactionDestinationVertex(trans), vertex1);
            assertEquals(modCount, wg.getGlobalModificationCounter());
        } finally {
            wg.commit();
        }
    } catch (InterruptedException ex) {
        assertTrue(ex.toString(), false);
    }
}
Also used : WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Test(org.testng.annotations.Test)

Example 73 with WritableGraph

use of au.gov.asd.tac.constellation.graph.WritableGraph in project constellation by constellation-app.

the class ModCountNGTest method setChareValueModCounts.

/**
 * Tests that the mod counts on the two graphs in a DualGraph match after a
 * char value is set on a graph with a single vertex.
 *
 * Note that this test currently uses an integer attribute as there is no
 * CharAttributeDescription class.
 */
@Test
public void setChareValueModCounts() {
    final DualGraph g = new DualGraph(null);
    try {
        long modCount;
        WritableGraph wg = g.getWritableGraph("", true);
        int attribute, vertex;
        final char value = 1, defaultValue = 0;
        try {
            vertex = wg.addVertex();
            attribute = wg.addAttribute(GraphElementType.VERTEX, IntegerAttributeDescription.ATTRIBUTE_NAME, "name", "description", defaultValue, null);
            modCount = wg.getGlobalModificationCounter();
        } finally {
            wg.commit();
        }
        wg = g.getWritableGraph("", true);
        try {
            assertEquals(defaultValue, wg.getCharValue(attribute, vertex));
            assertEquals(modCount, wg.getGlobalModificationCounter());
        } finally {
            wg.commit();
        }
        wg = g.getWritableGraph("", true);
        try {
            wg.setCharValue(attribute, vertex, value);
            modCount = wg.getGlobalModificationCounter();
        } finally {
            wg.commit();
        }
        wg = g.getWritableGraph("", true);
        try {
            assertEquals(value, wg.getCharValue(attribute, vertex));
            assertEquals(modCount, wg.getGlobalModificationCounter());
        } finally {
            wg.commit();
        }
    } catch (InterruptedException ex) {
        assertTrue(ex.toString(), false);
    }
}
Also used : WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Test(org.testng.annotations.Test)

Example 74 with WritableGraph

use of au.gov.asd.tac.constellation.graph.WritableGraph in project constellation by constellation-app.

the class ModCountNGTest method setFloatValueModCounts.

/**
 * Tests that the mod counts on the two graphs in a DualGraph match after a
 * float value is set on a graph with a single vertex.
 */
@Test
public void setFloatValueModCounts() {
    final DualGraph g = new DualGraph(null);
    try {
        long modCount;
        WritableGraph wg = g.getWritableGraph("", true);
        int attribute, vertex;
        final float value = 1f, defaultValue = 0f;
        try {
            vertex = wg.addVertex();
            attribute = wg.addAttribute(GraphElementType.VERTEX, FloatAttributeDescription.ATTRIBUTE_NAME, "name", "description", defaultValue, null);
            modCount = wg.getGlobalModificationCounter();
        } finally {
            wg.commit();
        }
        wg = g.getWritableGraph("", true);
        try {
            assertEquals(defaultValue, wg.getFloatValue(attribute, vertex));
            assertEquals(modCount, wg.getGlobalModificationCounter());
        } finally {
            wg.commit();
        }
        wg = g.getWritableGraph("", true);
        try {
            wg.setFloatValue(attribute, vertex, value);
            modCount = wg.getGlobalModificationCounter();
        } finally {
            wg.commit();
        }
        wg = g.getWritableGraph("", true);
        try {
            assertEquals(value, wg.getFloatValue(attribute, vertex));
            assertEquals(modCount, wg.getGlobalModificationCounter());
        } finally {
            wg.commit();
        }
    } catch (InterruptedException ex) {
        assertTrue(ex.toString(), false);
    }
}
Also used : WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Test(org.testng.annotations.Test)

Example 75 with WritableGraph

use of au.gov.asd.tac.constellation.graph.WritableGraph in project constellation by constellation-app.

the class ModCountNGTest method setObjectValueModCounts.

/**
 * Tests that the mod counts on the two graphs in a DualGraph match after an
 * object value is set on a graph with a single vertex.
 */
@Test
public void setObjectValueModCounts() {
    final DualGraph g = new DualGraph(null);
    try {
        long modCount;
        WritableGraph wg = g.getWritableGraph("", true);
        int attribute, vertex;
        final Object object = new Object();
        try {
            vertex = wg.addVertex();
            attribute = wg.addAttribute(GraphElementType.VERTEX, ObjectAttributeDescription.ATTRIBUTE_NAME, "name", "description", null, null);
            modCount = wg.getGlobalModificationCounter();
        } finally {
            wg.commit();
        }
        wg = g.getWritableGraph("", true);
        try {
            assertEquals(null, (Object) wg.getObjectValue(attribute, vertex));
            assertEquals(modCount, wg.getGlobalModificationCounter());
        } finally {
            wg.commit();
        }
        wg = g.getWritableGraph("", true);
        try {
            wg.setObjectValue(attribute, vertex, object);
            modCount = wg.getGlobalModificationCounter();
        } finally {
            wg.commit();
        }
        wg = g.getWritableGraph("", true);
        try {
            assertEquals(object, wg.getObjectValue(attribute, vertex));
            assertEquals(modCount, wg.getGlobalModificationCounter());
        } finally {
            wg.commit();
        }
    } catch (InterruptedException ex) {
        assertTrue(ex.toString(), false);
    }
}
Also used : WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Test(org.testng.annotations.Test)

Aggregations

WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)116 Test (org.testng.annotations.Test)77 DualGraph (au.gov.asd.tac.constellation.graph.locking.DualGraph)39 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)37 Graph (au.gov.asd.tac.constellation.graph.Graph)20 ArrayList (java.util.ArrayList)14 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)9 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)8 CompositeNodeState (au.gov.asd.tac.constellation.graph.schema.analytic.attribute.objects.CompositeNodeState)8 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)7 BeforeMethod (org.testng.annotations.BeforeMethod)7 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)6 Schema (au.gov.asd.tac.constellation.graph.schema.Schema)6 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)6 Attribute (au.gov.asd.tac.constellation.graph.Attribute)5 GraphAttribute (au.gov.asd.tac.constellation.graph.GraphAttribute)5 CopyToNewGraphPlugin (au.gov.asd.tac.constellation.graph.interaction.plugins.clipboard.CopyToNewGraphPlugin)5 ConstellationColor (au.gov.asd.tac.constellation.utilities.color.ConstellationColor)4 DuplicateKeyException (au.gov.asd.tac.constellation.graph.DuplicateKeyException)3 GraphRecordStore (au.gov.asd.tac.constellation.graph.processing.GraphRecordStore)3