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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
}
Aggregations