Improved code

This commit is contained in:
Luca Frosini 2022-09-12 16:53:39 +02:00
parent 1f52f9e5df
commit f13a36c1c6
1 changed files with 24 additions and 7 deletions

View File

@ -154,7 +154,7 @@ public class GRSFUtilities extends ContextTest {
}
@Test
// @Test
public void createNewGRSFGroups() throws ObjectNotFound, Exception {
String sysAdminAPI = CKANUtility.getSysAdminAPI();
String[] groupNames = new String[] {
@ -238,18 +238,25 @@ public class GRSFUtilities extends ContextTest {
// @Test
public void manageOrganizations() throws JsonProcessingException {
String context = SecretManagerProvider.instance.get().getContext();
ScopeBean scopeBean = new ScopeBean(context);
String sysAdminAPI = CKANUtility.getSysAdminAPI();
String[] organizations = new String[] {
"GRSF_Pre", "FIRMS", "FishSource", "RAM"
};
Map<String, String> organizations = new HashMap<>();
organizations.put(scopeBean.name(), scopeBean.name());
organizations.put("FIRMS", "FIRMS");
organizations.put("FishSource", "FishSource");
organizations.put("RAM", "RAM");
organizations.put("SDG", "FAO SDG 14.4.1 Questionnaire");
ObjectMapper objectMapper = new ObjectMapper();
for(String org : organizations) {
for(String org : organizations.keySet()) {
CKANOrganization ckanOrganization = new CKANOrganization();
ckanOrganization.setApiKey(sysAdminAPI);
ckanOrganization.setName(org.toLowerCase());
ObjectNode node = objectMapper.createObjectNode();
node.put("display_name", org);
node.put("title", org);
String fancyName = organizations.get(org);
node.put("display_name", fancyName);
node.put("title", fancyName);
node.put("name", org.toLowerCase());
String json = objectMapper.writeValueAsString(node);
try {
@ -404,4 +411,14 @@ public class GRSFUtilities extends ContextTest {
purgeGRSFRecords(100, 0);
}
@Test
public void purgeSpecificGRSFRecord() throws Exception {
CKANPackage ckanPackage = new CKANPackage();
MultivaluedMap<String, String> mvm = new MultivaluedHashMap<String,String>();
UriInfo uriInfo = CKANPackageTest.getUriInfo(mvm);
ckanPackage.setUriInfo(uriInfo);
ckanPackage.setName("70ae6895-7d3d-4f4a-86f9-bcb17d41bff6");
ckanPackage.purgeNoCheckNoDeleteFiles();
}
}