All resources filter test
This commit is contained in:
parent
da2158db6a
commit
f929862f94
|
@ -4,11 +4,15 @@ 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;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
public class TransformationTests {
|
||||
|
||||
static ObjectMapper mapper=null;
|
||||
|
@ -37,5 +41,15 @@ public class TransformationTests {
|
|||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<Body>
|
||||
<resourceFilters>
|
||||
<filter>
|
||||
<condition>$.resources[?(@.format=='CSV')]</condition>
|
||||
<condition>$.resources[?(@.format)]</condition>
|
||||
</filter>
|
||||
</resourceFilters>
|
||||
|
||||
|
|
Loading…
Reference in New Issue