@Test
  public void testMatches() throws Exception {
    // this is a dummy test for testing the behaviour of matches method
    String testEndpointFilter = String.format(filterPattern, objectClass);
    String endpointId = objectClass + Constants.SEPARATOR + "1.0.0";

    EndpointDescription endpointDescription1 = new EndpointDescription(endpointId, null);
    EndpointDescription endpointDescription2 = new EndpointDescription(endpointId, null);
    Assert.assertTrue(endpointDescription1.matches(testEndpointFilter));
    Assert.assertTrue(endpointDescription2.matches(testEndpointFilter));
  }
  /**
   * @param endpointName name affected {@link EndpointDescription}
   * @param dataType {@link DataType} to remove as a connected one
   */
  public void removeConnectedDataType(String endpointName, DataType dataType) {
    EndpointDescription endpointDesc = getNotClonedEndpointDescription(endpointName);

    if (endpointDesc != null) {
      EndpointDescription oldEndpointDesc = EndpointDescription.copy(endpointDesc);
      endpointDesc.removeConnectedDataType(dataType);
      firePropertyChange(
          PROPERTY_ENDPOINT,
          new EndpointChange(EndpointChange.Type.Modified, endpointDesc, oldEndpointDesc));
    }
  }
 /**
  * @param name name of {@link EndpointDescription} to get
  * @return {@link EndpointDescription} object with given name or <code>null</code> if given name
  *     doesn't exist
  */
 public EndpointDescription getEndpointDescription(String name) {
   EndpointDescription endpointDesc = getNotClonedEndpointDescription(name);
   if (endpointDesc != null) {
     return EndpointDescription.copy(endpointDesc);
   }
   return null;
 }
 private Set<EndpointDescription> cloneEndpointDescriptionValues(
     Collection<EndpointDescription> endpointDescriptions) {
   Set<EndpointDescription> clonedDescs = new HashSet<EndpointDescription>();
   for (EndpointDescription desc : endpointDescriptions) {
     clonedDescs.add(EndpointDescription.copy(desc));
   }
   return clonedDescs;
 }
  /**
   * Edits a static {@link EndpointDescription}.
   *
   * @param name name of {@link EndpointDescription} to edit
   * @param newDataType new {@link DataType}
   * @param newMetaData new meta data {@link Map}
   * @param checkIfDeclared perform check if static endpoint is declared
   * @return {@link EndpointDescription} edited
   * @throws IllegalArgumentException if no dynamic endpoint description with given name exists
   */
  public synchronized EndpointDescription editStaticEndpointDescription(
      String name, DataType newDataType, Map<String, String> newMetaData, boolean checkIfDeclared)
      throws IllegalArgumentException {

    EndpointDescription description = staticEndpointDescriptions.get(name);
    if (description == null) {
      if (checkIfDeclared) {
        throw new IllegalArgumentException(
            "Static endpoint description with name '" + name + "' doesn't exist");
      } else { // add description
        description = new EndpointDescription(null, endpointType);
        description.setName(name);
        description.setDataType(newDataType);
        description.setMetaData(newMetaData);
        staticEndpointDescriptions.put(name, description);
        return description;
      }
    }

    EndpointDescription oldDescription = EndpointDescription.copy(description);

    description.setDataType(newDataType);
    description.setMetaData(newMetaData);

    firePropertyChange(
        PROPERTY_ENDPOINT,
        new EndpointChange(EndpointChange.Type.Modified, description, oldDescription));

    return description;
  }
  /**
   * Edits a dynamic {@link EndpointDescription}.
   *
   * @param oldName old name of {@link EndpointDescription}
   * @param newName new name of {@link EndpointDescription}
   * @param newDataType new {@link DataType}
   * @param newMetaData new meta data {@link Map}
   * @param newDynEndpointId new name of endpoint the input belongs to
   * @param newParentGroup new name of endpoint parent group the input belongs to
   * @return {@link EndpointDescription} edited
   * @throws IllegalArgumentException if no dynamic endpoint description with given name exists or
   *     new name is invalid
   */
  public synchronized EndpointDescription editDynamicEndpointDescription(
      String oldName,
      String newName,
      DataType newDataType,
      Map<String, String> newMetaData,
      String newDynEndpointId,
      String newParentGroup)
      throws IllegalArgumentException {

    EndpointDescription description = dynamicEndpointDescriptions.remove(oldName);
    if (description == null) {
      throw new IllegalArgumentException(
          StringUtils.format(MESSAGE_DYNAMIC_ENDPOINT_DESCRIPTION_DOESNT_EXIST, oldName));
    }
    EndpointDescription oldDescription = EndpointDescription.copy(description);
    try {
      if (!isValidEndpointName(newName)) {
        throw new IllegalArgumentException(MESSAGE_DESIRED_ENDPOINT_NAME_ALREADY_EXISTS + newName);
      }
      description.setName(newName);
      description.setDataType(newDataType);
      description.setMetaData(newMetaData);
      description
          .getMetaData()
          .put(
              LoopComponentConstants.META_KEY_LOOP_ENDPOINT_TYPE,
              oldDescription.getMetaDataValue(LoopComponentConstants.META_KEY_LOOP_ENDPOINT_TYPE));
      if (newDynEndpointId != null) {
        description.setDynamicEndpointIdentifier(newDynEndpointId);
      }
      description.setParentGroupName(newParentGroup);
    } catch (IllegalArgumentException e) {
      dynamicEndpointDescriptions.put(oldName, description);
      throw e;
    }

    dynamicEndpointDescriptions.put(newName, description);

    firePropertyChange(
        PROPERTY_ENDPOINT,
        new EndpointChange(EndpointChange.Type.Modified, description, oldDescription));

    return description;
  }
  /**
   * Add a dynamic endpoint to the list of dynamic endpoints.
   *
   * @param endpointId identifier of dynamic {@link EndpointDefinition} to chose as the underlying
   *     {@link EndpointDefinition}
   * @param name name to set
   * @param dataType data type to set
   * @param metaData meta data to set
   * @param identifier identifier of the endpoint
   * @param parentGroup name of parent input group, <code>null</code> for using default group or
   *     none
   * @param checkIfDeclared perform check if dynamic endpoint is declared
   * @return {@link EndpointDescription} object created and added or <code>null</code> if the name
   *     already exists
   * @throws IllegalArgumentException if dynamic endpoint description with given name already exists
   *     or new name is invalid
   */
  public EndpointDescription addDynamicEndpointDescription(
      String endpointId,
      String name,
      DataType dataType,
      Map<String, String> metaData,
      String identifier,
      String parentGroup,
      boolean checkIfDeclared)
      throws IllegalArgumentException {

    if (checkIfDeclared
        && (!isDynamicEndpointDefinitionDeclared(endpointId) || !isValidEndpointName(name))) {
      String message;
      if (!isDynamicEndpointDefinitionDeclared(endpointId)) {
        message = StringUtils.format(NO_DYNAMIC_ENDPOINT_DEFINITION_WITH_ID_S_DECLARED, endpointId);
      } else {
        message = MESSAGE_DESIRED_ENDPOINT_NAME_ALREADY_EXISTS + name;
      }
      throw new IllegalArgumentException(message);
    }

    EndpointDescription desc =
        new EndpointDescription(
            endpointDefinitionsProvider.getDynamicEndpointDefinition(endpointId), identifier);

    desc.setName(name);
    desc.setDynamicEndpointIdentifier(endpointId);
    desc.setDataType(dataType);
    for (String key : metaData.keySet()) {
      desc.setMetaDataValue(key, metaData.get(key));
    }
    if (parentGroup != null) { // default (if there is one) should not be used as explicit
      // parent group is given
      desc.setParentGroupName(parentGroup);
    }
    dynamicEndpointDescriptions.put(name, desc);

    firePropertyChange(
        PROPERTY_ENDPOINT, new EndpointChange(EndpointChange.Type.Added, desc, null));

    return desc;
  }
 /**
  * Adds a static {@link EndpointDescription}.
  *
  * @param description {@link EndpointDescription} to add
  */
 public synchronized void addStaticEndpointDescription(EndpointDescription description) {
   staticEndpointDescriptions.put(description.getName(), description);
 }