### Question:
UserRoles { public static boolean checkAccess(UserInfo userInfo, RoleType type, String name, Collection<String> roles) { return checkAccess(userInfo, type, name, true, roles); }  static void initialize(SecurityDAO dao, boolean defaultAccess); static List<UserRole> getRoles(); static boolean checkAccess(UserInfo userInfo, RoleType type, String name, Collection<String> roles); static boolean isProjectAdmin(UserInfo userInfo); static boolean isProjectAdmin(UserInfo userInfo, Set<String> groups); static boolean isAdmin(UserInfo userInfo); static boolean checkAccess(UserInfo userInfo, RoleType type, String name, boolean useDefault,
									  Collection<String> roles); @Override String toString();  }### Answer:
@Test @SuppressWarnings("unchecked") public void checkAccess() { UserInfo userInfoDev = new UserInfo("developer", "token123"); userInfoDev.addRole("dev"); List<String> shapes1 = new ArrayList<>(); shapes1.add("shape_1"); shapes1.add("shape_2"); shapes1.add("shape_3"); ArrayList<String> devGroup = new ArrayList<>(); devGroup.add("dev"); Document doc1 = new Document().append("exploratory_shapes", shapes1).append("groups", devGroup); UserInfo userInfoTest = new UserInfo("tester", "token321"); userInfoTest.addRole("test"); List<String> shapes2 = new ArrayList<>(); shapes2.add("shape_2"); shapes2.add("shape_3"); ArrayList<String> testGroup = new ArrayList<>(); testGroup.add("test"); Document doc2 = new Document().append("exploratory_shapes", shapes2).append("groups", testGroup); MongoCursor cursor = mock(MongoCursor.class); FindIterable mockIterable = mock(FindIterable.class); when(dao.getRoles()).thenReturn(mockIterable); when(mockIterable.iterator()).thenReturn(cursor); when(cursor.hasNext()).thenReturn(true).thenReturn(true).thenReturn(false); when(cursor.next()).thenReturn(doc1).thenReturn(doc2); UserRoles.initialize(dao, true); assertTrue(UserRoles.checkAccess(userInfoDev, RoleType.EXPLORATORY_SHAPES, "shape_1", userInfoDev.getRoles())); assertTrue(UserRoles.checkAccess(userInfoDev, RoleType.EXPLORATORY_SHAPES, "shape_2", userInfoDev.getRoles())); assertTrue(UserRoles.checkAccess(userInfoDev, RoleType.EXPLORATORY_SHAPES, "shape_3", userInfoDev.getRoles())); assertTrue(UserRoles.checkAccess(userInfoDev, RoleType.EXPLORATORY_SHAPES, "someShape", userInfoDev.getRoles())); assertFalse(UserRoles.checkAccess(userInfoTest, RoleType.EXPLORATORY_SHAPES, "shape_1", userInfoTest.getRoles())); assertFalse(UserRoles.checkAccess(userInfoTest, RoleType.EXPLORATORY_SHAPES, "shape_2", userInfoTest.getRoles())); assertFalse(UserRoles.checkAccess(userInfoTest, RoleType.EXPLORATORY_SHAPES, "shape_3", userInfoTest.getRoles())); assertTrue(UserRoles.checkAccess(userInfoTest, RoleType.EXPLORATORY_SHAPES, "someShape", userInfoTest.getRoles())); }