forked from microsoftgraph/msgraph-sdk-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseCollectionPageTests.java
More file actions
76 lines (64 loc) · 2.43 KB
/
Copy pathBaseCollectionPageTests.java
File metadata and controls
76 lines (64 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package com.microsoft.graph.http;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import org.junit.Before;
import org.junit.Test;
import com.google.gson.JsonObject;
import com.microsoft.graph.core.IBaseClient;
import com.microsoft.graph.core.MockBaseClient;
import com.microsoft.graph.serializer.ISerializer;
import com.microsoft.graph.serializer.MockSerializer;
/**
* Test cases for {@see BaseCollectionPage}
*/
public class BaseCollectionPageTests {
private IRequestBuilder mRequestBuilder;
private static ArrayList<String> list;
private BaseCollectionPage<String, IRequestBuilder> baseCollectionPage;
private String requestUrl = "https://a.b.c/";
@Before
public void setUp() throws Exception {
list = new ArrayList<String>();
list.add("Object1");
list.add("Object2");
list.add("Object3");
IBaseClient mBaseClient = new MockBaseClient();
mRequestBuilder = new MockRequestBuilder(mBaseClient,requestUrl);
baseCollectionPage = new BaseCollectionPage<String, IRequestBuilder>(list,mRequestBuilder) {};
}
@Test
public void testNotNull() {
assertNotNull(baseCollectionPage);
}
@Test
public void testCurrentPage() {
assertEquals(3,baseCollectionPage.getCurrentPage().size());
assertEquals("Object2", baseCollectionPage.getCurrentPage().get(1));
Boolean success = false;
try{
baseCollectionPage.getCurrentPage().remove(1);
}catch (UnsupportedOperationException uEx){
success = true;
}
assertTrue(success);
}
@Test
public void testNextPage() {
assertEquals(mRequestBuilder, baseCollectionPage.getNextPage());
}
@Test
public void testRawObject() {
ISerializer serializer = new MockSerializer(null, null);
JsonObject jsonObject = new JsonObject();
assertNull(baseCollectionPage.getRawObject());
assertNull(baseCollectionPage.getSerializer());
baseCollectionPage.setRawObject(serializer,jsonObject);
assertNotNull(baseCollectionPage.getRawObject());
assertNotNull(baseCollectionPage.getSerializer());
assertEquals(serializer, baseCollectionPage.getSerializer());
assertEquals(jsonObject, baseCollectionPage.getRawObject());
}
}