taskadapter / redmine-java-api

Redmine Java API
Apache License 2.0
270 stars 163 forks source link

Project.addTrackers does not update redmine database #318

Closed javiertuya closed 5 years ago

javiertuya commented 5 years ago

Trackers can be added to a project object, however after calling projectManager.update the new trackers have not been added to Redmine.

It seems that java api tries to add tracker objects, but Redmine api requires an array of tracker ids. Some code to test this, latest assert fails when checking if Redmine has been updated

    @Test
    public void testUpdateTrackers() throws RedmineException {
        Project projectToCreate = generateRandomProject();
        String createdProjectKey = null;
        try {
            Project createdProject = projectManager.createProject(projectToCreate);
            createdProjectKey = createdProject.getIdentifier();
            Collection<Tracker> trackers=createdProject.getTrackers();
            assertEquals("assume redmine is configured with 1-Bug as default tracker", 1, trackers.size());

            Collection<Tracker> newTrackers=new ArrayList<Tracker>();
            newTrackers.add(TrackerFactory.create(2,"Feature"));
            newTrackers.add(TrackerFactory.create(3,"Support"));
            createdProject.addTrackers(newTrackers);
            assertEquals("trackers should be added to bean", 3, createdProject.getTrackers().size());

            projectManager.update(createdProject);
            createdProject=projectManager.getProjectByKey(createdProjectKey);
            assertEquals("trackers should be added to redmine", 3, createdProject.getTrackers().size());
        } finally {
            if (createdProjectKey != null) {
                projectManager.deleteProject(createdProjectKey);
            }
        }
    }