List of usage examples for java.time ZonedDateTime minusMinutes
public ZonedDateTime minusMinutes(long minutes)
From source file:Main.java
public static void main(String[] args) { ZonedDateTime dateTime = ZonedDateTime.now(); ZonedDateTime n = dateTime.minusMinutes(1234); System.out.println(n);/*from ww w.j a v a 2 s . c o m*/ }
From source file:nu.yona.server.analysis.service.AnalysisEngineService_determineRelevantGoalsTest.java
private ActivityPayload makeAppPayload(Set<ActivityCategoryDto> activityCategories, Duration timeAgo) { ZonedDateTime endTime = now().minus(timeAgo); ZonedDateTime startTime = endTime.minusMinutes(2); return ActivityPayload.createInstance(userAnonDto, deviceAnonDto, startTime, endTime, "n/a", activityCategories);//ww w. ja v a 2 s . c o m }
From source file:nu.yona.server.analysis.service.AnalysisEngineServiceTest.java
@Test public void analyze_networkActivityAfterAppActivityWithinConflictInterval_addActivity() { ZonedDateTime now = now(); mockExistingActivity(gamblingGoal, now.minusMinutes(10), now.minusMinutes(5), "Lotto App"); service.analyze(userAnonId, createNetworkActivityForCategories("lotto")); verify(mockActivityUpdater).addActivity(any(), any(), eq(GoalDto.createInstance(gamblingGoal)), any()); verify(mockActivityUpdater, never()).updateTimeExistingActivity(any(), any()); verify(mockActivityUpdater, never()).updateTimeLastActivity(any(), any(), any()); }
From source file:nu.yona.server.analysis.service.AnalysisEngineServiceTest.java
@Test public void analyze_appActivityDifferentAppWithinConflictInterval_addActivity() { ZonedDateTime now = now(); JUnitUtil.skipBefore("Skip shortly after midnight", now, 0, 11); mockExistingActivity(gamblingGoal, now.minusMinutes(10), now.minusMinutes(5), "Poker App"); service.analyze(userAnonId, deviceAnonId, createSingleAppActivity("Lotto App", now.minusMinutes(4), now.minusMinutes(2))); verify(mockActivityUpdater).addActivity(any(), any(), eq(GoalDto.createInstance(gamblingGoal)), any()); verify(mockActivityUpdater, never()).updateTimeExistingActivity(any(), any()); verify(mockActivityUpdater, never()).updateTimeLastActivity(any(), any(), any()); }
From source file:nu.yona.server.analysis.service.AnalysisEngineServiceTest.java
@Test public void analyze_appActivitySameAppOverlappingLastCachedActivityEndTime_updateTimeLastActivity() { ZonedDateTime now = now(); JUnitUtil.skipBefore("Skip shortly after midnight", now, 0, 11); mockExistingActivity(gamblingGoal, now.minusMinutes(10), now.minusMinutes(5), "Lotto App"); service.analyze(userAnonId, deviceAnonId, createSingleAppActivity("Lotto App", now.minusMinutes(5).minusSeconds(30), now.minusMinutes(2))); verify(mockActivityUpdater).updateTimeLastActivity(any(), eq(GoalDto.createInstance(gamblingGoal)), any()); verify(mockActivityUpdater, never()).updateTimeExistingActivity(any(), any()); verify(mockActivityUpdater, never()).addActivity(any(), any(), any(), any()); }
From source file:nu.yona.server.analysis.service.AnalysisEngineServiceTest.java
@Test public void analyze_appActivitySameAppWithinConflictIntervalButNotContinuous_addActivity() { ZonedDateTime now = now(); JUnitUtil.skipBefore("Skip shortly after midnight", now, 0, 11); ZonedDateTime existingActivityEndTime = now.minusMinutes(5); mockExistingActivity(gamblingGoal, now.minusMinutes(10), now.minusMinutes(5), "Lotto App"); service.analyze(userAnonId, deviceAnonId, createSingleAppActivity("Lotto App", existingActivityEndTime.plusSeconds(1), now.minusMinutes(2))); verify(mockActivityUpdater).addActivity(any(), any(), eq(GoalDto.createInstance(gamblingGoal)), any()); }
From source file:nu.yona.server.analysis.service.AnalysisEngineServiceTest.java
@Test public void analyze_appActivitySameAppWithinConflictIntervalContinuous_updateTimeLastActivity() { ZonedDateTime now = now(); JUnitUtil.skipBefore("Skip shortly after midnight", now, 0, 11); ZonedDateTime existingActivityEndTime = now.minusMinutes(5); mockExistingActivity(gamblingGoal, now.minusMinutes(10), existingActivityEndTime, "Lotto App"); service.analyze(userAnonId, deviceAnonId, createSingleAppActivity("Lotto App", existingActivityEndTime, now.minusMinutes(2))); verify(mockActivityUpdater).updateTimeLastActivity(any(), eq(GoalDto.createInstance(gamblingGoal)), any()); verify(mockActivityUpdater, never()).updateTimeExistingActivity(any(), any()); verify(mockActivityUpdater, never()).addActivity(any(), any(), any(), any()); }
From source file:nu.yona.server.analysis.service.AnalysisEngineServiceTest.java
@Test public void analyze_appActivityCompletelyPrecedingLastCachedActivity_addActivity() { ZonedDateTime now = now(); JUnitUtil.skipBefore("Skip shortly after midnight", now, 0, 11); ZonedDateTime existingActivityStartTime = now.minusMinutes(4); ZonedDateTime existingActivityEndTime = existingActivityStartTime.plusMinutes(2); mockExistingActivity(gamblingGoal, existingActivityStartTime, existingActivityEndTime, "Poker App"); ZonedDateTime startTime = now.minusMinutes(10); ZonedDateTime endTime = startTime.plusMinutes(5); service.analyze(userAnonId, deviceAnonId, createSingleAppActivity("Poker App", startTime, endTime)); verify(mockActivityUpdater).addActivity(any(), any(), eq(GoalDto.createInstance(gamblingGoal)), any()); verify(mockActivityUpdater, never()).updateTimeExistingActivity(any(), any()); verify(mockActivityUpdater, never()).updateTimeLastActivity(any(), any(), any()); }
From source file:nu.yona.server.analysis.service.AnalysisEngineServiceTest.java
@Test public void analyze_appActivityOverlappingLastCachedActivityBeginAndEnd_updateTimeLastActivity() { ZonedDateTime now = now(); JUnitUtil.skipBefore("Skip shortly after midnight", now, 0, 20); ZonedDateTime existingActivityStartTime = now.minusMinutes(5); ZonedDateTime existingActivityEndTime = now.minusSeconds(15); mockExistingActivity(gamblingGoal, existingActivityStartTime, existingActivityEndTime, "Poker App"); ZonedDateTime startTime = now.minusMinutes(10); ZonedDateTime endTime = now;/*from w ww.ja v a2s .co m*/ service.analyze(userAnonId, deviceAnonId, createSingleAppActivity("Poker App", startTime, endTime)); verify(mockActivityUpdater).updateTimeLastActivity(any(), eq(GoalDto.createInstance(gamblingGoal)), any()); verify(mockActivityUpdater, never()).updateTimeExistingActivity(any(), any()); verify(mockActivityUpdater, never()).addActivity(any(), any(), any(), any()); }
From source file:nu.yona.server.analysis.service.AnalysisEngineServiceTest.java
@Test public void analyze_appActivityOverlappingLastCachedActivityBeginOnly_updateTimeLastActivity() { ZonedDateTime now = now(); JUnitUtil.skipBefore("Skip shortly after midnight", now, 0, 11); ZonedDateTime existingActivityStartTime = now.minusMinutes(5); ZonedDateTime existingActivityEndTime = now.minusSeconds(15); mockExistingActivity(gamblingGoal, existingActivityStartTime, existingActivityEndTime, "Poker App"); ZonedDateTime startTime = now.minusMinutes(10); ZonedDateTime endTime = existingActivityEndTime.minusMinutes(2); service.analyze(userAnonId, deviceAnonId, createSingleAppActivity("Poker App", startTime, endTime)); verify(mockActivityUpdater).updateTimeLastActivity(any(), eq(GoalDto.createInstance(gamblingGoal)), any()); verify(mockActivityUpdater, never()).updateTimeExistingActivity(any(), any()); verify(mockActivityUpdater, never()).addActivity(any(), any(), any(), any()); }