Skip to content

Method: DeleteOperationsWithInheritanceRunner(Logger, PersistenceFactory, DataAccessor)

1: /*
2: * JOPA
3: * Copyright (C) 2024 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.test.runner;
19:
20: import cz.cvut.kbss.jopa.test.OWLClassA;
21: import cz.cvut.kbss.jopa.test.OWLClassQ;
22: import cz.cvut.kbss.jopa.test.OWLClassT;
23: import cz.cvut.kbss.jopa.test.environment.DataAccessor;
24: import cz.cvut.kbss.jopa.test.environment.PersistenceFactory;
25: import org.junit.jupiter.api.Test;
26: import org.slf4j.Logger;
27:
28: import static org.junit.jupiter.api.Assertions.*;
29:
30: public abstract class DeleteOperationsWithInheritanceRunner extends BaseInheritanceRunner {
31:
32: public DeleteOperationsWithInheritanceRunner(Logger logger, PersistenceFactory persistenceFactory,
33: DataAccessor dataAccessor) {
34: super(logger, persistenceFactory, dataAccessor);
35: }
36:
37: @Test
38: public void testRemoveEntityWithMappedSuperclass() {
39: this.em = getEntityManager("RemoveEntityWithMappedSuperclass", false);
40: persist(entityQ, entityA);
41:
42: em.getTransaction().begin();
43: final OWLClassQ toRemove = em.find(OWLClassQ.class, entityQ.getUri());
44: assertNotNull(toRemove);
45: em.remove(toRemove);
46: em.getTransaction().commit();
47:
48: assertNull(em.find(OWLClassQ.class, entityQ.getUri()));
49: assertNotNull(em.find(OWLClassA.class, entityA.getUri()));
50: verifyIndividualWasRemoved(entityQ.getUri());
51: }
52:
53: @Test
54: public void testRemoveEntityWithEntitySuperclass() {
55: this.em = getEntityManager("RemoveEntityWithEntitySuperclass", false);
56: persist(entityT, entityA);
57:
58: em.getTransaction().begin();
59: final OWLClassT toRemove = em.find(OWLClassT.class, entityT.getUri());
60: assertNotNull(toRemove);
61: em.remove(toRemove);
62: assertFalse(em.contains(toRemove));
63: em.getTransaction().commit();
64:
65: assertNull(em.find(OWLClassT.class, entityT.getUri()));
66: assertNotNull(em.find(OWLClassA.class, entityA.getUri()));
67: verifyIndividualWasRemoved(entityT.getUri());
68: }
69: }