public void setConfigAttributes(Object attributes, TaskFactory taskFactory) {
        clear();
        if (attributes == null) {
            return;
        }
        if (taskFactory == null) throw new IllegalArgumentException("ConfigContext cannot be null");
        Map attributeMap = (Map) attributes;
        String taskType = (String) attributeMap.get(TASK_OPTIONS);
        Task task = taskFactory.taskInstanceFor(taskType);
        task.setConfigAttributes(attributeMap.get(taskType), taskFactory);
        add(task);
    }
@Test
    public void shouldSetConfigAttributesForBuiltinTask() throws Exception {
        HashMap attributes = new HashMap();
        attributes.put(Tasks.TASK_OPTIONS, "ant");
        attributes.put("ant", antTaskAttribs("build.xml", "test", "foo"));
        TaskFactory taskFactory = mock(TaskFactory.class);
        AntTask antTask = new AntTask();
        when(taskFactory.taskInstanceFor(antTask.getTaskType())).thenReturn(antTask);
        Tasks tasks = new Tasks();
        Tasks spy = spy(tasks);
        spy.setConfigAttributes(attributes, taskFactory);

        assertThat(spy.size(), is(1));
        assertThat(spy.get(0), is(antTask("build.xml", "test", "foo")));
    }