Example #1
0
  @Test
  public void testUpdate() throws Exception {
    Resource rhmRes = model.getResource(FakeRDFModel.rhm);
    Property name = model.getProperty(foaf + "name");

    Statement nameSt = rhmRes.listProperties(name).nextStatement();
    String originalName = nameSt.getLiteral().getString();

    // assume update is always first remove and then add
    model.remove(nameSt);
    model.add(rhmRes, name, "TESTNAME");

    assert changes.size() == 2;
    assert rhmRes.listProperties(name).toList().size() == 1;
    assert rhmRes.listProperties(name).nextStatement().getLiteral().getString().equals("TESTNAME");

    changes.undo();

    assert changes.size() == 2;
    assert rhmRes.listProperties(name).toList().size() == 1;
    assert rhmRes
        .listProperties(name)
        .nextStatement()
        .getLiteral()
        .getString()
        .equals(originalName);

    changes.redo();

    assert changes.size() == 2;
    assert rhmRes.listProperties(name).toList().size() == 1;
    assert rhmRes.listProperties(name).nextStatement().getLiteral().getString().equals("TESTNAME");
  }
Example #2
0
  @Test
  public void testCreate() throws Exception {
    Model foo = FakeRDFModel.createInstance("Person", "name", "*****@*****.**");

    model.add(foo);

    assert foo.difference(changes.get(0).getChange()).isEmpty();

    assert changes.size() == 1;
    assert model.containsAll(foo);

    changes.undo();

    assert changes.size() == 1;
    assert !model.containsAny(foo);

    changes.redo();

    assert changes.size() == 1;
    assert model.containsAll(foo);
  }
Example #3
0
  @Test
  public void testDelete() throws Exception {
    Resource rhmRes = model.getResource(FakeRDFModel.rhm);

    Model toRemove = ModelFactory.createDefaultModel();
    toRemove.add(model.listStatements(rhmRes, null, (RDFNode) null));
    toRemove.add(model.listStatements(null, null, rhmRes));

    model.remove(toRemove);

    Model foo = changes.get(0).getChange();

    assert changes.size() == 1;
    assert !model.containsResource(rhmRes);

    changes.undo();

    assert changes.size() == 1;
    assert model.containsResource(rhmRes);
    assert model.containsAll(foo);

    changes.redo();

    assert changes.size() == 1;
    assert !model.containsResource(rhmRes);
  }
Example #4
0
 @Get("/1variable")
 @Produces("text/html")
 public Model helloBob() {
   return Model.of("name", "Bob");
 }