Created
January 24, 2013 22:17
-
-
Save okram/4628603 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
public void testAddOneAuthor() { | |
TransactionalGraph g = new EgoSystemGraph(); | |
AddAuthoredExtension aa = new AddAuthoredExtension(); | |
JSONObject request = new JSONObject(''' | |
{ | |
uri:'http://mypaper', | |
title:'My Paper', | |
citations:455, | |
keywords:[{uri:'keyword:blah'},{uri:'keyword:bam'}], | |
authors: [ | |
{uri:'http://marko',name:'Marko A. Rodriguez'} | |
] | |
} | |
''') | |
assertFalse(aa.addAuthored(new RexsterResourceContext(null, null, null, request, null, null, null), g).errorResponse); | |
assertEquals(g.V.count(), 4); | |
assertEquals(g.E.count(), 3); | |
assertEquals(g.V(Tokens.URI, "http://mypaper").title.next(), "My Paper"); | |
assertEquals(g.V(Tokens.URI, "http://mypaper").citations.next(), 455); | |
assertEquals(g.V(Tokens.URI, "http://marko").out(Tokens.AUTHORED).count(), 1); | |
assertEquals(g.V(Tokens.URI, "http://marko").out(Tokens.AUTHORED).next(), g.V(Tokens.URI, "http://mypaper").next()); | |
assertEquals(g.V(Tokens.URI, "http://mypaper").in(Tokens.AUTHORED).next(), g.V(Tokens.URI, "http://marko").next()); | |
assertEquals(g.V(Tokens.URI, "http://mypaper").out(Tokens.KEYWORD).count(), 2); | |
assertEquals(g.V(Tokens.URI, "keyword:blah").in(Tokens.KEYWORD).uri.next(), "http://mypaper"); | |
assertEquals(g.V(Tokens.URI, "keyword:bam").in(Tokens.KEYWORD).uri.next(), "http://mypaper"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment