Revision 52851
Added by Alessia Bardi over 5 years ago
modules/dnet-parthenos-publisher/trunk/test/main/java/eu/dnetlib/parthenos/catalogue/CatalogueRegistratorIntegrationTest.java | ||
---|---|---|
7 | 7 |
import eu.dnetlib.parthenos.CRM; |
8 | 8 |
import eu.dnetlib.parthenos.CRMdig; |
9 | 9 |
import eu.dnetlib.parthenos.CRMpe; |
10 |
import eu.dnetlib.parthenos.publisher.ParthenosPublisherException; |
|
11 | 10 |
import org.apache.jena.ontology.OntModel; |
12 | 11 |
import org.apache.jena.ontology.OntModelSpec; |
13 | 12 |
import org.apache.jena.rdf.model.InfModel; |
... | ... | |
25 | 24 |
import org.springframework.test.context.TestPropertySource; |
26 | 25 |
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
27 | 26 |
|
28 |
import static org.junit.Assert.assertFalse; |
|
29 |
import static org.junit.Assert.assertTrue; |
|
30 |
|
|
31 | 27 |
/** |
32 | 28 |
* Created by Alessia Bardi on 15/03/2018. |
33 | 29 |
* |
... | ... | |
43 | 39 |
private String nakalaService = "eu/dnetlib/parthenos/registry/nakala.rdf"; |
44 | 40 |
private String resourceCatName = "nakalatest"; |
45 | 41 |
|
46 |
private String rdfWithProviders = "eu/dnetlib/parthenos/registry/withProviders.rdf"; |
|
42 |
//private String rdfWithProviders = "eu/dnetlib/parthenos/registry/withProviders.rdf";
|
|
47 | 43 |
|
48 | 44 |
private String error500_1 = "eu/dnetlib/parthenos/registry/error500_1.rdf"; |
49 |
private String serviceSample = "eu/dnetlib/parthenos/registry/PE1_Service_sample.rdf"; |
|
50 |
private boolean doPurge=false; |
|
45 |
//private String serviceSample = "eu/dnetlib/parthenos/registry/PE1_Service_sample.rdf"; |
|
51 | 46 |
|
52 | 47 |
@Autowired |
53 | 48 |
private CatalogueRegistrator reg; |
... | ... | |
69 | 64 |
model.read(getStream(nakalaService), CRMpe.NS); |
70 | 65 |
ResIterator subjects = model.listSubjectsWithProperty(RDF.type, CRM.E7_Activity); |
71 | 66 |
Resource nakala = subjects.nextResource(); |
72 |
String uuid = reg.register(nakala, CRM.E7_Activity, "testGroup");
|
|
67 |
String uuid = reg.register(nakala, CRM.E7_Activity, CKANUtils.nakala_org);
|
|
73 | 68 |
System.out.println(uuid); |
74 | 69 |
purge(uuid); |
75 | 70 |
} |
... | ... | |
80 | 75 |
model.read(getStream(error500_1), CRMpe.NS); |
81 | 76 |
ResIterator subjects = model.listSubjectsWithProperty(RDF.type, CRM.E29_Design_or_Procedure); |
82 | 77 |
Resource r = subjects.nextResource(); |
83 |
String uuid = reg.register(r, CRM.E29_Design_or_Procedure, "testGroup");
|
|
78 |
String uuid = reg.register(r, CRM.E29_Design_or_Procedure, CKANUtils.Parthenos_org);
|
|
84 | 79 |
System.out.println(uuid); |
85 | 80 |
purge(uuid); |
86 | 81 |
} |
... | ... | |
90 | 85 |
reg.purge(resourceCatName); |
91 | 86 |
} |
92 | 87 |
|
93 |
// @Test |
|
94 |
// public void testAddGroup() throws IOException, URISyntaxException, ParthenosPublisherException { |
|
95 |
// InfModel model = loadBaseModel(); |
|
96 |
// model.read(getStream(rdfWithProviders), CRMpe.NS); |
|
97 |
// ResIterator it = model.listSubjectsWithProperty(CRMpe.PP2_provided_by); |
|
98 |
// while(it.hasNext()){ |
|
99 |
// Resource withProvider = it.nextResource(); |
|
100 |
// reg.ensureGroups(withProvider); |
|
101 |
// } |
|
102 |
// reg.getCatalogueAPIClient().purgeGroup("SISMEL"); |
|
103 |
// reg.getCatalogueAPIClient().purgeGroup("EHRI Consortium"); |
|
104 |
// } |
|
105 |
// |
|
106 |
// @Test |
|
107 |
// public void testAddGroup2() throws IOException, URISyntaxException, ParthenosPublisherException { |
|
108 |
// InfModel model = loadBaseModel(); |
|
109 |
// model.read(getStream(serviceSample), CRMpe.NS); |
|
110 |
// Resource subject = model.getResource("http://parthenos.d4science.org/handle/CP/Service/TEST"); |
|
111 |
// Iterator<String> providers = reg.getResourceReader().getProviderNames(subject); |
|
112 |
// reg.ensureGroups(subject); |
|
113 |
// while(providers.hasNext()){ |
|
114 |
// String p = providers.next(); |
|
115 |
// System.out.println("purging group "+p); |
|
116 |
// reg.getCatalogueAPIClient().purgeGroup(p); |
|
117 |
// } |
|
118 |
// } |
|
119 |
|
|
120 |
@Test |
|
121 |
public void testGroup() throws ParthenosPublisherException, IOException, URISyntaxException { |
|
122 |
assertFalse(reg.getCatalogueAPIClient().groupExist("sismeltest")); |
|
123 |
String sismelJson = "{" |
|
124 |
+ " \"name\":\"sismeltest\"," |
|
125 |
+ " \"id\":\"sismeltest\"," |
|
126 |
+ " \"title\": \"SISMEL TEST GROUP TITLE\"" |
|
127 |
//+ " \"description\": \"%s\"" |
|
128 |
+ "}"; |
|
129 |
reg.getCatalogueAPIClient().registerGroup(sismelJson, "sismeltest"); |
|
130 |
assertTrue(reg.getCatalogueAPIClient().groupExist("sismeltest")); |
|
131 |
reg.getCatalogueAPIClient().purgeGroup("sismeltest"); |
|
132 |
assertFalse(reg.getCatalogueAPIClient().groupExist("sismeltest")); |
|
133 |
} |
|
134 |
|
|
135 | 88 |
private void purge(final String uuid) throws IOException, URISyntaxException { |
136 | 89 |
reg.purge(uuid); |
137 | 90 |
} |
Also available in: Unified diff
Removed tests for CRUD ops on groups