1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.core.persistence.jpa.outer;
20
21 import static org.junit.jupiter.api.Assertions.assertNotNull;
22 import static org.junit.jupiter.api.Assertions.assertNull;
23 import static org.junit.jupiter.api.Assertions.fail;
24
25 import org.apache.syncope.common.lib.types.AnyTypeKind;
26 import org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException;
27 import org.apache.syncope.core.persistence.api.dao.PlainAttrDAO;
28 import org.apache.syncope.core.persistence.api.dao.PlainAttrValueDAO;
29 import org.apache.syncope.core.persistence.api.entity.user.UPlainAttr;
30 import org.apache.syncope.core.persistence.api.entity.user.UPlainAttrValue;
31 import org.apache.syncope.core.persistence.jpa.AbstractTest;
32 import org.junit.jupiter.api.Tag;
33 import org.junit.jupiter.api.Test;
34 import org.springframework.beans.factory.annotation.Autowired;
35 import org.springframework.transaction.annotation.Transactional;
36
37 @Tag("plainAttrTable")
38 @Transactional("Master")
39 public class PlainAttrTest extends AbstractTest {
40
41 @Autowired
42 private PlainAttrDAO plainAttrDAO;
43
44 @Autowired
45 private PlainAttrValueDAO plainAttrValueDAO;
46
47 @Test
48 public void deleteAttr() {
49 plainAttrDAO.delete(findPlainAttr("35f407a2-d254-4890-9e45-5a7dd8c8df7d", UPlainAttr.class));
50
51 entityManager().flush();
52
53 assertNull(findPlainAttr("35f407a2-d254-4890-9e45-5a7dd8c8df7d", UPlainAttr.class));
54 assertNull(findPlainAttrValue("0c67225a-030a-4c56-b337-17cf7a311f0f", UPlainAttrValue.class));
55 }
56
57 @Test
58 public void deleteAllAttValues() {
59 UPlainAttrValue value = findPlainAttrValue("7034de3b-3687-4db5-8454-363468f1a9de", UPlainAttrValue.class);
60 assertNotNull(value);
61
62 plainAttrValueDAO.deleteAll(value.getAttr(), anyUtilsFactory.getInstance(AnyTypeKind.USER));
63
64 value = findPlainAttrValue("7034de3b-3687-4db5-8454-363468f1a9de", UPlainAttrValue.class);
65 assertNull(value);
66
67
68 try {
69 entityManager().flush();
70 fail();
71 } catch (InvalidEntityException e) {
72 assertNotNull(e);
73 }
74 }
75 }