List of usage examples for com.liferay.portal.kernel.util CalendarFactoryUtil getCalendar
public static Calendar getCalendar(int year, int month, int date, int hour, int minute)
From source file:com.liferay.content.targeting.rule.time.TimeRuleTest.java
License:Open Source License
@Before public void setUp() throws Exception { _timeRule = new TimeRule(); mockStatic(CalendarFactoryUtil.class); mockStatic(JSONFactoryUtil.class); when(JSONFactoryUtil.createJSONObject(Mockito.anyString())).thenAnswer(new Answer<JSONObject>() { @Override// ww w .j a v a 2 s. c o m public JSONObject answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); return new JSONObjectImpl((String) args[0]); } }); when(JSONFactoryUtil.createJSONObject()).thenReturn(new JSONObjectImpl()); when(CalendarFactoryUtil.getCalendar(Mockito.anyInt(), Mockito.anyInt(), Mockito.anyInt(), Mockito.anyInt(), Mockito.anyInt())).thenAnswer(new Answer<Calendar>() { @Override public Calendar answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); return new GregorianCalendar((Integer) args[0], (Integer) args[1], (Integer) args[2], (Integer) args[3], (Integer) args[4]); } }); when(CalendarFactoryUtil.getCalendar()).thenReturn(new GregorianCalendar()); _5minutesAgo = new GregorianCalendar(); _5minutesAgo.set(Calendar.MINUTE, (_5minutesAgo.get(Calendar.MINUTE) - 5)); _in5minutes = new GregorianCalendar(); _in5minutes.set(Calendar.MINUTE, (_in5minutes.get(Calendar.MINUTE) + 5)); }