@Test public void testSetDefaultGeolocSearchPlaceTypeWithWrongValueShouldSettheDefaultPlaceTypeClassToNULL() { GisgraphyConfig gisgraphyConfig = new GisgraphyConfig(); gisgraphyConfig.setDefaultGeolocSearchPlaceType("NO"); assertNull(GisgraphyConfig.defaultGeolocSearchPlaceTypeClass); }
@Test public void testSetDefaultGeolocSearchPlaceTypeWithNullOrEmptyValueShouldSettheDefaultPlaceTypeClassToNULL() { GisgraphyConfig gisgraphyConfig = new GisgraphyConfig(); // set a value before testing gisgraphyConfig.setDefaultGeolocSearchPlaceType("TestEntity"); assertEquals(TestEntity.class, GisgraphyConfig.defaultGeolocSearchPlaceTypeClass); gisgraphyConfig.setDefaultGeolocSearchPlaceType(" "); assertNull(GisgraphyConfig.defaultGeolocSearchPlaceTypeClass); gisgraphyConfig.setDefaultGeolocSearchPlaceType("City"); gisgraphyConfig.setDefaultGeolocSearchPlaceType(null); assertNull(GisgraphyConfig.defaultGeolocSearchPlaceTypeClass); }
@Test public void testEmptyGoogleMapAPIKeyShouldLog() { GisgraphyConfig gisgraphyConfig = new GisgraphyConfig(); Logger saveLogger = GisgraphyConfig.logger; try { Logger logger = EasyMock.createMock(Logger.class); logger.warn((String) EasyMock.anyObject()); EasyMock.replay(logger); GisgraphyConfig.logger = logger; gisgraphyConfig.setGoogleMapAPIKey(" "); EasyMock.verify(logger); } finally { GisgraphyConfig.logger = saveLogger; } }
@Test public void testNullGoogleAnalyticsCodeShouldLog() { GisgraphyConfig gisgraphyConfig = new GisgraphyConfig(); Logger saveLogger = GisgraphyConfig.logger; try { Logger logger = EasyMock.createMock(Logger.class); logger.warn((String) EasyMock.anyObject()); EasyMock.replay(logger); GisgraphyConfig.logger = logger; gisgraphyConfig.setGoogleanalytics_uacctcode(null); EasyMock.verify(logger); Assert.assertEquals(null, GisgraphyConfig.googleanalytics_uacctcode); } finally { GisgraphyConfig.logger = saveLogger; } }
@Test public void testSetGoogleMapAPIKeyShouldLogAndSet() { GisgraphyConfig gisgraphyConfig = new GisgraphyConfig(); Logger saveLogger = GisgraphyConfig.logger; try { Logger logger = EasyMock.createMock(Logger.class); logger.info((String) EasyMock.anyObject()); EasyMock.replay(logger); GisgraphyConfig.logger = logger; String googleMapAPIKey = "key"; gisgraphyConfig.setGoogleMapAPIKey(googleMapAPIKey); Assert.assertEquals(googleMapAPIKey, GisgraphyConfig.googleMapAPIKey); EasyMock.verify(logger); } finally { GisgraphyConfig.logger = saveLogger; } }
@Test public void testSetDefaultGeolocSearchPlaceTypeShouldBeCaseSensitive() { GisgraphyConfig gisgraphyConfig = new GisgraphyConfig(); gisgraphyConfig.setDefaultGeolocSearchPlaceType("city"); assertNull(GisgraphyConfig.defaultGeolocSearchPlaceTypeClass); }
@Test public void testSetDefaultGeolocSearchPlaceTypeShouldReallySetTheClassAcordingToEntityPackage() { GisgraphyConfig gisgraphyConfig = new GisgraphyConfig(); gisgraphyConfig.setDefaultGeolocSearchPlaceType("TestEntity"); assertEquals(TestEntity.class, GisgraphyConfig.defaultGeolocSearchPlaceTypeClass); }