1
|
package eu.dnetlib.uoaadmintools;
|
2
|
|
3
|
import eu.dnetlib.uoaadmintools.dao.*;
|
4
|
import eu.dnetlib.uoaadmintools.entities.*;
|
5
|
import org.junit.Test;
|
6
|
import org.junit.runner.RunWith;
|
7
|
import org.springframework.beans.factory.annotation.Autowired;
|
8
|
import org.springframework.boot.test.context.SpringBootTest;
|
9
|
import org.springframework.test.context.junit4.SpringRunner;
|
10
|
|
11
|
import java.util.HashMap;
|
12
|
import java.util.List;
|
13
|
import java.util.Map;
|
14
|
|
15
|
@RunWith(SpringRunner.class)
|
16
|
@SpringBootTest
|
17
|
public class UoaAdminToolsApplicationTests {
|
18
|
|
19
|
@Autowired
|
20
|
private CommunityDAO communityDAO;
|
21
|
|
22
|
@Autowired
|
23
|
private EntityDAO entityDAO;
|
24
|
|
25
|
@Autowired
|
26
|
private PageDAO pageDAO;
|
27
|
|
28
|
@Autowired
|
29
|
private PageHelpContentDAO pageHelpContentDAO;
|
30
|
|
31
|
@Autowired
|
32
|
private StatisticsDAO statisticsDAO;
|
33
|
|
34
|
/*
|
35
|
|
36
|
@Test
|
37
|
public void createAllEntities() {
|
38
|
Map<String, String> entities = new HashMap<>();
|
39
|
entities.put("Publication", "publication");
|
40
|
entities.put("Research Data", "dataset");
|
41
|
entiites.put("Software", "software");
|
42
|
entities.put("Project", "project");
|
43
|
entities.put("Organization", "organization");
|
44
|
entities.put("Content Provider", "datasource");
|
45
|
|
46
|
for(entry<String, String> entr : entities.entrySet()) {
|
47
|
Entity entity = new Entity();
|
48
|
entity.setName(entr.getKey());
|
49
|
entity.setPid(entr.getValue());
|
50
|
entityDAO.save(entity);
|
51
|
}
|
52
|
}
|
53
|
|
54
|
@Test
|
55
|
public void createAllPages() {
|
56
|
String publication = entityDAO.findByPid("publication").getId();
|
57
|
String dataset = entityDAO.findByPid("dataset").getId();
|
58
|
String software = entityDAO.findByPid("software").getId();
|
59
|
String project = entityDAO.findByPid("project").getId();
|
60
|
String organization = entityDAO.findByPid("organization").getId();
|
61
|
String datasource = entityDAO.findByPid("datasource").getId();
|
62
|
|
63
|
|
64
|
Map<String, List<String>> pages = new HashMap<>();
|
65
|
pages.put("Search Publications", new ArrayList<>());
|
66
|
pages.get("Search Publications").add()
|
67
|
|
68
|
//entities.add("5a300ee4c97a7d2c000b9e9d"); // Publication
|
69
|
entities.add("5a319f8bc97a7d241ebddf75"); // Research Data
|
70
|
|
71
|
|
72
|
Page page = new Page();
|
73
|
page.setName("Search Research Data");
|
74
|
page.setRoute("/search/find/datasets");
|
75
|
page.setType("search");
|
76
|
page.setEntities(entities);
|
77
|
pageDAO.save(page);
|
78
|
}
|
79
|
|
80
|
|
81
|
|
82
|
@Test
|
83
|
public void deleteAllEntities() {
|
84
|
List<Entity> entities = entityDAO.findAll();
|
85
|
for(Entity entity : entities) {
|
86
|
entityDAO.delete(entity.getId());
|
87
|
}
|
88
|
}
|
89
|
|
90
|
@Test
|
91
|
public void deleteAllCommunities() {
|
92
|
List<Community> communities = communityDAO.findAll();
|
93
|
for(Community community : communities) {
|
94
|
communityDAO.delete(community.getId());
|
95
|
}
|
96
|
}
|
97
|
|
98
|
@Test
|
99
|
public void deleteAllPages() {
|
100
|
List<Page> pages = pageDAO.findAll();
|
101
|
for(Page page : pages) {
|
102
|
pageDAO.delete(page.getId());
|
103
|
}
|
104
|
}
|
105
|
|
106
|
@Test
|
107
|
public void deleteAllPageContents() {
|
108
|
List<PageHelpContent> pageHelpContents = pageHelpContentDAO.findAll();
|
109
|
for(PageHelpContent pageHelpContent : pageHelpContents) {
|
110
|
pageHelpContentDAO.delete(pageHelpContent.getId());
|
111
|
}
|
112
|
}
|
113
|
|
114
|
@Test
|
115
|
public void createEntity() {
|
116
|
Entity entity = new Entity();
|
117
|
entity.setName("Publication");
|
118
|
entityDAO.save(entity);
|
119
|
}
|
120
|
|
121
|
@Test
|
122
|
public void createPage() {
|
123
|
List<String> entities = new ArrayList<String>();
|
124
|
//entities.add("5a300ee4c97a7d2c000b9e9d"); // Publication
|
125
|
entities.add("5a319f8bc97a7d241ebddf75"); // Research Data
|
126
|
|
127
|
|
128
|
Page page = new Page();
|
129
|
page.setName("Search Research Data");
|
130
|
page.setRoute("/search/find/datasets");
|
131
|
page.setType("search");
|
132
|
page.setEntities(entities);
|
133
|
pageDAO.save(page);
|
134
|
}
|
135
|
|
136
|
@Test
|
137
|
public void createCommunity() {
|
138
|
Map<String, Boolean> entities = new HashMap<String, Boolean>();
|
139
|
//entities.put("5a300ee4c97a7d2c000b9e9d", true); // Publication
|
140
|
entities.put("5a319f8bc97a7d241ebddf75", false); // Research Data
|
141
|
//entities.put("5a3064f9c97a7d4964408ee0", false); // Software
|
142
|
//entities.put("5a30652ec97a7d4964408ee1", false); // Organization
|
143
|
//entities.put("5a306539c97a7d4964408ee2", false); // Project
|
144
|
//entities.put("5a30654dc97a7d4964408ee3", false); // Content Provider
|
145
|
|
146
|
Map<String, Boolean> pages = new HashMap<String, Boolean>();
|
147
|
//pages.put("5a30191ac97a7d3a7fa77362", true); // Search Publications
|
148
|
pages.put("5a31a4cac97a7d28468f0f5c", false); // Search Research Data
|
149
|
//pages.put("5a30657ac97a7d4964408ee4", false); // Search Software
|
150
|
//pages.put("5a30eeffc97a7d74234434ad", false); // Search Organizations
|
151
|
//pages.put("5a30efd9c97a7d7609b77ca5", false); // Search Projects
|
152
|
//pages.put("5a30f08bc97a7d7609b77ca7", false); // Search Content Providers
|
153
|
|
154
|
//pages.put("5a300f19c97a7d2c6e084b9f", false); // Test
|
155
|
|
156
|
Community community = new Community();
|
157
|
community.setName("Test Community");
|
158
|
community.setEntities(entities);
|
159
|
community.setPages(pages);
|
160
|
communityDAO.save(community);
|
161
|
}
|
162
|
*/
|
163
|
|
164
|
@Test
|
165
|
public void contextLoads() {
|
166
|
}
|
167
|
@Test
|
168
|
public void testStatistics() {
|
169
|
// Statistics stats= new Statistics("openiare");
|
170
|
// Statistics saved = statisticsDAO.save(stats);
|
171
|
// System.out.println(saved);
|
172
|
// Statistics stats = statisticsDAO.findByPid("openaire");
|
173
|
// System.out.println(stats.toString());
|
174
|
List<Statistics> statisticsList = statisticsDAO.findAll();
|
175
|
for(Statistics stat:statisticsList){
|
176
|
System.out.println(stat.toString());
|
177
|
}
|
178
|
// statisticsDAO.delete("5a9d0c71f9084558aad0fb3d");
|
179
|
// statisticsList = statisticsDAO.findAll();
|
180
|
// for(Statistics stats:statisticsList){
|
181
|
// System.out.println(stats.toString());
|
182
|
// }
|
183
|
// statisticsDAO.deleteAll();
|
184
|
}
|
185
|
@Test
|
186
|
public void createStatistics() {
|
187
|
List<Community> communities = communityDAO.findAll();
|
188
|
for(Community c:communities){
|
189
|
|
190
|
String pid = c.getPid();
|
191
|
System.out.println("Community :" +pid);
|
192
|
Statistics stats = statisticsDAO.findByPid(pid);
|
193
|
if(stats == null){
|
194
|
Statistics statistics = new Statistics(pid);
|
195
|
statisticsDAO.save(statistics);
|
196
|
System.out.println("Saved stats for :" +pid);
|
197
|
}
|
198
|
}
|
199
|
|
200
|
}
|
201
|
}
|