56 lines
1.9 KiB
Java
56 lines
1.9 KiB
Java
package org.gcube.tests;
|
|
|
|
import org.gcube.common.resources.gcore.GenericResource;
|
|
import org.gcube.common.resources.gcore.Resources;
|
|
import org.gcube.data.publishing.ckan2zenodo.Translator;
|
|
import org.gcube.data.publishing.ckan2zenodo.commons.IS;
|
|
import org.gcube.data.publishing.ckan2zenodo.model.CkanItemDescriptor;
|
|
import org.gcube.data.publishing.ckan2zenodo.model.CkanResource;
|
|
import org.junit.BeforeClass;
|
|
import org.junit.Test;
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
public class TransformationTests {
|
|
|
|
static ObjectMapper mapper=null;
|
|
@BeforeClass
|
|
public static void init () {
|
|
mapper=TestCommons.getMapper();
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
public void transform() throws Exception {
|
|
Translator basic=new Translator();
|
|
TestCommons.readAndTransform("/simpleItem.json",basic);
|
|
TestCommons.readAndTransform("/FSKXModel.json",basic);
|
|
TestCommons.readAndTransform("/ResearchObject.json",basic);
|
|
}
|
|
|
|
|
|
@Test
|
|
public void transformWithMappings() throws Exception {
|
|
|
|
GenericResource res=Resources.unmarshal(GenericResource.class, TransformationTests.class.getResourceAsStream("/ResearchObject.xml"));
|
|
Translator t=new Translator(IS.readMappings(res));
|
|
// TestCommons.readAndTransform("/ResearchObject.json", t);
|
|
TestCommons.readAndTransform("/crop_parameters.json",t);
|
|
}
|
|
|
|
@Test
|
|
public void filterResources() throws Exception {
|
|
GenericResource res=Resources.unmarshal(GenericResource.class, TransformationTests.class.getResourceAsStream("/ResearchObject.xml"));
|
|
Translator t=new Translator(IS.readMappings(res),IS.readResourceFilters(res));
|
|
|
|
String json=TestCommons.convertStreamToString(TransformationTests.class.getResourceAsStream("/ResearchObject.json"));
|
|
CkanItemDescriptor desc=new CkanItemDescriptor(json);
|
|
|
|
for(CkanResource filtered:t.filterResources(desc))
|
|
System.out.println("NAME : "+filtered.getName()+ " FORMAT : "+filtered.getFormat());
|
|
}
|
|
|
|
|
|
}
|