Search in sources :

Example 1 with TransactionEnforcerStubs.forGraphWrapper

use of nl.knaw.huygens.timbuctoo.core.TransactionEnforcerStubs.forGraphWrapper 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));
}
Also used : CoreMatchers(org.hamcrest.CoreMatchers) TransactionEnforcerStubs(nl.knaw.huygens.timbuctoo.core.TransactionEnforcerStubs) TransactionEnforcer(nl.knaw.huygens.timbuctoo.core.TransactionEnforcer) TinkerPopGraphManager(nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Test(org.junit.Test) HashMap(java.util.HashMap) Collection(nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) TransactionEnforcerStubs.forGraphWrapper(nl.knaw.huygens.timbuctoo.core.TransactionEnforcerStubs.forGraphWrapper) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) DatabaseConfiguredVres(nl.knaw.huygens.timbuctoo.model.vre.vres.DatabaseConfiguredVres) TestGraphBuilder.newGraph(nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph) TinkerPopGraphManager(nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager) DatabaseConfiguredVres(nl.knaw.huygens.timbuctoo.model.vre.vres.DatabaseConfiguredVres) TransactionEnforcer(nl.knaw.huygens.timbuctoo.core.TransactionEnforcer) Vre(nl.knaw.huygens.timbuctoo.model.vre.Vre) Test(org.junit.Test)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 HashMap (java.util.HashMap)1 TransactionEnforcer (nl.knaw.huygens.timbuctoo.core.TransactionEnforcer)1 TransactionEnforcerStubs (nl.knaw.huygens.timbuctoo.core.TransactionEnforcerStubs)1 TransactionEnforcerStubs.forGraphWrapper (nl.knaw.huygens.timbuctoo.core.TransactionEnforcerStubs.forGraphWrapper)1 Collection (nl.knaw.huygens.timbuctoo.core.dto.dataset.Collection)1 Vre (nl.knaw.huygens.timbuctoo.model.vre.Vre)1 DatabaseConfiguredVres (nl.knaw.huygens.timbuctoo.model.vre.vres.DatabaseConfiguredVres)1 TinkerPopGraphManager (nl.knaw.huygens.timbuctoo.server.TinkerPopGraphManager)1 TestGraphBuilder.newGraph (nl.knaw.huygens.timbuctoo.util.TestGraphBuilder.newGraph)1 CoreMatchers (org.hamcrest.CoreMatchers)1 CoreMatchers.instanceOf (org.hamcrest.CoreMatchers.instanceOf)1 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)1 Test (org.junit.Test)1