use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class IndexConsultedPropertyBlockSweeperTest method setUp.
@Before
public void setUp() throws IOException {
api = dbRule.getGraphDatabaseAPI();
nonIndexedPropKey = "notIndexed";
indexedPropKey = "indexed";
Label usedLabel = Label.label("UsedLabel");
try (Transaction transaction = api.beginTx()) {
api.schema().indexFor(usedLabel).on(indexedPropKey).create();
transaction.success();
}
try (Transaction transaction = api.beginTx()) {
indexedValue = "value1";
nonIndexedValue = "value2";
Node nodeA = api.createNode(usedLabel);
nodeA.setProperty(indexedPropKey, indexedValue);
nodeA.setProperty(nonIndexedPropKey, nonIndexedValue);
nodeId = nodeA.getId();
transaction.success();
}
DependencyResolver resolver = api.getDependencyResolver();
NeoStores neoStores = resolver.resolveDependency(RecordStorageEngine.class).testAccessNeoStores();
nodeStore = neoStores.getNodeStore();
PropertyKeyTokenStore propertyKeyTokenStore = neoStores.getPropertyKeyTokenStore();
propertyKeys = PropertyDeduplicatorTestUtil.indexPropertyKeys(propertyKeyTokenStore);
propertyStore = neoStores.getPropertyStore();
nodeRecord = getRecord(nodeStore, nodeId);
propertyId = nodeRecord.getNextProp();
indexMock = mock(IndexLookup.Index.class);
when(indexMock.contains(nodeId, indexedValue)).thenReturn(true);
propertyRemoverMock = mock(DuplicatePropertyRemover.class);
}
use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class IndexLookupTest method setUp.
@BeforeClass
public static void setUp() {
api = dbRule.getGraphDatabaseAPI();
String notUsedIndexPropKey = "notUsed";
String usedIndexPropKey = "used";
Label usedLabel = Label.label("UsedLabel");
Label notUsedLabel = Label.label("NotUsedLabel");
try (Transaction transaction = api.beginTx()) {
api.schema().indexFor(usedLabel).on(usedIndexPropKey).create();
transaction.success();
}
try (Transaction transaction = api.beginTx()) {
api.schema().awaitIndexesOnline(10, TimeUnit.SECONDS);
indexedNodePropertyValue = "value1";
notIndexedNodePropertyValue = "value2";
Node nodeA = api.createNode(usedLabel);
nodeA.setProperty(usedIndexPropKey, indexedNodePropertyValue);
nodeA.setProperty(notUsedIndexPropKey, notIndexedNodePropertyValue);
indexedNode = nodeA.getId();
Node nodeB = api.createNode(notUsedLabel);
nodeB.setProperty(usedIndexPropKey, notIndexedNodePropertyValue);
nodeB.setProperty(notUsedIndexPropKey, indexedNodePropertyValue);
notIndexedNode = nodeB.getId();
transaction.success();
}
DependencyResolver resolver = api.getDependencyResolver();
NeoStores neoStores = resolver.resolveDependency(RecordStorageEngine.class).testAccessNeoStores();
SchemaStore schemaStore = neoStores.getSchemaStore();
SchemaIndexProvider schemaIndexProvider = resolver.resolveDependency(SchemaIndexProvider.class);
indexLookup = new IndexLookup(schemaStore, schemaIndexProvider);
LabelTokenStore labelTokenStore = neoStores.getLabelTokenStore();
notUsedLabelId = findTokenFor(labelTokenStore, notUsedLabel.name()).id();
usedLabelId = findTokenFor(labelTokenStore, usedLabel.name()).id();
PropertyKeyTokenStore propertyKeyTokenStore = neoStores.getPropertyKeyTokenStore();
notUsedPropertyId = findTokenFor(propertyKeyTokenStore, notUsedIndexPropKey).id();
usedPropertyId = findTokenFor(propertyKeyTokenStore, usedIndexPropKey).id();
}
use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class CommitContentionTests method createNode.
private void createNode() {
try (Transaction transaction = db.beginTx()) {
db.createNode();
transaction.success();
}
}
use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class ConsistencyCheckServiceIntegrationTest method shouldAllowGraphCheckDisabled.
@Test
public void shouldAllowGraphCheckDisabled() throws IOException, ConsistencyCheckIncompleteException {
GraphDatabaseService gds = getGraphDatabaseService();
try (Transaction tx = gds.beginTx()) {
gds.createNode();
tx.success();
}
gds.shutdown();
ConsistencyCheckService service = new ConsistencyCheckService();
Config configuration = Config.embeddedDefaults(settings(ConsistencyCheckSettings.consistency_check_graph.name(), Settings.FALSE));
// when
Result result = runFullConsistencyCheck(service, configuration);
// then
assertTrue(result.isSuccessful());
}
use of org.neo4j.graphdb.Transaction in project neo4j by neo4j.
the class AbstractShellIT method getCurrentNode.
protected Node getCurrentNode() throws RemoteException, ShellException {
Serializable current = shellServer.interpretVariable(shellClient.getId(), Variables.CURRENT_KEY);
int nodeId = parseInt(current.toString().substring(1));
try (Transaction tx = db.beginTx()) {
Node nodeById = db.getNodeById(nodeId);
tx.success();
return nodeById;
}
}
Aggregations