Example usage for com.liferay.portal.model.impl CountryImpl CountryImpl

List of usage examples for com.liferay.portal.model.impl CountryImpl CountryImpl

Introduction

In this page you can find the example usage for com.liferay.portal.model.impl CountryImpl CountryImpl.

Prototype

CountryImpl

Source Link

Usage

From source file:com.liferay.content.targeting.rule.ip.geocode.IpGeocodeRuleTest.java

License:Open Source License

@Test
public void testMadrid() throws Exception {
    Country country = new CountryImpl();

    country.setA2("ES");

    when(CountryServiceUtil.fetchCountry(Mockito.anyLong())).thenReturn(country);

    Region region = new RegionImpl();

    region.setName("Madrid");

    when(RegionServiceUtil.getRegion(Mockito.anyLong())).thenReturn(region);

    when(_ipInfo.getCountryCode()).thenReturn("ES");

    when(_ipInfo.getRegionName()).thenReturn("Madrid");

    when(_ipGeocoder.getIPInfo(Mockito.anyString())).thenReturn(_ipInfo);

    Assert.assertTrue(_ipGeocodeRule.evaluate(null, _ruleInstance, _anonymousUser));
}

From source file:com.liferay.content.targeting.rule.ip.geocode.IpGeocodeRuleTest.java

License:Open Source License

@Test
public void testSpain() throws Exception {
    Country country = new CountryImpl();

    country.setA2("ES");

    when(CountryServiceUtil.fetchCountry(Mockito.anyLong())).thenReturn(country);

    when(RegionServiceUtil.getRegion(Mockito.anyLong())).thenReturn(null);

    when(_ipInfo.getCountryCode()).thenReturn("ES");

    when(_ipGeocoder.getIPInfo(Mockito.anyString())).thenReturn(_ipInfo);

    Assert.assertTrue(_ipGeocodeRule.evaluate(null, _ruleInstance, _anonymousUser));
}

From source file:com.liferay.content.targeting.rule.ip.geocode.IpGeocodeRuleTest.java

License:Open Source License

@Test
public void testUSA() throws Exception {
    Country country = new CountryImpl();

    country.setA2("US");

    when(CountryServiceUtil.fetchCountry(Mockito.anyLong())).thenReturn(country);

    when(RegionServiceUtil.getRegion(Mockito.anyLong())).thenReturn(null);

    when(_ipInfo.getCountryCode()).thenReturn("US");

    when(_ipGeocoder.getIPInfo(Mockito.anyString())).thenReturn(_ipInfo);

    Assert.assertTrue(_ipGeocodeRule.evaluate(null, _ruleInstance, _anonymousUser));
}

From source file:com.liferay.contenttargeting.rules.ipgeocode.IpGeocodeRuleTest.java

License:Open Source License

@Test
public void testMadrid() throws Exception {
    Country country = new CountryImpl();

    country.setA2("ES");

    when(CountryServiceUtil.fetchCountry(Mockito.anyLong())).thenReturn(country);

    Region region = new RegionImpl();

    region.setName("Madrid");

    when(RegionServiceUtil.getRegion(Mockito.anyLong())).thenReturn(region);

    when(_ipInfo.getCountryCode()).thenReturn("ES");

    when(_ipInfo.getRegion()).thenReturn("Madrid");

    when(_ipGeocoder.getIPInfo(Mockito.anyString())).thenReturn(_ipInfo);

    Assert.assertTrue(_ipGeocodeRule.evaluate(null, _ruleInstance, _anonymousUser));
}