From bc501f41f6d46fe79d65dc5cfb2c37f65bf20b38 Mon Sep 17 00:00:00 2001 From: "miriam.baglioni" Date: Tue, 13 Apr 2021 16:40:24 +0200 Subject: [PATCH] added test class for community removal from the set to be dumped --- .../dump/community/RemoveCommunityTest.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/community/RemoveCommunityTest.java b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/community/RemoveCommunityTest.java index 441e757cd..153f08d3d 100644 --- a/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/community/RemoveCommunityTest.java +++ b/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/community/RemoveCommunityTest.java @@ -1,4 +1,60 @@ + package eu.dnetlib.dhp.oa.graph.dump.community; +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.file.Files; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.LocalFileSystem; +import org.apache.hadoop.fs.Path; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import eu.dnetlib.dhp.oa.graph.dump.MakeTar; +import eu.dnetlib.dhp.oa.graph.dump.MakeTarTest; + public class RemoveCommunityTest { + + private static String workingDir; + + @BeforeAll + public static void beforeAll() throws IOException { + workingDir = Files + .createTempDirectory(MakeTarTest.class.getSimpleName()) + .toString(); + } + + @Test + public void testRemove() throws Exception { + LocalFileSystem fs = FileSystem.getLocal(new Configuration()); + + fs + .copyFromLocalFile( + false, new Path(getClass() + .getResource("/eu/dnetlib/dhp/oa/graph/dump/communityMapPath/communitymap.json") + .getPath()), + new Path(workingDir + "/communityMap")); + + String path = workingDir + "/communityMap"; + + RemoveCommunities.main(new String[] { + "-nameNode", "local", + "-path", path, + "-communityId", "beopen" + } + + ); + + CommunityMap cm = new ObjectMapper() + .readValue(new FileInputStream(workingDir + "/communityMap"), CommunityMap.class); + + Assertions.assertEquals(1, cm.size()); + Assertions.assertTrue(cm.containsKey("beopen")); + + } }