use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class TinkerPopOperationsTest method createEntityAddsAnEntityWithItsPropertiesToTheDatabase.
@Test
public void createEntityAddsAnEntityWithItsPropertiesToTheDatabase() throws Exception {
TinkerPopGraphManager graphManager = newGraph().wrap();
Vres vres = createConfiguration();
final Collection collection = vres.getCollection("testthings").get();
final TinkerPopOperations instance = forGraphWrapperAndMappings(graphManager, vres);
List<TimProperty<?>> properties = Lists.newArrayList();
properties.add(new StringProperty("prop1", "val1"));
properties.add(new StringProperty("prop2", "val2"));
CreateEntity createEntity = withProperties(properties);
instance.createEntity(collection, Optional.empty(), createEntity);
assertThat(graphManager.getGraph().traversal().V().has("tim_id", createEntity.getId().toString()).has("testthing_prop1", "val1").has("testthing_prop2", "val2").hasNext(), is(true));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class LoadSaveVreTest method initGraph.
private Tuple<DataStoreOperations, Graph> initGraph(Consumer<TestGraphBuilder> init) {
TestGraphBuilder testGraphBuilder = newGraph();
init.accept(testGraphBuilder);
TinkerPopGraphManager graphManager = testGraphBuilder.wrap();
return tuple(TinkerPopOperationsStubs.forGraphWrapper(graphManager), graphManager.getGraph());
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class LoadSaveVresTest method onlyReloadReloadsTheConfigurationsFromTheGraph.
@Test
public void onlyReloadReloadsTheConfigurationsFromTheGraph() throws JsonProcessingException {
TinkerPopGraphManager graphManager = newGraph().withVertex(v -> {
v.withLabel(Vre.DATABASE_LABEL).withProperty(Vre.VRE_NAME_PROPERTY_NAME, "VreA");
}).wrap();
TransactionEnforcer transactionEnforcer = TransactionEnforcerStubs.forGraphWrapper(graphManager);
DatabaseConfiguredVres instance = new DatabaseConfiguredVres(transactionEnforcer);
assertThat(instance.getVre("VreA"), instanceOf(Vre.class));
assertThat(instance.getVre("VreB"), CoreMatchers.equalTo(null));
// TODO find a clearer way to write this test.
// This call overrides the GraphManager pointer, so the DatabaseConfiguredVres has an empty database again.
graphManager = newGraph().withVertex(v -> {
v.withLabel(Vre.DATABASE_LABEL).withProperty(Vre.VRE_NAME_PROPERTY_NAME, "VreB");
}).wrap();
assertThat(instance.getVre("VreA"), instanceOf(Vre.class));
assertThat(instance.getVre("VreB"), CoreMatchers.equalTo(null));
instance.reload();
assertThat(instance.getVre("VreB"), instanceOf(Vre.class));
assertThat(instance.getVre("VreA"), CoreMatchers.equalTo(null));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class Neo4JIndexHandlerTest method findByIdReturnsAnEmptyTraversalWhenNoResultsAreFound.
@Test
public void findByIdReturnsAnEmptyTraversalWhenNoResultsAreFound() {
UUID id1 = UUID.randomUUID();
TinkerPopGraphManager tinkerPopGraphManager = newGraph().withVertex(v -> v.withTimId(id1.toString()).withProperty("keyword_type", "keywordType").withProperty("displayName", "query")).wrap();
Neo4jIndexHandler instance = new Neo4jIndexHandler(tinkerPopGraphManager);
Optional<Vertex> result = instance.findById(id1);
assertThat(result.isPresent(), is(false));
}
use of nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager in project timbuctoo by HuygensING.
the class Neo4JIndexHandlerTest method findByQuickSearchReturnsAnEmtptyTraversalWhenNoVerticesAreFound.
@Test
public void findByQuickSearchReturnsAnEmtptyTraversalWhenNoVerticesAreFound() {
String id1 = UUID.randomUUID().toString();
String id2 = UUID.randomUUID().toString();
String id3 = UUID.randomUUID().toString();
TinkerPopGraphManager tinkerPopGraphManager = newGraph().withVertex(v -> v.withTimId(id1).withProperty("displayName", "query")).withVertex(v -> v.withTimId(id2).withProperty("displayName", "query2")).withVertex(v -> v.withTimId(id3).withProperty("displayName", "other")).wrap();
Neo4jIndexHandler instance = new Neo4jIndexHandler(tinkerPopGraphManager);
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id1).next());
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id2).next());
addToQuickSearchIndex(instance, collection, tinkerPopGraphManager.getGraph().traversal().V().has("tim_id", id3).next());
QuickSearch quickSearch = QuickSearch.fromQueryString("queryWithoutResult");
GraphTraversal<Vertex, Vertex> vertices = instance.findByQuickSearch(collection, quickSearch);
assertThat(vertices.map(v -> v.get().value("tim_id")).toList(), is(empty()));
}
Aggregations