@Test public void followStudents() { paths = Arrays.asList("v1", ResourceNames.STUDENT_SCHOOL_ASSOCIATIONS, "ssa123", ResourceNames.STUDENTS); when(studentValidator.isReadAllowed(Matchers.anyListOf(String.class), any(MultivaluedMapImpl.class))).thenReturn(true); assertTrue(underTest.isAllowed(request)); paths = Arrays.asList("v1", ResourceNames.TEACHERS, "teacher123", ResourceNames.TEACHER_SECTION_ASSOCIATIONS); when(studentValidator.isReadAllowed(Matchers.anyListOf(String.class), any(MultivaluedMapImpl.class))).thenReturn(false); assertFalse(underTest.isAllowed(request)); }
@Override protected boolean isReadAllowed(List<String> path, MultivaluedMap<String, String> queryParameters) { List<String> subPath = null; if (path.size() == 3) { subPath = Arrays.asList(path.get(2)); } else if (path.size() == 4) { subPath = Arrays.asList(path.get(2), path.get(3)); } if (subPath != null && path.get(0).equals(ResourceNames.PARENTS) && ALLOWED_DELTA_FOR_PARENT.contains(subPath)) { return true; } return studentAccessValidator.isReadAllowed(path, queryParameters); }
ParentAccessValidator extends AccessValidator { @Override protected boolean isReadAllowed(List<String> path, MultivaluedMap<String, String> queryParameters) { List<String> subPath = null; if (path.size() == 3) { subPath = Arrays.asList(path.get(2)); } else if (path.size() == 4) { subPath = Arrays.asList(path.get(2), path.get(3)); } if (subPath != null && path.get(0).equals(ResourceNames.PARENTS) && ALLOWED_DELTA_FOR_PARENT.contains(subPath)) { return true; } return studentAccessValidator.isReadAllowed(path, queryParameters); } }
ParentAccessValidator extends AccessValidator { @Override protected boolean isReadAllowed(List<String> path, MultivaluedMap<String, String> queryParameters) { List<String> subPath = null; if (path.size() == 3) { subPath = Arrays.asList(path.get(2)); } else if (path.size() == 4) { subPath = Arrays.asList(path.get(2), path.get(3)); } if (subPath != null && path.get(0).equals(ResourceNames.PARENTS) && ALLOWED_DELTA_FOR_PARENT.contains(subPath)) { return true; } return studentAccessValidator.isReadAllowed(path, queryParameters); }  }
ParentAccessValidator extends AccessValidator { @Override protected boolean isReadAllowed(List<String> path, MultivaluedMap<String, String> queryParameters) { List<String> subPath = null; if (path.size() == 3) { subPath = Arrays.asList(path.get(2)); } else if (path.size() == 4) { subPath = Arrays.asList(path.get(2), path.get(3)); } if (subPath != null && path.get(0).equals(ResourceNames.PARENTS) && ALLOWED_DELTA_FOR_PARENT.contains(subPath)) { return true; } return studentAccessValidator.isReadAllowed(path, queryParameters); }   }
ParentAccessValidator extends AccessValidator { @Override protected boolean isReadAllowed(List<String> path, MultivaluedMap<String, String> queryParameters) { List<String> subPath = null; if (path.size() == 3) { subPath = Arrays.asList(path.get(2)); } else if (path.size() == 4) { subPath = Arrays.asList(path.get(2), path.get(3)); } if (subPath != null && path.get(0).equals(ResourceNames.PARENTS) && ALLOWED_DELTA_FOR_PARENT.contains(subPath)) { return true; } return studentAccessValidator.isReadAllowed(path, queryParameters); }    }