Skip to content

Commit

Permalink
DirectEditing - use NextcloudClient in test cases
Browse files Browse the repository at this point in the history
Signed-off-by: ZetaTom <70907959+ZetaTom@users.noreply.github.com>
  • Loading branch information
ZetaTom committed Dec 20, 2023
1 parent 5b5eab3 commit ed90690
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> result = new DirectEditingCreateFileRemoteOperation("/test.md",
"text",
"textdocument")
.execute(client);
.execute(nextcloudClient);
assertTrue(result.isSuccess());

String url = result.getResultData();
Expand All @@ -55,7 +55,7 @@ public void createFileFromTemplate() {
"text",
"textdocument",
"1")
.execute(client);
.execute(nextcloudClient);
assertTrue(result.isSuccess());

String url = result.getResultData();
Expand All @@ -69,7 +69,7 @@ public void createFileWithSpecialCharacterFromTemplate() {
"text",
"textdocument",
"1")
.execute(client);
.execute(nextcloudClient);
assertTrue(result.isSuccess());

String url = result.getResultData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TemplateList> 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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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<String> result = new DirectEditingOpenFileRemoteOperation(remotePath, "text")
.execute(nextcloudClient);
assertTrue(result.isSuccess());

String url = (String) result.getSingleData();
String url = result.getResultData();

assertFalse(url.isEmpty());
}
Expand All @@ -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<String> result = new DirectEditingOpenFileRemoteOperation(remotePath, "text")
.execute(nextcloudClient);
assertTrue(result.isSuccess());

String url = (String) result.getSingleData();
String url = result.getResultData();

assertFalse(url.isEmpty());
}
Expand All @@ -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<String> result = new DirectEditingOpenFileRemoteOperation(remotePath, "text")
.execute(nextcloudClient);
assertTrue(result.isSuccess());

String url = (String) result.getSingleData();
String url = result.getResultData();

assertFalse(url.isEmpty());
}
Expand All @@ -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<String> result = new DirectEditingOpenFileRemoteOperation(remotePath, "text")
.execute(nextcloudClient);
assertFalse(result.isSuccess());
}
}

0 comments on commit ed90690

Please sign in to comment.