-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1272 from amihaiemil/1270
#1270 UpdateTaskEstimation implemented and tested
- Loading branch information
Showing
2 changed files
with
92 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
self-core-impl/src/test/java/com/selfxdsd/core/managers/UpdateTaskEstimationTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* Copyright (c) 2020-2021, Self XDSD Contributors | ||
* All rights reserved. | ||
* <p> | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), | ||
* to read the Software only. Permission is hereby NOT GRANTED to use, copy, | ||
* modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
* the Software. | ||
* <p> | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, | ||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | ||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
* POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package com.selfxdsd.core.managers; | ||
|
||
import com.selfxdsd.api.*; | ||
import com.selfxdsd.api.pm.Step; | ||
import org.junit.Test; | ||
import org.mockito.Mockito; | ||
|
||
/** | ||
* Unit tests for {@link UpdateTaskEstimation}. | ||
* @author Mihai Andronache (amihaiemil@gmail.com) | ||
* @version $Id$ | ||
* @since 0.0.96 | ||
*/ | ||
public final class UpdateTaskEstimationTestCase { | ||
|
||
/** | ||
* UpdateTaskEstimation can update the Task's estimation. | ||
*/ | ||
@Test | ||
public void updatesTaskEstimation() { | ||
final Task task = Mockito.mock(Task.class); | ||
|
||
final Event event = Mockito.mock(Event.class); | ||
final Issue issue = Mockito.mock(Issue.class); | ||
Mockito.when(issue.issueId()).thenReturn("1"); | ||
final Estimation estimation = Mockito.mock(Estimation.class); | ||
Mockito.when(estimation.minutes()).thenReturn(125); | ||
Mockito.when(issue.estimation()).thenReturn(estimation); | ||
Mockito.when(event.issue()).thenReturn(issue); | ||
|
||
final Tasks tasks = Mockito.mock(Tasks.class); | ||
Mockito.when( | ||
tasks.getById("1", "john/test", "github", Boolean.FALSE) | ||
).thenReturn(task); | ||
final Project project = Mockito.mock(Project.class); | ||
Mockito.when(project.repoFullName()).thenReturn("john/test"); | ||
Mockito.when(project.provider()).thenReturn("github"); | ||
Mockito.when(project.tasks()).thenReturn(tasks); | ||
Mockito.when(event.project()).thenReturn(project); | ||
|
||
final Step next = Mockito.mock(Step.class); | ||
final Step update = new UpdateTaskEstimation(next); | ||
update.perform(event); | ||
|
||
Mockito.verify(task, Mockito.times(1)).updateEstimation(125); | ||
Mockito.verify(next, Mockito.times(1)).perform(event); | ||
} | ||
} |