1
|
package eu.dnetlib.uoaadmintools;
|
2
|
|
3
|
import eu.dnetlib.uoaadmintools.dao.*;
|
4
|
import eu.dnetlib.uoaadmintools.entities.Notifications;
|
5
|
import eu.dnetlib.uoaadmintoolslibrary.dao.PortalDAO;
|
6
|
import eu.dnetlib.uoaadmintoolslibrary.entities.Portal;
|
7
|
import org.junit.Test;
|
8
|
import org.junit.runner.RunWith;
|
9
|
import org.springframework.beans.factory.annotation.Autowired;
|
10
|
import org.springframework.boot.test.context.SpringBootTest;
|
11
|
import org.springframework.test.context.junit4.SpringRunner;
|
12
|
|
13
|
import java.util.List;
|
14
|
|
15
|
@RunWith(SpringRunner.class)
|
16
|
@SpringBootTest
|
17
|
public class NotificationsTests {
|
18
|
|
19
|
@Autowired
|
20
|
private PortalDAO communityDAO;
|
21
|
|
22
|
|
23
|
@Autowired
|
24
|
private NotificationsDAO notificationsDAO;
|
25
|
|
26
|
@Test
|
27
|
public void test() {
|
28
|
String mail = "sofie.mpl@gmail.com";
|
29
|
String id="ni";
|
30
|
System.out.println(notificationsDAO.findByPortalPid(id));
|
31
|
|
32
|
Notifications notifications = notificationsDAO.findByManagerEmailAndPortalPid(mail , id);
|
33
|
if(notifications == null){
|
34
|
notifications = new Notifications();
|
35
|
notifications.setPortalPid(id);
|
36
|
notifications.setManagerEmail(mail);
|
37
|
}
|
38
|
notifications.setNotifyForNewManagers(false);
|
39
|
notifications.setNotifyForNewSubscribers(false);
|
40
|
|
41
|
notificationsDAO.save(notifications);
|
42
|
System.out.println(notificationsDAO.findByPortalPid(id));
|
43
|
|
44
|
|
45
|
|
46
|
|
47
|
}
|
48
|
|
49
|
@Test
|
50
|
public void remove() {
|
51
|
List <Portal> communities = communityDAO.findAll();
|
52
|
for(Portal com : communities){
|
53
|
List <Notifications> notificationsList = notificationsDAO.findByPortalPid(com.getPid());
|
54
|
for(Notifications notifications:notificationsList){
|
55
|
// notificationsDAO.delete(notifications.getId());
|
56
|
}
|
57
|
}
|
58
|
|
59
|
}
|
60
|
|
61
|
}
|