### Question:
DateFilterCriteriaGenerator { public void generate(ContainerRequest request) { List<String> schoolYears = request.getQueryParameters().get(ParameterConstants.SCHOOL_YEARS); if (schoolYears != null && schoolYears.size() > 0) { String schoolYearRange = schoolYears.get(0); SessionDateInfo sessionDateInfo = sessionRangeCalculator.findDateRange(schoolYearRange); EntityFilterInfo entityFilterInfo = entityIdentifier.findEntity(request.getPath()); GranularAccessFilter filter = new DateFilterCriteriaBuilder().forEntity(entityFilterInfo.getEntityName()) .connectedBy(entityFilterInfo.getConnectingEntityList()) .withDateAttributes(entityFilterInfo.getBeginDateAttribute(), entityFilterInfo.getEndDateAttribute()) .withSessionAttribute(entityFilterInfo.getSessionAttribute()) .startingFrom(sessionDateInfo.getStartDate()) .endingTo(sessionDateInfo.getEndDate()) .withSessionIds(sessionDateInfo.getSessionIds()) .build(); granularAccessFilterProvider.storeGranularAccessFilter(filter); } }  void generate(ContainerRequest request);  }### Answer:
@Test public void testGenerate() throws Exception { ContainerRequest request = mock(ContainerRequest.class); MultivaluedMap<String,String> parameters = mock(MultivaluedMap.class); List<String> schoolYears = new ArrayList<String>(); schoolYears.add("begin"); schoolYears.add("end"); SessionDateInfo sessionDateInfo = new SessionDateInfo("01-01-2010","01-31-2012", new HashSet<String>()); EntityFilterInfo entityFilterInfo = new EntityFilterInfo(); entityFilterInfo.setEntityName("testEntity"); entityFilterInfo.setBeginDateAttribute("beginDate"); entityFilterInfo.setEndDateAttribute("endDate"); Mockito.when(request.getQueryParameters()).thenReturn(parameters); Mockito.when(parameters.get(ParameterConstants.SCHOOL_YEARS)).thenReturn(schoolYears); Mockito.when(sessionRangeCalculator.findDateRange(anyString())).thenReturn(sessionDateInfo); Mockito.when(entityIdentifier.findEntity(anyString())).thenReturn(entityFilterInfo); dateFilterCriteriaGenerator.generate(request); }