-
-
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 #1266 from amihaiemil/1265
#1265 started refactoring of estimation update to use Steps
- Loading branch information
Showing
4 changed files
with
155 additions
and
35 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
self-core-impl/src/main/java/com/selfxdsd/core/managers/IssueEstimationChanged.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,72 @@ | ||
package com.selfxdsd.core.managers; | ||
|
||
import com.selfxdsd.api.Event; | ||
import com.selfxdsd.api.Issue; | ||
import com.selfxdsd.api.Project; | ||
import com.selfxdsd.api.Task; | ||
import com.selfxdsd.api.pm.PreconditionCheck; | ||
import com.selfxdsd.api.pm.Step; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Step which checks if an Issue's estimation has been changed. | ||
* @author Mihai Andronache (amihaiemil@gmail.com) | ||
* @version $Id$ | ||
* @since 0.0.96 | ||
* @todo #1265:30min Write some unit tests for this class. | ||
*/ | ||
public final class IssueEstimationChanged extends PreconditionCheck { | ||
|
||
/** | ||
* Logger. | ||
*/ | ||
private static final Logger LOG = LoggerFactory.getLogger( | ||
IssueEstimationChanged.class | ||
); | ||
|
||
/** | ||
* Ctor. | ||
* @param onTrue Step that should be performed next if the check is true. | ||
* @param onFalse Step that should be performed next if the check is false. | ||
*/ | ||
public IssueEstimationChanged(final Step onTrue, final Step onFalse) { | ||
super(onTrue, onFalse); | ||
} | ||
|
||
@Override | ||
public void perform(final Event event) { | ||
final Issue issue = event.issue(); | ||
final String issueId = issue.issueId(); | ||
final Project project = event.project(); | ||
final Task task = project.tasks().getById( | ||
issueId, | ||
project.repoFullName(), | ||
project.provider(), | ||
issue.isPullRequest() | ||
); | ||
final int oldEstimation = task.estimation(); | ||
final int newEstimation = issue.estimation().minutes(); | ||
if (oldEstimation != newEstimation) { | ||
LOG.debug(String.format( | ||
"The estimation of Issue [#%s-%s-%s] has changed from %s min. " | ||
+ "to %s min.", | ||
issue.issueId(), | ||
issue.repoFullName(), | ||
issue.provider(), | ||
oldEstimation, | ||
newEstimation | ||
)); | ||
this.onTrue().perform(event); | ||
} else { | ||
LOG.debug(String.format( | ||
"The estimation of Issue [#%s-%s-%s] was NOT changed.", | ||
issue.issueId(), | ||
issue.repoFullName(), | ||
issue.provider() | ||
)); | ||
this.onFalse().perform(event); | ||
} | ||
|
||
} | ||
} |
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
60 changes: 60 additions & 0 deletions
60
self-core-impl/src/main/java/com/selfxdsd/core/managers/UpdateTaskEstimation.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,60 @@ | ||
/** | ||
* 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.Event; | ||
import com.selfxdsd.api.pm.Intermediary; | ||
import com.selfxdsd.api.pm.Step; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Step which updates a Task's estimation. | ||
* @author Mihai Andronache (amihaiemil@gmail.com) | ||
* @version $Id$ | ||
* @since 0.0.96 | ||
* @todo #1265:60min Implement and test the method perform from this class. | ||
* It should simply update a task's estimation and forward to the next step. | ||
*/ | ||
public final class UpdateTaskEstimation extends Intermediary { | ||
|
||
/** | ||
* Logger. | ||
*/ | ||
private static final Logger LOG = LoggerFactory.getLogger( | ||
UpdateTaskEstimation.class | ||
); | ||
|
||
/** | ||
* Ctor. | ||
* @param next The next step to perform. | ||
*/ | ||
public UpdateTaskEstimation(final Step next) { | ||
super(next); | ||
} | ||
|
||
@Override | ||
public void perform(final Event event) { | ||
throw new UnsupportedOperationException("Not yet implemented."); | ||
} | ||
} |
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