forked from D-Net/dnet-hadoop
[BipFinderInstanceLevel] added tests in test class
This commit is contained in:
parent
4993666d73
commit
e7d5a39c03
|
@ -11,7 +11,6 @@ import java.util.List;
|
|||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import eu.dnetlib.dhp.schema.oaf.utils.CleaningFunctions;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.spark.SparkConf;
|
||||
import org.apache.spark.api.java.JavaRDD;
|
||||
|
@ -34,6 +33,7 @@ import eu.dnetlib.dhp.schema.oaf.Instance;
|
|||
import eu.dnetlib.dhp.schema.oaf.KeyValue;
|
||||
import eu.dnetlib.dhp.schema.oaf.Measure;
|
||||
import eu.dnetlib.dhp.schema.oaf.Result;
|
||||
import eu.dnetlib.dhp.schema.oaf.utils.CleaningFunctions;
|
||||
import eu.dnetlib.dhp.schema.oaf.utils.OafMapperUtils;
|
||||
import eu.dnetlib.dhp.utils.DHPUtils;
|
||||
|
||||
|
@ -102,12 +102,33 @@ public class PrepareBipFinder implements Serializable {
|
|||
Instance inst = new Instance();
|
||||
inst.setMeasures(getMeasure(v));
|
||||
|
||||
inst.setPid(Arrays.asList(OafMapperUtils.structuredProperty(cleanedPid,
|
||||
OafMapperUtils.qualifier(DOI, DOI_CLASSNAME,
|
||||
inst
|
||||
.setPid(
|
||||
Arrays
|
||||
.asList(
|
||||
OafMapperUtils
|
||||
.structuredProperty(
|
||||
cleanedPid,
|
||||
OafMapperUtils
|
||||
.qualifier(
|
||||
DOI, DOI_CLASSNAME,
|
||||
ModelConstants.DNET_PID_TYPES,
|
||||
ModelConstants.DNET_PID_TYPES), null)));
|
||||
ModelConstants.DNET_PID_TYPES),
|
||||
null)));
|
||||
r.setInstance(Arrays.asList(inst));
|
||||
r.setDataInfo(OafMapperUtils.dataInfo(false,null,null,false, OafMapperUtils.qualifier(ModelConstants.PROVENANCE_ENRICH, null,ModelConstants.DNET_PROVENANCE_ACTIONS, ModelConstants.DNET_PROVENANCE_ACTIONS)));
|
||||
r
|
||||
.setDataInfo(
|
||||
OafMapperUtils
|
||||
.dataInfo(
|
||||
false, null, true,
|
||||
false,
|
||||
OafMapperUtils
|
||||
.qualifier(
|
||||
ModelConstants.PROVENANCE_ENRICH,
|
||||
null,
|
||||
ModelConstants.DNET_PROVENANCE_ACTIONS,
|
||||
ModelConstants.DNET_PROVENANCE_ACTIONS),
|
||||
null));
|
||||
return r;
|
||||
}, Encoders.bean(Result.class))
|
||||
.write()
|
||||
|
|
|
@ -245,6 +245,45 @@ public class ProduceTest {
|
|||
.get(0)
|
||||
.getValue());
|
||||
|
||||
Assertions.assertEquals("10.3390/s18072310",
|
||||
tmp.filter(row -> row.getId().equals(doi)).collect()
|
||||
.get(0)
|
||||
.getInstance().get(0)
|
||||
.getPid().get(0)
|
||||
.getValue().toLowerCase());
|
||||
|
||||
Assertions.assertEquals("doi",
|
||||
tmp.filter(row -> row.getId().equals(doi)).collect()
|
||||
.get(0)
|
||||
.getInstance().get(0)
|
||||
.getPid().get(0)
|
||||
.getQualifier().getClassid());
|
||||
|
||||
Assertions.assertEquals("Digital Object Identifier",
|
||||
tmp.filter(row -> row.getId().equals(doi)).collect()
|
||||
.get(0)
|
||||
.getInstance().get(0)
|
||||
.getPid().get(0)
|
||||
.getQualifier().getClassname());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void produceTestMeasures() throws Exception {
|
||||
final String doi = "unresolved::10.3390/s18072310::doi";
|
||||
JavaRDD<Result> tmp = getResultJavaRDD();
|
||||
|
||||
List<StructuredProperty> mes = tmp
|
||||
.filter(row -> row.getInstance() != null && row.getInstance().size() > 0)
|
||||
.flatMap(row -> row.getInstance().iterator())
|
||||
.flatMap(i -> i.getPid().iterator())
|
||||
.collect();
|
||||
|
||||
Assertions.assertEquals(86, mes.size());
|
||||
|
||||
tmp.filter(row -> row.getInstance() != null && row.getInstance().size() > 0)
|
||||
.foreach(e -> Assertions.assertEquals("sysimport:enrich", e.getDataInfo().getProvenanceaction().getClassid()));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue