Last active
July 1, 2017 16:33
-
-
Save jonayGodoy/b090fd1d9512b625c23a39e9b89975fe to your computer and use it in GitHub Desktop.
Revisions
-
jonayGodoy renamed this gist
Jul 1, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jonayGodoy created this gist
Jul 1, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ @Test public void user_only_can_delete_own_commentary() throws Exception { User user = new UserStub("user"); Commentary userCommentary = new Commentary("Hola mundo", anyUser); Commentary anyCommentary = new Commentary("Hola mundo", new User("anyUser", new Authentication())); Assert.assertTrue(user.deleteCommentary(userCommentary)); Assert.assertFalse(user.deleteCommentary(anyCommentary)); } @Test public void admin_can_delete_all_commentary() throws Exception { User user = new AdminStub("JonayRules"); Commentary userCommentary = new Commentary("Hola mundo", anyUser); Commentary anyCommentary = new Commentary("Hola mundo", new User("anyUser", new Authentication())); Assert.assertTrue(user.deleteCommentary(userCommentary)); Assert.assertTrue(user.deleteCommentary(anyCommentary)); } } public class UserStub extends User{ private String name; private String authenticationLevel; private Authentication authentication; public UserStub(String name,String authenticationLevel) { super(name); this.authenticationLevel = authenticationLevel; } protected Authentication getAuthentication() { return AnyFramework.generateAuthentication("USER"); } } public class AdminStub extends User{ private String name; private Authentication authentication; public UserStub(String name,String authenticationLevel) { super(name); this.authenticationLevel = authenticationLevel; } protected Authentication getAuthentication() { return AnyFramework.generateAuthentication("ADMIN"); } }