Package com.atlassian.jira.rest.client.domain.input

Examples of com.atlassian.jira.rest.client.domain.input.ComponentInput


    final Iterable<BasicComponent> components = client.getProjectClient().getProject("TST", pm).getComponents();
    assertEquals(2, Iterables.size(components));
    final BasicComponent basicComponent = Iterables.get(components, 0);
    final BasicComponent basicComponent2 = Iterables.get(components, 1);
    final String componentName = "my component";
    final ComponentInput componentInput = new ComponentInput(componentName, "a description", null, null);
    final Component component = client.getComponentClient().createComponent("TST", componentInput, pm);
    assertEquals(componentInput.getName(), component.getName());
    assertEquals(componentInput.getDescription(), component.getDescription());
    assertNull(component.getLead());
    assertProjectHasComponents(basicComponent.getName(), basicComponent2.getName(), componentName);

    client.getComponentClient().removeComponent(basicComponent.getSelf(), null, pm);
    assertProjectHasComponents(basicComponent2.getName(), componentName);
View Full Code Here


  public void testCreateAndRemoveComponentAsUnauthorizedUsers() {
    final Iterable<BasicComponent> components = client.getProjectClient().getProject("TST", pm).getComponents();
    assertEquals(2, Iterables.size(components));
    final BasicComponent basicComponent = Iterables.get(components, 0);

    final ComponentInput componentInput = new ComponentInput("my component", "a description", null, null);
    setUser1();

    final Response.Status expectedForbiddenErrorCode = (doesJiraReturnCorrectErrorCodeForForbiddenOperation()) ? Response.Status.FORBIDDEN : Response.Status.UNAUTHORIZED;
    TestUtil.assertErrorCode(expectedForbiddenErrorCode, "The user wseliga does not have permission to complete this operation.", new Runnable() {
      @Override
      public void run() {
        client.getComponentClient().removeComponent(basicComponent.getSelf(), null, pm);
      }
    });
    TestUtil.assertErrorCode(expectedForbiddenErrorCode, "You cannot edit the configuration of this project.", new Runnable() {
      @Override
      public void run() {
        client.getComponentClient().createComponent("TST", componentInput, pm);
      }
    });

    setAnonymousMode();
    TestUtil.assertErrorCode(Response.Status.NOT_FOUND, IntegrationTestUtil.TESTING_JIRA_5_OR_NEWER ?
                "The component with id 10000 does not exist." : "This user does not have permission to complete this operation.", new Runnable() {
      @Override
      public void run() {
        client.getComponentClient().removeComponent(basicComponent.getSelf(), null, pm);
      }
    });

    if (IntegrationTestUtil.TESTING_JIRA_5_OR_NEWER) {
      TestUtil.assertErrorCode(Response.Status.NOT_FOUND, "No project could be found with key 'TST'.", new Runnable() {
        @Override
        public void run() {
          client.getComponentClient().createComponent("TST", componentInput, pm);
        }
      });
    } else {
      // IMO for anonymous access still Response.Status.UNAUTHORIZED should be returned - JRADEV-7671
      TestUtil.assertErrorCode(expectedForbiddenErrorCode, "You cannot edit the configuration of this project.", new Runnable() {
        @Override
        public void run() {
          client.getComponentClient().createComponent("TST", componentInput, pm);
        }
      });
    }


    setAdmin();
    // now let's try to add a component with colliding name
    final ComponentInput dupeComponentInput = new ComponentInput(basicComponent.getName(), "a description", null, null);
    TestUtil.assertErrorCode(Response.Status.BAD_REQUEST, "A component with the name Component A already exists in this project.", new Runnable() {
      @Override
      public void run() {
        client.getComponentClient().createComponent("TST", dupeComponentInput, pm);
      }
View Full Code Here

  @SuppressWarnings({"ConstantConditions"})
  @Test
  @JiraBuildNumberDependent(BN_JIRA_4_4)
  public void testCreateComponentWithLead() {
    final ComponentInput componentInput = new ComponentInput("my component name", "a description", "admin", AssigneeType.COMPONENT_LEAD);
    final Component component = client.getComponentClient().createComponent("TST", componentInput, pm);
    assertNotNull(component.getAssigneeInfo());
    assertEquals(IntegrationTestUtil.USER_ADMIN_LATEST, component.getAssigneeInfo().getAssignee());
    assertEquals(AssigneeType.COMPONENT_LEAD, component.getAssigneeInfo().getAssigneeType());
    assertTrue(component.getAssigneeInfo().isAssigneeTypeValid());
    assertEquals(IntegrationTestUtil.USER_ADMIN_LATEST, component.getAssigneeInfo().getRealAssignee());
    assertEquals(AssigneeType.COMPONENT_LEAD, component.getAssigneeInfo().getRealAssigneeType());

    final ComponentInput componentInput2 = new ComponentInput("my component name2", "a description", IntegrationTestUtil.USER1.getName(), AssigneeType.UNASSIGNED);
    final Component component2 = client.getComponentClient().createComponent("TST", componentInput2, pm);
    assertNotNull(component2.getAssigneeInfo());
    assertNull(component2.getAssigneeInfo().getAssignee());
    assertEquals(AssigneeType.UNASSIGNED, component2.getAssigneeInfo().getAssigneeType());
    assertFalse(component2.getAssigneeInfo().isAssigneeTypeValid());
View Full Code Here

    final BasicComponent basicComponent = Iterables.get(client.getProjectClient().getProject("TST", pm).getComponents(), 0);
    final Component component = client.getComponentClient().getComponent(basicComponent.getSelf(), pm);
    final String newName = basicComponent.getName() + "updated";
    Component adjustedComponent = new Component(component.getSelf(), component.getId(), newName, component.getDescription(), component.getLead(), component.getAssigneeInfo());

    Component updatedComponent = client.getComponentClient().updateComponent(basicComponent.getSelf(), new ComponentInput(newName, null, null, null), pm);
    assertEquals(adjustedComponent, updatedComponent);
    assertEquals(adjustedComponent, client.getComponentClient().getComponent(basicComponent.getSelf(), pm));

    final String newDescription = "updated description";
    adjustedComponent = new Component(component.getSelf(), component.getId(), newName, newDescription, IntegrationTestUtil.USER1_LATEST, component.getAssigneeInfo());
    updatedComponent = client.getComponentClient().updateComponent(basicComponent.getSelf(), new ComponentInput(null, newDescription, IntegrationTestUtil.USER1.getName(), null), pm);
    assertEquals(adjustedComponent, updatedComponent);

    adjustedComponent = new Component(component.getSelf(), component.getId(), newName, newDescription, IntegrationTestUtil.USER1_LATEST,
        new Component.AssigneeInfo(IntegrationTestUtil.USER1_LATEST, AssigneeType.COMPONENT_LEAD, IntegrationTestUtil.USER1_LATEST, AssigneeType.COMPONENT_LEAD, true));

    updatedComponent = client.getComponentClient().updateComponent(basicComponent.getSelf(), new ComponentInput(null, newDescription, IntegrationTestUtil.USER1.getName(), AssigneeType.COMPONENT_LEAD), pm);
    assertEquals(adjustedComponent, updatedComponent);


    // now with non-assignable assignee (thus we are inheriting assignee from project settings and component-level settings are ignored)
    adjustedComponent = new Component(component.getSelf(), component.getId(), newName, newDescription, IntegrationTestUtil.USER2_LATEST,
        new Component.AssigneeInfo(IntegrationTestUtil.USER2_LATEST, AssigneeType.COMPONENT_LEAD, IntegrationTestUtil.USER_ADMIN_LATEST, AssigneeType.PROJECT_DEFAULT, false));

    updatedComponent = client.getComponentClient().updateComponent(basicComponent.getSelf(), new ComponentInput(null, newDescription, IntegrationTestUtil.USER2.getName(), AssigneeType.COMPONENT_LEAD), pm);
    assertEquals(adjustedComponent, updatedComponent);

  }
View Full Code Here

  @Test
  @JiraBuildNumberDependent(BN_JIRA_4_4)
  public void testGetComponentRelatedIssuesCount() {
    final BasicComponent bc = findEntityByName(client.getProjectClient().getProject("TST", pm).getComponents(), "Component A");
    assertEquals(1, client.getComponentClient().getComponentRelatedIssuesCount(bc.getSelf(), pm));
    final ComponentInput componentInput = new ComponentInput("my component name", "a description", "admin", AssigneeType.COMPONENT_LEAD);
    final Component component = client.getComponentClient().createComponent("TST", componentInput, pm);
    assertEquals(0, client.getComponentClient().getComponentRelatedIssuesCount(component.getSelf(), pm));

    client.getComponentClient().removeComponent(bc.getSelf(), component.getSelf(), pm);
    assertEquals(1, client.getComponentClient().getComponentRelatedIssuesCount(component.getSelf(), pm));
View Full Code Here

TOP

Related Classes of com.atlassian.jira.rest.client.domain.input.ComponentInput

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.