@Test
public void deleteActivityTest() throws Exception {

    // Setup:
    Activity toRemove = activityFactory.createNew(activityIRI);
    Activity other = activityFactory.createNew(VALUE_FACTORY.createIRI("http://test.com/other"));
    Entity generated1 = entityFactory.createNew(VALUE_FACTORY.createIRI("http://test.com/generated/1"));
    Entity invalidated1 = entityFactory.createNew(VALUE_FACTORY.createIRI("http://test.com/invalidated/1"));
    Entity used1 = entityFactory.createNew(VALUE_FACTORY.createIRI("http://test.com/used/1"));
    Entity generated2 = entityFactory.createNew(VALUE_FACTORY.createIRI("http://test.com/generated/2"));
    Entity invalidated2 = entityFactory.createNew(VALUE_FACTORY.createIRI("http://test.com/invalidated/2"));
    Entity used2 = entityFactory.createNew(VALUE_FACTORY.createIRI("http://test.com/used/2"));
    toRemove.setGenerated(Collections.singleton(generated1));
    toRemove.setInvalidated(Collections.singleton(invalidated1));
    toRemove.setUsed(Collections.singleton(used1));
    toRemove.setGenerated(Collections.singleton(generated2));
    toRemove.setInvalidated(Collections.singleton(invalidated2));
    toRemove.setUsed(Collections.singleton(used2));
    other.setGenerated(Collections.singleton(generated1));
    other.setInvalidated(Collections.singleton(invalidated1));
    other.setUsed(Collections.singleton(used1));
    try (RepositoryConnection conn = repo.getConnection()) {
        conn.add(toRemove.getModel());
        conn.add(generated1.getModel());
        conn.add(invalidated1.getModel());
        conn.add(used1.getModel());
        conn.add(generated2.getModel());
        conn.add(invalidated2.getModel());
        conn.add(used2.getModel());
        conn.add(other.getModel());
    }
    service.deleteActivity(activityIRI);
    try (RepositoryConnection conn = repo.getConnection()) {
        toRemove.getModel().forEach(statement -> assertFalse(conn.contains(statement.getSubject(), statement.getPredicate(), statement.getObject())));
        generated1.getModel().forEach(statement -> assertTrue(conn.contains(statement.getSubject(), statement.getPredicate(), statement.getObject())));
        invalidated1.getModel().forEach(statement -> assertTrue(conn.contains(statement.getSubject(), statement.getPredicate(), statement.getObject())));
        used1.getModel().forEach(statement -> assertTrue(conn.contains(statement.getSubject(), statement.getPredicate(), statement.getObject())));
        generated2.getModel().forEach(statement -> assertFalse(conn.contains(statement.getSubject(), statement.getPredicate(), statement.getObject())));
        invalidated2.getModel().forEach(statement -> assertFalse(conn.contains(statement.getSubject(), statement.getPredicate(), statement.getObject())));
        used2.getModel().forEach(statement -> assertFalse(conn.contains(statement.getSubject(), statement.getPredicate(), statement.getObject())));
        other.getModel().forEach(statement -> assertTrue(conn.contains(statement.getSubject(), statement.getPredicate(), statement.getObject())));
    }
}