Skip to content

Instantly share code, notes, and snippets.

@usbportnoy
Last active September 29, 2016 03:36
Show Gist options
  • Select an option

  • Save usbportnoy/3f88f66e485d289035f18440f3c89556 to your computer and use it in GitHub Desktop.

Select an option

Save usbportnoy/3f88f66e485d289035f18440f3c89556 to your computer and use it in GitHub Desktop.
public class ProfileOnlineStatusTest {
@Test
public void this_week() throws Exception {
Profile profile = new Profile();
//sets instance to right now
Calendar calendar = Calendar.getInstance();
// 6 days is less than a week
calendar.set(Calendar.DAY_OF_YEAR, calendar.get(Calendar.DAY_OF_YEAR) - 6);
//get time of right now and set users online status with it
profile.setLastOnline(calendar.getTime());
//create and configure
OnlineStatus onlineStatus = new OnlineStatus();
onlineStatus.setOnlineThresholdHrs(1);
onlineStatus.setRecentOnlineThresholdDays(7);
OnlineStatus.States status = onlineStatus.getStatus(
profile.getLastOnline(),
Calendar.getInstance()
);
assertEquals(OnlineStatus.States.Recent, status);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment