Skip to content

Commit 6a69bdc

Browse files
committed
Adjust test, ensure deep copy in getCurrentPage()
1 parent fae78ca commit 6a69bdc

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/test/java/com/microsoft/graph/http/BaseCollectionPageTests.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package com.microsoft.graph.http;
22

3+
import static org.junit.jupiter.api.Assertions.*;
34
import static org.mockito.Mockito.mock;
45

5-
import static org.junit.jupiter.api.Assertions.assertEquals;
6-
import static org.junit.jupiter.api.Assertions.assertNotNull;
7-
import static org.junit.jupiter.api.Assertions.assertTrue;
8-
96
import java.util.ArrayList;
107

118
import org.junit.jupiter.api.BeforeEach;
@@ -48,13 +45,11 @@ public void testNotNull() {
4845
public void testCurrentPage() {
4946
assertEquals(3,baseCollectionPage.getCurrentPage().size());
5047
assertEquals("Object2", baseCollectionPage.getCurrentPage().get(1));
51-
Boolean success = false;
52-
try{
53-
baseCollectionPage.getCurrentPage().remove(1);
54-
}catch (UnsupportedOperationException uEx){
55-
success = true;
56-
}
57-
assertTrue(success);
48+
49+
//Test to ensure the returned list from getCurrentPage is a deep copy of baseCollectionPage contents.
50+
ArrayList<String> baseCollectionContentsCopy = (ArrayList<String>) baseCollectionPage.getCurrentPage();
51+
baseCollectionContentsCopy.remove(1);
52+
assertNotEquals(baseCollectionPage.getCurrentPage().size(), baseCollectionContentsCopy.size());
5853
}
5954

6055
@Test

0 commit comments

Comments
 (0)