Last active
July 1, 2017 16:33
-
-
Save jonayGodoy/b090fd1d9512b625c23a39e9b89975fe to your computer and use it in GitHub Desktop.
static not static 2
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
| @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"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment