use of org.neo4j.graphdb.Label in project neo4j by neo4j.
the class NodeProxyTest method createDropNodeLongArrayProperty.
@Test
public void createDropNodeLongArrayProperty() {
Label markerLabel = Label.label("marker");
String testPropertyKey = "testProperty";
byte[] propertyValue = RandomUtils.nextBytes(1024);
try (Transaction tx = db.beginTx()) {
Node node = db.createNode(markerLabel);
node.setProperty(testPropertyKey, propertyValue);
tx.success();
}
try (Transaction tx = db.beginTx()) {
Node node = Iterators.single(db.findNodes(markerLabel));
assertArrayEquals(propertyValue, (byte[]) node.getProperty(testPropertyKey));
tx.success();
}
try (Transaction tx = db.beginTx()) {
Node node = Iterators.single(db.findNodes(markerLabel));
node.removeProperty(testPropertyKey);
tx.success();
}
try (Transaction tx = db.beginTx()) {
Node node = Iterators.single(db.findNodes(markerLabel));
assertFalse(node.hasProperty(testPropertyKey));
tx.success();
}
}
use of org.neo4j.graphdb.Label in project neo4j by neo4j.
the class RelationshipProxyTest method createDropRelationshipLongStringProperty.
@Test
public void createDropRelationshipLongStringProperty() {
Label markerLabel = DynamicLabel.label("marker");
String testPropertyKey = "testProperty";
String propertyValue = RandomStringUtils.randomAscii(255);
try (Transaction tx = db.beginTx()) {
Node start = db.createNode(markerLabel);
Node end = db.createNode(markerLabel);
Relationship relationship = start.createRelationshipTo(end, withName("type"));
relationship.setProperty(testPropertyKey, propertyValue);
tx.success();
}
try (Transaction tx = db.beginTx()) {
Relationship relationship = db.getRelationshipById(0);
assertEquals(propertyValue, relationship.getProperty(testPropertyKey));
tx.success();
}
try (Transaction tx = db.beginTx()) {
Relationship relationship = db.getRelationshipById(0);
relationship.removeProperty(testPropertyKey);
tx.success();
}
try (Transaction tx = db.beginTx()) {
Relationship relationship = db.getRelationshipById(0);
assertFalse(relationship.hasProperty(testPropertyKey));
tx.success();
}
}
use of org.neo4j.graphdb.Label in project neo4j by neo4j.
the class NodeMatcher method matches.
@Override
public boolean matches(Object value) {
if (value instanceof Node) {
Node node = (Node) value;
int nbrOfLabels = 0;
for (Label l : node.getLabels()) {
if (!labelNames.contains(l.name())) {
return false;
}
++nbrOfLabels;
}
return labelNames.size() == nbrOfLabels && propertyMatcher.matches(node.getAllProperties());
}
return false;
}
use of org.neo4j.graphdb.Label in project neo4j by neo4j.
the class LabelIT method creatingIndexOnMasterShouldHaveSlavesBuildItAsWell.
@Test
public void creatingIndexOnMasterShouldHaveSlavesBuildItAsWell() throws Throwable {
// GIVEN
HighlyAvailableGraphDatabase slave1 = cluster.getAnySlave();
HighlyAvailableGraphDatabase slave2 = cluster.getAnySlave(/*except*/
slave1);
Label label = label("Person");
// WHEN
TransactionContinuation txOnSlave1 = createNodeAndKeepTxOpen(slave1, label);
TransactionContinuation txOnSlave2 = createNodeAndKeepTxOpen(slave2, label);
commit(txOnSlave1);
commit(txOnSlave2);
// THEN
assertEquals(getLabelId(slave1, label), getLabelId(slave2, label));
}
use of org.neo4j.graphdb.Label in project neo4j by neo4j.
the class LabelScanStoreHaIT method setUp.
@Before
public void setUp() {
KernelExtensionFactory<?> testExtension = labelScanStoreExtension(monitor);
TestHighlyAvailableGraphDatabaseFactory factory = new TestHighlyAvailableGraphDatabaseFactory();
factory.removeKernelExtensions(extension -> extension.getClass().getName().contains("LabelScan"));
factory.addKernelExtension(testExtension);
ClusterManager clusterManager = new ClusterManager.Builder(testDirectory.directory("root")).withDbFactory(factory).withSharedSetting(GraphDatabaseSettings.label_index, labelIndexSettingName()).withStoreDirInitializer((serverId, storeDir) -> {
if (serverId == 1) {
GraphDatabaseService db = new TestGraphDatabaseFactory().addKernelExtension(testExtension).newEmbeddedDatabaseBuilder(storeDir.getAbsoluteFile()).setConfig(GraphDatabaseSettings.label_index, labelIndexSettingName()).newGraphDatabase();
try {
createSomeLabeledNodes(db, new Label[] { Labels.First }, new Label[] { Labels.First, Labels.Second }, new Label[] { Labels.Second });
} finally {
db.shutdown();
}
}
}).build();
life.add(clusterManager);
life.start();
cluster = clusterManager.getCluster();
cluster.await(allSeesAllAsAvailable());
cluster.await(allAvailabilityGuardsReleased());
}
Aggregations