forked from D-Net/dnet-hadoop
This commit is contained in:
parent
a01800224c
commit
e145972962
|
@ -36,7 +36,6 @@ import org.mockito.Mock;
|
||||||
import org.mockito.junit.jupiter.MockitoExtension;
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
|
||||||
import static org.mockito.Mockito.lenient;
|
import static org.mockito.Mockito.lenient;
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
@ExtendWith(MockitoExtension.class)
|
@ExtendWith(MockitoExtension.class)
|
||||||
public class DumpJobTest {
|
public class DumpJobTest {
|
||||||
|
@ -65,6 +64,15 @@ public class DumpJobTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private SparkDumpCommunityProducts dumpCommunityProducts;
|
||||||
|
|
||||||
|
private QueryInformationSystem queryInformationSystem;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private ISLookUpService isLookUpService;
|
||||||
|
|
||||||
|
|
||||||
List<String> communityMap = Arrays.asList("<community id=\"egi\" label=\"EGI Federation\"/>",
|
List<String> communityMap = Arrays.asList("<community id=\"egi\" label=\"EGI Federation\"/>",
|
||||||
"<community id=\"fet-fp7\" label=\"FET FP7\"/>" ,
|
"<community id=\"fet-fp7\" label=\"FET FP7\"/>" ,
|
||||||
"<community id=\"fet-h2020\" label=\"FET H2020\"/>" ,
|
"<community id=\"fet-h2020\" label=\"FET H2020\"/>" ,
|
||||||
|
@ -89,16 +97,6 @@ public class DumpJobTest {
|
||||||
"<community id=\"covid-19\" label=\"COVID-19\"/>",
|
"<community id=\"covid-19\" label=\"COVID-19\"/>",
|
||||||
"<community id=\"enermaps\" label=\"Energy Research\"/>");
|
"<community id=\"enermaps\" label=\"Energy Research\"/>");
|
||||||
|
|
||||||
@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') " +
|
private static final String XQUERY = "for $x in collection('/db/DRIVER/ContextDSResources/ContextDSResourceType') " +
|
||||||
" where $x//CONFIGURATION/context[./@type='community' or ./@type='ri'] " +
|
" where $x//CONFIGURATION/context[./@type='community' or ./@type='ri'] " +
|
||||||
" return " +
|
" return " +
|
||||||
|
@ -131,9 +129,8 @@ public class DumpJobTest {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp() throws ISLookUpException {
|
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(isLookUpService.quickSearchProfile(XQUERY)).thenReturn(communityMap);
|
||||||
|
lenient().when(dumpCommunityProducts.getIsLookUpService(MOCK_IS_LOOK_UP_URL)).thenReturn(isLookUpService);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,17 +146,8 @@ public class DumpJobTest {
|
||||||
final String sourcePath = getClass()
|
final String sourcePath = getClass()
|
||||||
.getResource("/eu/dnetlib/dhp/oa/graph/dump/dataset.json")
|
.getResource("/eu/dnetlib/dhp/oa/graph/dump/dataset.json")
|
||||||
.getPath();
|
.getPath();
|
||||||
dumpCommunityProducts
|
|
||||||
.main(
|
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");
|
||||||
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
|
|
||||||
});
|
|
||||||
|
|
||||||
final JavaSparkContext sc = JavaSparkContext.fromSparkContext(spark.sparkContext());
|
final JavaSparkContext sc = JavaSparkContext.fromSparkContext(spark.sparkContext());
|
||||||
|
|
||||||
|
@ -174,6 +162,10 @@ public class DumpJobTest {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@Test
|
||||||
|
public void test0() throws ISLookUpException {
|
||||||
|
System.out.println(new Gson().toJson(queryInformationSystem.getCommunityMap()));
|
||||||
|
}
|
||||||
|
|
||||||
// @Test
|
// @Test
|
||||||
// public void bulktagBySubjectNoPreviousContextTest() throws Exception {
|
// public void bulktagBySubjectNoPreviousContextTest() throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue