@Test(groups = "wso2.greg", dependsOnMethods = "testAddResourceThroughRxt")
  public void testAddDependencyFromRxtResource()
      throws AddAssociationRegistryExceptionException, RemoteException {

    String dependencyType = "depends";
    String todo = "add";
    relationServiceClient.addAssociation(PATH + RES_NAME, dependencyType, RXT_RESOURCE_PATH, todo);

    DependenciesBean bean = relationServiceClient.getDependencies(PATH + RES_NAME);
    assertTrue(
        dependencyType.equalsIgnoreCase(bean.getAssociationBeans()[0].getAssociationType()),
        "Dependency type is not correct");

    assertTrue(
        RXT_RESOURCE_PATH.equalsIgnoreCase(bean.getAssociationBeans()[0].getDestinationPath()),
        "Target dependency is not correct");

    assertTrue(
        (PATH + RES_NAME).equalsIgnoreCase(bean.getAssociationBeans()[0].getSourcePath()),
        "Source dependency is not correct");

    // remove dependency
    relationServiceClient.addAssociation(
        PATH + RES_NAME, dependencyType, RXT_RESOURCE_PATH, "remove");
  }
  @Test(groups = "wso2.greg", dependsOnMethods = "testAddWsdlAsADependency")
  public void testAddPolicyAsADependency()
      throws MalformedURLException, ResourceAdminServiceExceptionException, RemoteException,
          AddAssociationRegistryExceptionException {

    Boolean nameExists = false;
    String path =
        FrameworkPathUtil.getSystemResourceLocation()
            + "artifacts"
            + File.separator
            + "GREG"
            + File.separator
            + "policy"
            + File.separator
            + "policy.xml";
    DataHandler dataHandler = new DataHandler(new URL("file:///" + path));
    resourceAdminClient.addPolicy("desc 1", dataHandler);
    PolicyBean policyBean = listMetaDataServiceClient.listPolicies();
    String[] names = policyBean.getName();

    for (String name : names) {
      if (name.equalsIgnoreCase("policy.xml")) {
        nameExists = true;
      }
    }

    assertTrue(nameExists, "Policy does not exist.");

    String[] policyNames = listMetaDataServiceClient.listPolicies().getPath();
    for (String policyName : policyNames) {
      if (policyName.contains("policy.xml")) {

        pathToPolicy = "/_system/governance" + policyName;
      }
    }

    String dependencyType = "depends";
    String todo = "add";
    relationServiceClient.addAssociation(PATH + RES_NAME, dependencyType, pathToPolicy, todo);

    DependenciesBean bean = relationServiceClient.getDependencies(PATH + RES_NAME);
    assertTrue(
        dependencyType.equalsIgnoreCase(bean.getAssociationBeans()[0].getAssociationType()),
        "Dependency type is not correct");

    assertTrue(
        pathToPolicy.equalsIgnoreCase(bean.getAssociationBeans()[0].getDestinationPath()),
        "Target dependency is not correct");

    assertTrue(
        (PATH + RES_NAME).equalsIgnoreCase(bean.getAssociationBeans()[0].getSourcePath()),
        "Source dependency is not correct");

    // remove dependency
    relationServiceClient.addAssociation(PATH + RES_NAME, dependencyType, pathToPolicy, "remove");
  }
  @Test(dependsOnMethods = "testAddResource")
  public void testAddDependencyFromChildCollection()
      throws MalformedURLException, ResourceAdminServiceExceptionException, RemoteException,
          AddAssociationRegistryExceptionException {

    String dependencyType = "depends";
    String todo = "add";

    relationServiceClient.addAssociation(
        PATH + RES_NAME, dependencyType, PATH + CHILDS_CHILD_NAME, todo);

    DependenciesBean bean = relationServiceClient.getDependencies(PATH + RES_NAME);
    assertTrue(
        dependencyType.equalsIgnoreCase(bean.getAssociationBeans()[0].getAssociationType()),
        "Dependency type is not correct");

    assertTrue(
        (PATH + CHILDS_CHILD_NAME)
            .equalsIgnoreCase(bean.getAssociationBeans()[0].getDestinationPath()),
        "Target dependency is not correct");

    assertTrue(
        (PATH + RES_NAME).equalsIgnoreCase(bean.getAssociationBeans()[0].getSourcePath()),
        "Source dependency is not correct");
  }
  @Test(groups = "wso2.greg", dependsOnMethods = "testAddPolicyAsADependency")
  public void testAddSchemaAsADependency()
      throws MalformedURLException, ResourceAdminServiceExceptionException, RemoteException,
          AddAssociationRegistryExceptionException {
    String path =
        FrameworkPathUtil.getSystemResourceLocation()
            + "artifacts"
            + File.separator
            + "GREG"
            + File.separator
            + "schema"
            + File.separator
            + "books.xsd";
    DataHandler dataHandler = new DataHandler(new URL("file:///" + path));
    resourceAdminClient.addSchema("desc 1", dataHandler);
    SchemaBean schemaBean = listMetaDataServiceClient.listSchemas();

    String[] names2 = schemaBean.getName();
    Boolean nameExists = false;

    for (String name : names2) {
      if (name.equalsIgnoreCase("books.xsd")) {
        nameExists = true;
      }
    }
    assertTrue(nameExists, "Schema does not exist.");

    String dependencyType = "depends";
    String todo = "add";
    relationServiceClient.addAssociation(PATH + RES_NAME, dependencyType, SCHEMA_PATH, todo);

    DependenciesBean bean = relationServiceClient.getDependencies(PATH + RES_NAME);
    assertTrue(
        dependencyType.equalsIgnoreCase(bean.getAssociationBeans()[0].getAssociationType()),
        "Dependency type is not correct");

    assertTrue(
        SCHEMA_PATH.equalsIgnoreCase(bean.getAssociationBeans()[0].getDestinationPath()),
        "Target dependency is not correct");

    assertTrue(
        (PATH + RES_NAME).equalsIgnoreCase(bean.getAssociationBeans()[0].getSourcePath()),
        "Source dependency is not correct");

    // remove dependency
    relationServiceClient.addAssociation(PATH + RES_NAME, dependencyType, SCHEMA_PATH, "remove");
  }
  @Test(groups = "wso2.greg", dependsOnMethods = "testAddDependencyFromOwnCollection")
  public void testAddWsdlAsADependency()
      throws MalformedURLException, ResourceAdminServiceExceptionException, RemoteException,
          AddAssociationRegistryExceptionException, XPathExpressionException {
    String resourcePath =
        FrameworkPathUtil.getSystemResourceLocation()
            + "artifacts"
            + File.separator
            + "GREG"
            + File.separator
            + "wsdl"
            + File.separator
            + "AmazonWebServices.wsdl";
    DataHandler dh = new DataHandler(new URL("file:///" + resourcePath));
    resourceAdminClient.addResource(
        ROOT + "AmazonWebServices.wsdl", "application/wsdl+xml", "testDesc", dh);
    assertTrue(
        resourceAdminClient
            .getResource(WSDL_PATH)[0]
            .getAuthorUserName()
            .contains(automationContext.getContextTenant().getContextUser().getUserName()),
        "WSDL has not been added");

    String dependencyType = "depends";
    String todo = "add";

    relationServiceClient.addAssociation(PATH + RES_NAME, dependencyType, WSDL_PATH, todo);

    DependenciesBean bean = relationServiceClient.getDependencies(PATH + RES_NAME);
    assertTrue(
        dependencyType.equalsIgnoreCase(bean.getAssociationBeans()[0].getAssociationType()),
        "Dependency type is not correct");

    assertTrue(
        WSDL_PATH.equalsIgnoreCase(bean.getAssociationBeans()[0].getDestinationPath()),
        "Target dependency is not correct");

    assertTrue(
        (PATH + RES_NAME).equalsIgnoreCase(bean.getAssociationBeans()[0].getSourcePath()),
        "Source dependency is not correct");

    // remove dependency
    relationServiceClient.addAssociation(PATH + RES_NAME, dependencyType, WSDL_PATH, "remove");
  }
  @Test(groups = "wso2.greg", dependsOnMethods = "testAddDependencyFromParentCollection")
  public void testAddDependencyFromOwnCollection()
      throws AddAssociationRegistryExceptionException, RemoteException {
    String dependencyType = "depends";
    String todo = "add";

    relationServiceClient.addAssociation(PATH + RES_NAME, dependencyType, PATH, todo);

    DependenciesBean bean = relationServiceClient.getDependencies(PATH + RES_NAME);
    assertTrue(
        dependencyType.equalsIgnoreCase(bean.getAssociationBeans()[0].getAssociationType()),
        "Dependency type is not correct");

    assertTrue(
        (PATH.substring(0, PATH.length() - 1))
            .equalsIgnoreCase(bean.getAssociationBeans()[0].getDestinationPath()),
        "Target dependency is not correct");

    assertTrue(
        (PATH + RES_NAME).equalsIgnoreCase(bean.getAssociationBeans()[0].getSourcePath()),
        "Source dependency is not correct");

    relationServiceClient.addAssociation(PATH + RES_NAME, dependencyType, PATH, "remove");
  }
  @Test(groups = "wso2.greg", dependsOnMethods = "testAddDependencyFromChildCollection")
  public void testMoveDependency()
      throws ResourceAdminServiceExceptionException, RemoteException,
          AddAssociationRegistryExceptionException, XPathExpressionException {
    resourceAdminClient.moveResource(PATH, PATH + CHILDS_CHILD_NAME, ROOT, CHILDS_CHILD_NAME);

    String authorUserName =
        resourceAdminClient.getResource(ROOT + CHILDS_CHILD_NAME)[0].getAuthorUserName();
    assertTrue(
        automationContext
            .getContextTenant()
            .getContextUser()
            .getUserName()
            .equalsIgnoreCase(authorUserName),
        "Collection move failure");

    String dependencyType = "depends";

    DependenciesBean bean = relationServiceClient.getDependencies(PATH + RES_NAME);
    assertTrue(
        dependencyType.equalsIgnoreCase(bean.getAssociationBeans()[0].getAssociationType()),
        "Dependency type is not correct");

    assertTrue(
        (ROOT + CHILDS_CHILD_NAME)
            .equalsIgnoreCase(bean.getAssociationBeans()[0].getDestinationPath()),
        "Target dependency is not correct");

    assertTrue(
        (PATH + RES_NAME).equalsIgnoreCase(bean.getAssociationBeans()[0].getSourcePath()),
        "Source dependency is not correct");

    // remove the dependency
    relationServiceClient.addAssociation(
        PATH + RES_NAME, dependencyType, ROOT + CHILDS_CHILD_NAME, "remove");
  }