Project

General

Profile

1
package eu.dnetlib.parthenos.catalogue;
2

    
3
import java.io.IOException;
4

    
5
import eu.dnetlib.parthenos.publisher.ParthenosPublisherException;
6
import eu.dnetlib.parthenos.rdf.ResourceReader;
7
import org.apache.commons.io.IOUtils;
8
import org.junit.Before;
9
import org.junit.Test;
10
import org.springframework.core.io.ClassPathResource;
11

    
12
/**
13
 * Created by Alessia Bardi on 11/12/2017.
14
 *
15
 * @author Alessia Bardi
16
 */
17
public class CatalogueRegistratorTest {
18

    
19
	private CatalogueRegistrator reg;
20
	private ResourceReader reader = new ResourceReader();
21

    
22
	private String appToken = "fakeToken";
23
	private String baseUrl = "https://this.is.a.fake.base.url/catalogue";
24

    
25
	private String recordPath = "eu/dnetlib/parthenos/registry/nakala.rdf";
26
	private String recordId = "parthenos___::8d777f385d3dfec8815d20f7496026dc";
27

    
28
	@Before
29
	public void setup() throws Exception {
30
		reg = new CatalogueRegistrator();
31
		reg.setApplicationToken(appToken);
32
		reg.setBaseURL(baseUrl);
33
		reg.setResourceReader(reader);
34
		reg.init();
35
	}
36

    
37
	@Test
38
	public void testRegister() throws IOException, ParthenosPublisherException {
39
		String record = getString(recordPath);
40
		int res = reg.register(record, recordId);
41
		System.out.println(res);
42
	}
43

    
44

    
45
	private String getString(final String classpath) {
46
		try {
47
			final ClassPathResource resource = new ClassPathResource(classpath);
48
			return IOUtils.toString(resource.getInputStream(), "UTF-8");
49
		}catch(IOException e){
50
			return null;
51
		}
52
	}
53

    
54
}
    (1-1/1)