From ed90690b12c416575ec80cbdb3c88a101895e450 Mon Sep 17 00:00:00 2001 From: ZetaTom <70907959+ZetaTom@users.noreply.github.com> Date: Mon, 11 Dec 2023 12:36:56 +0100 Subject: [PATCH] DirectEditing - use NextcloudClient in test cases Signed-off-by: ZetaTom <70907959+ZetaTom@users.noreply.github.com> --- ...ectEditingCreateFileRemoteOperationIT.java | 12 +++++----- ...btainListOfTemplatesRemoteOperationIT.java | 16 +++++++------ ...irectEditingOpenFileRemoteOperationIT.java | 24 +++++++++++-------- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingCreateFileRemoteOperationIT.java b/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingCreateFileRemoteOperationIT.java index 79a0e9c11d..45f892cbc9 100644 --- a/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingCreateFileRemoteOperationIT.java +++ b/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingCreateFileRemoteOperationIT.java @@ -27,21 +27,21 @@ package com.nextcloud.android.lib.resources.directediting; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import com.owncloud.android.AbstractIT; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import org.junit.Test; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + public class DirectEditingCreateFileRemoteOperationIT extends AbstractIT { @Test public void createEmptyFile() { RemoteOperationResult result = new DirectEditingCreateFileRemoteOperation("/test.md", "text", "textdocument") - .execute(client); + .execute(nextcloudClient); assertTrue(result.isSuccess()); String url = result.getResultData(); @@ -55,7 +55,7 @@ public void createFileFromTemplate() { "text", "textdocument", "1") - .execute(client); + .execute(nextcloudClient); assertTrue(result.isSuccess()); String url = result.getResultData(); @@ -69,7 +69,7 @@ public void createFileWithSpecialCharacterFromTemplate() { "text", "textdocument", "1") - .execute(client); + .execute(nextcloudClient); assertTrue(result.isSuccess()); String url = result.getResultData(); diff --git a/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingObtainListOfTemplatesRemoteOperationIT.java b/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingObtainListOfTemplatesRemoteOperationIT.java index 5bc21ab979..2b83b1fa2a 100644 --- a/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingObtainListOfTemplatesRemoteOperationIT.java +++ b/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingObtainListOfTemplatesRemoteOperationIT.java @@ -27,27 +27,29 @@ package com.nextcloud.android.lib.resources.directediting; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import com.owncloud.android.AbstractIT; import com.owncloud.android.lib.common.TemplateList; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import org.junit.Test; +import java.util.Objects; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + public class DirectEditingObtainListOfTemplatesRemoteOperationIT extends AbstractIT { @Test public void testGetAll() { - RemoteOperationResult result = new DirectEditingObtainListOfTemplatesRemoteOperation("text", + RemoteOperationResult result = new DirectEditingObtainListOfTemplatesRemoteOperation("text", "textdocument") - .execute(client); + .execute(nextcloudClient); assertTrue(result.isSuccess()); TemplateList templateList = (TemplateList) result.getResultData(); - assertEquals("Empty file", templateList.getTemplates().get("empty").getTitle()); - assertEquals("md", templateList.getTemplates().get("empty").getExtension()); + assertEquals("Empty file", Objects.requireNonNull(templateList.getTemplates().get("empty")).getTitle()); + assertEquals("md", Objects.requireNonNull(templateList.getTemplates().get("empty")).getExtension()); } } diff --git a/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingOpenFileRemoteOperationIT.java b/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingOpenFileRemoteOperationIT.java index 4657320bfb..641681c0c8 100644 --- a/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingOpenFileRemoteOperationIT.java +++ b/library/src/androidTest/java/com/nextcloud/android/lib/resources/directediting/DirectEditingOpenFileRemoteOperationIT.java @@ -27,9 +27,6 @@ package com.nextcloud.android.lib.resources.directediting; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import com.owncloud.android.AbstractIT; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation; @@ -41,6 +38,9 @@ import java.io.IOException; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + public class DirectEditingOpenFileRemoteOperationIT extends AbstractIT { @Test public void openFile() throws IOException { @@ -57,10 +57,11 @@ public void openFile() throws IOException { TestCase.assertTrue(new ReadFileRemoteOperation(remotePath).execute(client).isSuccess()); // open file - RemoteOperationResult result = new DirectEditingOpenFileRemoteOperation(remotePath, "text").execute(client); + RemoteOperationResult result = new DirectEditingOpenFileRemoteOperation(remotePath, "text") + .execute(nextcloudClient); assertTrue(result.isSuccess()); - String url = (String) result.getSingleData(); + String url = result.getResultData(); assertFalse(url.isEmpty()); } @@ -80,10 +81,11 @@ public void openFileWithSpecialChars() throws IOException { TestCase.assertTrue(new ReadFileRemoteOperation(remotePath).execute(client).isSuccess()); // open file - RemoteOperationResult result = new DirectEditingOpenFileRemoteOperation(remotePath, "text").execute(client); + RemoteOperationResult result = new DirectEditingOpenFileRemoteOperation(remotePath, "text") + .execute(nextcloudClient); assertTrue(result.isSuccess()); - String url = (String) result.getSingleData(); + String url = result.getResultData(); assertFalse(url.isEmpty()); } @@ -103,10 +105,11 @@ public void openFileWithSpecialChars2() throws IOException { TestCase.assertTrue(new ReadFileRemoteOperation(remotePath).execute(client).isSuccess()); // open file - RemoteOperationResult result = new DirectEditingOpenFileRemoteOperation(remotePath, "text").execute(client); + RemoteOperationResult result = new DirectEditingOpenFileRemoteOperation(remotePath, "text") + .execute(nextcloudClient); assertTrue(result.isSuccess()); - String url = (String) result.getSingleData(); + String url = result.getResultData(); assertFalse(url.isEmpty()); } @@ -118,7 +121,8 @@ public void openNonExistingFile() { TestCase.assertFalse(new ReadFileRemoteOperation(remotePath).execute(client).isSuccess()); // open file - RemoteOperationResult result = new DirectEditingOpenFileRemoteOperation(remotePath, "text").execute(client); + RemoteOperationResult result = new DirectEditingOpenFileRemoteOperation(remotePath, "text") + .execute(nextcloudClient); assertFalse(result.isSuccess()); } }