@Test public void replacesTaskWithNameAndType() { final Map<String, ?> options = GUtil.map(Task.TASK_NAME, "task", Task.TASK_TYPE, Task.class); final Task task = task("task"); context.checking( new Expectations() { { one(taskFactory).createTask(project, options); will(returnValue(task)); } }); assertThat(container.replace("task", Task.class), sameInstance(task)); }
@Test public void canReplaceDuplicateTask() { addTask("task"); final Task newTask = task("task"); context.checking( new Expectations() { { one(taskFactory).createTask(project, GUtil.map(Task.TASK_NAME, "task")); will(returnValue(newTask)); } }); container.replace("task"); assertThat(container.getByName("task"), sameInstance(newTask)); }