LogoPluginHandler implements PluginHandler { @Override public boolean modifyPlugin(final JSONObject plugin, final ModifierParams params, final String mapSrs) { return setupLogoPluginConfig(plugin); }  @Override boolean modifyPlugin(final JSONObject plugin,
                                final ModifierParams params,
                                final String mapSrs); static final String PLUGIN_NAME; static final String KEY_ID; static final String KEY_CONFIG; static final String KEY_MAP_URL; static final String KEY_TERMS_URL; }
@Test public void testSetupLogoPluginConfigNullValue() { JSONObject plugin = null; boolean success = handler.modifyPlugin(plugin, null, null); assertFalse("Should return false if given null", success); }
@Test public void testSetupLogoPluginConfigWrongPlugin() { JSONObject pluginConfig = JSONHelper.createJSONObject(LogoPluginHandler.KEY_ID, "Wrong plugin"); boolean success = handler.modifyPlugin(pluginConfig, null, null); assertFalse("Should return false if given wrong plugin", success); }
@Test public void testSetupLogoPluginConfigNoProperties() { JSONObject pluginConfig = ResourceHelper.readJSONResource("LogoPluginConfig-empty.json", this); handler.modifyPlugin(pluginConfig, null, null); JSONTestHelper.shouldEqual(pluginConfig, ResourceHelper.readJSONResource("LogoPluginConfig-empty-expected.json", this)); }
@Test public void testSetupLogoPluginConfigSimpleProperties() throws Exception { PropertyUtil.addProperty("oskari.map.url", "/"); PropertyUtil.addProperty("oskari.map.terms.url", "http: JSONObject pluginConfig = ResourceHelper.readJSONResource("LogoPluginConfig-empty.json", this); handler.modifyPlugin(pluginConfig, null, null); JSONTestHelper.shouldEqual(pluginConfig, ResourceHelper.readJSONResource("LogoPluginConfig-expected-config-simple.json", this)); }
@Test public void testSetupLogoPluginConfigLocalizedProperties() throws Exception { PropertyUtil.addProperty("oskari.map.url.en", "/map"); PropertyUtil.addProperty("oskari.map.url.fi", "/kartta"); PropertyUtil.addProperty("oskari.map.terms.url.en", "/terms"); PropertyUtil.addProperty("oskari.map.terms.url.fi", "/ehdot"); JSONObject pluginConfig = ResourceHelper.readJSONResource("LogoPluginConfig-empty.json", this); handler.modifyPlugin(pluginConfig, null, null); JSONTestHelper.shouldEqual(pluginConfig, ResourceHelper.readJSONResource("LogoPluginConfig-expected-config-localized.json", this)); }
@Test public void testSetupLogoPluginExistingMapUrl() throws Exception { PropertyUtil.addProperty("oskari.map.url.en", "/map"); PropertyUtil.addProperty("oskari.map.url.fi", "/kartta"); PropertyUtil.addProperty("oskari.map.terms.url.en", "/terms"); PropertyUtil.addProperty("oskari.map.terms.url.fi", "/ehdot"); JSONObject pluginConfig = ResourceHelper.readJSONResource("LogoPluginConfig-existing-config.json", this); handler.modifyPlugin(pluginConfig, null, null); JSONTestHelper.shouldEqual(pluginConfig, ResourceHelper.readJSONResource("LogoPluginConfig-existing-config-expected.json", this)); }