/**
   * @throws Exception Expected exception because user is not allowed to promote LC without
   *     permission(ex: using WS)
   */
  @Test(
      groups = "wso2.greg",
      description = "Promote from Commencement to Creation without permission",
      dependsOnMethods = "testDemoteFromCreationAgain",
      expectedExceptions = org.apache.axis2.AxisFault.class)
  public void testPromoteToCreationAgain() throws Exception, GovernanceException {
    lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(absPath);
    boolean isPermitted = false;
    for (String action : lifeCycle.getAvailableActions()[0].getActions()) {
      if (action.equalsIgnoreCase(ACTION_PROMOTE)) {
        isPermitted = true;
      }
    }
    assertFalse(isPermitted, "Allowed to promote without permission");

    lifeCycleAdminServiceClient.invokeAspect(
        absPath,
        LC_NAME,
        ACTION_ITEM_CLICK,
        new String[] {"false", "false", "false", "false", "false", "false"});

    lifeCycleAdminServiceClient.invokeAspect(absPath, LC_NAME, ACTION_PROMOTE, null);

    lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(absPath);

    for (Property prop : lifeCycle.getLifecycleProperties()) {
      if (("registry.lifecycle." + LC_NAME + ".state").equalsIgnoreCase(prop.getKey())) {
        assertNotNull(prop.getValues(), "State Value Not Found");
        assertTrue(prop.getValues()[0].equalsIgnoreCase(LC_STATE0), "Promoted without permission");
      }
    }
  }
  @Test(
      groups = "wso2.greg",
      description = "Promote from Commencement to Creation to Development",
      dependsOnMethods = "testAddLcToService")
  public void testPromoteLC()
      throws RemoteException, CustomLifecyclesChecklistAdminServiceExceptionException,
          LifeCycleManagementServiceExceptionException, RegistryExceptionException {

    lifeCycleAdminServiceClient.invokeAspect(absPath, LC_NAME, ACTION_PROMOTE, null);
    lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(absPath);
    for (Property prop : lifeCycle.getLifecycleProperties()) {
      if (("registry.lifecycle." + LC_NAME + ".state").equalsIgnoreCase(prop.getKey())) {
        assertNotNull(prop.getValues(), "State Value Not Found");
        assertTrue(
            prop.getValues()[0].equalsIgnoreCase(LC_STATE1), "LifeCycle not promoted to Creation");
      }
    }
    lifeCycleAdminServiceClient.invokeAspect(absPath, LC_NAME, ACTION_PROMOTE, null);
    lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(absPath);
    for (Property prop : lifeCycle.getLifecycleProperties()) {
      if (("registry.lifecycle." + LC_NAME + ".state").equalsIgnoreCase(prop.getKey())) {
        assertNotNull(prop.getValues(), "State Value Not Found");
        assertTrue(
            prop.getValues()[0].equalsIgnoreCase(LC_STATE2),
            "LifeCycle not promoted to Development");
      }
    }
  }
  /** @throws Exception */
  @Test(
      groups = "wso2.greg",
      description = "Demote  from Creation with permission",
      dependsOnMethods = "testSetNewUser")
  public void testDemoteFromCreationAgain() throws Exception {
    addRole("archrole", user2Info.getUserNameWithoutDomain());
    lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(absPath);
    boolean isPermitted = false;
    for (String action : lifeCycle.getAvailableActions()[0].getActions()) {
      if (action.equalsIgnoreCase(ACTION_DEMOTE)) {
        isPermitted = true;
      }
    }
    assertTrue(isPermitted, "Not allowed to demote with permission");

    lifeCycleAdminServiceClient.invokeAspect(absPath, LC_NAME, ACTION_DEMOTE, null);
    lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(absPath);

    for (Property prop : lifeCycle.getLifecycleProperties()) {
      if (("registry.lifecycle." + LC_NAME + ".state").equalsIgnoreCase(prop.getKey())) {
        assertNotNull(prop.getValues(), "State Value Not Found");
        assertTrue(
            prop.getValues()[0].equalsIgnoreCase(LC_STATE0),
            "Not promoted to Creation with permission");
      }
    }
  }
Ejemplo n.º 4
0
  //    @Test(groups = {"wso2.greg"}, description = "add lifecycle to service",
  //          dependsOnMethods = {"testCreateLc"})
  public void testAddLC()
      throws RegistryException, CustomLifecyclesChecklistAdminServiceExceptionException,
          RemoteException {
    wsRegistryServiceClient.associateAspect(servicePath, "DiffEnvironmentLC");

    LifecycleBean lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(servicePath);

    Property[] properties = lifeCycle.getLifecycleProperties();

    boolean lcAdded = false;
    for (Property prop : properties) {
      if (prop.getKey().contains("DiffEnvironmentLC")) {
        lcAdded = true;
      }
    }
    Assert.assertTrue(lcAdded);
  }
  /** @throws Exception */
  @Test(
      groups = "wso2.greg",
      description = "Promote from Commencement to Creation",
      dependsOnMethods = "testAddLcToService")
  public void testPromoteToCreation() throws Exception {

    addRole("managerrole", userInfo.getUserNameWithoutDomain());
    lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(absPath);
    boolean isPermitted = false;
    for (String action : lifeCycle.getAvailableActions()[0].getActions()) {
      if (action.equalsIgnoreCase(ACTION_PROMOTE)) {
        isPermitted = true;
      }
    }
    assertTrue(isPermitted, "Not allowed to promote with permission");

    lifeCycleAdminServiceClient.invokeAspect(absPath, LC_NAME, ACTION_PROMOTE, null);

    Service[] services = serviceManager.getAllServices();

    for (Service service : services) {
      String path = service.getPath();
      if (path.contains("IntergalacticService13")) {
        serviceString = path;
      }
    }
    lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(absPath);

    for (Property prop : lifeCycle.getLifecycleProperties()) {
      if (("registry.lifecycle." + LC_NAME + ".state").equalsIgnoreCase(prop.getKey())) {
        assertNotNull(prop.getValues(), "State Value Not Found");
        assertTrue(
            prop.getValues()[0].equalsIgnoreCase(LC_STATE1),
            "Not promoted to Creation with permission");
      }
    }
  }
  /** @throws Exception */
  @Test(
      groups = "wso2.greg",
      description = "Add lifecycle to a service",
      dependsOnMethods = "testSubscribeLCApprovalNeededNotification")
  public void testAddLcToService() throws Exception {

    wsRegistryServiceClient.associateAspect(absPath, LC_NAME);
    lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(absPath);
    Property[] properties = lifeCycle.getLifecycleProperties();
    boolean lcStatus = false;
    for (Property prop : properties) {
      if (prop.getKey().contains(LC_NAME)) {
        lcStatus = true;
      }
    }
    assertTrue(lcStatus, "LifeCycle not added to service");
  }
  @Test(
      groups = "wso2.greg",
      description = "Add lifecycle to a service",
      dependsOnMethods = "testCreateNewLifeCycle")
  public void testAddLcToService()
      throws RegistryException, RemoteException,
          CustomLifecyclesChecklistAdminServiceExceptionException,
          ListMetadataServiceRegistryExceptionException, ResourceAdminServiceExceptionException {

    wsRegistryServiceClient.associateAspect(absPath, LC_NAME);
    lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(absPath);
    Property[] properties = lifeCycle.getLifecycleProperties();
    boolean lcStatus = false;
    for (Property prop : properties) {
      if (prop.getKey().contains(LC_NAME)) {
        lcStatus = true;
      }
    }
    assertTrue(lcStatus, "LifeCycle not added to service");
  }
  /** @throws Exception */
  @Test(
      groups = "wso2.greg",
      description = "Remove LC Transition Event Approval(Untick)",
      dependsOnMethods = "testSubscribeLCApprovalWithdrawnNotification")
  public void testLCTransitionApprovalWithDrawn() throws Exception {

    lifeCycleAdminServiceClient.invokeAspect(
        absPath, LC_NAME, ACTION_VOTE_CLICK, new String[] {"false", "false"});
    lifeCycle = lifeCycleAdminServiceClient.getLifecycleBean(absPath);
    for (Property prop : lifeCycle.getLifecycleApproval()) {
      if (prop.getKey().contains("registry.custom_lifecycle.votes.option")
          && !prop.getKey().contains("permission")) {
        for (String value : prop.getValues()) {
          if (value.startsWith("current")) {
            assertEquals(value, "current:0", "Not Approved");
          }
        }
      }
    }
  }