Skip to content

Commit 60edf7f

Browse files
RajeshGovosanjuktaghosh7Manvendra-P-Singhhimanshupr2627
authored
Test drive v3 appdata snippets (googleworkspace#240)
* git-on-borg files of gmail-api-snippets * Update build.gradle test12 * Update build.gradle * Drive-v3: AppData snippets UnitTest Co-authored-by: sanjuktaghosh7 <sanjuktaghosh@google.com> Co-authored-by: Manvendra-P-Singh <singhmanvendra@google.com> Co-authored-by: himanshupr2627 <himanshupr@google.com>
1 parent 5bb5996 commit 60edf7f

6 files changed

Lines changed: 95 additions & 3 deletions

File tree

drive/snippets/drive_v2/src/main/java/FetchAppDataFolder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class FetchAppDataFolder {
3838
* Fetches appDataFolder and prints it's folder id.
3939
* @return Application data folder's ID.
4040
*/
41-
public String fetchAppDataFolder() throws IOException {
41+
public static String fetchAppDataFolder() throws IOException {
4242
/*Load pre-authorized user credentials from the environment.
4343
TODO(developer) - See https://developers.google.com/identity for
4444
guides on implementing OAuth2 for your application.*/

drive/snippets/drive_v2/src/main/java/ListAppData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class ListAppData {
3838
* list down files in the application data folder.
3939
* @return list of 10 files.
4040
*/
41-
public FileList listAppData() throws IOException {
41+
public static FileList listAppData() throws IOException {
4242
/*Load pre-authorized user credentials from the environment.
4343
TODO(developer) - See https://developers.google.com/identity for
4444
guides on implementing OAuth2 for your application.*/

drive/snippets/drive_v2/src/main/java/UploadAppData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class UploadAppData {
3737
* Creates a file in the application data folder.
3838
* @return Created file's Id.
3939
*/
40-
private static String uploadAppData() throws IOException {
40+
public static String uploadAppData() throws IOException {
4141
/*Load pre-authorized user credentials from the environment.
4242
TODO(developer) - See https://developers.google.com/identity for
4343
guides on implementing OAuth2 for your application.*/
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import org.junit.Test;
16+
17+
import java.io.IOException;
18+
import java.security.GeneralSecurityException;
19+
20+
import static org.junit.Assert.assertNotNull;
21+
22+
// Unit test class for testing of FetchAppDataFolder snippet
23+
public class TestFetchAppdataFolder {
24+
@Test
25+
public void fetchAppDataFolder() throws IOException, GeneralSecurityException {
26+
String id = FetchAppDataFolder.fetchAppDataFolder();
27+
assertNotNull(id);
28+
}
29+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import com.google.api.services.drive.model.FileList;
16+
import org.junit.Test;
17+
18+
import java.io.IOException;
19+
import java.security.GeneralSecurityException;
20+
21+
import static org.junit.Assert.assertNotEquals;
22+
23+
// Unit test class for testing of ListAppData snippet
24+
public class TestListAppdata extends BaseTest{
25+
@Test
26+
public void listAppData() throws IOException, GeneralSecurityException {
27+
String id = UploadAppData.uploadAppData();
28+
deleteFileOnCleanup(id);
29+
FileList files = ListAppData.listAppData();
30+
assertNotEquals(0, files.getItems().size());
31+
}
32+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import org.junit.Test;
16+
17+
import java.io.IOException;
18+
import java.security.GeneralSecurityException;
19+
20+
import static org.junit.Assert.assertNotNull;
21+
22+
// Unit test class for testing of UploadAppData snippet
23+
public class TestUploadAppdata extends BaseTest{
24+
@Test
25+
public void uploadAppData()
26+
throws IOException, GeneralSecurityException {
27+
String id = UploadAppData.uploadAppData();
28+
assertNotNull(id);
29+
deleteFileOnCleanup(id);
30+
}
31+
}

0 commit comments

Comments
 (0)