Skip to content

Commit

Permalink
#1243 Remaining tests for *Tasks update estimation.
Browse files Browse the repository at this point in the history
  • Loading branch information
criske committed Oct 20, 2021
1 parent 91f78db commit 4d62bbc
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
* @author criske
* @version $Id$
* @since 0.0.6
* @todo #1237:30min Write remaining testcases for updating estimation
* in {@link ContributorTasks} and {@link ProjectTasks}.
*/
public final class ContractTasksTestCase {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,51 @@ public void throwsWhenRemovingTaskNotPartOf() {
tasks.remove(task);
}

/**
* Can update task estimation if task is part of ContributorTasks.
*/
@Test
public void canUpdateTaskEstimation(){
final Storage storage = Mockito.mock(Storage.class);
final Task task = Mockito.mock(Task.class);
final Contributor contributor = Mockito.mock(Contributor.class);
final Tasks tasks = new ContributorTasks(
"mihai", "github",
() -> Stream.of(task),
storage
);

Mockito.when(contributor.username()).thenReturn("mihai");
Mockito.when(contributor.provider()).thenReturn("github");
Mockito.when(task.assignee()).thenReturn(contributor);
Mockito.when(storage.tasks()).thenReturn(Mockito.mock(Tasks.class));

tasks.updateEstimation(task, 30);
Mockito.verify(storage.tasks(), Mockito.times(1))
.updateEstimation(task, 30);
}

/**
* Throws Self Exception on update estimation when Task is not part
* of ContributorTasks.
*/
@Test(expected = TasksException.OfContributor.NotFound.class)
public void throwsWhenUpdateEstimationTaskNotPartOfContributorTasks(){
final Task task = Mockito.mock(Task.class);
final Contributor contributor = Mockito.mock(Contributor.class);
final Tasks tasks = new ContributorTasks(
"mihai", "github",
() -> Stream.of(task),
Mockito.mock(Storage.class)
);

Mockito.when(contributor.username()).thenReturn("mihai");
Mockito.when(contributor.provider()).thenReturn("github");
Mockito.when(task.assignee()).thenReturn(contributor);

tasks.updateEstimation(Mockito.mock(Task.class), 30);
}

/**
* Mock an Issue for test.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,58 @@ public void canBeUnassignedIfPartOfProjectTasks(){

}

/**
* An assigned Task part of ProjectTasks can update estimation.
*/
@Test
public void canUpdateEstimationIfPartOfProjectTasks(){
final Storage storage = Mockito.mock(Storage.class);
final Task task = Mockito.mock(Task.class);
final Project project = Mockito.mock(Project.class);
final Tasks tasks = new ProjectTasks(
"john/test", "github",
() -> Stream.of(task),
storage
);

Mockito.when(project.repoFullName()).thenReturn("john/test");
Mockito.when(project.provider()).thenReturn("github");
Mockito.when(task.project()).thenReturn(project);
Mockito.when(storage.tasks()).thenReturn(Mockito.mock(Tasks.class));

tasks.updateEstimation(task, 30);

Mockito.verify(storage.tasks()).updateEstimation(task, 30);

}

/**
* Throws Self Exception on update estimation when Task is not part of
* ProjectTasks.
*/
@Test(expected = TasksException.OfProject.NotFound.class)
public void throwsOnUpdateEstiomationWhenTaskNotPartOfProjectTasks(){
final Task task = Mockito.mock(Task.class);
final Task otherTask = Mockito.mock(Task.class);
final Project project = Mockito.mock(Project.class);
final Project otherProject = Mockito.mock(Project.class);
final Tasks tasks = new ProjectTasks(
"john/test", "github",
() -> Stream.of(task),
Mockito.mock(Storage.class)
);

Mockito.when(project.repoFullName()).thenReturn("john/test");
Mockito.when(project.provider()).thenReturn("github");
Mockito.when(task.project()).thenReturn(project);
Mockito.when(otherProject.repoFullName()).thenReturn("john/test-other");
Mockito.when(otherProject.provider()).thenReturn("github");
Mockito.when(otherTask.project()).thenReturn(otherProject);

tasks.updateEstimation(otherTask, 30);
}


/**
* Can remove a task from storage if task is part of ProjectTasks.
*/
Expand Down

1 comment on commit 4d62bbc

@zoeself
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@criske I've closed the Issues [#1243] since their to-dos disappeared from the code.

The to-dos may have been removed in an earlier commit, but I've found it just now.

Please sign in to comment.