Package com.taskadapter.redmineapi.bean

Examples of com.taskadapter.redmineapi.bean.Project


   *            content to parse.
   * @return parsed project.
   */
  public static Project parseMinimalProject(JSONObject content)
      throws JSONException {
    final Project result = ProjectFactory.create(JsonInput.getInt(content, "id"));
    result.setIdentifier(JsonInput.getStringOrNull(content, "identifier"));
    result.setName(JsonInput.getStringNotNull(content, "name"));
    return result;
  }
View Full Code Here


   * @param content
   *            content to parse.
   * @return parsed project.
   */
  public static Project parseProject(JSONObject content) throws JSONException {
    final Project result = ProjectFactory.create(JsonInput.getInt(content, "id"));
    result.setIdentifier(JsonInput.getStringOrNull(content, "identifier"));
    result.setName(JsonInput.getStringNotNull(content, "name"));
    result.setDescription(JsonInput
        .getStringOrEmpty(content, "description"));
    result.setHomepage(JsonInput.getStringOrEmpty(content, "homepage"));
    result.setCreatedOn(getDateOrNull(content, "created_on"));
    result.setUpdatedOn(getDateOrNull(content, "updated_on"));
    final JSONObject parentProject = JsonInput.getObjectOrNull(content,
        "parent");
    if (parentProject != null)
      result.setParentId(JsonInput.getInt(parentProject, "id"));
    result.addTrackers(JsonInput.getListOrEmpty(content, "trackers",
        TRACKER_PARSER));
        result.addCustomFields(JsonInput.getListOrEmpty(content, "custom_fields",
                CUSTOM_FIELD_PARSER));
    return result;
  }
View Full Code Here

  private static final String REDMINE_ISSUES = "issue/redmine_issues.json";

  @Test
  public void testParseProject1() throws ParseException, JSONException {
    final String projectString = "{\"project\":{\"created_on\":\"2012/05/11 06:53:21 -0700\",\"updated_on\":\"2012/05/11 06:53:20 -0700\",\"homepage\":\"\",\"trackers\":[{\"name\":\"Bug\",\"id\":1},{\"name\":\"Feature\",\"id\":2},{\"name\":\"Support\",\"id\":3}],\"identifier\":\"test1336744548920\",\"name\":\"test project\",\"id\":6143}}";
    final Project project = RedmineJSONParser.PROJECT_PARSER
        .parse(RedmineJSONParser.getResponseSingleObject(projectString,
            "project"));

    final Project template = ProjectFactory.create(6143);
    template.setIdentifier("test1336744548920");
    template.setName("test project");
    template.setHomepage("");
    template.setCreatedOn(new SimpleDateFormat("dd.MM.yyyy HH:mm:ss Z")
        .parse("11.05.2012 06:53:21 -0700"));
    template.setUpdatedOn(new SimpleDateFormat("dd.MM.yyyy HH:mm:ss Z")
        .parse("11.05.2012 06:53:20 -0700"));
    template.addTrackers(Arrays.asList(TrackerFactory.create(1, "Bug"), TrackerFactory.create(
                2, "Feature"), TrackerFactory.create(3, "Support")));
    template.setDescription("");
    Assert.assertEquals(template, project);
  }
View Full Code Here

  }

  @Test
  public void testParseProjectRedmine() throws IOException, JSONException {
    String json = MyIOUtils.getResourceAsString("project/redmine_project.json");
    Project project = RedmineJSONParser.parseProject(RedmineJSONParser
        .getResponseSingleObject(json, "project"));
    Integer expectedProjectID = 23;
    String expectedName = "test project";
    String expectedKey = "test1295649781087";
    Assert.assertEquals(expectedProjectID, project.getId());
    Assert.assertEquals(expectedName, project.getName());
    Assert.assertEquals(expectedKey, project.getIdentifier());

    Collection<Tracker> trackers = project.getTrackers();
    Assert.assertNotNull("Trackers list must not be NULL", trackers);
    Assert.assertEquals(3, trackers.size());

    Tracker tracker = project.getTrackerByName("Support");
    Assert.assertNotNull("Tracker must be not null", tracker);
    Integer expectedTrackerId = 3;
    Assert.assertEquals("checking id of 'support' tracker",
        expectedTrackerId, tracker.getId());
  }
View Full Code Here

  }

    @Test
    public void testProjectWithCustomField() throws IOException, JSONException {
        String json = MyIOUtils.getResourceAsString("project/redmine_projectWithCustomField.json");
        Project project = RedmineJSONParser.parseProject(RedmineJSONParser
                .getResponseSingleObject(json, "project"));

        Assert.assertEquals(project.getCustomFields().size(), 2);
        String expectedCustomeFieldValue = "Should have a value";
        Assert.assertEquals(expectedCustomeFieldValue, project.getCustomFieldById(1).getValue());
        Assert.assertEquals("", project.getCustomFieldById(6).getValue());
    }
View Full Code Here

  @Test
  public void testParseProjectNoTracker() throws IOException, JSONException {
    String json = MyIOUtils
        .getResourceAsString("project/redmine_project_no_trackers.json");
    Project project = RedmineJSONParser.parseProject(RedmineJSONParser
        .getResponseSingleObject(json, "project"));
    Collection<Tracker> trackers = project.getTrackers();
    assertThat(trackers).isEmpty();
  }
View Full Code Here

    @Test
    public void testVersionWithCustomField() throws IOException, JSONException {
    String json = MyIOUtils
      .getResourceAsString("redmine_versionWithCustomField.json");
    Project version = RedmineJSONParser
      .parseProject(RedmineJSONParser.getResponseSingleObject(json,
        "version"));
 
    Assert.assertEquals(version.getCustomFields().size(), 2);
    String expectedCustomeFieldValue = "Should have a value";
    Assert.assertEquals(expectedCustomeFieldValue, version
      .getCustomFieldById(1).getValue());
    Assert.assertEquals("", version.getCustomFieldById(6).getValue());
    }
View Full Code Here

    /**
     * @return project key
     */
    public static String createProject(RedmineManager mgr) {
        Project testProject = ProjectFactory.create("test project", "test" + Calendar.getInstance().getTimeInMillis());

        String projectKey;
        try {
            Project createdProject = mgr.getProjectManager().createProject(testProject);
            projectKey = createdProject.getIdentifier();
        } catch (Exception e) {
            logger.error("Exception while configuring tests", e);
            throw new RuntimeException(e);
        }
        return projectKey;
View Full Code Here

        }
        return projectKey;
    }

    public static Project createAndReturnProject(ProjectManager mgr) {
        Project testProject = ProjectFactory.create("test project", "test" + Calendar.getInstance().getTimeInMillis());
        try {
            return mgr.createProject(testProject);
        } catch (Exception e) {
            logger.error("Exception while configuring tests", e);
            throw new RuntimeException(e);
View Full Code Here

        Assert.assertEquals("Checking projects number", expectedProjectsNumber, projectsList.size());
    }

    @Test
    public void testProjects1Info() {
        Project aceProject = ProjectFactory.create(15);
        aceProject.setIdentifier("test1295577237142");
        aceProject.setName("test project 15");

        Project projectFromList = findProjectInList(aceProject.getId());
        Assert.assertNotNull("Checking project is loaded", projectFromList);

        // could use project.equals later when it's implemented in the class
        Assert.assertEquals("Checking the loaded project info", aceProject.getId(), projectFromList.getId());
        Assert.assertEquals("Checking the loaded project info", aceProject.getName(), projectFromList.getName());
        Assert.assertEquals("Checking the loaded project info", aceProject.getIdentifier(), projectFromList.getIdentifier());
    }
View Full Code Here

TOP

Related Classes of com.taskadapter.redmineapi.bean.Project

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.