nus-yam/ex-repair huggingface dataset:
Program: 62150
Project: 62150
Buggy source:
@Override public void process(Topology topology,FlowExecutionContext context){
  Optional<DeploymentMatchingConfiguration> configurationOptional=context.getConfiguration(DeploymentMatchingConfiguration.class,this.getClass().getSimpleName());
  if (!configurationOptional.isPresent()) {
    context.log().error(new LocationPolicyTask());
    return;
  }
  DeploymentMatchingConfiguration matchingConfiguration=configurationOptional.get();
  Map<String,String> lastUserSubstitutions=getUserMatches(matchingConfiguration);
  Map<String,V> matchesById=getMatchesById(context);
  Map<String,T> topologyTemplateMap=getTopologyTemplates(topology);
  Map<String,T> originalTemplates=Maps.newHashMap();
  for (  Map.Entry<String,String> substitutedNodeEntry : lastUserSubstitutions.entrySet()) {
    String templateId=substitutedNodeEntry.getKey();
    String matchedLocationResourceId=substitutedNodeEntry.getValue();
    originalTemplates.put(templateId,topologyTemplateMap.get(templateId));
    processReplacement(topology,topologyTemplateMap,matchesById,templateId,matchedLocationResourceId);
  }
  context.getExecutionCache().put(getOriginalTemplateCacheKey(),originalTemplates);
}

Fixed version (ground truth):
@Override public void process(Topology topology,FlowExecutionContext context){
  Optional<DeploymentMatchingConfiguration> configurationOptional=context.getConfiguration(DeploymentMatchingConfiguration.class,this.getClass().getSimpleName());
  if (!configurationOptional.isPresent()) {
    context.log().error(new LocationPolicyTask());
    return;
  }
  DeploymentMatchingConfiguration matchingConfiguration=configurationOptional.get();
  Map<String,String> lastUserSubstitutions=getUserMatches(matchingConfiguration);
  Map<String,V> matchesById=getMatchesById(context);
  Map<String,T> topologyTemplateMap=getTopologyTemplates(topology);
  Map<String,T> originalTemplates=Maps.newHashMap();
  Map<String,T> replacedTemplates=Maps.newHashMap();
  for (  Map.Entry<String,String> substitutedNodeEntry : lastUserSubstitutions.entrySet()) {
    String templateId=substitutedNodeEntry.getKey();
    String matchedLocationResourceId=substitutedNodeEntry.getValue();
    originalTemplates.put(templateId,topologyTemplateMap.get(templateId));
    processReplacement(topology,topologyTemplateMap,matchesById,templateId,matchedLocationResourceId);
    replacedTemplates.put(templateId,topologyTemplateMap.get(templateId));
  }
  context.getExecutionCache().put(getOriginalTemplateCacheKey(),originalTemplates);
  context.getExecutionCache().put(getReplacedTemplateCacheKey(),replacedTemplates);
}
Program: 62152
Project: 62152
Buggy source:
@Override protected boolean typeSpecificMatching(NodeTemplate abstractTemplate,LocationResourceTemplate candidate,NodeType candidateType,LocationResources locationResources,MatchingConfiguration matchingConfiguration){
  for (  Entry<String,Capability> candidateCapability : safe(candidate.getTemplate().getCapabilities()).entrySet()) {
    MatchingFilterDefinition configuredFilterDefinition=matchingConfiguration == null ? null : matchingConfiguration.getCapabilities().get(candidateCapability.getKey());
    Map<String,List<IMatchPropertyConstraint>> configuredFilters=configuredFilterDefinition == null ? null : configuredFilterDefinition.getProperties();
    CapabilityType capabilityType=locationResources.getCapabilityTypes().get(candidateCapability.getValue().getType());
    Capability templateCapability=safe(abstractTemplate.getCapabilities()).get(candidateCapability.getKey());
    if (templateCapability != null && !isValidTemplatePropertiesMatch(templateCapability.getProperties(),candidateCapability.getValue().getProperties(),capabilityType.getProperties(),configuredFilters)) {
      return false;
    }
  }
  return true;
}

Fixed version (ground truth):
@Override protected boolean typeSpecificMatching(NodeTemplate abstractTemplate,LocationResourceTemplate candidate,NodeType candidateType,LocationResources locationResources,MatchingConfiguration matchingConfiguration){
  for (  Entry<String,Capability> candidateCapability : safe(candidate.getTemplate().getCapabilities()).entrySet()) {
    MatchingFilterDefinition configuredFilterDefinition=matchingConfiguration == null ? null : safe(matchingConfiguration.getCapabilities()).get(candidateCapability.getKey());
    Map<String,List<IMatchPropertyConstraint>> configuredFilters=configuredFilterDefinition == null ? null : configuredFilterDefinition.getProperties();
    CapabilityType capabilityType=locationResources.getCapabilityTypes().get(candidateCapability.getValue().getType());
    Capability templateCapability=safe(abstractTemplate.getCapabilities()).get(candidateCapability.getKey());
    if (templateCapability != null && !isValidTemplatePropertiesMatch(templateCapability.getProperties(),candidateCapability.getValue().getProperties(),capabilityType.getProperties(),configuredFilters)) {
      return false;
    }
  }
  return true;
}
Program: 62153
Project: 62153
Buggy source:
/** 
 * Execute the deployment flow with a modification of changing the substitution for one of the nodes.
 * @param application The application for which to execute the deployment flow.
 * @param environment The environment for which to execute the deployment flow.
 * @param topology The topology linked to the specified environment.
 * @param nodeId The id of the node for which to configure property.
 * @param propertyName The id of the property to set value.
 * @param propertyValue the value of the property.
 * @return The flow execution context.
 */
public FlowExecutionContext updateProperty(Application application,ApplicationEnvironment environment,Topology topology,String nodeId,String propertyName,Object propertyValue){
  FlowExecutionContext executionContext=new FlowExecutionContext(alienDAO,topology,new EnvironmentContext(application,environment));
  List<ITopologyModifier> modifierList=getModifierListWithSelectionAction(nodeId,propertyName,propertyValue);
  flowExecutor.execute(topology,modifierList,executionContext);
  return executionContext;
}

Fixed version (ground truth):
/** 
 * Execute the deployment flow with a modification of changing the substitution for one of the nodes.
 * @param application The application for which to execute the deployment flow.
 * @param environment The environment for which to execute the deployment flow.
 * @param topology The topology linked to the specified environment.
 * @param nodeId The id of the node for which to configure property.
 * @param propertyName The id of the property to set value.
 * @param propertyValue the value of the property.
 * @return The flow execution context.
 */
public FlowExecutionContext updateProperty(Application application,ApplicationEnvironment environment,Topology topology,String nodeId,String propertyName,Object propertyValue){
  FlowExecutionContext executionContext=new FlowExecutionContext(deploymentConfigurationDao,topology,new EnvironmentContext(application,environment));
  List<ITopologyModifier> modifierList=getModifierListWithSelectionAction(nodeId,propertyName,propertyValue);
  flowExecutor.execute(topology,modifierList,executionContext);
  return executionContext;
}
Program: 62154
Project: 62154
Buggy source:
/** 
 * Execute the deployment flow with a modification of changing the substitution for one of the nodes.
 * @param application The application for which to execute the deployment flow.
 * @param environment The environment for which to execute the deployment flow.
 * @param topology The topology linked to the specified environment.
 * @param nodeId The id of the node to substitute at matching phase.
 * @param resourceTemplateId The id of the location resource to substitute.
 * @return The flow execution context.
 */
public FlowExecutionContext updateSubstitution(Application application,ApplicationEnvironment environment,Topology topology,String nodeId,String resourceTemplateId){
  FlowExecutionContext executionContext=new FlowExecutionContext(alienDAO,topology,new EnvironmentContext(application,environment));
  SetMatchedPolicyModifier setMatchedPolicyModifier=new SetMatchedPolicyModifier(nodeId,resourceTemplateId);
  List<ITopologyModifier> modifierList=getModifierListWithSelectionAction(setMatchedPolicyModifier);
  flowExecutor.execute(topology,modifierList,executionContext);
  if (!setMatchedPolicyModifier.isExecuted()) {
    throw new NotFoundException("String_Node_Str" + resourceTemplateId + "String_Node_Str"+ nodeId+ "String_Node_Str");
  }
  return executionContext;
}

Fixed version (ground truth):
/** 
 * Execute the deployment flow with a modification of changing the substitution for one of the nodes.
 * @param application The application for which to execute the deployment flow.
 * @param environment The environment for which to execute the deployment flow.
 * @param topology The topology linked to the specified environment.
 * @param nodeId The id of the node to substitute at matching phase.
 * @param resourceTemplateId The id of the location resource to substitute.
 * @return The flow execution context.
 */
public FlowExecutionContext updateSubstitution(Application application,ApplicationEnvironment environment,Topology topology,String nodeId,String resourceTemplateId){
  FlowExecutionContext executionContext=new FlowExecutionContext(deploymentConfigurationDao,topology,new EnvironmentContext(application,environment));
  SetMatchedPolicyModifier setMatchedPolicyModifier=new SetMatchedPolicyModifier(nodeId,resourceTemplateId);
  List<ITopologyModifier> modifierList=getModifierListWithSelectionAction(setMatchedPolicyModifier);
  flowExecutor.execute(topology,modifierList,executionContext);
  if (!setMatchedPolicyModifier.isExecuted()) {
    throw new NotFoundException("String_Node_Str" + resourceTemplateId + "String_Node_Str"+ nodeId+ "String_Node_Str");
  }
  return executionContext;
}
Program: 62156
Project: 62156
Buggy source:
public void processTopologyComposition(Topology topology){
  Deque<CompositionCouple> stack=new ArrayDeque<CompositionCouple>();
  recursivelyBuildSubstitutionStack(topology,stack,"String_Node_Str");
  if (!stack.isEmpty()) {
    Iterator<CompositionCouple> compositionIterator=stack.descendingIterator();
    while (compositionIterator.hasNext()) {
      processComposition(compositionIterator.next());
    }
    if (log.isDebugEnabled()) {
      log.debug(String.format("String_Node_Str",topology.getId(),stack.size()));
    }
    TopologyContext topologyContext=workflowBuilderService.buildTopologyContext(topology);
    workflowBuilderService.reinitWorkflow(INSTALL,topologyContext);
    workflowBuilderService.reinitWorkflow(UNINSTALL,topologyContext);
  }
}

Fixed version (ground truth):
public void processTopologyComposition(Topology topology){
  Deque<CompositionCouple> stack=new ArrayDeque<CompositionCouple>();
  recursivelyBuildSubstitutionStack(topology,stack,"String_Node_Str");
  if (!stack.isEmpty()) {
    Iterator<CompositionCouple> compositionIterator=stack.descendingIterator();
    while (compositionIterator.hasNext()) {
      processComposition(compositionIterator.next());
    }
    if (log.isDebugEnabled()) {
      log.debug(String.format("String_Node_Str",topology.getId(),stack.size()));
    }
    TopologyContext topologyContext=workflowBuilderService.buildTopologyContext(topology);
    workflowBuilderService.reinitWorkflow(INSTALL,topologyContext);
    workflowBuilderService.reinitWorkflow(START,topologyContext);
    workflowBuilderService.reinitWorkflow(STOP,topologyContext);
    workflowBuilderService.reinitWorkflow(UNINSTALL,topologyContext);
  }
}
Program: 62160
Project: 62160
Buggy source:
@When("String_Node_Str") public void updateState(String message,Float percent) throws Throwable {
  MaintenanceUpdateDTO updateDTO=new MaintenanceUpdateDTO(message,percent);
  Context.getInstance().registerRestResponse(getRestClientInstance().putJSon("String_Node_Str",Context.getJsonMapper().writeValueAsString(updateDTO)));
}

Fixed version (ground truth):
@When("String_Node_Str") public void updateState(String message,Integer percent) throws Throwable {
  MaintenanceUpdateDTO updateDTO=new MaintenanceUpdateDTO(message,percent);
  Context.getInstance().registerRestResponse(getRestClientInstance().putJSon("String_Node_Str",Context.getJsonMapper().writeValueAsString(updateDTO)));
}
Program: 62161
Project: 62161
Buggy source:
private void setNodeProperty(FlowExecutionContext context,LocationResourceTemplate locationResourceTemplate,NodeTemplate nodeTemplate,DeploymentMatchingConfiguration matchingConfiguration) throws ConstraintViolationException, ConstraintValueDoNotMatchPropertyTypeException {
  PropertyDefinition propertyDefinition=ToscaContext.getOrFail(NodeType.class,locationResourceTemplate.getTemplate().getType()).getProperties().get(propertyName);
  if (propertyDefinition == null) {
    throw new NotFoundException("String_Node_Str" + propertyName + "String_Node_Str"+ nodeTemplateId+ "String_Node_Str"+ locationResourceTemplate.getTemplate().getType()+ "String_Node_Str");
  }
  AbstractPropertyValue locationResourcePropertyValue=locationResourceTemplate.getTemplate().getProperties().get(propertyName);
  ensureNotSet(locationResourcePropertyValue,"String_Node_Str",propertyName,propertyValue);
  ensureNotSet(nodeTemplate.getProperties().get(propertyName),"String_Node_Str",propertyName,propertyValue);
  NodePropsOverride nodePropsOverride=getNodePropsOverride(matchingConfiguration);
  ConstraintPropertyService.checkPropertyConstraint(propertyName,propertyValue,propertyDefinition);
  if (propertyValue == null) {
    nodePropsOverride.getProperties().remove(propertyName);
  }
 else {
    nodePropsOverride.getProperties().put(propertyName,PropertyService.asPropertyValue(propertyValue));
  }
  context.saveConfiguration(matchingConfiguration);
}

Fixed version (ground truth):
private void setNodeProperty(FlowExecutionContext context,LocationResourceTemplate locationResourceTemplate,NodeTemplate nodeTemplate,DeploymentMatchingConfiguration matchingConfiguration) throws ConstraintViolationException, ConstraintValueDoNotMatchPropertyTypeException {
  PropertyDefinition propertyDefinition=ToscaContext.getOrFail(NodeType.class,locationResourceTemplate.getTemplate().getType()).getProperties().get(propertyName);
  if (propertyDefinition == null) {
    throw new NotFoundException("String_Node_Str" + propertyName + "String_Node_Str"+ nodeTemplateId+ "String_Node_Str"+ locationResourceTemplate.getTemplate().getType()+ "String_Node_Str");
  }
  AbstractPropertyValue locationResourcePropertyValue=locationResourceTemplate.getTemplate().getProperties().get(propertyName);
  ensureNotSet(locationResourcePropertyValue,"String_Node_Str",propertyName,propertyValue);
  ensureNotSet(nodeTemplate.getProperties().get(propertyName),"String_Node_Str",propertyName,propertyValue);
  NodePropsOverride nodePropsOverride=getNodePropsOverride(matchingConfiguration);
  if (propertyValue == null) {
    nodePropsOverride.getProperties().remove(propertyName);
  }
 else {
    ConstraintPropertyService.checkPropertyConstraint(propertyName,propertyValue,propertyDefinition);
    nodePropsOverride.getProperties().put(propertyName,PropertyService.asPropertyValue(propertyValue));
  }
  context.saveConfiguration(matchingConfiguration);
}
Program: 62162
Project: 62162
Buggy source:
private boolean mergeNode(Topology topology,FlowExecutionContext context,String nodeTemplateId,NodePropsOverride nodePropsOverride){
  if (nodePropsOverride == null) {
    return false;
  }
  final ConfigChanged configChanged=new ConfigChanged();
  NodeTemplate nodeTemplate=topology.getNodeTemplates().get(nodeTemplateId);
  nodeTemplate.setProperties(mergeProperties(nodePropsOverride.getProperties(),nodeTemplate.getProperties(),s -> {
    configChanged.changed=true;
    context.getLog().info("String_Node_Str" + s + "String_Node_Str"+ nodeTemplateId+ "String_Node_Str");
  }
));
  Iterator<Entry<String,NodeCapabilitiesPropsOverride>> capabilitiesOverrideIter=safe(nodePropsOverride.getCapabilities()).entrySet().iterator();
  while (capabilitiesOverrideIter.hasNext()) {
    Entry<String,NodeCapabilitiesPropsOverride> capabilityProperties=capabilitiesOverrideIter.next();
    Capability capability=safe(nodeTemplate.getCapabilities()).get(capabilityProperties.getKey());
    if (capability == null) {
      configChanged.changed=true;
      capabilitiesOverrideIter.remove();
    }
 else {
      capability.setProperties(mergeProperties(capability.getProperties(),capabilityProperties.getValue().getProperties(),s -> {
        configChanged.changed=true;
        context.getLog().info("String_Node_Str" + s + "String_Node_Str"+ capabilityProperties.getKey()+ "String_Node_Str"+ nodeTemplateId+ "String_Node_Str");
      }
));
    }
  }
  return configChanged.changed;
}

Fixed version (ground truth):
private boolean mergeNode(Topology topology,FlowExecutionContext context,String nodeTemplateId,NodePropsOverride nodePropsOverride){
  if (nodePropsOverride == null) {
    return false;
  }
  final ConfigChanged configChanged=new ConfigChanged();
  NodeTemplate nodeTemplate=topology.getNodeTemplates().get(nodeTemplateId);
  nodeTemplate.setProperties(mergeProperties(nodePropsOverride.getProperties(),nodeTemplate.getProperties(),s -> {
    configChanged.changed=true;
    context.getLog().info("String_Node_Str" + s + "String_Node_Str"+ nodeTemplateId+ "String_Node_Str");
  }
));
  Iterator<Entry<String,NodeCapabilitiesPropsOverride>> capabilitiesOverrideIter=safe(nodePropsOverride.getCapabilities()).entrySet().iterator();
  while (capabilitiesOverrideIter.hasNext()) {
    Entry<String,NodeCapabilitiesPropsOverride> overrideCapabilityProperties=capabilitiesOverrideIter.next();
    Capability capability=safe(nodeTemplate.getCapabilities()).get(overrideCapabilityProperties.getKey());
    if (capability == null) {
      configChanged.changed=true;
      capabilitiesOverrideIter.remove();
    }
 else {
      capability.setProperties(mergeProperties(overrideCapabilityProperties.getValue().getProperties(),capability.getProperties(),s -> {
        configChanged.changed=true;
        context.getLog().info("String_Node_Str" + s + "String_Node_Str"+ overrideCapabilityProperties.getKey()+ "String_Node_Str"+ nodeTemplateId+ "String_Node_Str");
      }
));
    }
  }
  return configChanged.changed;
}
Program: 62163
Project: 62163
Buggy source:
private List<ITopologyModifier> getModifierListWithSelectionAction(String nodeId,Optional<String> optionalCapabilityName,String propertyName,Object propertyValue){
  List<ITopologyModifier> modifierList=flowExecutor.getDefaultFlowModifiers();
  for (int i=0; i < modifierList.size(); i++) {
    if (modifierList.get(i) == postMatchingNodeSetupModifier) {
      modifierList.add(i + 1,new SetMatchedNodePropertyModifier(propertyService,nodeId,optionalCapabilityName,propertyName,propertyValue));
      return modifierList;
    }
  }
  throw new IllegalArgumentException("String_Node_Str");
}

Fixed version (ground truth):
private List<ITopologyModifier> getModifierListWithSelectionAction(String nodeId,Optional<String> optionalCapabilityName,String propertyName,Object propertyValue){
  List<ITopologyModifier> modifierList=flowExecutor.getDefaultFlowModifiers();
  for (int i=0; i < modifierList.size(); i++) {
    if (modifierList.get(i) == postMatchingNodeSetupModifier) {
      modifierList.add(i,new SetMatchedNodePropertyModifier(propertyService,nodeId,optionalCapabilityName,propertyName,propertyValue));
      return modifierList;
    }
  }
  throw new IllegalArgumentException("String_Node_Str");
}
Program: 62165
Project: 62165
Buggy source:
private void setNodeProperty(FlowExecutionContext context,LocationResourceTemplate locationResourceTemplate,NodeTemplate nodeTemplate,DeploymentMatchingConfiguration matchingConfiguration) throws ConstraintViolationException, ConstraintValueDoNotMatchPropertyTypeException {
  PropertyDefinition propertyDefinition=ToscaContext.getOrFail(NodeType.class,locationResourceTemplate.getTemplate().getType()).getProperties().get(propertyName);
  if (propertyDefinition == null) {
    throw new NotFoundException("String_Node_Str" + propertyName + "String_Node_Str"+ nodeTemplateId+ "String_Node_Str"+ locationResourceTemplate.getTemplate().getType()+ "String_Node_Str");
  }
  AbstractPropertyValue locationResourcePropertyValue=locationResourceTemplate.getTemplate().getProperties().get(propertyName);
  ensureNotSet(locationResourcePropertyValue,"String_Node_Str",propertyName,propertyValue);
  ensureNotSet(nodeTemplate.getProperties().get(propertyName),"String_Node_Str",propertyName,propertyValue);
  propertyService.setPropertyValue(nodeTemplate,propertyDefinition,propertyName,propertyValue);
  NodePropsOverride nodePropsOverride=getNodePropsOverride(matchingConfiguration);
  nodePropsOverride.getProperties().put(propertyName,nodeTemplate.getProperties().get(propertyName));
  context.saveConfiguration(matchingConfiguration);
}

Fixed version (ground truth):
private void setNodeProperty(FlowExecutionContext context,LocationResourceTemplate locationResourceTemplate,NodeTemplate nodeTemplate,DeploymentMatchingConfiguration matchingConfiguration) throws ConstraintViolationException, ConstraintValueDoNotMatchPropertyTypeException {
  PropertyDefinition propertyDefinition=ToscaContext.getOrFail(NodeType.class,locationResourceTemplate.getTemplate().getType()).getProperties().get(propertyName);
  if (propertyDefinition == null) {
    throw new NotFoundException("String_Node_Str" + propertyName + "String_Node_Str"+ nodeTemplateId+ "String_Node_Str"+ locationResourceTemplate.getTemplate().getType()+ "String_Node_Str");
  }
  AbstractPropertyValue locationResourcePropertyValue=locationResourceTemplate.getTemplate().getProperties().get(propertyName);
  ensureNotSet(locationResourcePropertyValue,"String_Node_Str",propertyName,propertyValue);
  ensureNotSet(nodeTemplate.getProperties().get(propertyName),"String_Node_Str",propertyName,propertyValue);
  ConstraintPropertyService.checkPropertyConstraint(propertyName,propertyValue,propertyDefinition);
  NodePropsOverride nodePropsOverride=getNodePropsOverride(matchingConfiguration);
  nodePropsOverride.getProperties().put(propertyName,PropertyService.asPropertyValue(propertyValue));
  context.saveConfiguration(matchingConfiguration);
}
Program: 62167
Project: 62167
Buggy source:
private void setNodeProperty(FlowExecutionContext context,LocationResourceTemplate locationResourceTemplate,NodeTemplate nodeTemplate,DeploymentMatchingConfiguration matchingConfiguration) throws ConstraintViolationException, ConstraintValueDoNotMatchPropertyTypeException {
  PropertyDefinition propertyDefinition=ToscaContext.getOrFail(NodeType.class,locationResourceTemplate.getTemplate().getType()).getProperties().get(propertyName);
  if (propertyDefinition == null) {
    throw new NotFoundException("String_Node_Str" + propertyName + "String_Node_Str"+ nodeTemplateId+ "String_Node_Str"+ locationResourceTemplate.getTemplate().getType()+ "String_Node_Str");
  }
  AbstractPropertyValue locationResourcePropertyValue=locationResourceTemplate.getTemplate().getProperties().get(propertyName);
  ensureNotSet(locationResourcePropertyValue,"String_Node_Str",propertyName,propertyValue);
  ensureNotSet(nodeTemplate.getProperties().get(propertyName),"String_Node_Str",propertyName,propertyValue);
  ConstraintPropertyService.checkPropertyConstraint(propertyName,propertyValue,propertyDefinition);
  NodePropsOverride nodePropsOverride=getNodePropsOverride(matchingConfiguration);
  nodePropsOverride.getProperties().put(propertyName,PropertyService.asPropertyValue(propertyValue));
  context.saveConfiguration(matchingConfiguration);
}

Fixed version (ground truth):
private void setNodeProperty(FlowExecutionContext context,LocationResourceTemplate locationResourceTemplate,NodeTemplate nodeTemplate,DeploymentMatchingConfiguration matchingConfiguration) throws ConstraintViolationException, ConstraintValueDoNotMatchPropertyTypeException {
  PropertyDefinition propertyDefinition=ToscaContext.getOrFail(NodeType.class,locationResourceTemplate.getTemplate().getType()).getProperties().get(propertyName);
  if (propertyDefinition == null) {
    throw new NotFoundException("String_Node_Str" + propertyName + "String_Node_Str"+ nodeTemplateId+ "String_Node_Str"+ locationResourceTemplate.getTemplate().getType()+ "String_Node_Str");
  }
  AbstractPropertyValue locationResourcePropertyValue=locationResourceTemplate.getTemplate().getProperties().get(propertyName);
  ensureNotSet(locationResourcePropertyValue,"String_Node_Str",propertyName,propertyValue);
  ensureNotSet(nodeTemplate.getProperties().get(propertyName),"String_Node_Str",propertyName,propertyValue);
  NodePropsOverride nodePropsOverride=getNodePropsOverride(matchingConfiguration);
  ConstraintPropertyService.checkPropertyConstraint(propertyName,propertyValue,propertyDefinition);
  if (propertyValue == null) {
    nodePropsOverride.getProperties().remove(propertyName);
  }
 else {
    nodePropsOverride.getProperties().put(propertyName,PropertyService.asPropertyValue(propertyValue));
  }
  context.saveConfiguration(matchingConfiguration);
}
Program: 62168
Project: 62168
Buggy source:
@Override public void process(Topology topology,FlowExecutionContext context){
  Optional<DeploymentMatchingConfiguration> configurationOptional=context.getConfiguration(DeploymentMatchingConfiguration.class,NodeMatchingConfigAutoSelectModifier.class.getSimpleName());
  if (!configurationOptional.isPresent()) {
    context.log().error(new LocationPolicyTask());
    return;
  }
  DeploymentMatchingConfiguration matchingConfiguration=configurationOptional.get();
  Map<String,String> lastUserSubstitutions=matchingConfiguration.getMatchedLocationResources();
  Map<String,Set<String>> locResTemplateIdsPerNodeIds=(Map<String,Set<String>>)context.getExecutionCache().get(FlowExecutionContext.MATCHED_LOCATION_RESOURCE_TEMPLATE_IDS_PER_NODE);
  Set<String> nodeAvailableSubstitutions=locResTemplateIdsPerNodeIds.get(nodeId);
  for (  String matchedLRTId : safe(nodeAvailableSubstitutions)) {
    if (matchedLRTId.equals(locationResourceTemplateId)) {
      lastUserSubstitutions.put(nodeId,locationResourceTemplateId);
      context.saveConfiguration(matchingConfiguration);
      return;
    }
  }
  throw new NotFoundException("String_Node_Str" + locationResourceTemplateId + "String_Node_Str"+ nodeId+ "String_Node_Str");
}

Fixed version (ground truth):
@Override public void process(Topology topology,FlowExecutionContext context){
  executed=true;
  Optional<DeploymentMatchingConfiguration> configurationOptional=context.getConfiguration(DeploymentMatchingConfiguration.class,NodeMatchingConfigAutoSelectModifier.class.getSimpleName());
  if (!configurationOptional.isPresent()) {
    context.log().error(new LocationPolicyTask());
    return;
  }
  DeploymentMatchingConfiguration matchingConfiguration=configurationOptional.get();
  Map<String,String> lastUserSubstitutions=matchingConfiguration.getMatchedLocationResources();
  Map<String,Set<String>> locResTemplateIdsPerNodeIds=(Map<String,Set<String>>)context.getExecutionCache().get(FlowExecutionContext.MATCHED_LOCATION_RESOURCE_TEMPLATE_IDS_PER_NODE);
  Set<String> nodeAvailableSubstitutions=locResTemplateIdsPerNodeIds.get(nodeId);
  for (  String matchedLRTId : safe(nodeAvailableSubstitutions)) {
    if (matchedLRTId.equals(locationResourceTemplateId)) {
      lastUserSubstitutions.put(nodeId,locationResourceTemplateId);
      context.saveConfiguration(matchingConfiguration);
      return;
    }
  }
  throw new NotFoundException("String_Node_Str" + locationResourceTemplateId + "String_Node_Str"+ nodeId+ "String_Node_Str");
}
Program: 62169
Project: 62169
Buggy source:
/** 
 * Execute the deployment flow with a modification of changing the substitution for one of the nodes.
 * @param application The application for which to execute the deployment flow.
 * @param environment The environment for which to execute the deployment flow.
 * @param topology The topology linked to the specified environment.
 * @param nodeId The id of the node to substitute at matching phase.
 * @param locationResourceTemplateId The id of the location resources to substitute.
 * @return The flow execution context.
 */
public FlowExecutionContext updateSubstitution(Application application,ApplicationEnvironment environment,Topology topology,String nodeId,String locationResourceTemplateId){
  FlowExecutionContext executionContext=new FlowExecutionContext(alienDAO,topology,new EnvironmentContext(application,environment));
  List<ITopologyModifier> modifierList=getModifierListWithSelectionAction(nodeId,locationResourceTemplateId);
  flowExecutor.execute(topology,modifierList,executionContext);
  return executionContext;
}

Fixed version (ground truth):
/** 
 * Execute the deployment flow with a modification of changing the substitution for one of the nodes.
 * @param application The application for which to execute the deployment flow.
 * @param environment The environment for which to execute the deployment flow.
 * @param topology The topology linked to the specified environment.
 * @param nodeId The id of the node to substitute at matching phase.
 * @param locationResourceTemplateId The id of the location resources to substitute.
 * @return The flow execution context.
 */
public FlowExecutionContext updateSubstitution(Application application,ApplicationEnvironment environment,Topology topology,String nodeId,String locationResourceTemplateId){
  FlowExecutionContext executionContext=new FlowExecutionContext(alienDAO,topology,new EnvironmentContext(application,environment));
  SetMatchedNodeModifier setMatchedNodeModifier=new SetMatchedNodeModifier(nodeId,locationResourceTemplateId);
  List<ITopologyModifier> modifierList=getModifierListWithSelectionAction(setMatchedNodeModifier);
  flowExecutor.execute(topology,modifierList,executionContext);
  if (!setMatchedNodeModifier.isExecuted()) {
    throw new NotFoundException("String_Node_Str" + locationResourceTemplateId + "String_Node_Str"+ nodeId+ "String_Node_Str");
  }
  return executionContext;
}
Program: 62170
Project: 62170
Buggy source:
private List<ITopologyModifier> getModifierListWithSelectionAction(String nodeId,String locationResourceTemplateId){
  List<ITopologyModifier> modifierList=flowExecutor.getDefaultFlowModifiers();
  for (int i=0; i < modifierList.size(); i++) {
    if (modifierList.get(i) == nodeMatchingConfigAutoSelectModifier) {
      modifierList.add(i + 1,new SetMatchedNodeModifier(nodeId,locationResourceTemplateId));
      return modifierList;
    }
  }
  throw new IllegalArgumentException("String_Node_Str");
}

Fixed version (ground truth):
private List<ITopologyModifier> getModifierListWithSelectionAction(SetMatchedNodeModifier matchedNodeModifier){
  List<ITopologyModifier> modifierList=flowExecutor.getDefaultFlowModifiers();
  for (int i=0; i < modifierList.size(); i++) {
    if (modifierList.get(i) == nodeMatchingConfigAutoSelectModifier) {
      modifierList.add(i + 1,matchedNodeModifier);
      return modifierList;
    }
  }
  throw new IllegalArgumentException("String_Node_Str");
}
Program: 62171
Project: 62171
Buggy source:
private void processLocationResourceTemplateSubstitution(String nodeId,String locationResourceTemplateId,Topology topology){
  NodeTemplate locationNode=locationResourceService.getOrFail(locationResourceTemplateId).getTemplate();
  NodeTemplate abstractTopologyNode=topology.getNodeTemplates().put(nodeId,locationNode);
  locationNode.setName(abstractTopologyNode.getName());
  locationNode.setRelationships(abstractTopologyNode.getRelationships());
  locationNode.setProperties(CollectionUtils.merge(abstractTopologyNode.getProperties(),locationNode.getProperties(),false));
  for (  Map.Entry<String,Capability> locationCapabilityEntry : safe(locationNode.getCapabilities()).entrySet()) {
    Capability locationCapability=locationCapabilityEntry.getValue();
    Capability abstractCapability=safe(abstractTopologyNode.getCapabilities()).get(locationCapabilityEntry.getKey());
    if (abstractCapability != null && MapUtils.isNotEmpty(abstractCapability.getProperties())) {
      locationCapability.setProperties(CollectionUtils.merge(abstractCapability.getProperties(),locationCapability.getProperties(),false));
    }
  }
}

Fixed version (ground truth):
private void processLocationResourceTemplateSubstitution(String nodeId,String locationResourceTemplateId,Topology topology){
  NodeTemplate locationNode=locationResourceService.getOrFail(locationResourceTemplateId).getTemplate();
  NodeTemplate abstractTopologyNode=topology.getNodeTemplates().put(nodeId,locationNode);
  locationNode.setName(abstractTopologyNode.getName());
  locationNode.setRelationships(abstractTopologyNode.getRelationships());
  Set<String> topologyNotMergedProps=Sets.newHashSet();
  locationNode.setProperties(CollectionUtils.merge(abstractTopologyNode.getProperties(),locationNode.getProperties(),true,topologyNotMergedProps));
  for (  Map.Entry<String,Capability> locationCapabilityEntry : safe(locationNode.getCapabilities()).entrySet()) {
    Capability locationCapability=locationCapabilityEntry.getValue();
    Capability abstractCapability=safe(abstractTopologyNode.getCapabilities()).get(locationCapabilityEntry.getKey());
    if (abstractCapability != null && MapUtils.isNotEmpty(abstractCapability.getProperties())) {
      locationCapability.setProperties(CollectionUtils.merge(abstractCapability.getProperties(),locationCapability.getProperties(),true,topologyNotMergedProps));
    }
  }
}
Program: 62172
Project: 62172
Buggy source:
public DeploymentConfiguration getDeploymentConfiguration(DeploymentTopology deploymentTopology){
  DeploymentSubstitutionConfiguration substitutionConfiguration=getAvailableNodeSubstitutions(deploymentTopology);
  Map<String,Set<String>> availableSubstitutions=substitutionConfiguration.getAvailableSubstitutions();
  Map<String,String> existingSubstitutions=deploymentTopology.getSubstitutedNodes();
  if (availableSubstitutions.size() != existingSubstitutions.size()) {
    updateDeploymentTopology(deploymentTopology);
  }
  return new DeploymentConfiguration(deploymentTopology,substitutionConfiguration);
}

Fixed version (ground truth):
public DeploymentConfiguration getDeploymentConfiguration(DeploymentTopology deploymentTopology){
  DeploymentSubstitutionConfiguration substitutionConfiguration=getAvailableNodeSubstitutions(deploymentTopology);
  Map<String,Set<String>> availableSubstitutions=substitutionConfiguration.getAvailableSubstitutions();
  Map<String,String> existingSubstitutions=deploymentTopology.getSubstitutedNodes();
  if (substitutionsHaveChanged(existingSubstitutions,availableSubstitutions)) {
    updateDeploymentTopology(deploymentTopology);
  }
  return new DeploymentConfiguration(deploymentTopology,substitutionConfiguration);
}
Program: 62173
Project: 62173
Buggy source:
@Before public void init() throws IOException {
  thrownException=null;
  GetMultipleDataResult<Application> apps=alienDAO.search(Application.class,"String_Node_Str",null,100);
  for (  Application application : apps.getData()) {
    applicationService.delete(application.getId());
  }
  FacetedSearchResult<Topology> searchResult=catalogService.search(Topology.class,"String_Node_Str",100,null);
  Topology[] topologies=searchResult.getData();
  for (  Topology topology : topologies) {
    csarService.forceDeleteCsar(topology.getId());
  }
  topologyIds.clear();
  editionContextManager.clearCache();
}

Fixed version (ground truth):
@Before public void init() throws IOException {
  thrownException=null;
  GetMultipleDataResult<Application> apps=alienDAO.search(Application.class,"String_Node_Str",null,100);
  for (  Application application : apps.getData()) {
    applicationService.delete(application.getId());
  }
  FacetedSearchResult<Topology> searchResult=catalogService.search(Topology.class,"String_Node_Str",100,null);
  Topology[] topologies=searchResult.getData();
  for (  Topology topology : topologies) {
    try {
      csarService.forceDeleteCsar(topology.getId());
    }
 catch (    NotFoundException e) {
      alienDAO.delete(Topology.class,topology.getId());
    }
  }
  topologyIds.clear();
  editionContextManager.clearCache();
}
Program: 62174
Project: 62174
Buggy source:
private ApplicationTopologyVersion createTopologyVersion(String applicationId,String version,String qualifier,String description,Topology topology){
  String delegateType=ArchiveDelegateType.APPLICATION.toString();
  Csar csar=new Csar(applicationId,version);
  csar.setWorkspace(APP_WORKSPACE_PREFIX + "String_Node_Str" + applicationId);
  csar.setDelegateId(applicationId);
  csar.setDelegateType(delegateType);
  topology.setArchiveName(csar.getName());
  topology.setArchiveVersion(csar.getVersion());
  topology.setWorkspace(csar.getWorkspace());
  if (!VersionUtil.isSnapshot(version)) {
    checkTopologyReleasable(topology);
  }
  archiveIndexer.importNewArchive(csar,topology);
  ApplicationTopologyVersion applicationTopologyVersion=new ApplicationTopologyVersion();
  applicationTopologyVersion.setArchiveId(csar.getId());
  applicationTopologyVersion.setQualifier(qualifier);
  applicationTopologyVersion.setDescription(description);
  return applicationTopologyVersion;
}

Fixed version (ground truth):
@SneakyThrows private ApplicationTopologyVersion createTopologyVersion(String applicationId,String version,String qualifier,String description,Topology topology){
  Path originalTopologyArchive=archiveRepositry.getExpandedCSAR(topology.getArchiveName(),topology.getArchiveVersion());
  String delegateType=ArchiveDelegateType.APPLICATION.toString();
  Csar csar=new Csar(applicationId,version);
  csar.setWorkspace(APP_WORKSPACE_PREFIX + "String_Node_Str" + applicationId);
  csar.setDelegateId(applicationId);
  csar.setDelegateType(delegateType);
  ArtifactUtil.changeTopologyArtifactReferences(topology,csar);
  topology.setArchiveName(csar.getName());
  topology.setArchiveVersion(csar.getVersion());
  topology.setWorkspace(csar.getWorkspace());
  if (!VersionUtil.isSnapshot(version)) {
    checkTopologyReleasable(topology);
  }
  Path newTopologyTempPath=Files.createTempDirectory(tempDirPath,"String_Node_Str");
  ArtifactUtil.copyCsarArtifacts(originalTopologyArchive,newTopologyTempPath);
  archiveIndexer.importNewArchive(csar,topology,newTopologyTempPath);
  ApplicationTopologyVersion applicationTopologyVersion=new ApplicationTopologyVersion();
  applicationTopologyVersion.setArchiveId(csar.getId());
  applicationTopologyVersion.setQualifier(qualifier);
  applicationTopologyVersion.setDescription(description);
  return applicationTopologyVersion;
}
Program: 62175
Project: 62175
Buggy source:
/** 
 * <p> Import a new empty archive with a topology. </p> <p> Note: this archive is not created from parsing but from alien4cloud API. This service will index the archive and topology as well as initialize the file repository and tosca yaml. </p> <p> This method cannot be used to override a topology, even a SNAPSHOT as any update to a topology from the API MUST be done through the editor. </p>
 * @param csar The archive to be imported.
 * @param topology The topology to be part of the topology.
 */
public synchronized void importNewArchive(Csar csar,Topology topology){
  ArchiveRoot archiveRoot=new ArchiveRoot();
  archiveRoot.setArchive(csar);
  archiveRoot.setTopology(topology);
  publisher.publishEvent(new BeforeArchiveIndexed(this,archiveRoot));
  ensureUniqueness(csar.getName(),csar.getVersion());
  workflowBuilderService.initWorkflows(workflowBuilderService.buildTopologyContext(topology));
  if (csar.getYamlFilePath() == null) {
    csar.setYamlFilePath("String_Node_Str");
  }
  String yaml=exportService.getYaml(csar,topology);
  csarService.save(csar);
  topologyServiceCore.save(topology);
  archiveRepositry.storeCSAR(csar,yaml);
  publisher.publishEvent(new AfterArchiveIndexed(this,archiveRoot));
}

Fixed version (ground truth):
/** 
 * <p> Import a new empty archive with a topology. </p> <p> Note: this archive is not created from parsing but from alien4cloud API. This service will index the archive and topology as well as initialize the file repository and tosca yaml. </p> <p> This method cannot be used to override a topology, even a SNAPSHOT as any update to a topology from the API MUST be done through the editor. </p>
 * @param csar The archive to be imported.
 * @param topology The topology to be part of the topology.
 * @param topologyPath if the new topology must be created inside this directory to have all its artifacts
 */
@SneakyThrows public synchronized void importNewArchive(Csar csar,Topology topology,Path topologyPath){
  ArchiveRoot archiveRoot=new ArchiveRoot();
  archiveRoot.setArchive(csar);
  archiveRoot.setTopology(topology);
  publisher.publishEvent(new BeforeArchiveIndexed(this,archiveRoot));
  ensureUniqueness(csar.getName(),csar.getVersion());
  workflowBuilderService.initWorkflows(workflowBuilderService.buildTopologyContext(topology));
  if (csar.getYamlFilePath() == null) {
    csar.setYamlFilePath("String_Node_Str");
  }
  String yaml=exportService.getYaml(csar,topology);
  csarService.save(csar);
  topologyServiceCore.save(topology);
  if (topologyPath == null) {
    archiveRepositry.storeCSAR(csar,yaml);
  }
 else {
    Files.write(topologyPath.resolve(csar.getYamlFilePath()),yaml.getBytes(Charset.forName("String_Node_Str")));
    archiveRepositry.storeCSAR(csar,topologyPath);
  }
  publisher.publishEvent(new AfterArchiveIndexed(this,archiveRoot));
}
Program: 62176
Project: 62176
Buggy source:
@Override public Topology createTopologyAsTemplate(String name,String description,String version,String workspace,String fromTopologyId){
  NameValidationUtils.validate("String_Node_Str",name);
  Csar csar=new Csar(name,StringUtils.isNotBlank(version) ? version : VersionUtil.DEFAULT_VERSION_NAME);
  csar.setWorkspace(workspace);
  csar.setDelegateType(ArchiveDelegateType.CATALOG.toString());
  if (description == null) {
    csar.setDescription("String_Node_Str");
  }
 else {
    csar.setDescription("String_Node_Str" + description);
  }
  Topology topology;
  if (fromTopologyId != null) {
    topology=alienDAO.findById(Topology.class,fromTopologyId);
  }
 else {
    topology=new Topology();
  }
  topology.setDescription(description);
  topology.setArchiveName(csar.getName());
  topology.setArchiveVersion(csar.getVersion());
  topology.setWorkspace(csar.getWorkspace());
  csar.setDependencies(topology.getDependencies());
  archiveIndexer.importNewArchive(csar,topology);
  return topology;
}

Fixed version (ground truth):
@Override public Topology createTopologyAsTemplate(String name,String description,String version,String workspace,String fromTopologyId){
  NameValidationUtils.validate("String_Node_Str",name);
  Csar csar=new Csar(name,StringUtils.isNotBlank(version) ? version : VersionUtil.DEFAULT_VERSION_NAME);
  csar.setWorkspace(workspace);
  csar.setDelegateType(ArchiveDelegateType.CATALOG.toString());
  if (description == null) {
    csar.setDescription("String_Node_Str");
  }
 else {
    csar.setDescription("String_Node_Str" + description);
  }
  Topology topology;
  if (fromTopologyId != null) {
    topology=alienDAO.findById(Topology.class,fromTopologyId);
  }
 else {
    topology=new Topology();
  }
  topology.setDescription(description);
  topology.setArchiveName(csar.getName());
  topology.setArchiveVersion(csar.getVersion());
  topology.setWorkspace(csar.getWorkspace());
  csar.setDependencies(topology.getDependencies());
  archiveIndexer.importNewArchive(csar,topology,null);
  return topology;
}
Program: 62178
Project: 62178
Buggy source:
/** 
 * Generate resources related to a csar list
 * @param csars
 * @return
 */
public List<Usage> generateCsarsInfo(Csar[] csars){
  String resourceName;
  String resourceId;
  List<Usage> resourceList=Lists.newArrayList();
  for (  Csar csar : csars) {
    if (ArchiveDelegateType.APPLICATION.toString().equals(csar.getDelegateType())) {
      Application application=applicationService.checkAndGetApplication(csar.getDelegateId());
      resourceName=application.getName();
      resourceId=csar.getDelegateId();
    }
 else {
      resourceName=csar.getName();
      resourceId=csar.getId();
    }
    Usage temp=new Usage(resourceName,Csar.class.getSimpleName().toLowerCase(),resourceId,csar.getWorkspace());
    resourceList.add(temp);
  }
  return resourceList;
}

Fixed version (ground truth):
/** 
 * Generate resources related to a csar list
 * @param csars
 * @return
 */
public List<Usage> generateCsarsInfo(Csar[] csars){
  String resourceName;
  String resourceId;
  List<Usage> resourceList=Lists.newArrayList();
  for (  Csar csar : csars) {
    if (ArchiveDelegateType.APPLICATION.toString().equals(csar.getDelegateType())) {
      Application application=applicationService.checkAndGetApplication(csar.getDelegateId());
      resourceName=application.getName();
    }
 else {
      resourceName=csar.getName();
    }
    Usage temp=new Usage(resourceName,Csar.class.getSimpleName().toLowerCase(),csar.getId(),csar.getWorkspace());
    resourceList.add(temp);
  }
  return resourceList;
}
Program: 62179
Project: 62179
Buggy source:
@Then("String_Node_Str") public void I_should_have_a_delete_csar_response_with_related_resources(DataTable usageDT) throws Throwable {
  RestResponse<?> restResponse=JsonUtil.read(Context.getInstance().getRestResponse());
  Assert.assertNotNull(restResponse);
  List<Usage> resultData=JsonUtil.toList(JsonUtil.toString(restResponse.getData()),Usage.class);
  boolean isPresent;
  for (  Usage usage : resultData) {
    isPresent=false;
    for (    DataTableRow row : usageDT.getGherkinRows()) {
      if (usage.getResourceName().equals(row.getCells().get(0)) && usage.getResourceType().equals(row.getCells().get(1))) {
        Assert.assertTrue(usage.getResourceName() + "String_Node_Str" + usage.getResourceType(),true);
        isPresent=true;
        break;
      }
    }
    if (!isPresent) {
      Assert.assertFalse("String_Node_Str" + usage.getResourceName() + "String_Node_Str"+ usage.getResourceType(),true);
    }
  }
}

Fixed version (ground truth):
@Then("String_Node_Str") public void I_should_have_a_delete_csar_response_with_related_resources(DataTable usageDT) throws Throwable {
  RestResponse<?> restResponse=JsonUtil.read(Context.getInstance().getRestResponse());
  Assert.assertNotNull(restResponse);
  List<Usage> resultData=JsonUtil.toList(JsonUtil.toString(restResponse.getData()),Usage.class);
  boolean isPresent;
  for (  Usage usage : resultData) {
    isPresent=false;
    for (    DataTableRow row : usageDT.getGherkinRows()) {
      if (usage.getResourceName().equals(row.getCells().get(0)) && usage.getResourceType().equals(row.getCells().get(1))) {
        isPresent=true;
        break;
      }
    }
    if (!isPresent) {
      Assert.assertFalse("String_Node_Str" + usage.getResourceName() + "String_Node_Str"+ usage.getResourceType(),true);
    }
  }
}