-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#70 get (ugly/repetitive/error-prone) implementations of projection o…
…perators for subject, object and predicate ready for integration testing
- Loading branch information
Showing
13 changed files
with
444 additions
and
132 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
bakemono/src/main/java/com/ontology2/bakemono/mapmap/UniqueInternalURIObjectMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.ontology2.bakemono.mapmap; | ||
|
||
import com.google.common.base.Function; | ||
import com.ontology2.bakemono.primitiveTriples.PrimitiveTriple; | ||
import com.ontology2.bakemono.primitiveTriples.ProjectInternalURIObject; | ||
import com.ontology2.bakemono.primitiveTriples.ProjectURIObject; | ||
import org.apache.hadoop.io.Text; | ||
|
||
public class UniqueInternalURIObjectMapper extends PTUniqueMapMapper<Text> { | ||
|
||
private final Function<PrimitiveTriple,Text> primitiveTriple = new ProjectInternalURIObject(); | ||
|
||
@Override | ||
Function<PrimitiveTriple, Text> getKeyFunction() { | ||
return primitiveTriple; | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
bakemono/src/main/java/com/ontology2/bakemono/mapmap/UniqueInternalURIObjectTool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.ontology2.bakemono.mapmap; | ||
|
||
/** | ||
* Created with IntelliJ IDEA. | ||
* User: paul_000 | ||
* Date: 11/12/13 | ||
* Time: 1:45 PM | ||
* To change this template use File | Settings | File Templates. | ||
*/ | ||
public class UniqueInternalURIObjectTool extends UniqTool { | ||
@Override | ||
protected Class getMapperClass() { | ||
return UniqueInternalURIObjectMapper.class; | ||
} | ||
|
||
@Override | ||
protected String getJobName() { | ||
return "uniqInternalURIObjects"; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
bakemono/src/main/java/com/ontology2/bakemono/mapmap/UniqueURIPredicateMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.ontology2.bakemono.mapmap; | ||
|
||
import com.google.common.base.Function; | ||
import com.ontology2.bakemono.primitiveTriples.PrimitiveTriple; | ||
import com.ontology2.bakemono.primitiveTriples.ProjectPredicate; | ||
import com.ontology2.bakemono.primitiveTriples.ProjectURIObject; | ||
import org.apache.hadoop.io.Text; | ||
|
||
public class UniqueURIPredicateMapper extends PTUniqueMapMapper<Text> { | ||
|
||
private final Function<PrimitiveTriple,Text> primitiveTriple = new ProjectPredicate(); | ||
|
||
@Override | ||
Function<PrimitiveTriple, Text> getKeyFunction() { | ||
return primitiveTriple; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
bakemono/src/main/java/com/ontology2/bakemono/mapmap/UniqueURIPredicateTool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.ontology2.bakemono.mapmap; | ||
|
||
public class UniqueURIPredicateTool extends UniqTool { | ||
|
||
protected Class getMapperClass() { | ||
return UniqueURIPredicateMapper.class; | ||
} | ||
|
||
@Override | ||
protected String getJobName() { | ||
return "uniqueURIPredicateTool"; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
bakemono/src/main/java/com/ontology2/bakemono/mapmap/UniqueURISubjectMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.ontology2.bakemono.mapmap; | ||
|
||
import com.google.common.base.Function; | ||
import com.ontology2.bakemono.primitiveTriples.PrimitiveTriple; | ||
import com.ontology2.bakemono.primitiveTriples.ProjectPredicate; | ||
import com.ontology2.bakemono.primitiveTriples.ProjectSubject; | ||
import org.apache.hadoop.io.Text; | ||
|
||
/** | ||
* Created with IntelliJ IDEA. | ||
* User: paul_000 | ||
* Date: 11/12/13 | ||
* Time: 5:45 PM | ||
* To change this template use File | Settings | File Templates. | ||
*/ | ||
public class UniqueURISubjectMapper extends PTUniqueMapMapper<Text> { | ||
|
||
private final Function<PrimitiveTriple,Text> primitiveTriple = new ProjectSubject(); | ||
|
||
@Override | ||
Function<PrimitiveTriple, Text> getKeyFunction() { | ||
return primitiveTriple; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
bakemono/src/main/java/com/ontology2/bakemono/mapmap/UniqueURISubjectTool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.ontology2.bakemono.mapmap; | ||
|
||
public class UniqueURISubjectTool extends UniqTool { | ||
@Override | ||
protected Class getMapperClass() { | ||
return UniqueURISubjectMapper.class; | ||
} | ||
|
||
@Override | ||
protected String getJobName() { | ||
return "uniqURISubjectTool"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
bakemono/src/test/java/com/ontology2/bakemono/mapmap/UniqPredicateMapperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.ontology2.bakemono.mapmap; | ||
|
||
import static org.junit.Assert.*; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.verifyNoMoreInteractions; | ||
|
||
import org.apache.hadoop.io.LongWritable; | ||
import org.apache.hadoop.io.Text; | ||
import org.apache.hadoop.mapreduce.Mapper; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
|
||
public class UniqPredicateMapperTest { | ||
UniqueURIPredicateMapper mapper; | ||
@Before | ||
public void setup() { | ||
mapper=new UniqueURIPredicateMapper(); | ||
} | ||
|
||
@Test | ||
public void testExternalURITriple() throws IOException, InterruptedException { | ||
Text t=new Text("<http://a.example.com/>\t<http://b.example.com/>\t<http://c.example.com/> ."); | ||
Mapper.Context c=mock(Mapper.Context.class); | ||
mapper.map(new LongWritable(75),t,c); | ||
verify(c).write(new Text("<http://b.example.com/>"),new LongWritable(1)); | ||
verifyNoMoreInteractions(c); | ||
} | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
bakemono/src/test/java/com/ontology2/bakemono/mapmap/UniqueInternalUriObjectMapperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.ontology2.bakemono.mapmap; | ||
|
||
import static org.junit.Assert.*; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.verifyNoMoreInteractions; | ||
|
||
import org.apache.hadoop.io.LongWritable; | ||
import org.apache.hadoop.io.Text; | ||
import org.apache.hadoop.mapreduce.Mapper; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
|
||
public class UniqueInternalUriObjectMapperTest { | ||
UniqueInternalURIObjectMapper mapper; | ||
|
||
@Before | ||
public void setup() { | ||
mapper=new UniqueInternalURIObjectMapper(); | ||
} | ||
|
||
@Test | ||
public void testExternalURITriple() throws IOException, InterruptedException { | ||
Text t=new Text("<http://a.example.com/>\t<http://b.example.com/>\t<http://c.example.com/> ."); | ||
Mapper.Context c=mock(Mapper.Context.class); | ||
mapper.map(new LongWritable(75),t,c); | ||
verifyNoMoreInteractions(c); | ||
} | ||
|
||
@Test | ||
public void testInternalURITriple() throws IOException, InterruptedException { | ||
Text t=new Text("<http://a.example.com/>\t<http://b.example.com/>\t<http://rdf.basekb.com/ns/f00t> ."); | ||
Mapper.Context c=mock(Mapper.Context.class); | ||
mapper.map(new LongWritable(75),t,c); | ||
verify(c).write(new Text("<http://rdf.basekb.com/ns/f00t>"),new LongWritable(1)); | ||
verifyNoMoreInteractions(c); | ||
} | ||
|
||
@Test | ||
public void testLiteralTriple() throws IOException, InterruptedException { | ||
Text t=new Text("<http://a.example.com/>\t<http://b.example.com/>\t\"even on the darkest night\"@en ."); | ||
Mapper.Context c=mock(Mapper.Context.class); | ||
mapper.map(new LongWritable(75),t,c); | ||
verifyNoMoreInteractions(c); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
bakemono/src/test/java/com/ontology2/bakemono/mapmap/UniqueSubjectMapperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.ontology2.bakemono.mapmap; | ||
|
||
import org.apache.hadoop.io.LongWritable; | ||
import org.apache.hadoop.io.Text; | ||
import org.apache.hadoop.mapreduce.Mapper; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.verifyNoMoreInteractions; | ||
|
||
public class UniqueSubjectMapperTest { | ||
UniqueURISubjectMapper mapper; | ||
@Before | ||
public void setup() { | ||
mapper=new UniqueURISubjectMapper(); | ||
} | ||
|
||
@Test | ||
public void testExternalURITriple() throws IOException, InterruptedException { | ||
Text t=new Text("<http://a.example.com/>\t<http://b.example.com/>\t<http://c.example.com/> ."); | ||
Mapper.Context c=mock(Mapper.Context.class); | ||
mapper.map(new LongWritable(75),t,c); | ||
verify(c).write(new Text("<http://a.example.com/>"),new LongWritable(1)); | ||
verifyNoMoreInteractions(c); | ||
} | ||
} |