nus-yam/ex-repair huggingface dataset:
Program: 9939
Project: 9939
Buggy source:
public void execute(Event<UIWsrpConsumerOverview> event){
  UIApplication uiApp=event.getRequestContext().getUIApplication();
  try {
    UIWsrpConsumerOverview consumerOverview=event.getSource();
    WSRPConsumer consumer=consumerOverview.getConsumerFromEvent(event);
    if (consumer != null) {
      ConsumerRegistry registry=consumerOverview.getConsumerRegistry();
      RefreshResult result=consumer.refresh(true);
      if (result.hasIssues()) {
        RegistrationInfo expected=new RegistrationInfo(consumer.getProducerInfo().getRegistrationInfo());
        expected.refresh(result.getServiceDescription(),consumer.getProducerId(),true,true,true);
        consumerOverview.setExpectedRegistrationInfo(expected);
        registry.deactivateConsumerWith(consumer.getProducerId());
        uiApp.addMessage(new ApplicationMessage("String_Node_Str",null,ApplicationMessage.ERROR));
      }
 else {
        if (consumer.isActive()) {
          registry.activateConsumerWith(consumer.getProducerId());
        }
 else {
          registry.deactivateConsumerWith(consumer.getProducerId());
        }
        uiApp.addMessage(new ApplicationMessage("String_Node_Str",null,ApplicationMessage.INFO));
      }
      consumerOverview.refreshGrid(event);
    }
  }
 catch (  Exception e) {
    uiApp.addMessage(new ApplicationMessage("String_Node_Str" + e.getCause(),null,ApplicationMessage.ERROR));
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public void execute(Event<UIWsrpConsumerOverview> event){
  UIApplication uiApp=event.getRequestContext().getUIApplication();
  try {
    UIWsrpConsumerOverview consumerOverview=event.getSource();
    WSRPConsumer consumer=consumerOverview.getConsumerFromEvent(event);
    if (consumer != null) {
      ConsumerRegistry registry=consumerOverview.getConsumerRegistry();
      RefreshResult result=consumer.refresh(true);
      if (result.hasIssues()) {
        RegistrationInfo expected=new RegistrationInfo(consumer.getProducerInfo().getRegistrationInfo());
        expected.refresh(result.getServiceDescription(),consumer.getProducerId(),true,true,true);
        consumerOverview.setExpectedRegistrationInfo(expected);
        registry.deactivateConsumerWith(consumer.getProducerId());
        uiApp.addMessage(new ApplicationMessage("String_Node_Str",null,ApplicationMessage.ERROR));
      }
 else {
        if (consumer.isActive()) {
          registry.activateConsumerWith(consumer.getProducerId());
        }
 else {
          registry.deactivateConsumerWith(consumer.getProducerId());
        }
        uiApp.addMessage(new ApplicationMessage("String_Node_Str",null,ApplicationMessage.INFO));
      }
      consumerOverview.refreshGrid(event);
    }
  }
 catch (  Exception e) {
    uiApp.addMessage(new ApplicationMessage("String_Node_Str",new String[]{e.getCause().toString()},ApplicationMessage.ERROR));
    e.printStackTrace();
  }
}
Program: 9940
Project: 9940
Buggy source:
public UIWsrpRegistrationDetails(String name,UIWsrpProducerEditor parent) throws Exception {
  super(name);
  policy=new UIFormStringInput(POLICY_CLASS,POLICY_CLASS,null);
  addUIFormInput(policy);
  validator=new UIFormStringInput(VALIDATOR_CLASS,VALIDATOR_CLASS,null);
  addUIFormInput(validator);
  registrationProperties=addChild(UIGrid.class,REGISTRATION_PROPERTIES,REGISTRATION_PROPERTIES);
  ValueRenderer<LocalizedString> renderer=new ValueRenderer<LocalizedString>(){
    @Override public String render(    LocalizedString value){
      return value.getValue();
    }
  }
;
  registrationProperties.registerRendererFor(renderer,LocalizedString.class);
  registrationProperties.configure("String_Node_Str",FIELDS,SELECT_ACTIONS);
  registrationProperties.getUIPageIterator().setId(REGISTRATION_PROPERTIES_ITERATOR);
  registrationProperties.getUIPageIterator().setRendered(false);
  addChild(registrationProperties.getUIPageIterator());
  init(parent.getService().getConfiguration().getRegistrationRequirements());
  UIPopupWindow popup=addChild(UIPopupWindow.class,null,null);
  popup.setWindowSize(400,300);
  UIWsrpProducerPropertyEditor propertyForm=createUIComponent(UIWsrpProducerPropertyEditor.class,null,"String_Node_Str");
  popup.setUIComponent(propertyForm);
  popup.setRendered(false);
}

Fixed version (ground truth):
public UIWsrpRegistrationDetails(String name,UIWsrpProducerEditor parent) throws Exception {
  super(name);
  policy=new UIFormStringInput(POLICY_CLASS,POLICY_CLASS,null);
  addUIFormInput(policy);
  validator=new UIFormStringInput(VALIDATOR_CLASS,VALIDATOR_CLASS,null);
  addUIFormInput(validator);
  registrationProperties=parent.getRegistrationProperties();
  ValueRenderer<LocalizedString> renderer=new ValueRenderer<LocalizedString>(){
    @Override public String render(    LocalizedString value){
      return value.getValue();
    }
  }
;
  registrationProperties.registerRendererFor(renderer,LocalizedString.class);
  registrationProperties.configure("String_Node_Str",FIELDS,SELECT_ACTIONS);
  registrationProperties.getUIPageIterator().setId(REGISTRATION_PROPERTIES_ITERATOR);
  registrationProperties.getUIPageIterator().setRendered(false);
  addChild(registrationProperties.getUIPageIterator());
  init(parent.getService().getConfiguration().getRegistrationRequirements());
  UIPopupWindow popup=addChild(UIPopupWindow.class,null,null);
  popup.setWindowSize(400,300);
  UIWsrpProducerPropertyEditor propertyForm=createUIComponent(UIWsrpProducerPropertyEditor.class,null,"String_Node_Str");
  popup.setUIComponent(propertyForm);
  popup.setRendered(false);
}
Program: 9941
Project: 9941
Buggy source:
@Override public void processRender(WebuiApplication app,WebuiRequestContext context) throws Exception {
  if (hasEditPermissionOnNavigation() || hasEditPermissionOnPage()) {
    super.processRender(app,context);
  }
}

Fixed version (ground truth):
@Override public void processRender(WebuiApplication app,WebuiRequestContext context) throws Exception {
  if (hasEditPermissionOnNavigation() || hasEditPermissionOnPage() || hasEditPermissionOnPortal()) {
    super.processRender(app,context);
  }
}
Program: 9942
Project: 9942
Buggy source:
public UIWsrpProducerEditor() throws Exception {
  configService=Util.getUIPortalApplication().getApplicationComponent(ProducerConfigurationService.class);
  regReqForDesc=new UIFormCheckBoxInput(REG_REQUIRED_FOR_DESCRIPTION,REG_REQUIRED_FOR_DESCRIPTION,null);
  addUIFormInput(regReqForDesc);
  strictMode=new UIFormCheckBoxInput(STRICT_MODE,STRICT_MODE,null);
  addUIFormInput(strictMode);
  regRequired=new UIFormCheckBoxInput<Boolean>(REQUIRES_REGISTRATION,REQUIRES_REGISTRATION,null);
  regRequired.setOnChange("String_Node_Str");
  addUIFormInput(regRequired);
  setActions(new String[]{});
  registrationDetails=new UIWsrpRegistrationDetails(REGISTRATION_DETAILS,this);
  addUIFormInput(registrationDetails);
  init();
}

Fixed version (ground truth):
public UIWsrpProducerEditor() throws Exception {
  configService=Util.getUIPortalApplication().getApplicationComponent(ProducerConfigurationService.class);
  regReqForDesc=new UIFormCheckBoxInput(REG_REQUIRED_FOR_DESCRIPTION,REG_REQUIRED_FOR_DESCRIPTION,null);
  addUIFormInput(regReqForDesc);
  strictMode=new UIFormCheckBoxInput(STRICT_MODE,STRICT_MODE,null);
  addUIFormInput(strictMode);
  regRequired=new UIFormCheckBoxInput<Boolean>(REQUIRES_REGISTRATION,REQUIRES_REGISTRATION,null);
  regRequired.setOnChange("String_Node_Str");
  addUIFormInput(regRequired);
  setActions(new String[]{});
  registrationDetails=addChild(UIWsrpRegistrationDetails.class,null,null);
  init();
}
Program: 9943
Project: 9943
Buggy source:
public UIWsrpRegistrationDetails(String name,UIWsrpProducerEditor parent) throws Exception {
  super(name);
  policy=new UIFormStringInput(POLICY_CLASS,POLICY_CLASS,null);
  addUIFormInput(policy);
  validator=new UIFormStringInput(VALIDATOR_CLASS,VALIDATOR_CLASS,null);
  addUIFormInput(validator);
  addChild(parent.getRegistrationProperties());
  registrationProperties=getChildById(REGISTRATION_PROPERTIES);
  ValueRenderer<LocalizedString> renderer=new ValueRenderer<LocalizedString>(){
    @Override public String render(    LocalizedString value){
      return value.getValue();
    }
  }
;
  registrationProperties.registerRendererFor(renderer,LocalizedString.class);
  registrationProperties.configure("String_Node_Str",FIELDS,SELECT_ACTIONS);
  registrationProperties.getUIPageIterator().setId(REGISTRATION_PROPERTIES_ITERATOR);
  registrationProperties.getUIPageIterator().setRendered(false);
  addChild(registrationProperties.getUIPageIterator());
  init(parent.getService().getConfiguration().getRegistrationRequirements());
  UIPopupWindow popup=addChild(UIPopupWindow.class,null,null);
  popup.setWindowSize(400,300);
  UIWsrpProducerPropertyEditor propertyForm=createUIComponent(UIWsrpProducerPropertyEditor.class,null,"String_Node_Str");
  popup.setUIComponent(propertyForm);
  popup.setRendered(false);
}

Fixed version (ground truth):
public UIWsrpRegistrationDetails() throws Exception {
  policy=new UIFormStringInput(POLICY_CLASS,POLICY_CLASS,null);
  addUIFormInput(policy);
  validator=new UIFormStringInput(VALIDATOR_CLASS,VALIDATOR_CLASS,null);
  addUIFormInput(validator);
  registrationProperties=addChild(UIGrid.class,REGISTRATION_PROPERTIES,REGISTRATION_PROPERTIES);
  ValueRenderer<LocalizedString> renderer=new ValueRenderer<LocalizedString>(){
    @Override public String render(    LocalizedString value){
      return value.getValue();
    }
  }
;
  registrationProperties.registerRendererFor(renderer,LocalizedString.class);
  registrationProperties.configure("String_Node_Str",FIELDS,SELECT_ACTIONS);
  registrationProperties.getUIPageIterator().setId(REGISTRATION_PROPERTIES_ITERATOR);
  registrationProperties.getUIPageIterator().setRendered(false);
  addChild(registrationProperties.getUIPageIterator());
  init(getService().getConfiguration().getRegistrationRequirements());
  UIPopupWindow popup=addChild(UIPopupWindow.class,null,null);
  popup.setWindowSize(400,300);
  UIWsrpProducerPropertyEditor propertyForm=createUIComponent(UIWsrpProducerPropertyEditor.class,null,"String_Node_Str");
  popup.setUIComponent(propertyForm);
  popup.setRendered(false);
}
Program: 9945
Project: 9945
Buggy source:
public void execute(Event<UIWsrpProducerOverview> event) throws Exception {
  UIWsrpProducerOverview wsrpProducerOverview=event.getSource();
  UIPopupWindow popup=wsrpProducerOverview.getChild(UIPopupWindow.class);
  UIWsrpProducerPropertyEditor editor=(UIWsrpProducerPropertyEditor)popup.getUIComponent();
  editor.setRegistrationPropertyDescription(null);
  popup.setRendered(true);
  popup.setShow(true);
  popup.setShowCloseButton(true);
}

Fixed version (ground truth):
public void execute(Event<UIFormCheckBoxInput> event) throws Exception {
  UIFormCheckBoxInput source=event.getSource();
  UIWsrpProducerEditor parent=source.getAncestorOfType(UIWsrpProducerEditor.class);
  parent.init();
  event.getRequestContext().addUIComponentToUpdateByAjax(parent);
}
Program: 9946
Project: 9946
Buggy source:
public UIWsrpProducerEditor() throws Exception {
  addUIFormInput(new UIFormCheckBoxInput(REG_REQUIRED_FOR_DESCRIPTION,REG_REQUIRED_FOR_DESCRIPTION,null));
  addUIFormInput(new UIFormCheckBoxInput(STRICT_MODE,STRICT_MODE,null));
  addUIFormInput(new UIFormCheckBoxInput(REQUIRES_REGISTRATION,REQUIRES_REGISTRATION,null));
  UIPopupWindow popup=addChild(UIPopupWindow.class,null,null);
  popup.setWindowSize(400,300);
  UIWsrpProducerPropertyEditor propertyForm=createUIComponent(UIWsrpProducerPropertyEditor.class,null,"String_Node_Str");
  popup.setUIComponent(propertyForm);
  popup.setRendered(false);
}

Fixed version (ground truth):
public UIWsrpProducerEditor() throws Exception {
  configService=Util.getUIPortalApplication().getApplicationComponent(ProducerConfigurationService.class);
  regReqForDesc=new UIFormCheckBoxInput(REG_REQUIRED_FOR_DESCRIPTION,REG_REQUIRED_FOR_DESCRIPTION,null);
  addUIFormInput(regReqForDesc);
  strictMode=new UIFormCheckBoxInput(STRICT_MODE,STRICT_MODE,null);
  addUIFormInput(strictMode);
  regRequired=new UIFormCheckBoxInput<Boolean>(REQUIRES_REGISTRATION,REQUIRES_REGISTRATION,null);
  regRequired.setOnChange("String_Node_Str");
  addUIFormInput(regRequired);
  setActions(new String[]{});
  registrationDetails=new UIWSRPFormInputSet(REGISTRATION_DETAILS);
  addUIFormInput(registrationDetails);
  policy=new UIFormStringInput(POLICY_CLASS,POLICY_CLASS,null);
  registrationDetails.addUIFormInput(policy);
  validator=new UIFormStringInput(VALIDATOR_CLASS,VALIDATOR_CLASS,null);
  registrationDetails.addUIFormInput(validator);
  registrationProperties=registrationDetails.addChild(UIGrid.class,REGISTRATION_PROPERTIES,null);
  registrationProperties.configure("String_Node_Str",FIELDS,SELECT_ACTIONS);
  registrationProperties.getUIPageIterator().setId(REGISTRATION_PROPERTIES_ITERATOR);
  registrationDetails.addChild(registrationProperties.getUIPageIterator());
  registrationProperties.getUIPageIterator().setRendered(false);
  init();
  UIPopupWindow popup=addChild(UIPopupWindow.class,null,null);
  popup.setWindowSize(400,300);
  UIWsrpProducerPropertyEditor propertyForm=createUIComponent(UIWsrpProducerPropertyEditor.class,null,"String_Node_Str");
  popup.setUIComponent(propertyForm);
  popup.setRendered(false);
}
Program: 9947
Project: 9947
Buggy source:
public UIWsrpProducerOverview() throws Exception {
  producerForm=createUIComponent(UIWsrpProducerEditor.class,null,"String_Node_Str");
  producerForm.setConfigService(getProducerConfigurationService());
  addChild(producerForm);
}

Fixed version (ground truth):
public UIWsrpProducerOverview() throws Exception {
  producerForm=createUIComponent(UIWsrpProducerEditor.class,null,"String_Node_Str");
  addChild(producerForm);
}
Program: 9948
Project: 9948
Buggy source:
private void init() throws Exception {
  ProducerConfiguration configuration=configService.getConfiguration();
  ProducerRegistrationRequirements registrationRequirements=configuration.getRegistrationRequirements();
  regReqForDesc.setValue(registrationRequirements.isRegistrationRequiredForFullDescription());
  strictMode.setValue(configuration.isUsingStrictMode());
  boolean registrationRequired=registrationRequirements.isRegistrationRequired();
  regRequired.setValue(registrationRequired);
  if (registrationRequired) {
    registrationDetails.setRendered(true);
    RegistrationPolicy policy=registrationRequirements.getPolicy();
    String policyClassName=policy.getClass().getName();
    this.policy.setValue(policyClassName);
    if (ProducerRegistrationRequirements.DEFAULT_POLICY_CLASS_NAME.equals(policyClassName)) {
      DefaultRegistrationPolicy defaultPolicy=(DefaultRegistrationPolicy)policy;
      validator.setValue(defaultPolicy.getValidator().getClass().getName());
      validator.setRendered(true);
    }
 else {
      validator.setRendered(false);
    }
    Map<QName,RegistrationPropertyDescription> regProps=configuration.getRegistrationRequirements().getRegistrationProperties();
    registrationProperties.getUIPageIterator().setPageList(createPageList(getPropertyList(regProps)));
  }
 else {
    registrationDetails.setRendered(false);
  }
}

Fixed version (ground truth):
private void init() throws Exception {
  ProducerConfiguration configuration=configService.getConfiguration();
  ProducerRegistrationRequirements registrationRequirements=configuration.getRegistrationRequirements();
  regReqForDesc.setValue(registrationRequirements.isRegistrationRequiredForFullDescription());
  strictMode.setValue(configuration.isUsingStrictMode());
  boolean registrationRequired=registrationRequirements.isRegistrationRequired();
  regRequired.setValue(registrationRequired);
  if (registrationRequired) {
    registrationDetails.setRendered(true);
    RegistrationPolicy policy=registrationRequirements.getPolicy();
    String policyClassName=policy.getClass().getName();
    this.policy.setValue(policyClassName);
    if (ProducerRegistrationRequirements.DEFAULT_POLICY_CLASS_NAME.equals(policyClassName)) {
      DefaultRegistrationPolicy defaultPolicy=(DefaultRegistrationPolicy)policy;
      validator.setValue(defaultPolicy.getValidator().getClass().getName());
      validator.setRendered(true);
    }
 else {
      validator.setRendered(false);
    }
  }
 else {
    registrationDetails.setRendered(false);
  }
}
Program: 9949
Project: 9949
Buggy source:
public UIWsrpProducerEditor() throws Exception {
  configService=Util.getUIPortalApplication().getApplicationComponent(ProducerConfigurationService.class);
  regReqForDesc=new UIFormCheckBoxInput(REG_REQUIRED_FOR_DESCRIPTION,REG_REQUIRED_FOR_DESCRIPTION,null);
  addUIFormInput(regReqForDesc);
  strictMode=new UIFormCheckBoxInput(STRICT_MODE,STRICT_MODE,null);
  addUIFormInput(strictMode);
  regRequired=new UIFormCheckBoxInput<Boolean>(REQUIRES_REGISTRATION,REQUIRES_REGISTRATION,null);
  regRequired.setOnChange("String_Node_Str");
  addUIFormInput(regRequired);
  setActions(new String[]{});
  registrationDetails=new UIWSRPFormInputSet(REGISTRATION_DETAILS);
  addUIFormInput(registrationDetails);
  policy=new UIFormStringInput(POLICY_CLASS,POLICY_CLASS,null);
  registrationDetails.addUIFormInput(policy);
  validator=new UIFormStringInput(VALIDATOR_CLASS,VALIDATOR_CLASS,null);
  registrationDetails.addUIFormInput(validator);
  registrationProperties=registrationDetails.addChild(UIGrid.class,REGISTRATION_PROPERTIES,null);
  registrationProperties.configure("String_Node_Str",FIELDS,SELECT_ACTIONS);
  registrationProperties.getUIPageIterator().setId(REGISTRATION_PROPERTIES_ITERATOR);
  registrationDetails.addChild(registrationProperties.getUIPageIterator());
  registrationProperties.getUIPageIterator().setRendered(false);
  init();
  UIPopupWindow popup=addChild(UIPopupWindow.class,null,null);
  popup.setWindowSize(400,300);
  UIWsrpProducerPropertyEditor propertyForm=createUIComponent(UIWsrpProducerPropertyEditor.class,null,"String_Node_Str");
  popup.setUIComponent(propertyForm);
  popup.setRendered(false);
}

Fixed version (ground truth):
public UIWsrpProducerEditor() throws Exception {
  configService=Util.getUIPortalApplication().getApplicationComponent(ProducerConfigurationService.class);
  regReqForDesc=new UIFormCheckBoxInput(REG_REQUIRED_FOR_DESCRIPTION,REG_REQUIRED_FOR_DESCRIPTION,null);
  addUIFormInput(regReqForDesc);
  strictMode=new UIFormCheckBoxInput(STRICT_MODE,STRICT_MODE,null);
  addUIFormInput(strictMode);
  regRequired=new UIFormCheckBoxInput<Boolean>(REQUIRES_REGISTRATION,REQUIRES_REGISTRATION,null);
  regRequired.setOnChange("String_Node_Str");
  addUIFormInput(regRequired);
  setActions(new String[]{});
  registrationDetails=new UIWSRPFormInputSet(REGISTRATION_DETAILS);
  addUIFormInput(registrationDetails);
  policy=new UIFormStringInput(POLICY_CLASS,POLICY_CLASS,null);
  registrationDetails.addUIFormInput(policy);
  validator=new UIFormStringInput(VALIDATOR_CLASS,VALIDATOR_CLASS,null);
  registrationDetails.addUIFormInput(validator);
  init();
}
Program: 9950
Project: 9950
Buggy source:
private void handle(ServletContext scontext,URL gadgetsURL){
  ChromatticLifeCycle lifeCycle=gadgetRegistryService.getChromatticLifeCycle();
  SessionContext context=lifeCycle.openContext();
  InputStream in;
  try {
    in=gadgetsURL.openStream();
    DocumentBuilder db=DocumentBuilderFactory.newInstance().newDocumentBuilder();
    Document docXML=db.parse(in);
    NodeList nodeList=docXML.getElementsByTagName("String_Node_Str");
    for (int i=0; i < nodeList.getLength(); i++) {
      Element gadgetElement=(Element)nodeList.item(i);
      String gadgetName=gadgetElement.getAttribute("String_Node_Str");
      log.info("String_Node_Str" + gadgetName);
      Element pathElt=XMLTools.getUniqueChild(gadgetElement,"String_Node_Str",false);
      if (pathElt != null) {
        String path=XMLTools.asString(pathElt,true);
        ServletLocalImporter importer=new ServletLocalImporter(gadgetName,gadgetRegistryService.getRegistry(),path,scontext,true);
        importer.doImport();
      }
 else {
        Element urlElt=XMLTools.getUniqueChild(gadgetElement,"String_Node_Str",false);
        if (urlElt != null) {
          String url=XMLTools.asString(urlElt,true);
          ServletLocalImporter importer=new ServletLocalImporter(gadgetName,gadgetRegistryService.getRegistry(),url,scontext,false);
          importer.doImport();
        }
      }
    }
  }
 catch (  Exception e) {
    log.error("String_Node_Str" + gadgetsURL,e);
  }
 finally {
    lifeCycle.closeContext(true);
  }
}

Fixed version (ground truth):
private void handle(ServletContext scontext,URL gadgetsURL){
  ChromatticLifeCycle lifeCycle=gadgetRegistryService.getChromatticLifeCycle();
  SessionContext context=lifeCycle.openContext();
  InputStream in;
  try {
    in=gadgetsURL.openStream();
    DocumentBuilder db=DocumentBuilderFactory.newInstance().newDocumentBuilder();
    Document docXML=db.parse(in);
    NodeList nodeList=docXML.getElementsByTagName("String_Node_Str");
    for (int i=0; i < nodeList.getLength(); i++) {
      Element gadgetElement=(Element)nodeList.item(i);
      String gadgetName=gadgetElement.getAttribute("String_Node_Str");
      log.info("String_Node_Str" + gadgetName);
      Element pathElt=XMLTools.getUniqueChild(gadgetElement,"String_Node_Str",false);
      if (pathElt != null) {
        String path=XMLTools.asString(pathElt,true);
        ServletLocalImporter importer=new ServletLocalImporter(gadgetName,gadgetRegistryService.getRegistry(),path,scontext,true);
        importer.doImport();
      }
 else {
        Element urlElt=XMLTools.getUniqueChild(gadgetElement,"String_Node_Str",false);
        if (urlElt != null) {
          String url=XMLTools.asString(urlElt,true);
          ServletLocalImporter importer=new ServletLocalImporter(gadgetName,gadgetRegistryService.getRegistry(),url,scontext,false);
          importer.doImport();
        }
      }
    }
  }
 catch (  Exception e) {
    log.error("String_Node_Str" + gadgetsURL,e);
  }
 finally {
    lifeCycle.closeContext(context,true);
  }
}
Program: 9951
Project: 9951
Buggy source:
public void saveSource(Gadget gadget,Source source) throws Exception {
  if (gadget == null) {
    throw new NullPointerException();
  }
  if (source == null) {
    throw new NullPointerException();
  }
  GadgetDefinition def=gadgetRegistryService.getRegistry().getGadget(gadget.getName());
  if (def == null) {
    throw new IllegalStateException("String_Node_Str" + gadget.getName());
  }
  GadgetData data=def.getData();
  if (data instanceof LocalGadgetData) {
    LocalGadgetData localData=(LocalGadgetData)data;
    localData.setSource(source.getTextContent());
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
}

Fixed version (ground truth):
public void saveSource(Gadget gadget,Source source) throws Exception {
  if (gadget == null) {
    throw new NullPointerException();
  }
  if (source == null) {
    throw new NullPointerException();
  }
  GadgetRegistry registry=gadgetRegistryService.getRegistry();
  GadgetDefinition def=registry.getGadget(gadget.getName());
  GadgetData data=def.getData();
  if (data instanceof LocalGadgetData) {
    GadgetSpec spec=new GadgetSpec(Uri.parse("String_Node_Str"),source.getTextContent());
    ModulePrefs prefs=spec.getModulePrefs();
    String description=prefs.getDescription();
    String thumbnail=prefs.getThumbnail().toString();
    String title=getGadgetTitle(prefs,gadget.getName());
    String referenceURL=prefs.getTitleUrl().toString();
    def.setDescription(description);
    def.setThumbnail(thumbnail);
    def.setTitle(title);
    def.setReferenceURL(referenceURL);
    LocalGadgetData localData=(LocalGadgetData)data;
    localData.setSource(source.getTextContent());
  }
 else {
    throw new IllegalArgumentException("String_Node_Str");
  }
}
Program: 9952
Project: 9952
Buggy source:
/** 
 * Rebuild UIPortal with updated UserPortalConfig
 * @param uiPortal
 * @param portalConfig
 * @throws Exception
 */
private void rebuildUIPortal(UIPortal uiPortal,UserPortalConfig portalConfig,boolean showMaxWindow) throws Exception {
  PageNode backupSelectedNode=uiPortal.getSelectedNode();
  PageNavigation backupSelectedNavigation=uiPortal.getSelectedNavigation();
  List<PageNode> backupSelectedPaths=uiPortal.getSelectedPaths();
  uiPortal.getChildren().clear();
  PortalDataMapper.toUIPortal(uiPortal,portalConfig);
  uiPortal.setSelectedNode(backupSelectedNode);
  uiPortal.setSelectedNavigation(backupSelectedNavigation);
  uiPortal.setSelectedPaths(backupSelectedPaths);
  UIPageBody uiPageBody=uiPortal.findFirstComponentOfType(UIPageBody.class);
  UIPage uiPage=(UIPage)uiPageBody.getUIComponent();
  uiPage.setShowMaxWindow(showMaxWindow);
  if (showMaxWindow) {
    uiPortal.setMaximizedUIComponent(uiPage);
  }
 else {
    UIComponent uiPortalMaxComponent=uiPortal.getMaximizedUIComponent();
    if (uiPortalMaxComponent instanceof UIPage) {
      uiPortal.setMaximizedUIComponent(null);
    }
    UIComponent pageBodyMaxComponent=uiPageBody.getMaximizedUIComponent();
    if (pageBodyMaxComponent instanceof UIPage) {
      uiPageBody.setMaximizedUIComponent(null);
    }
  }
}

Fixed version (ground truth):
/** 
 * Rebuild UIPortal with updated UserPortalConfig
 * @param uiPortal
 * @param portalConfig
 * @throws Exception
 */
private void rebuildUIPortal(UIPortal uiPortal,UserPortalConfig portalConfig) throws Exception {
  PageNode backupSelectedNode=uiPortal.getSelectedNode();
  PageNavigation backupSelectedNavigation=uiPortal.getSelectedNavigation();
  List<PageNode> backupSelectedPaths=uiPortal.getSelectedPaths();
  uiPortal.getChildren().clear();
  PortalDataMapper.toUIPortal(uiPortal,portalConfig);
  uiPortal.setSelectedNode(backupSelectedNode);
  uiPortal.setSelectedNavigation(backupSelectedNavigation);
  uiPortal.setSelectedPaths(backupSelectedPaths);
}
Program: 9953
Project: 9953
Buggy source:
/** 
 * Update the layout of UIPortal if both ownerType and ownerId of navigation are changed
 * @param uiPortal
 * @param formerNav
 * @param newNav
 * @param uiPortalApp
 * @throws Exception
 */
private void updateLayout(UIPortal uiPortal,PageNavigation formerNav,PageNavigation newNav,UIPortalApplication uiPortalApp) throws Exception {
  if (formerNav == null || newNav == null) {
    return;
  }
  String newOwnerType=newNav.getOwnerType();
  String newOwnerId=newNav.getOwnerId();
  String formerOwnerType=formerNav.getOwnerType();
  String formerOwnerId=formerNav.getOwnerId();
  if (newOwnerId.equals(formerOwnerId) && formerOwnerType.equals(newOwnerType)) {
    return;
  }
  DataStorage storage=uiPortalApp.getApplicationComponent(DataStorage.class);
  PortalConfig pConfig=storage.getPortalConfig(newOwnerType,newOwnerId);
  Container container=pConfig.getPortalLayout();
  if (container != null) {
    boolean showMaxWindow=false;
    try {
      PageNode selectedNode=uiPortal.getSelectedNode();
      Page displayedPage=storage.getPage(selectedNode.getPageReference());
      showMaxWindow=displayedPage.isShowMaxWindow();
    }
 catch (    Exception ex) {
    }
    UserPortalConfig portalConfig=uiPortalApp.getUserPortalConfig();
    portalConfig.setPortal(pConfig);
    rebuildUIPortal(uiPortal,portalConfig,showMaxWindow);
  }
}

Fixed version (ground truth):
/** 
 * Update the layout of UIPortal if both ownerType and ownerId of navigation are changed
 * @param uiPortal
 * @param formerNav
 * @param newNav
 * @param uiPortalApp
 * @throws Exception
 */
private void updateLayout(UIPortal uiPortal,PageNavigation formerNav,PageNavigation newNav,UIPortalApplication uiPortalApp) throws Exception {
  if (formerNav == null || newNav == null) {
    return;
  }
  String newOwnerType=newNav.getOwnerType();
  String newOwnerId=newNav.getOwnerId();
  String formerOwnerType=formerNav.getOwnerType();
  String formerOwnerId=formerNav.getOwnerId();
  if (newOwnerId.equals(formerOwnerId) && formerOwnerType.equals(newOwnerType)) {
    return;
  }
  DataStorage storage=uiPortalApp.getApplicationComponent(DataStorage.class);
  PortalConfig pConfig=storage.getPortalConfig(newOwnerType,newOwnerId);
  Container container=pConfig.getPortalLayout();
  if (container != null) {
    UserPortalConfig portalConfig=uiPortalApp.getUserPortalConfig();
    portalConfig.setPortal(pConfig);
    rebuildUIPortal(uiPortal,portalConfig);
  }
}
Program: 9954
Project: 9954
Buggy source:
public void setPageBody(PageNode pageNode,UIPortal uiPortal) throws Exception {
  WebuiRequestContext context=Util.getPortalRequestContext();
  ExoContainer appContainer=context.getApplication().getApplicationServiceContainer();
  UserPortalConfigService userPortalConfigService=(UserPortalConfigService)appContainer.getComponentInstanceOfType(UserPortalConfigService.class);
  Page page=null;
  UIPage uiPage=null;
  if (pageNode != null) {
    try {
      if (pageNode.getPageReference() != null) {
        page=userPortalConfigService.getPage(pageNode.getPageReference(),context.getRemoteUser());
      }
    }
 catch (    Exception e) {
      UIPortalApplication uiApp=getAncestorOfType(UIPortalApplication.class);
      uiApp.addMessage(new ApplicationMessage(e.getMessage(),new Object[]{}));
    }
  }
  uiPortal.setMaximizedUIComponent(null);
  if (page != null) {
    if (Page.DESKTOP_PAGE.equals(page.getFactoryId())) {
      uiPage=createUIComponent(context,UIDesktopPage.class,null,null);
    }
 else {
      uiPage=createUIComponent(context,UIPage.class,null,null);
    }
    PortalDataMapper.toUIPage(uiPage,page);
    if (uiPage.isShowMaxWindow())     uiPortal.setMaximizedUIComponent(uiPage);
  }
  setUIComponent(uiPage);
}

Fixed version (ground truth):
public void setPageBody(PageNode pageNode,UIPortal uiPortal) throws Exception {
  WebuiRequestContext context=Util.getPortalRequestContext();
  ExoContainer appContainer=context.getApplication().getApplicationServiceContainer();
  UserPortalConfigService userPortalConfigService=(UserPortalConfigService)appContainer.getComponentInstanceOfType(UserPortalConfigService.class);
  Page page=null;
  UIPage uiPage=null;
  if (pageNode != null) {
    try {
      if (pageNode.getPageReference() != null) {
        page=userPortalConfigService.getPage(pageNode.getPageReference(),context.getRemoteUser());
      }
    }
 catch (    Exception e) {
      UIPortalApplication uiApp=getAncestorOfType(UIPortalApplication.class);
      uiApp.addMessage(new ApplicationMessage(e.getMessage(),new Object[]{}));
    }
  }
  uiPortal.setMaximizedUIComponent(null);
  if (page != null) {
    if (Page.DESKTOP_PAGE.equals(page.getFactoryId())) {
      uiPage=createUIComponent(context,UIDesktopPage.class,null,null);
    }
 else {
      uiPage=createUIComponent(context,UIPage.class,null,null);
    }
    PortalDataMapper.toUIPage(uiPage,page);
    if (uiPage.isShowMaxWindow()) {
      uiPortal.setMaximizedUIComponent(uiPage);
    }
 else {
      UIComponent maximizedComponent=uiPortal.getMaximizedUIComponent();
      if (maximizedComponent != null && maximizedComponent instanceof UIPage) {
        uiPortal.setMaximizedUIComponent(null);
      }
      UIComponent maximizedComponentInPageBody=this.getMaximizedUIComponent();
      if (maximizedComponentInPageBody != null && maximizedComponentInPageBody instanceof UIPage) {
        this.setMaximizedUIComponent(null);
      }
    }
  }
  setUIComponent(uiPage);
}
Program: 9955
Project: 9955
Buggy source:
public void setNavigation(List<PageNavigation> navs) throws Exception {
  navigations=navs;
  selectedPaths_=new ArrayList<PageNode>();
  if (navigations == null || navigations.size() < 1)   return;
  PageNavigation pNav=null;
  for (  PageNavigation nav : navs) {
    if (nav.getNodes() != null && nav.getNodes().size() > 0) {
      pNav=nav;
      break;
    }
  }
  if (pNav == null)   return;
  selectedNode_=pNav.getNodes().get(0);
  selectedPaths_.add(selectedNode_);
  UIPageBody uiPageBody=findFirstComponentOfType(UIPageBody.class);
  if (uiPageBody == null)   return;
  uiPageBody.setPageBody(selectedNode_,this);
  UIPortalApplication uiApp=Util.getUIPortalApplication();
  refreshNavigation(uiApp.getLocale());
}

Fixed version (ground truth):
public void setNavigation(List<PageNavigation> navs) throws Exception {
  navigations=navs;
  selectedPaths_=new ArrayList<PageNode>();
  if (navigations == null || navigations.size() < 1)   return;
  PageNavigation pNav=null;
  for (  PageNavigation nav : navs) {
    if (nav.getNodes() != null && nav.getNodes().size() > 0) {
      pNav=nav;
      break;
    }
  }
  if (pNav == null)   return;
  if (selectedNode_ == null) {
    selectedNode_=pNav.getNodes().get(0);
    selectedPaths_.add(selectedNode_);
  }
  UIPageBody uiPageBody=findFirstComponentOfType(UIPageBody.class);
  if (uiPageBody == null)   return;
  uiPageBody.setPageBody(selectedNode_,this);
  UIPortalApplication uiApp=Util.getUIPortalApplication();
  refreshNavigation(uiApp.getLocale());
}
Program: 9956
Project: 9956
Buggy source:
/** 
 * Rebuild UIPortal with updated UserPortalConfig
 * @param uiPortal
 * @param portalConfig
 * @throws Exception
 */
private void rebuildUIPortal(UIPortal uiPortal,UserPortalConfig portalConfig,boolean showMaxWindow) throws Exception {
  PageNode backupSelectedNode=uiPortal.getSelectedNode();
  PageNavigation backupSelectedNavigation=uiPortal.getSelectedNavigation();
  List<PageNode> backupSelectedPaths=uiPortal.getSelectedPaths();
  uiPortal.getChildren().clear();
  PortalDataMapper.toUIPortal(uiPortal,portalConfig);
  uiPortal.setSelectedNode(backupSelectedNode);
  uiPortal.setSelectedNavigation(backupSelectedNavigation);
  uiPortal.setSelectedPaths(backupSelectedPaths);
  UIPageBody uiPageBody=uiPortal.findFirstComponentOfType(UIPageBody.class);
  UIPage uiPage=(UIPage)uiPageBody.getUIComponent();
  uiPage.setShowMaxWindow(showMaxWindow);
  if (showMaxWindow) {
    uiPortal.setMaximizedUIComponent(uiPage);
  }
 else {
    UIComponent showedMaxComponent=uiPortal.getMaximizedUIComponent();
    if (showedMaxComponent instanceof UIPage) {
      uiPortal.setMaximizedUIComponent(null);
    }
  }
}

Fixed version (ground truth):
/** 
 * Rebuild UIPortal with updated UserPortalConfig
 * @param uiPortal
 * @param portalConfig
 * @throws Exception
 */
private void rebuildUIPortal(UIPortal uiPortal,UserPortalConfig portalConfig,boolean showMaxWindow) throws Exception {
  PageNode backupSelectedNode=uiPortal.getSelectedNode();
  PageNavigation backupSelectedNavigation=uiPortal.getSelectedNavigation();
  List<PageNode> backupSelectedPaths=uiPortal.getSelectedPaths();
  uiPortal.getChildren().clear();
  PortalDataMapper.toUIPortal(uiPortal,portalConfig);
  uiPortal.setSelectedNode(backupSelectedNode);
  uiPortal.setSelectedNavigation(backupSelectedNavigation);
  uiPortal.setSelectedPaths(backupSelectedPaths);
  UIPageBody uiPageBody=uiPortal.findFirstComponentOfType(UIPageBody.class);
  UIPage uiPage=(UIPage)uiPageBody.getUIComponent();
  uiPage.setShowMaxWindow(showMaxWindow);
  if (showMaxWindow) {
    uiPortal.setMaximizedUIComponent(uiPage);
  }
 else {
    UIComponent uiPortalMaxComponent=uiPortal.getMaximizedUIComponent();
    if (uiPortalMaxComponent instanceof UIPage) {
      uiPortal.setMaximizedUIComponent(null);
    }
    UIComponent pageBodyMaxComponent=uiPageBody.getMaximizedUIComponent();
    if (pageBodyMaxComponent instanceof UIPage) {
      uiPageBody.setMaximizedUIComponent(null);
    }
  }
}
Program: 9957
Project: 9957
Buggy source:
private String scriptRemovingComponent(String componentId,String componentType){
  StringBuffer buffer=new StringBuffer();
  buffer.append("String_Node_Str");
  buffer.append(componentType);
  buffer.append("String_Node_Str");
  buffer.append(componentId);
  buffer.append("String_Node_Str");
  return buffer.toString();
}

Fixed version (ground truth):
private String scriptRemovingComponent(String componentId,String prefix){
  StringBuffer buffer=new StringBuffer();
  buffer.append("String_Node_Str");
  buffer.append(prefix);
  buffer.append(componentId);
  buffer.append("String_Node_Str");
  return buffer.toString();
}
Program: 9958
Project: 9958
Buggy source:
/** 
 * Returns the top ancestor( of type org.exoplatform.portal.webui.container.UIContainer but not of type UIPortal) of a given container
 */
private static org.exoplatform.portal.webui.container.UIContainer getTopBlockContainer(org.exoplatform.portal.webui.container.UIContainer container){
  if (container instanceof UIPortal) {
    return null;
  }
  org.exoplatform.portal.webui.container.UIContainer topAncestor=container;
  org.exoplatform.portal.webui.container.UIContainer intermediateCont;
  try {
    intermediateCont=topAncestor.getParent();
    while (intermediateCont != null && !(intermediateCont instanceof UIPortal)) {
      topAncestor=intermediateCont;
      intermediateCont=topAncestor.getParent();
    }
  }
 catch (  ClassCastException ex) {
  }
  return topAncestor;
}

Fixed version (ground truth):
/** 
 * Returns the top ancestor( of type org.exoplatform.portal.webui.container.UIContainer but not of type UIPortal or UIPage) of a given container
 */
private static org.exoplatform.portal.webui.container.UIContainer getTopBlockContainer(org.exoplatform.portal.webui.container.UIContainer container){
  if (container instanceof UIPortal || container instanceof UIPage) {
    return null;
  }
  org.exoplatform.portal.webui.container.UIContainer topAncestor=container;
  org.exoplatform.portal.webui.container.UIContainer intermediateCont;
  try {
    intermediateCont=topAncestor.getParent();
    while (intermediateCont != null && !(intermediateCont instanceof UIPortal) && !(intermediateCont instanceof UIPage)) {
      topAncestor=intermediateCont;
      intermediateCont=topAncestor.getParent();
    }
  }
 catch (  ClassCastException ex) {
  }
  return topAncestor;
}
Program: 9959
Project: 9959
Buggy source:
/** 
 * <p>Execute the task with a session. The method attempts first to get a current session and if no such session is found then a session will be created for the scope of the method.</p>
 * @param task the task to execute
 * @throws Exception any exception thrown by the task
 */
private <T extends POMTask>T execute(T task) throws Exception {
  POMSession session=POMSessionManager.getSession();
  if (session == null) {
    session=pomMgr.openSession();
    try {
      executor.execute(session,task);
    }
  finally {
      pomMgr.closeSession(true);
    }
  }
 else {
    session.execute(task);
  }
  return task;
}

Fixed version (ground truth):
/** 
 * <p>Execute the task with a session. The method attempts first to get a current session and if no such session is found then a session will be created for the scope of the method.</p>
 * @param task the task to execute
 * @throws Exception any exception thrown by the task
 */
private <T extends POMTask>T execute(T task) throws Exception {
  POMSession session=POMSessionManager.getSession();
  if (session == null) {
    session=pomMgr.openSession();
    try {
      executor.execute(session,task);
    }
  finally {
      pomMgr.closeSession(true);
    }
  }
 else {
    executor.execute(session,task);
  }
  return task;
}
Program: 9960
Project: 9960
Buggy source:
private <K extends Serializable,V>void read(POMSession session,CacheableDataTask<K,V> task) throws Exception {
  K key=task.getKey();
  Object o=cache.get(key);
  V v=null;
  if (o != null) {
    Class<V> type=task.getValueType();
    if (type.isInstance(o)) {
      v=type.cast(o);
    }
  }
  if (v != null) {
    task.setValue(v);
  }
 else {
    next.execute(session,task);
    v=task.getValue();
    if (v != null) {
      cache.put(key,v);
    }
  }
}

Fixed version (ground truth):
private <K extends Serializable,V>void read(POMSession session,CacheableDataTask<K,V> task) throws Exception {
  K key=task.getKey();
  Object o=cache.get(key);
  V v=null;
  if (o != null) {
    Class<V> type=task.getValueType();
    if (type.isInstance(o)) {
      v=type.cast(o);
    }
  }
  if (v != null) {
    task.setValue(v);
  }
 else {
    readCount.incrementAndGet();
    super.execute(session,task);
    v=task.getValue();
    if (v != null) {
      cache.put(key,v);
    }
  }
}
Program: 9961
Project: 9961
Buggy source:
private <K extends Serializable,V>void create(POMSession session,CacheableDataTask<K,V> task) throws Exception {
  next.execute(session,task);
}

Fixed version (ground truth):
private <K extends Serializable,V>void create(POMSession session,CacheableDataTask<K,V> task) throws Exception {
  super.execute(session,task);
}
Program: 9962
Project: 9962
Buggy source:
public void execute(POMSession session,POMTask task) throws Exception {
  if (task instanceof CacheableDataTask) {
    if (!session.isModified()) {
      CacheableDataTask<?,?> loadTask=(CacheableDataTask<?,?>)task;
switch (loadTask.getAccessMode()) {
case READ:
        read(session,loadTask);
      break;
case CREATE:
    create(session,loadTask);
  break;
case WRITE:
write(session,loadTask);
break;
case DESTROY:
remove(session,loadTask);
break;
default :
throw new UnsupportedOperationException();
}
}
}
 else {
next.execute(session,task);
}
}

Fixed version (ground truth):
public void execute(POMSession session,POMTask task) throws Exception {
  if (task instanceof CacheableDataTask) {
    if (!session.isModified()) {
      CacheableDataTask<?,?> loadTask=(CacheableDataTask<?,?>)task;
switch (loadTask.getAccessMode()) {
case READ:
        read(session,loadTask);
      break;
case CREATE:
    create(session,loadTask);
  break;
case WRITE:
write(session,loadTask);
break;
case DESTROY:
remove(session,loadTask);
break;
default :
throw new UnsupportedOperationException();
}
}
 else {
super.execute(session,task);
}
}
 else {
super.execute(session,task);
}
}
Program: 9963
Project: 9963
Buggy source:
private <K extends Serializable,V>void write(POMSession session,CacheableDataTask<K,V> task) throws Exception {
  K key=task.getKey();
  cache.remove(key);
  next.execute(session,task);
}

Fixed version (ground truth):
private <K extends Serializable,V>void write(POMSession session,CacheableDataTask<K,V> task) throws Exception {
  K key=task.getKey();
  cache.remove(key);
  super.execute(session,task);
}
Program: 9964
Project: 9964
Buggy source:
public DataCache(CacheService cacheService,TaskExecutor next){
  this.next=next;
  this.cache=cacheService.getCacheInstance(DataCache.class.getSimpleName());
}

Fixed version (ground truth):
public DataCache(CacheService cacheService,TaskExecutor next){
  super(next);
  this.cache=cacheService.getCacheInstance(DataCache.class.getSimpleName());
}
Program: 9965
Project: 9965
Buggy source:
private <K extends Serializable,V>void remove(POMSession session,CacheableDataTask<K,V> task) throws Exception {
  K key=task.getKey();
  cache.remove(key);
  next.execute(session,task);
}

Fixed version (ground truth):
private <K extends Serializable,V>void remove(POMSession session,CacheableDataTask<K,V> task) throws Exception {
  K key=task.getKey();
  cache.remove(key);
  super.execute(session,task);
}
Program: 9966
Project: 9966
Buggy source:
@Override public boolean equals(Object obj){
  if (obj instanceof OwnerKey) {
    OwnerKey that=(OwnerKey)obj;
    return type.equals(that.type) && id.equals(that.id);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean equals(Object obj){
  if (obj == this) {
    return true;
  }
  if (getClass().isInstance(obj)) {
    OwnerKey that=(OwnerKey)obj;
    return type.equals(that.type) && id.equals(that.id);
  }
  return false;
}
Program: 9967
Project: 9967
Buggy source:
@Override protected void setUp() throws Exception {
  Listener listener=new Listener(){
    @Override public void onEvent(    Event event) throws Exception {
      events.add(event);
    }
  }
;
  PortalContainer container=PortalContainer.getInstance();
  userPortalConfigSer_=(UserPortalConfigService)container.getComponentInstanceOfType(UserPortalConfigService.class);
  orgService_=(OrganizationService)container.getComponentInstanceOfType(OrganizationService.class);
  idmService=(JBossIDMService)container.getComponentInstanceOfType(JBossIDMService.class);
  mgr=(POMSessionManager)container.getComponentInstanceOfType(POMSessionManager.class);
  authenticator=(Authenticator)container.getComponentInstanceOfType(Authenticator.class);
  listenerService=(ListenerService)container.getComponentInstanceOfType(ListenerService.class);
  events=new LinkedList<Event>();
  storage_=(DataStorage)container.getComponentInstanceOfType(DataStorage.class);
  if (!registered) {
    listenerService.addListener(UserPortalConfigService.CREATE_PAGE_EVENT,listener);
    listenerService.addListener(UserPortalConfigService.REMOVE_PAGE_EVENT,listener);
    listenerService.addListener(UserPortalConfigService.UPDATE_PAGE_EVENT,listener);
    listenerService.addListener(UserPortalConfigService.CREATE_NAVIGATION_EVENT,listener);
    listenerService.addListener(UserPortalConfigService.REMOVE_NAVIGATION_EVENT,listener);
    listenerService.addListener(UserPortalConfigService.UPDATE_NAVIGATION_EVENT,listener);
  }
}

Fixed version (ground truth):
@Override protected void setUp() throws Exception {
  Listener listener=new Listener(){
    @Override public void onEvent(    Event event) throws Exception {
      events.add(event);
    }
  }
;
  PortalContainer container=PortalContainer.getInstance();
  userPortalConfigSer_=(UserPortalConfigService)container.getComponentInstanceOfType(UserPortalConfigService.class);
  orgService_=(OrganizationService)container.getComponentInstanceOfType(OrganizationService.class);
  idmService=(JBossIDMService)container.getComponentInstanceOfType(JBossIDMService.class);
  mgr=(POMSessionManager)container.getComponentInstanceOfType(POMSessionManager.class);
  authenticator=(Authenticator)container.getComponentInstanceOfType(Authenticator.class);
  listenerService=(ListenerService)container.getComponentInstanceOfType(ListenerService.class);
  events=new LinkedList<Event>();
  storage_=(DataStorage)container.getComponentInstanceOfType(DataStorage.class);
  mopStorage=(POMDataStorage)container.getComponentInstanceOfType(POMDataStorage.class);
  if (!registered) {
    listenerService.addListener(UserPortalConfigService.CREATE_PAGE_EVENT,listener);
    listenerService.addListener(UserPortalConfigService.REMOVE_PAGE_EVENT,listener);
    listenerService.addListener(UserPortalConfigService.UPDATE_PAGE_EVENT,listener);
    listenerService.addListener(UserPortalConfigService.CREATE_NAVIGATION_EVENT,listener);
    listenerService.addListener(UserPortalConfigService.REMOVE_NAVIGATION_EVENT,listener);
    listenerService.addListener(UserPortalConfigService.UPDATE_NAVIGATION_EVENT,listener);
  }
}