Skip to content
This repository was archived by the owner on Sep 4, 2020. It is now read-only.

Commit 9b405f5

Browse files
committed
Updates to code to address Peter's feedback for build.gradle, concurrency/DefaultExecutorsTests.java, serializer/CalendarSerializerTests.java, and ISO8601Test.java.
1 parent c6551b3 commit 9b405f5

3 files changed

Lines changed: 27 additions & 21 deletions

File tree

graphsdk/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ android {
2222
buildToolsVersion "23.0.1"
2323

2424
defaultConfig {
25-
minSdkVersion 23
25+
minSdkVersion 15
2626
targetSdkVersion 23
2727
versionCode this.getVersionCode()
2828
versionName this.getVersionName()

graphsdk/src/androidTest/java/com/microsoft/graph/concurrency/DefaultExecutorsTests.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,20 @@ public void testNotNull() {
3131

3232
public void testPerformOnBackground() {
3333
final String expectedLogMessage = "Starting background task, current active count: 0";
34-
final AtomicBoolean success = new AtomicBoolean(false);
35-
final SimpleWaiter simpleWaiter = new SimpleWaiter();
36-
final AtomicReference<CallingState> callingState = new AtomicReference<>(CallingState.Unknown);
34+
final String expectedResult = "test perform on background success";
35+
final ExecutorTestCallback<String> callback = new ExecutorTestCallback<>();
3736

3837
defaultExecutors.performOnBackground(new Runnable() {
3938
@Override
4039
public void run() {
41-
success.set(true);
42-
callingState.set(Looper.getMainLooper().isCurrentThread() ? CallingState.Foreground : CallingState.Background);
43-
simpleWaiter.signal();
40+
callback.success(expectedResult);
4441
}
4542
});
4643

47-
simpleWaiter.waitForSignal();
48-
assertEquals(CallingState.Background, callingState.get());
49-
assertTrue(success.get());
44+
callback._completionWaiter.waitForSignal();
45+
assertEquals(CallingState.Background,callback._callingState.get());
46+
assertTrue(callback._successCalled.get());
47+
assertEquals(expectedResult, callback._successResult.get());
5048
assertEquals(1,mLogger.getLogMessages().size());
5149
assertTrue(mLogger.hasMessage(expectedLogMessage));
5250
}

graphsdk/src/androidTest/java/com/microsoft/graph/serializer/CalendarSerializerTests.java renamed to graphsdk/src/androidTest/java/com/microsoft/graph/serializer/ISO8601Test.java

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,47 @@
11
package com.microsoft.graph.serializer;
22

33
import android.test.AndroidTestCase;
4-
import junit.framework.Assert;
4+
55
import java.util.Calendar;
66
import java.util.Date;
77
import java.util.TimeZone;
88

9-
109
/**
11-
* Test cases for {@see CalendarSerializer}
10+
* Test cases for the {@see ISO8601} class
1211
*/
13-
public class CalendarSerializerTests extends AndroidTestCase {
12+
public class ISO8601Test extends AndroidTestCase {
1413

15-
public void testCalendarSerialize() throws Exception {
14+
/**
15+
* Make sure that dates with and without millis can be converted properly into strings
16+
* @throws Exception If there is an exception during the test
17+
*/
18+
public void testFromDate() throws Exception {
1619
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
1720
final Calendar date = Calendar.getInstance();
1821
date.setTime(new Date(123456789012345L));
19-
Assert.assertEquals("5882-03-11T00:30:12.345Z", CalendarSerializer.serialize(date));
22+
assertEquals("5882-03-11T00:30:12.345Z", CalendarSerializer.serialize(date));
2023

2124
final Calendar dateNoMillis = Calendar.getInstance();
2225
dateNoMillis.setTime(new Date(123456789012000L));
23-
Assert.assertEquals("5882-03-11T00:30:12.000Z", CalendarSerializer.serialize(dateNoMillis));
26+
assertEquals("5882-03-11T00:30:12.000Z", CalendarSerializer.serialize(dateNoMillis));
2427
}
2528

26-
public void testCalendarDeserialize() throws Exception {
29+
/**
30+
* Make sure that dates in string format with and without millis can be converted properly into date objects
31+
* @throws Exception If there is an exception during the test
32+
*/
33+
public void testToDate() throws Exception {
2734
TimeZone.setDefault(TimeZone.getTimeZone("PST"));
2835
final long toTheSecondDate = 123456789012000L;
2936
final Calendar dateToSecond = CalendarSerializer.deserialize("5882-03-11T00:30:12Z");
30-
Assert.assertEquals(toTheSecondDate, dateToSecond.getTimeInMillis());
37+
assertEquals(toTheSecondDate, dateToSecond.getTimeInMillis());
3138

3239
final long toTheMillisecondDate = 123456789012345L;
3340
final Calendar dateToTheMillisecond = CalendarSerializer.deserialize("5882-03-11T00:30:12.345Z");
34-
Assert.assertEquals(toTheMillisecondDate, dateToTheMillisecond.getTimeInMillis());
41+
assertEquals(toTheMillisecondDate, dateToTheMillisecond.getTimeInMillis());
3542

3643
final Calendar dateToTheExtremeMillisecond = CalendarSerializer.deserialize("5882-03-11T00:30:12.3456789Z");
37-
Assert.assertEquals(toTheMillisecondDate, dateToTheExtremeMillisecond.getTimeInMillis());
44+
assertEquals(toTheMillisecondDate, dateToTheExtremeMillisecond.getTimeInMillis());
3845
}
46+
3947
}

0 commit comments

Comments
 (0)