56 lines
2.0 KiB
Java
56 lines
2.0 KiB
Java
package org.gcube.data.publishing.gCatFeeder.collectors.dm;
|
|
|
|
import java.io.IOException;
|
|
import java.util.Collection;
|
|
import java.util.Set;
|
|
|
|
import org.codehaus.jackson.JsonGenerationException;
|
|
import org.codehaus.jackson.map.JsonMappingException;
|
|
import org.codehaus.jackson.map.ObjectMapper;
|
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
import org.gcube.data.publishing.gCatFeeder.collectors.dm.model.InternalAlgorithmDescriptor;
|
|
import org.gcube.data.publishing.gCatFeeder.model.CatalogueFormatData;
|
|
import org.gcube.data.publishing.gCatfeeder.collectors.CollectorPlugin;
|
|
import org.gcube.data.publishing.gCatfeeder.collectors.DataCollector;
|
|
import org.gcube.data.publishing.gCatfeeder.collectors.DataTransformer;
|
|
import org.gcube.data.publishing.gCatfeeder.collectors.model.faults.CatalogueNotSupportedException;
|
|
import org.gcube.data.publishing.gCatfeeder.collectors.model.faults.CollectorFault;
|
|
import org.junit.Before;
|
|
import org.junit.BeforeClass;
|
|
import org.junit.Test;
|
|
|
|
public class TranslationTest {
|
|
|
|
@BeforeClass
|
|
public static void checkTestEnabled() {
|
|
|
|
}
|
|
|
|
@Before
|
|
public void setToken() {
|
|
// disable if maven property
|
|
// set token
|
|
SecurityTokenProvider.instance.set("***REMOVED***");
|
|
}
|
|
|
|
|
|
@Test
|
|
public void testTranslation() throws CollectorFault, CatalogueNotSupportedException, JsonGenerationException, JsonMappingException, IOException {
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
CollectorPlugin plugin=new DataMinerPlugin();
|
|
DataCollector collector=plugin.getCollector();
|
|
Collection collected=collector.collect();
|
|
System.out.println("Found "+collected.size()+" elements");
|
|
for(Object obj:collected)
|
|
System.out.println(mapper.writeValueAsString(obj)+"\n");
|
|
|
|
for(String destinationcatalogue : (Set<String>)plugin.getSupportedCatalogueTypes()) {
|
|
DataTransformer<? extends CatalogueFormatData, InternalAlgorithmDescriptor> transformer=plugin.getTransformerByCatalogueType(destinationcatalogue);
|
|
transformer.transform(collected);
|
|
}
|
|
}
|
|
|
|
}
|