forked from D-Net/dnet-hadoop
59 lines
1.4 KiB
Java
59 lines
1.4 KiB
Java
|
|
package eu.dnetlib.dhp.export;
|
|
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
import java.util.stream.Collectors;
|
|
|
|
import org.apache.commons.io.IOUtils;
|
|
import org.junit.jupiter.api.Assertions;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
import eu.dnetlib.dhp.schema.action.AtomicAction;
|
|
import eu.dnetlib.dhp.schema.oaf.*;
|
|
|
|
public class ScholexplorerDumpUpdateTest {
|
|
|
|
@Test
|
|
void testPatchScholexplorer() throws Exception {
|
|
|
|
final List<String> json = IOUtils.readLines(getClass().getResourceAsStream("scholexplorer_actions.json"));
|
|
|
|
json.stream().map(ScholexplorerPatcher::patchAtomicAction).filter(Objects::nonNull).forEach(aa -> {
|
|
|
|
Oaf o = aa.getPayload();
|
|
|
|
if (o instanceof Result) {
|
|
final Result r = (Result) aa.getPayload();
|
|
System.out.println(r.getId());
|
|
|
|
Map<String, StructuredProperty> pids = r
|
|
.getPid()
|
|
.stream()
|
|
.collect(
|
|
Collectors
|
|
.toMap(
|
|
k -> k.getValue(),
|
|
v -> v));
|
|
|
|
r.getInstance().forEach(i -> {
|
|
Assertions.assertTrue(i.getPid().isEmpty());
|
|
Assertions.assertTrue(!i.getAlternateIdentifier().isEmpty());
|
|
|
|
Assertions.assertEquals("UNKNOWN", i.getAccessright().getClassid());
|
|
|
|
Assertions
|
|
.assertTrue(
|
|
pids
|
|
.keySet()
|
|
.containsAll(i.getPid().stream().map(p -> p.getValue()).collect(Collectors.toSet())));
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
}
|