### Question:
TimePeriodUpdater implements LiveContextUpdater { protected List<URI> findTimePeriods(ResourceStore resourceStore, Calendar when) { int hour = when.get(Calendar.HOUR_OF_DAY); int dayOfWeek = getDayOfWeekFromMonday(when); int dayOfMonth = when.get(Calendar.DAY_OF_MONTH); int weekOfYear = when.get(Calendar.WEEK_OF_YEAR); int month = when.get(Calendar.MONTH) + 1; int year = when.get(Calendar.YEAR); String query = StringUtils.strjoinNL( "PREFIX dpo: <http: "SELECT DISTINCT ?instance WHERE {", " {", " ?instance a dpo:TimePeriod ;", " dpo:minHour ?minHour ;", " dpo:maxHour ?maxHour .", " FILTER(?minHour <= "+hour+") .", " FILTER(?maxHour >= "+hour+") .", " } UNION {", " ?instance a dpo:TimePeriod ;", " dpo:minDayOfWeek ?minDayOfWeek ;", " dpo:maxDayOfWeek ?maxDayOfWeek .", " FILTER(?minDayOfWeek <= "+dayOfWeek+") .", " FILTER(?maxDayOfWeek >= "+dayOfWeek+") .", " } UNION {", " ?instance a dpo:TimePeriod ;", " dpo:minDayOfMonth ?minDayOfMonth ;", " dpo:maxDayOfMonth ?maxDayOfMonth .", " FILTER(?minDayOfMonth <= "+dayOfMonth+") .", " FILTER(?maxDayOfMonth >= "+dayOfMonth+") .", " } UNION {", " ?instance a dpo:TimePeriod ;", " dpo:minWeek ?minWeek ;", " dpo:maxWeek ?maxWeek .", " FILTER(?minWeek <= "+weekOfYear+") .", " FILTER(?maxWeek >= "+weekOfYear+") .", " } UNION {", " ?instance a dpo:TimePeriod ;", " dpo:minMonth ?minMonth ;", " dpo:maxMonth ?maxMonth .", " FILTER(?minMonth <= "+month+") .", " FILTER(?maxMonth >= "+month+") .", " } UNION {", " ?instance a dpo:TimePeriod ;", " dpo:minYear ?minYear ;", " dpo:maxYear ?maxYear .", " FILTER(?minYear <= "+year+") .", " FILTER(?maxYear >= "+year+") .", " }", "}"); ClosableIterator<QueryRow> rows = resourceStore.sparqlSelect(query).iterator(); List<URI> results = new ArrayList<URI>(); while (rows.hasNext()) { results.add(rows.next().getValue("instance").asURI()); } return results; }  void setConnectionProvider(ConnectionProvider connectionProvider); void setTenantManager(TenantManager tenantManager); @Override void update();  }### Answer:
@Test public void testHour() throws Exception { assertTrue(timePeriodUpdater.findTimePeriods(this.resourceStore, MAY18AT1339).contains(AFTERNOON)); }
@Test public void testDayOfWeek() throws Exception { assertTrue(timePeriodUpdater.findTimePeriods(this.resourceStore, MAY18AT1339).contains(FRIDAY)); }
@Test public void testWeekend() throws Exception { assertFalse(timePeriodUpdater.findTimePeriods(this.resourceStore, MAY18AT1339).contains(WEEKEND)); assertTrue(timePeriodUpdater.findTimePeriods(this.resourceStore, MAY20AT0839).contains(WEEKEND)); }
@Test public void testFindTimePeriodsByWeek() throws Exception { assertTrue(timePeriodUpdater.findTimePeriods(this.resourceStore, MAY18AT1339).contains(WEEK20)); }