This is a very interesting problem. The heart of the issue is that Microsoft Project does actually have at least one resource assignment for each task, it's just that when you have no "real" resource assignments, all the work for the task is assigned to a "nobody" resource. If you look in the XML that Microsoft Project has generated, you'll see <Assignment>
tags, with the resource shown as <ResourceUID>-65535</ResourceUID>
, which is the "null" resource (real resources will have a positive integer value here).
In order to modify the file so that the duration of the task increases to 3 days, you'll need to change the Remaining Work attribute of this assignment.
Here is a fragment of code which does that for you:
// Read the sample project
ProjectFile project = new UniversalProjectReader().read("so-duration-question.xml");
// Find the task we want to update
Task task = project.getTaskByID(Integer.valueOf(3));
// With this sample data we know we only have one resource assignment
ResourceAssignment assignment = task.getResourceAssignments().get(0);
// Set remaining work seems to be the driver for MS Project
assignment.setRemainingWork(Duration.getInstance(3, TimeUnit.DAYS));
// Write our modified file
new MSPDIWriter().write(project, "so-duration-answer.xml");
Obviously your real code will need to check what resource assignments actually exist for the task you are modifying.