66import com .google .gson .JsonArray ;
77import com .google .gson .JsonElement ;
88import com .google .gson .JsonObject ;
9+ import com .google .gson .JsonPrimitive ;
910import com .microsoft .graph .extensions .DriveItem ;
1011import com .microsoft .graph .extensions .File ;
1112import com .microsoft .graph .extensions .IDirectoryObjectCollectionPage ;
@@ -28,33 +29,22 @@ public class ExcelTests extends AndroidTestCase {
2829 public void setUp ()
2930 {
3031 testBase = new TestBase ();
31- fileId = createTestFile ("_excelTestResourceAndroid.xlsx" );
32-
3332 }
3433
35- public String createTestFile (String fileName )
36- {
37- try {
38- DriveItem excelWorkbook = new DriveItem ();
39- excelWorkbook .name = fileName ;
40- excelWorkbook .file = new File ();
41-
42- DriveItem driveItem = testBase .graphClient .getMe ().getDrive ().getRoot ().getChildren ().buildRequest ().post (excelWorkbook );
43- return driveItem .id ;
44- }
45- catch (GraphServiceException ex ) {
46- // File could not be created successfully
47- }
48- return null ;
49- }
50-
51-
5234 public void testCreateNamedItem () {
53- // JsonObject range = new JsonObject();
54- // range.addProperty("address", "Sheet1!A1");
55- // WorkbookNamedItem item = testBase.graphClient.getMe().getDrive().getItems("015U5LKCVICVSIQ6DKOVELGXD3WAEHMMAI").getWorkbook().getNames().getAdd("named-range", range, "Comment").buildRequest().post();
56- // assertNotNull(item);
57- // assertEquals("named-range", item.name);
35+ JsonObject range = new JsonObject ();
36+ range .addProperty ("address" , "Sheet1!A1" );
37+ WorkbookNamedItem item = testBase .graphClient
38+ .getMe ()
39+ .getDrive ()
40+ .getItems ("015U5LKCVICVSIQ6DKOVELGXD3WAEHMMAI" )
41+ .getWorkbook ()
42+ .getNames ()
43+ .getAdd ("testNamedRange" , new JsonPrimitive ("Sheet1!A1" ), "Comment" )
44+ .buildRequest ()
45+ .post ();
46+ assertNotNull (item );
47+ assertEquals ("testNamedRange" , item .name );
5848 }
5949
6050 public void testGetNamedItems () {
0 commit comments