List of usage examples for com.liferay.portal.json JSONObjectImpl JSONObjectImpl
public JSONObjectImpl(String json) throws JSONException
From source file:com.liferay.content.targeting.rule.age.AgeRuleTest.java
License:Open Source License
@Before public void setUp() throws Exception { _ageRule = new AgeRule(); mockStatic(JSONFactoryUtil.class); when(JSONFactoryUtil.createJSONObject(Mockito.anyString())).thenAnswer(new Answer<JSONObject>() { @Override/* ww w . j av a2 s. com*/ public JSONObject answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); return new JSONObjectImpl((String) args[0]); } }); when(JSONFactoryUtil.createJSONObject()).thenReturn(new JSONObjectImpl()); Calendar today = new GregorianCalendar(); Calendar calendar25YearsOld = new GregorianCalendar((today.get(Calendar.YEAR) - 25), 1, 1); when(_user.getBirthday()).thenReturn(calendar25YearsOld.getTime()); }
From source file:com.liferay.content.targeting.rule.facebook.FacebookAgeRuleTest.java
License:Open Source License
@Before public void setUp() throws Exception { _facebookAgeRule = new FacebookAgeRule(); mockStatic(FacebookUtil.class); mockStatic(JSONFactoryUtil.class); when(JSONFactoryUtil.createJSONObject(Mockito.anyString())).thenAnswer(new Answer<JSONObject>() { @Override// w w w .j a va 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(FacebookUtil.getFacebookUser(Mockito.anyString())) .thenReturn(FacebookUtilTest.getFacebookUser(getClass())); }
From source file:com.liferay.content.targeting.rule.facebook.FacebookCityRuleTest.java
License:Open Source License
@Before public void setUp() throws Exception { _facebookCityRule = new FacebookCityRule(); mockStatic(FacebookUtil.class); mockStatic(JSONFactoryUtil.class); when(JSONFactoryUtil.createJSONObject(Mockito.anyString())).thenAnswer(new Answer<JSONObject>() { @Override/* w ww . ja v a 2s.com*/ public JSONObject answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); return new JSONObjectImpl((String) args[0]); } }); when(JSONFactoryUtil.createJSONObject()).thenReturn(new JSONObjectImpl()); when(FacebookUtil.getFacebookUser(Mockito.anyString())) .thenReturn(FacebookUtilTest.getFacebookUser(getClass())); }
From source file:com.liferay.content.targeting.rule.facebook.FacebookEducationRuleTest.java
License:Open Source License
@Before public void setUp() throws Exception { _facebookEducationRule = new FacebookEducationRule(); mockStatic(FacebookUtil.class); mockStatic(JSONFactoryUtil.class); when(JSONFactoryUtil.createJSONObject(Mockito.anyString())).thenAnswer(new Answer<JSONObject>() { @Override//w w w.ja va 2s . co 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(FacebookUtil.getFacebookUser(Mockito.anyString())) .thenReturn(FacebookUtilTest.getFacebookUser(getClass())); }
From source file:com.liferay.content.targeting.rule.facebook.FacebookFriendsRuleTest.java
License:Open Source License
@Before public void setUp() throws Exception { _facebookFriendsRule = new FacebookFriendsRule(); mockStatic(FacebookUtil.class); mockStatic(JSONFactoryUtil.class); when(JSONFactoryUtil.createJSONObject(Mockito.anyString())).thenAnswer(new Answer<JSONObject>() { @Override//w ww .j av a2s . c o m public JSONObject answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); return new JSONObjectImpl((String) args[0]); } }); }
From source file:com.liferay.content.targeting.rule.facebook.FacebookGenderRuleTest.java
License:Open Source License
@Before public void setUp() throws Exception { _genderRule = new FacebookGenderRule(); mockStatic(FacebookUtil.class); mockStatic(JSONFactoryUtil.class); when(JSONFactoryUtil.createJSONObject(Mockito.anyString())).thenAnswer(new Answer<JSONObject>() { @Override//from w w w . ja va 2 s .c om public JSONObject answer(InvocationOnMock invocation) throws Throwable { Object[] args = invocation.getArguments(); return new JSONObjectImpl((String) args[0]); } }); when(FacebookUtil.getFacebookUser(Mockito.anyString())) .thenReturn(FacebookUtilTest.getFacebookUser(getClass())); }
From source file:com.liferay.content.targeting.rule.ip.geocode.IpGeocodeRuleTest.java
License:Open Source License
@Before public void setUp() throws Exception { _ipGeocodeRule = new IpGeocodeRule(); _ipGeocodeRule.setIPGeocoder(_ipGeocoder); mockStatic(CountryServiceUtil.class); mockStatic(JSONFactoryUtil.class); mockStatic(RegionServiceUtil.class); when(JSONFactoryUtil.createJSONObject(Mockito.anyString())).thenAnswer(new Answer<JSONObject>() { @Override// ww w. jav 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()); }
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//w w w . jav a2 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)); }