Skip to content

Commit d2a1930

Browse files
committed
Merge pull request OfficeDev#419 from itbw/integer
fix OfficeDev#380 bug with recurrences
2 parents 8055d82 + 3f6798d commit d2a1930

2 files changed

Lines changed: 64 additions & 4 deletions

File tree

src/main/java/microsoft/exchange/webservices/data/property/complex/recurrence/pattern/Recurrence.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ public boolean tryReadElementFromXml(EwsServiceXmlReader reader)
554554
return true;
555555
} else {
556556
if (reader.getLocalName().equals(XmlElementNames.DayOfMonth)) {
557-
this.dayOfMonth = reader.readElementValue(int.class);
557+
this.dayOfMonth = reader.readElementValue(Integer.class);
558558
return true;
559559
} else {
560560
return false;
@@ -583,7 +583,7 @@ public void internalValidate() throws Exception {
583583
* @throws ServiceValidationException the service validation exception
584584
*/
585585
public int getDayOfMonth() throws ServiceValidationException {
586-
return this.getFieldValueOrThrowIfNull(int.class, this.dayOfMonth,
586+
return this.getFieldValueOrThrowIfNull(Integer.class, this.dayOfMonth,
587587
"DayOfMonth");
588588

589589
}
@@ -1367,7 +1367,7 @@ public boolean tryReadElementFromXml(EwsServiceXmlReader reader)
13671367
} else {
13681368
if (reader.getLocalName().equals(XmlElementNames.DayOfMonth)) {
13691369

1370-
this.dayOfMonth = reader.readElementValue(int.class);
1370+
this.dayOfMonth = reader.readElementValue(Integer.class);
13711371
return true;
13721372
} else if (reader.getLocalName().equals(XmlElementNames.Month)) {
13731373

@@ -1432,7 +1432,7 @@ public void setMonth(Month value) {
14321432
*/
14331433
public int getDayOfMonth() throws ServiceValidationException {
14341434

1435-
return this.getFieldValueOrThrowIfNull(int.class, this.dayOfMonth,
1435+
return this.getFieldValueOrThrowIfNull(Integer.class, this.dayOfMonth,
14361436
"DayOfMonth");
14371437

14381438
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* The MIT License Copyright (c) 2012 Microsoft Corporation
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
5+
* associated documentation files (the "Software"), to deal in the Software without restriction,
6+
* including without limitation the rights to use, copy, modify, merge, publish, distribute,
7+
* sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
8+
* furnished to do so, subject to the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included in all copies or
11+
* substantial portions of the Software.
12+
*
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
14+
* NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16+
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18+
*/
19+
20+
package microsoft.exchange.webservices.data.property.complex;
21+
22+
import static org.junit.Assert.assertEquals;
23+
import static org.mockito.Mockito.doReturn;
24+
import microsoft.exchange.webservices.data.core.EwsServiceXmlReader;
25+
import microsoft.exchange.webservices.data.core.XmlElementNames;
26+
import microsoft.exchange.webservices.data.property.complex.recurrence.pattern.Recurrence.MonthlyPattern;
27+
import microsoft.exchange.webservices.data.property.complex.recurrence.pattern.Recurrence.YearlyPattern;
28+
29+
import org.junit.Test;
30+
import org.mockito.Mockito;
31+
32+
public class RecurrenceReaderTest {
33+
34+
@Test
35+
public void testMonthlyPattern() throws Exception {
36+
37+
EwsServiceXmlReader reader = Mockito.mock(EwsServiceXmlReader.class);
38+
doReturn(XmlElementNames.DayOfMonth).when(reader).getLocalName();
39+
doReturn(1).when(reader).readElementValue(Integer.class);
40+
41+
MonthlyPattern monthly = new MonthlyPattern();
42+
monthly.tryReadElementFromXml(reader);
43+
44+
assertEquals(1, monthly.getDayOfMonth());
45+
}
46+
47+
@Test
48+
public void testYearlyPattern() throws Exception {
49+
50+
EwsServiceXmlReader reader = Mockito.mock(EwsServiceXmlReader.class);
51+
doReturn(XmlElementNames.DayOfMonth).when(reader).getLocalName();
52+
doReturn(1).when(reader).readElementValue(Integer.class);
53+
54+
YearlyPattern yearly = new YearlyPattern();
55+
yearly.tryReadElementFromXml(reader);
56+
57+
assertEquals(1, yearly.getDayOfMonth());
58+
}
59+
60+
}

0 commit comments

Comments
 (0)