Set implements Service { public Element exec(Element params, ServiceContext context) throws Exception { GeonetContext gc = (GeonetContext) context.getHandlerContext(Geonet.CONTEXT_NAME); saveCswServerConfig(params, gc.getBean(SettingManager.class)); saveCswCapabilitiesInfo(params, context); return new Element(Jeeves.Elem.RESPONSE).setText("ok"); }  void init(Path appPath, ServiceConfig params); Element exec(Element params, ServiceContext context);  }
@Test public void testExec() throws Exception { final ServiceContext context = createServiceContext(); loginAsAdmin(context); assertEquals("true", _settingsRepository.findOne(Settings.SYSTEM_CSW_ENABLE).getValue()); assertEquals("-1", _settingsRepository.findOne(Settings.SYSTEM_CSW_CAPABILITY_RECORD_UUID).getValue()); final Element params = createParams(read("csw.enable", "off"), read("csw.capabilityRecordId", "2")); final Element results = new Set().exec(params, context); assertEquals("ok", results.getText()); assertEquals("false", _settingsRepository.findOne(Settings.SYSTEM_CSW_ENABLE).getValue()); assertEquals("2", _settingsRepository.findOne(Settings.SYSTEM_CSW_CAPABILITY_RECORD_UUID).getValue()); }