Skip to content

Commit

Permalink
Merge pull request #17 from aphextinez/software-testing
Browse files Browse the repository at this point in the history
Fix delete() in Entity.java with tx.success(), add portfolio functions
  • Loading branch information
James Miller V committed Sep 20, 2013
2 parents 047e05e + 924fd70 commit 7025406
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/app/Cli.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,17 @@ public Result addToPorfolio( String session_id, String description, String resou

@Command
public Result removeFromPorfolio( String session_id, String cit ) {

try(Transaction tx = GraphDatabase.get().beginTx()) {
Result res = validateSession( session_id );
if( !res.success ){

return res;
}
Citation c = new Citation(new Token(cit));

c.delete();
tx.success();
return null;
}
}

@Command
Expand Down
1 change: 1 addition & 0 deletions src/app/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public void delete() {
r.delete();
}
internalNode.delete();
tx.success();
}
}

Expand Down
26 changes: 26 additions & 0 deletions src/test/integrate/Portfolio.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,30 @@ public void check_addToPortfolio() {
}
}

@Test
public void check_addAndDeletePortfolio() {
try(Transaction tx = app.GraphDatabase.get().beginTx()) {
String uemail = "[email protected]";
String upass = "password";
app.Email email = new app.Email(uemail);
app.User user = new app.User();
user.setPassword(upass);
user.addEmail(email);
app.Citation[] array = new app.Citation[] { new app.Citation("blah", "bloo"), new app.Citation("boppidee", "bbbb"),
new app.Citation("hehe", "haha"), new app.Citation("heehaw", "meemaw")};
for (app.Citation c : array) {
user.addToPortfolio(c);
}
Iterator<app.Citation> iterator = user.viewPortfolio().iterator();
assertTrue(iterator.hasNext());
while (iterator.hasNext() ) {
app.Citation cGet = iterator.next();
user.removeFromPortfolio(cGet);
}
Iterator<app.Citation> iteratorCheck = user.viewPortfolio().iterator();
assertFalse(iteratorCheck.hasNext());
tx.success();
}
}

}

0 comments on commit 7025406

Please sign in to comment.