diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/CreateRelationTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/CreateRelationTest.java index b556fa2d66..5f21e0bc5a 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/CreateRelationTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/complete/CreateRelationTest.java @@ -1,6 +1,8 @@ package eu.dnetlib.dhp.oa.graph.dump.complete; + +import eu.dnetlib.dhp.schema.oaf.Project; import java.util.*; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -203,6 +205,7 @@ public class CreateRelationTest { " \n" + " oac_ni\n" + " 2018-03-01T12:00:00\n" + + " \n" + " \n" + " \n" + " re3data_____::5b9bf9171d92df854cf3c520692e9122\n" + @@ -437,8 +440,58 @@ public class CreateRelationTest { " \n" + " oaa_elixir-gr\n" + " 2018-03-01T12:00:00\n" + - " \n" + - " \n" + " \n" + + " \n" + + " BIO-INFORMATICS RESEARCH NETWORK COORDINATING CENTER (BIRN-CC)\n" + + " \n" + + " 1U24RR025736-01\n" + + " NIH\n" + + " \n" + + " \n" + + " COLLABORATIVE RESEARCH: The Cognitive Neuroscience of Category Learning\n" + + " \n" + + " 0223843\n" + + " NSF\n" + + " \n" + + " \n" + + " The Cognitive Atlas: Developing an Interdisciplinary Knowledge Base Through Socia\n" + + " \n" + + " 5R01MH082795-05\n" + + " NIH\n" + + " \n" + + " \n" + + " Fragmented early life environmental and emotional / cognitive vulnerabilities\n" + + " \n" + + " 1P50MH096889-01A1\n" + + " NIH\n" + + " \n" + + " \n" + + " Enhancement of the 1000 Functional Connectome Project\n" + + " \n" + + " 1R03MH096321-01A1\n" + + " TUBITAK\n" + + " \n" + + " \n" + + " CRCNS Data Sharing: An open data repository for cognitive neuroscience: The OpenfMRI Project\n" + + " \n" + + " 1131441\n" + + " NSF\n" + + " \n" + + " \n" + + " Enhancing Human Cortical Plasticity: Visual Psychophysics and fMRI\n" + + " \n" + + " 0121950\n" + + " NSF\n" + + " \n" + + " \n" + + " Transforming statistical methodology for neuroimaging meta-analysis.\n" + + " \n" + + " 100309\n" + + " WT\n" + + " \n" + + " " + + + " \n" + " \n" + " rest________::b8e502674c3c3499d5374e9b2ea6d8d5\n" + @@ -566,4 +619,99 @@ public class CreateRelationTest { tmp.contains("10|doajarticles::2899208a99aa7d142646e0a80bfeef05")); } + + @Test + public void test2() { + List cInfoList = new ArrayList<>(); + final Consumer consumer = ci -> cInfoList.add(ci); + + queryInformationSystem + .getContextRelation(consumer, "projects", ModelSupport.getIdPrefix(Project.class)); + + cInfoList.forEach(c -> System.out.println(new Gson().toJson(c))); + + + List rList = new ArrayList<>(); + + cInfoList.forEach(cInfo -> Process.getRelation(cInfo).forEach(rList::add)); + + Assertions.assertEquals(44 , rList.size()); + + Assertions + .assertFalse( + rList + .stream() + .map(r -> r.getSource().getId()) + .collect(Collectors.toSet()) + .contains( + String + .format( + "%s|%s::%s", Constants.CONTEXT_ID, + Constants.CONTEXT_NS_PREFIX, + DHPUtils.md5("dh-ch")))); + + Assertions + .assertEquals( + 2, + rList + .stream() + .filter( + r -> r + .getSource() + .getId() + .equals( + String + .format( + "%s|%s::%s", Constants.CONTEXT_ID, + Constants.CONTEXT_NS_PREFIX, + DHPUtils.md5("clarin")))) + .collect(Collectors.toList()) + .size()); + + Assertions + .assertEquals( + 2, + rList + .stream() + .filter( + r -> r + .getTarget() + .getId() + .equals( + String + .format( + "%s|%s::%s", Constants.CONTEXT_ID, + Constants.CONTEXT_NS_PREFIX, + DHPUtils.md5("clarin")))) + .collect(Collectors.toList()) + .size()); + + Set tmp = rList + .stream() + .filter( + r -> r + .getSource() + .getId() + .equals( + String + .format( + "%s|%s::%s", Constants.CONTEXT_ID, + Constants.CONTEXT_NS_PREFIX, + DHPUtils.md5("clarin")))) + .map(r -> r.getTarget().getId()) + .collect(Collectors.toSet()); + + Assertions + .assertTrue( + tmp.contains("40|corda__h2020::b5a4eb56bf84bef2ebc193306b4d423f") && + tmp.contains("40|corda_______::ef782b2d85676aa3e5a907427feb18c4") ); + + rList.forEach(rel -> { + if (rel.getSource().getId().startsWith("40|")){ + String proj = rel.getSource().getId().substring(3); + Assertions.assertTrue(proj.substring(0, proj.indexOf("::")).length() == 12); + } + }); + + } }