|
1 | 1 | package ldbc.snb.datagen.test;
|
2 | 2 |
|
| 3 | +import ldbc.snb.datagen.test.csv.*; |
| 4 | +import org.codehaus.groovy.vmplugin.v5.JUnit4Utils; |
| 5 | +import org.junit.Before; |
| 6 | +import org.junit.BeforeClass; |
3 | 7 | import org.junit.Test;
|
| 8 | +import static org.junit.Assert.*; |
| 9 | + |
| 10 | +import java.io.File; |
| 11 | +import java.util.ArrayList; |
| 12 | +import java.util.List; |
| 13 | +import java.util.Set; |
4 | 14 |
|
5 | 15 | /**
|
6 | 16 | * Created by aprat on 18/12/15.
|
7 | 17 | */
|
8 | 18 | public class LDBCDatagenTest {
|
9 | 19 |
|
| 20 | + final String dir = "./test_data/social_network"; |
| 21 | + |
| 22 | + @BeforeClass |
| 23 | + public static void generateData() { |
| 24 | + ProcessBuilder pb = new ProcessBuilder("java", "-cp", "ldbc_snb_datagen.jar","org.apache.hadoop.util.RunJar","./ldbc_snb_datagen.jar","./test_params.ini"); |
| 25 | + pb.directory(new File("./")); |
| 26 | + try { |
| 27 | + Process p = pb.start(); |
| 28 | + p.waitFor(); |
| 29 | + |
| 30 | + }catch(Exception e) { |
| 31 | + System.err.println(e.getMessage()); |
| 32 | + } |
| 33 | + } |
| 34 | + |
| 35 | + @Test |
| 36 | + public void personTest() { |
| 37 | + testIdUniqueness(dir+"/person_0_0.csv", 0); |
| 38 | + } |
| 39 | + |
| 40 | + @Test |
| 41 | + public void postTest() { |
| 42 | + testIdUniqueness(dir+"/post_0_0.csv", 0); |
| 43 | + } |
| 44 | + |
| 45 | + @Test |
| 46 | + public void forumTest() { |
| 47 | + testIdUniqueness(dir+"/forum_0_0.csv", 0); |
| 48 | + } |
| 49 | + |
| 50 | + @Test |
| 51 | + public void commentTest() { |
| 52 | + testIdUniqueness(dir+"/comment_0_0.csv", 0); |
| 53 | + } |
| 54 | + |
| 55 | + @Test |
| 56 | + public void organisationTest() { |
| 57 | + testIdUniqueness(dir+"/organisation_0_0.csv", 0); |
| 58 | + } |
| 59 | + |
| 60 | + @Test |
| 61 | + public void placeTest() { |
| 62 | + testIdUniqueness(dir+"/place_0_0.csv", 0); |
| 63 | + } |
| 64 | + |
| 65 | + @Test |
| 66 | + public void tagTest() { |
| 67 | + testIdUniqueness(dir+"/tag_0_0.csv", 0); |
| 68 | + } |
| 69 | + |
10 | 70 | @Test
|
11 |
| - public void dummyTest() { |
12 |
| - System.out.println("TEST PASSED"); |
| 71 | + public void tagclassTest() { |
| 72 | + testIdUniqueness(dir+"/tagclass_0_0.csv", 0); |
13 | 73 | }
|
| 74 | + |
| 75 | + @Test |
| 76 | + public void personKnowsPersonTest() { |
| 77 | + testPairUniquenessPlusExistance(dir+"/person_knows_person_0_0.csv",0,1,dir+"/person_0_0.csv",0); |
| 78 | + } |
| 79 | + |
| 80 | + @Test |
| 81 | + public void organisationIsLocatedInPlaceTest() { |
| 82 | + testPairUniquenessPlusExistance(dir+"/organisation_isLocatedIn_place_0_0.csv",0,1,dir+"/organisation_0_0.csv",0,dir+"/place_0_0.csv",0); |
| 83 | + } |
| 84 | + |
| 85 | + @Test |
| 86 | + public void placeIsPartOfPlaceTest() { |
| 87 | + testPairUniquenessPlusExistance(dir+"/place_isPartOf_place_0_0.csv",0,1,dir+"/place_0_0.csv",0); |
| 88 | + } |
| 89 | + |
| 90 | + @Test |
| 91 | + public void tagClassIsSubclassOfTest() { |
| 92 | + testPairUniquenessPlusExistance(dir+"/tagclass_isSubclassOf_tagclass_0_0.csv",0,1,dir+"/tagclass_0_0.csv",0); |
| 93 | + } |
| 94 | + |
| 95 | + @Test |
| 96 | + public void tagHasTypeTagclassCheck() { |
| 97 | + testPairUniquenessPlusExistance(dir+"/tag_hasType_tagclass_0_0.csv",0,1,dir+"/tag_0_0.csv",0,dir+"/tagclass_0_0.csv",0); |
| 98 | + } |
| 99 | + |
| 100 | + @Test |
| 101 | + public void personStudyAtOrganisationCheck() { |
| 102 | + testPairUniquenessPlusExistance(dir+"/person_studyAt_organisation_0_0.csv",0,1,dir+"/person_0_0.csv",0,dir+"/organisation_0_0.csv",0); |
| 103 | + } |
| 104 | + |
| 105 | + @Test |
| 106 | + public void personWorkAtOrganisationCheck() { |
| 107 | + testPairUniquenessPlusExistance(dir+"/person_workAt_organisation_0_0.csv",0,1,dir+"/person_0_0.csv",0,dir+"/organisation_0_0.csv",0); |
| 108 | + } |
| 109 | + |
| 110 | + @Test |
| 111 | + public void personHasInterestTagCheck() { |
| 112 | + testPairUniquenessPlusExistance(dir+"/person_hasInterest_tag_0_0.csv",0,1,dir+"/person_0_0.csv",0,dir+"/tag_0_0.csv",0); |
| 113 | + } |
| 114 | + |
| 115 | + @Test |
| 116 | + public void personIsLocatedInPlaceCheck() { |
| 117 | + testPairUniquenessPlusExistance(dir+"/person_isLocatedIn_place_0_0.csv",0,1,dir+"/person_0_0.csv",0,dir+"/place_0_0.csv",0); |
| 118 | + } |
| 119 | + |
| 120 | + @Test |
| 121 | + public void forumHasTagCheck() { |
| 122 | + testPairUniquenessPlusExistance(dir+"/forum_hasTag_tag_0_0.csv",0,1,dir+"/forum_0_0.csv",0,dir+"/tag_0_0.csv",0); |
| 123 | + } |
| 124 | + |
| 125 | + @Test |
| 126 | + public void forumHasModeratorPersonCheck() { |
| 127 | + testPairUniquenessPlusExistance(dir+"/forum_hasModerator_person_0_0.csv",0,1,dir+"/forum_0_0.csv",0,dir+"/person_0_0.csv",0); |
| 128 | + } |
| 129 | + |
| 130 | + @Test |
| 131 | + public void forumHasMemberPersonCheck() { |
| 132 | + testPairUniquenessPlusExistance(dir+"/forum_hasMember_person_0_0.csv",0,1,dir+"/forum_0_0.csv",0,dir+"/person_0_0.csv",0); |
| 133 | + } |
| 134 | + |
| 135 | + @Test |
| 136 | + public void forumContainerOfPostCheck() { |
| 137 | + testPairUniquenessPlusExistance(dir+"/forum_containerOf_post_0_0.csv",0,1,dir+"/forum_0_0.csv",0,dir+"/post_0_0.csv",0); |
| 138 | + } |
| 139 | + |
| 140 | + @Test |
| 141 | + public void commentHasCreatorPersonCheck() { |
| 142 | + testPairUniquenessPlusExistance(dir+"/comment_hasCreator_person_0_0.csv",0,1,dir+"/comment_0_0.csv",0,dir+"/person_0_0.csv",0); |
| 143 | + } |
| 144 | + |
| 145 | + @Test |
| 146 | + public void commentHasTagTagCheck() { |
| 147 | + testPairUniquenessPlusExistance(dir+"/comment_hasTag_tag_0_0.csv",0,1,dir+"/comment_0_0.csv",0,dir+"/tag_0_0.csv",0); |
| 148 | + } |
| 149 | + |
| 150 | + @Test |
| 151 | + public void commentIsLocatedInPlaceCheck() { |
| 152 | + testPairUniquenessPlusExistance(dir+"/comment_isLocatedIn_place_0_0.csv",0,1,dir+"/comment_0_0.csv",0,dir+"/place_0_0.csv",0); |
| 153 | + } |
| 154 | + |
| 155 | + @Test |
| 156 | + public void commentReplyOfCommentCheck() { |
| 157 | + testPairUniquenessPlusExistance(dir+"/comment_replyOf_comment_0_0.csv",0,1,dir+"/comment_0_0.csv",0,dir+"/comment_0_0.csv",0); |
| 158 | + } |
| 159 | + |
| 160 | + @Test |
| 161 | + public void commentReplyOfPostCheck() { |
| 162 | + testPairUniquenessPlusExistance(dir+"/comment_replyOf_post_0_0.csv",0,1,dir+"/comment_0_0.csv",0,dir+"/post_0_0.csv",0); |
| 163 | + } |
| 164 | + |
| 165 | + @Test |
| 166 | + public void postHasCreatorPersonCheck() { |
| 167 | + testPairUniquenessPlusExistance(dir+"/post_hasCreator_person_0_0.csv",0,1,dir+"/post_0_0.csv",0,dir+"/person_0_0.csv",0); |
| 168 | + } |
| 169 | + |
| 170 | + @Test |
| 171 | + public void postIsLocatedInPlaceCheck() { |
| 172 | + testPairUniquenessPlusExistance(dir+"/post_isLocatedIn_place_0_0.csv",0,1,dir+"/post_0_0.csv",0,dir+"/place_0_0.csv",0); |
| 173 | + } |
| 174 | + |
| 175 | + @Test |
| 176 | + public void personLikesCommentCheck() { |
| 177 | + testPairUniquenessPlusExistance(dir+"/person_likes_comment_0_0.csv",0,1,dir+"/person_0_0.csv",0,dir+"/comment_0_0.csv",0); |
| 178 | + } |
| 179 | + |
| 180 | + @Test |
| 181 | + public void personLikesPostCheck() { |
| 182 | + testPairUniquenessPlusExistance(dir+"/person_likes_post_0_0.csv",0,1,dir+"/person_0_0.csv",0,dir+"/post_0_0.csv",0); |
| 183 | + } |
| 184 | + |
| 185 | + public void testIdUniqueness(String fileName, int column) { |
| 186 | + FileChecker fileChecker = new FileChecker(fileName); |
| 187 | + UniquenessCheck check = new UniquenessCheck(0); |
| 188 | + fileChecker.addCheck(check); |
| 189 | + if(!fileChecker.run(1)) assertEquals("ERROR PASSING TEST ID UNIQUENESS FOR FILE "+fileName,true, false); |
| 190 | + } |
| 191 | + |
| 192 | + public void testPairUniquenessPlusExistance(String relationFileName, int columnA, int columnB, String entityFileNameA, int entityColumnA, String entityFileNameB, int entityColumnB) { |
| 193 | + Set<String> organisations = Column.readColumnAsSet(entityFileNameA,entityColumnA); |
| 194 | + Set<String> places = Column.readColumnAsSet(entityFileNameB,entityColumnB); |
| 195 | + FileChecker fileChecker = new FileChecker(relationFileName); |
| 196 | + PairUniquenessCheck pairUniquenessCheck = new PairUniquenessCheck(0,1); |
| 197 | + fileChecker.addCheck(pairUniquenessCheck); |
| 198 | + List<Set<String>> entityARefColumns = new ArrayList<Set<String>>(); |
| 199 | + entityARefColumns.add(organisations); |
| 200 | + List<Set<String>> entityBRefColumns = new ArrayList<Set<String>>(); |
| 201 | + entityBRefColumns.add(places); |
| 202 | + List<Integer> organisationIndices = new ArrayList<Integer>(); |
| 203 | + organisationIndices.add(0); |
| 204 | + List<Integer> placeIndices = new ArrayList<Integer>(); |
| 205 | + placeIndices.add(1); |
| 206 | + ExistsCheck existsEntityACheck = new ExistsCheck(organisationIndices, entityARefColumns); |
| 207 | + ExistsCheck existsEntityBCheck = new ExistsCheck(placeIndices, entityBRefColumns); |
| 208 | + fileChecker.addCheck(existsEntityACheck); |
| 209 | + fileChecker.addCheck(existsEntityBCheck); |
| 210 | + assertEquals("ERROR PASSING ORGANISATION_ISLOCATEDIN_PLACE TEST",true, fileChecker.run(1)); |
| 211 | + |
| 212 | + } |
| 213 | + |
| 214 | + public void testPairUniquenessPlusExistance(String relationFileName, int columnA, int columnB, String entityFileName, int entityColumn) { |
| 215 | + Set<String> persons = Column.readColumnAsSet(entityFileName,entityColumn); |
| 216 | + FileChecker fileChecker = new FileChecker(relationFileName); |
| 217 | + PairUniquenessCheck pairUniquenessCheck = new PairUniquenessCheck(columnA,columnB); |
| 218 | + fileChecker.addCheck(pairUniquenessCheck); |
| 219 | + List<Set<String>> refcolumns = new ArrayList<Set<String>>(); |
| 220 | + refcolumns.add(persons); |
| 221 | + List<Integer> columnIndices = new ArrayList<Integer>(); |
| 222 | + columnIndices.add(0); |
| 223 | + columnIndices.add(1); |
| 224 | + ExistsCheck existsCheck = new ExistsCheck(columnIndices, refcolumns); |
| 225 | + fileChecker.addCheck(existsCheck); |
| 226 | + assertEquals("ERROR PASSING "+relationFileName+" TEST",true, fileChecker.run(1)); |
| 227 | + } |
| 228 | + |
14 | 229 | }
|
0 commit comments