ItEr20S07CUIntroducionAvanceUnidadeTraballoItEr19S12: Extracting equivalence method and moved to AdvanceType
Adding test case that reproduced the error. This way they're more resilient to change.
This commit is contained in:
parent
25f6116ca2
commit
a37285c7e8
2 changed files with 9 additions and 2 deletions
|
|
@ -123,4 +123,10 @@ public class AdvanceType {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static boolean equivalentInDB(AdvanceType type, AdvanceType otherType) {
|
||||
if (type.getId() == null || otherType.getId() == null)
|
||||
return false;
|
||||
return type.getId().equals(otherType.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import java.util.Set;
|
|||
|
||||
import org.hibernate.validator.NotEmpty;
|
||||
import org.navalplanner.business.advance.entities.AdvanceAssigment;
|
||||
import org.navalplanner.business.advance.entities.AdvanceType;
|
||||
import org.navalplanner.business.advance.exceptions.DuplicateAdvanceAssigmentForOrderElementException;
|
||||
import org.navalplanner.business.advance.exceptions.DuplicateValueTrueReportGlobalAdvanceException;
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
|
|
@ -209,8 +210,8 @@ public abstract class OrderElement {
|
|||
throws DuplicateAdvanceAssigmentForOrderElementException {
|
||||
for (AdvanceAssigment advanceAssigment : orderElement
|
||||
.getAdvanceAssigments()) {
|
||||
if (advanceAssigment.getAdvanceType().getId().equals(
|
||||
newAdvanceAssigment.getAdvanceType().getId())) {
|
||||
if (AdvanceType.equivalentInDB(advanceAssigment.getAdvanceType(),
|
||||
newAdvanceAssigment.getAdvanceType())) {
|
||||
throw new DuplicateAdvanceAssigmentForOrderElementException(
|
||||
"Duplicate Advance Assigment For Order Element", this,
|
||||
OrderElement.class);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue