From e145972962d54b027d0286b84a7e697fbaf9b515 Mon Sep 17 00:00:00 2001 From: "miriam.baglioni" Date: Thu, 11 Jun 2020 13:08:39 +0200 Subject: [PATCH] - --- .../dhp/oa/graph/dump/DumpJobTest.java | 50 ++++++++----------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/DumpJobTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/DumpJobTest.java index 0852e4b0d..6c9a3c252 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/DumpJobTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/DumpJobTest.java @@ -36,7 +36,6 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import static org.mockito.Mockito.lenient; -import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) public class DumpJobTest { @@ -65,6 +64,15 @@ public class DumpJobTest { } + @Mock + private SparkDumpCommunityProducts dumpCommunityProducts; + + private QueryInformationSystem queryInformationSystem; + + @Mock + private ISLookUpService isLookUpService; + + List communityMap = Arrays.asList("", "" , "" , @@ -89,16 +97,6 @@ public class DumpJobTest { "", ""); - @Mock - private SparkDumpCommunityProducts dumpCommunityProducts; - - @Mock - private QueryInformationSystem queryInformationSystem; - - @Mock - private ISLookUpService isLookUpService; - - private static final String XQUERY = "for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') " + " where $x//CONFIGURATION/context[./@type='community' or ./@type='ri'] " + " return " + @@ -131,9 +129,8 @@ public class DumpJobTest { @BeforeEach public void setUp() throws ISLookUpException { - lenient().when(dumpCommunityProducts.getCommunityMap(MOCK_IS_LOOK_UP_URL)).thenReturn(map); - lenient().when(queryInformationSystem.getCommunityMap(MOCK_IS_LOOK_UP_URL)).thenReturn(communityMap); lenient().when(isLookUpService.quickSearchProfile(XQUERY)).thenReturn(communityMap); + lenient().when(dumpCommunityProducts.getIsLookUpService(MOCK_IS_LOOK_UP_URL)).thenReturn(isLookUpService); } @@ -147,33 +144,28 @@ public class DumpJobTest { public void test1() throws Exception { final String sourcePath = getClass() - .getResource("/eu/dnetlib/dhp/oa/graph/dump/dataset.json") - .getPath(); - dumpCommunityProducts - .main( - new String[] { - "-isSparkSessionManaged", Boolean.FALSE.toString(), - "-sourcePath", sourcePath, - "-resultType","dataset", - "-resultTableName", "eu.dnetlib.dhp.schema.oaf.Dataset", - "-dumpTableName","eu.dnetlib.dhp.schema.dump.oaf.Dataset", - "-outputPath", workingDir.toString() + "/dataset", - "-isLookUpUrl", MOCK_IS_LOOK_UP_URL - }); + .getResource("/eu/dnetlib/dhp/oa/graph/dump/dataset.json") + .getPath(); + + dumpCommunityProducts.exec(MOCK_IS_LOOK_UP_URL,Boolean.FALSE, workingDir.toString()+"/dataset",sourcePath,"eu.dnetlib.dhp.schema.oaf.Dataset","eu.dnetlib.dhp.schema.dump.oaf.Dataset"); final JavaSparkContext sc = JavaSparkContext.fromSparkContext(spark.sparkContext()); JavaRDD tmp = sc - .textFile(workingDir.toString() + "/dataset") - .map(item -> OBJECT_MAPPER.readValue(item, eu.dnetlib.dhp.schema.dump.oaf.Dataset.class)); + .textFile(workingDir.toString() + "/dataset") + .map(item -> OBJECT_MAPPER.readValue(item, eu.dnetlib.dhp.schema.dump.oaf.Dataset.class)); org.apache.spark.sql.Dataset verificationDataset = spark - .createDataset(tmp.rdd(), Encoders.bean(eu.dnetlib.dhp.schema.dump.oaf.Dataset.class)); + .createDataset(tmp.rdd(), Encoders.bean(eu.dnetlib.dhp.schema.dump.oaf.Dataset.class)); verificationDataset.show(false); } + @Test + public void test0() throws ISLookUpException { + System.out.println(new Gson().toJson(queryInformationSystem.getCommunityMap())); + } // @Test // public void bulktagBySubjectNoPreviousContextTest() throws Exception {