ItEr41S05ValidacionEProbasFuncionaisItEr40S05: Fixing bug of conversion in calendars and test detected in year change.
It is fixed a bug of conversion between the month field in XMLGregorianCalendar and java.util.Calendar detected by change of year. It is also fixed a test which gave CriterionSatisfactions just until 2010; with the year change the satisfactions were not active and the test failed.
This commit is contained in:
parent
db6b8382d4
commit
abe94db641
2 changed files with 17 additions and 3 deletions
|
|
@ -121,10 +121,10 @@ public class ResourceTest {
|
|||
Worker worker = Worker.create("firstName", "surName", "2333232");
|
||||
assertThat(worker.getCurrentCriterionsFor(type).size(), equalTo(0));
|
||||
worker.addSatisfaction(criterionWithItsType, Interval
|
||||
.range(year(2000),year(2010)));
|
||||
.range(year(2000),year(2020)));
|
||||
assertThat(worker.getCurrentCriterionsFor(type).size(), equalTo(1));
|
||||
worker.addSatisfaction(criterionWithItsType, Interval
|
||||
.from(year(2010)));
|
||||
.from(year(2020)));
|
||||
assertThat(worker.getCurrentCriterionsFor(type).size(), equalTo(1));
|
||||
worker.addSatisfaction(otherCriterionWithItsType, Interval
|
||||
.from(year(2000)));
|
||||
|
|
|
|||
|
|
@ -60,7 +60,8 @@ public class DateConverter {
|
|||
dateAsXMLGregorianCalendar =
|
||||
DatatypeFactory.newInstance().newXMLGregorianCalendarDate(
|
||||
dateAsCalendar.get(Calendar.YEAR),
|
||||
dateAsCalendar.get(Calendar.MONTH),
|
||||
convertMonthFieldFromCalendarToXMLGregorianCalendar(
|
||||
dateAsCalendar.get(Calendar.MONTH)),
|
||||
dateAsCalendar.get(Calendar.DAY_OF_MONTH),
|
||||
DatatypeConstants.FIELD_UNDEFINED);
|
||||
} catch (DatatypeConfigurationException e) {
|
||||
|
|
@ -71,6 +72,19 @@ public class DateConverter {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts from @{link Calendar} month field format to
|
||||
* @{link XMLGregorianCalendar} format.
|
||||
*
|
||||
* It is needed the conversion because
|
||||
* @{link XMLGregorianCalendar} months go from 1 to 12 while
|
||||
* @{link Calendar} months go from 0 to 11
|
||||
*
|
||||
*/
|
||||
private final static int convertMonthFieldFromCalendarToXMLGregorianCalendar(int month) {
|
||||
return month+1;
|
||||
}
|
||||
|
||||
/**
|
||||
* It converts a <code>XMLGregorianCalendar</code> representing a
|
||||
* <code>xsd:date</code> XML type to a <code>Date</code>.<br/><br/>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue