Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: tobiasKaminsky <[email protected]>
  • Loading branch information
tobiasKaminsky committed May 20, 2022
1 parent 2c44e87 commit 1f03609
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class UnifiedSearchRemoteOperationIT : AbstractIT() {
@Test
fun filesSearch() {
val remotePath = "/testFolder"
assertTrue(CreateFolderRemoteOperation(remotePath, true).execute(client).isSuccess)
assertTrue(CreateFolderRemoteOperation(remotePath, true).execute(nextcloudClient).isSuccess)
val remoteFile = ReadFileRemoteOperation(remotePath)
.execute(client).data[0] as RemoteFile
val fileId = remoteFile.localId
Expand All @@ -80,7 +80,12 @@ class UnifiedSearchRemoteOperationIT : AbstractIT() {

@Test
fun filesSearchWhitespace() {
assertTrue(CreateFolderRemoteOperation("/test Folder/", true).execute(client).isSuccess)
assertTrue(
CreateFolderRemoteOperation(
"/test Folder/",
true
).execute(nextcloudClient).isSuccess
)

val result = UnifiedSearchRemoteOperation("files", "test").execute(nextcloudClient)
assertTrue(result.isSuccess)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void getEditLinkForRoot() {
public void getEditLinkForFolder() {
String path = "/workspace/sub1/";

assertTrue(new CreateFolderRemoteOperation(path, true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation(path, true).execute(nextcloudClient).isSuccess());

RemoteOperationResult result = new RichWorkspaceDirectEditingRemoteOperation(path).execute(client);
assertTrue(result.isSuccess());
Expand All @@ -70,7 +70,7 @@ public void reuseExistingFile() throws IOException {
String filePath = folder + "Readme.md";
File txtFile = getFile(ASSETS__TEXT_FILE_NAME);

assertTrue(new CreateFolderRemoteOperation(folder, true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation(folder, true).execute(nextcloudClient).isSuccess());

RemoteOperationResult uploadResult = new UploadFileRemoteOperation(txtFile.getAbsolutePath(),
filePath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ class GetActivitiesRemoteOperationIT : AbstractIT() {
@Test
fun getActivities() {
// set-up, create a folder so there is an activity
assertTrue(CreateFolderRemoteOperation("/test/123/1", true).execute(client).isSuccess)
assertTrue(
CreateFolderRemoteOperation(
"/test/123/1",
true
).execute(nextcloudClient).isSuccess
)

val result = nextcloudClient.execute(GetActivitiesRemoteOperation())
assertTrue(result.isSuccess)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
*/
package com.owncloud.android;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

import android.util.Log;

import com.owncloud.android.lib.common.operations.RemoteOperationResult;
Expand All @@ -42,10 +46,6 @@

import java.io.File;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

/**
* Class to test CopyRemoteFileOperation
*/
Expand Down Expand Up @@ -180,7 +180,7 @@ public void createFixtures() throws Exception {

RemoteOperationResult result;
for (String folderPath : FOLDERS_IN_FIXTURE) {
result = new CreateFolderRemoteOperation(folderPath, true).execute(client);
result = new CreateFolderRemoteOperation(folderPath, true).execute(nextcloudClient);

assertTrue("Error creating folder" + folderPath + ": " + result, result.isSuccess());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
*/
package com.owncloud.android;

import static org.junit.Assert.assertTrue;

import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation;
import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
Expand All @@ -39,8 +41,6 @@
import java.util.Iterator;
import java.util.List;

import static org.junit.Assert.assertTrue;

/**
* Class to test Create Folder Operation
*/
Expand Down Expand Up @@ -70,13 +70,13 @@ public void setUp() {
public void testCreateFolder() {
String remotePath = mFullPath2FolderBase;
mCreatedFolderPaths.add(remotePath);
RemoteOperationResult result = new CreateFolderRemoteOperation(remotePath, true).execute(client);
RemoteOperationResult result = new CreateFolderRemoteOperation(remotePath, true).execute(nextcloudClient);
assertTrue(result.isSuccess());

// Create Subfolder
remotePath = mFullPath2FolderBase + FOLDER_PATH_BASE;
mCreatedFolderPaths.add(remotePath);
result = new CreateFolderRemoteOperation(remotePath, true).execute(client);
result = new CreateFolderRemoteOperation(remotePath, true).execute(nextcloudClient);
assertTrue(result.isSuccess());
}

Expand All @@ -87,31 +87,31 @@ public void testCreateFolder() {
@Test
public void testCreateFolderSpecialCharactersOnNewVersion() {
String remotePath = mFullPath2FolderBase + "_<";
RemoteOperationResult result = new CreateFolderRemoteOperation(remotePath, true).execute(client);
RemoteOperationResult result = new CreateFolderRemoteOperation(remotePath, true).execute(nextcloudClient);
assertTrue("Remote path: " + remotePath, result.isSuccess());

remotePath = mFullPath2FolderBase + "_>";
result = new CreateFolderRemoteOperation(remotePath, true).execute(client);
result = new CreateFolderRemoteOperation(remotePath, true).execute(nextcloudClient);
assertTrue("Remote path: " + remotePath, result.isSuccess());

remotePath = mFullPath2FolderBase + "_:";
result = new CreateFolderRemoteOperation(remotePath, true).execute(client);
result = new CreateFolderRemoteOperation(remotePath, true).execute(nextcloudClient);
assertTrue("Remote path: " + remotePath, result.isSuccess());

remotePath = mFullPath2FolderBase + "_\"";
result = new CreateFolderRemoteOperation(remotePath, true).execute(client);
result = new CreateFolderRemoteOperation(remotePath, true).execute(nextcloudClient);
assertTrue("Remote path: " + remotePath, result.isSuccess());

remotePath = mFullPath2FolderBase + "_|";
result = new CreateFolderRemoteOperation(remotePath, true).execute(client);
result = new CreateFolderRemoteOperation(remotePath, true).execute(nextcloudClient);
assertTrue("Remote path: " + remotePath, result.isSuccess());

remotePath = mFullPath2FolderBase + "_?";
result = new CreateFolderRemoteOperation(remotePath, true).execute(client);
result = new CreateFolderRemoteOperation(remotePath, true).execute(nextcloudClient);
assertTrue("Remote path: " + remotePath, result.isSuccess());

remotePath = mFullPath2FolderBase + "_*";
result = new CreateFolderRemoteOperation(remotePath, true).execute(client);
result = new CreateFolderRemoteOperation(remotePath, true).execute(nextcloudClient);
assertTrue("Remote path: " + remotePath, result.isSuccess());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void setUp() throws Exception {
mFullPath2Folder = baseFolderPath + FOLDER_PATH;
mFullPath2File = baseFolderPath + FILE_PATH;

RemoteOperationResult result = new CreateFolderRemoteOperation(mFullPath2Folder, true).execute(client);
RemoteOperationResult result = new CreateFolderRemoteOperation(mFullPath2Folder, true).execute(nextcloudClient);
assertTrue("Error creating folder" + mFullPath2Folder + ": " + result, result.isSuccess());

File textFile = getFile(ASSETS__TEXT_FILE_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@
public class GetSharesIT extends AbstractIT {
@Test
public void testGetShares() {
assertTrue(new CreateFolderRemoteOperation("/1/", true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/1/", true).execute(nextcloudClient).isSuccess());
assertTrue(new CreateShareRemoteOperation("/1/",
ShareType.PUBLIC_LINK,
"",
false,
"",
1).execute(client).isSuccess());

assertTrue(new CreateFolderRemoteOperation("/2/", true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/2/", true).execute(nextcloudClient).isSuccess());
assertTrue(new CreateShareRemoteOperation("/2/",
ShareType.PUBLIC_LINK,
"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void uploadAndModify() {

// create folder
String folder = "/" + RandomString.make(20) + "/";
assertTrue(new CreateFolderRemoteOperation(folder, true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation(folder, true).execute(nextcloudClient).isSuccess());
RemoteFile remoteFolder = (RemoteFile) new ReadFileRemoteOperation(folder).execute(client).getSingleData();

assertNotNull(remoteFolder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ReadFileRemoteOperationIT : AbstractIT() {
fun readRemoteFolder() {
val remotePath = "/test/"

assertTrue(CreateFolderRemoteOperation(remotePath, true).execute(client).isSuccess)
assertTrue(CreateFolderRemoteOperation(remotePath, true).execute(nextcloudClient).isSuccess)

val result = ReadFileRemoteOperation(remotePath).execute(client)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ReadFolderRemoteOperationIT : AbstractIT() {
fun readRemoteFolderWithContent() {
val remotePath = "/test/"

assertTrue(CreateFolderRemoteOperation(remotePath, true).execute(client).isSuccess)
assertTrue(CreateFolderRemoteOperation(remotePath, true).execute(nextcloudClient).isSuccess)

// create file
val filePath = createFile("text")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void testSearchByFileIdEmpty() {

@Test
public void testSearchByFileIdSuccess() {
assertTrue(new CreateFolderRemoteOperation("/test/", true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/test/", true).execute(nextcloudClient).isSuccess());

RemoteOperationResult readFile = new ReadFileRemoteOperation("/test/").execute(client);
assertTrue(readFile.isSuccess());
Expand Down Expand Up @@ -164,7 +164,7 @@ public void oneFavorite() {
String path = "/testFolder/";

// create folder, make it favorite
new CreateFolderRemoteOperation(path, true).execute(client);
new CreateFolderRemoteOperation(path, true).execute(nextcloudClient);
assertTrue(new ToggleFavoriteRemoteOperation(true, path).execute(client).isSuccess());

SearchRemoteOperation sut = new SearchRemoteOperation("",
Expand Down Expand Up @@ -413,7 +413,7 @@ public void showOnlyFolders() throws IOException {
assertTrue(result.isSuccess());
assertTrue(result.getResultData().isEmpty());

assertTrue(new CreateFolderRemoteOperation("/folder/", false).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/folder/", false).execute(nextcloudClient).isSuccess());

result = sut.execute(client);
assertTrue(result.isSuccess());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import androidx.test.platform.app.InstrumentationRegistry;

import com.nextcloud.common.NextcloudClient;
import com.owncloud.android.AbstractIT;
import com.owncloud.android.lib.common.OwnCloudBasicCredentials;
import com.owncloud.android.lib.common.OwnCloudClient;
Expand All @@ -47,15 +48,17 @@

import java.util.List;

import okhttp3.Credentials;

public class GetSharesRemoteOperationIT extends AbstractIT {
@Test
public void searchSharedFiles() {
assertTrue(new CreateFolderRemoteOperation("/shareToAdmin/", true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/shareToGroup/", true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/shareViaLink/", true).execute(client).isSuccess());
// assertTrue(new CreateFolderRemoteOperation("/shareViaMail/", true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/noShare/", true).execute(client).isSuccess());
//assertTrue(new CreateFolderRemoteOperation("/shareToCircle/", true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/shareToAdmin/", true).execute(nextcloudClient).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/shareToGroup/", true).execute(nextcloudClient).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/shareViaLink/", true).execute(nextcloudClient).isSuccess());
// assertTrue(new CreateFolderRemoteOperation("/shareViaMail/", true).execute(nextcloudClient).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/noShare/", true).execute(nextcloudClient).isSuccess());
//assertTrue(new CreateFolderRemoteOperation("/shareToCircle/", true).execute(nextcloudClient).isSuccess());

GetSharesRemoteOperation sut = new GetSharesRemoteOperation();

Expand Down Expand Up @@ -180,7 +183,7 @@ public void sharedWithMe() {


// share folder to user "admin"
assertTrue(new CreateFolderRemoteOperation("/shareToAdmin/", true).execute(client).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/shareToAdmin/", true).execute(nextcloudClient).isSuccess());
assertTrue(new CreateShareRemoteOperation("/shareToAdmin/",
ShareType.USER,
"admin",
Expand All @@ -206,8 +209,14 @@ public void sharedWithMe() {
clientUser1.setCredentials(new OwnCloudBasicCredentials(loginName, password));
clientUser1.setUserId(loginName); // for test same as userId

NextcloudClient nextcloudClient1 = new NextcloudClient(
url,
loginName,
Credentials.basic(loginName, password),
context);

// share folder to previous user
assertTrue(new CreateFolderRemoteOperation("/shareToUser/", true).execute(clientUser1).isSuccess());
assertTrue(new CreateFolderRemoteOperation("/shareToUser/", true).execute(nextcloudClient1).isSuccess());
assertTrue(new CreateShareRemoteOperation("/shareToUser/",
ShareType.USER,
client.getCredentials().getUsername(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,12 @@ class UpdateShareRemoteOperationIT : AbstractIT() {
}

private fun testUpdateNote(note: String) {
Assert.assertTrue(CreateFolderRemoteOperation("/note/", true).execute(client).isSuccess)
Assert.assertTrue(
CreateFolderRemoteOperation(
"/note/",
true
).execute(nextcloudClient).isSuccess
)

// share folder to user "admin"
val createOperationResult = CreateShareRemoteOperation(
Expand Down Expand Up @@ -96,7 +101,12 @@ class UpdateShareRemoteOperationIT : AbstractIT() {
@Test
fun updateLabel() {
val label = "test & test"
Assert.assertTrue(CreateFolderRemoteOperation("/label/", true).execute(client).isSuccess)
Assert.assertTrue(
CreateFolderRemoteOperation(
"/label/",
true
).execute(nextcloudClient).isSuccess
)

// share folder via public link
val createOperationResult = CreateShareRemoteOperation(
Expand Down Expand Up @@ -131,7 +141,12 @@ class UpdateShareRemoteOperationIT : AbstractIT() {
@Test
fun invalidPassword() {
val folder = "/invalidPassword/"
Assert.assertTrue(CreateFolderRemoteOperation(folder, true).execute(client).isSuccess)
Assert.assertTrue(
CreateFolderRemoteOperation(
folder,
true
).execute(nextcloudClient).isSuccess
)

// share folder via public link
val createOperationResult = CreateShareRemoteOperation(
Expand Down Expand Up @@ -178,7 +193,12 @@ class UpdateShareRemoteOperationIT : AbstractIT() {
@Test
fun validPassword() {
val folder = "/validPassword/"
Assert.assertTrue(CreateFolderRemoteOperation(folder, true).execute(client).isSuccess)
Assert.assertTrue(
CreateFolderRemoteOperation(
folder,
true
).execute(nextcloudClient).isSuccess
)

// share folder via public link
val createOperationResult = CreateShareRemoteOperation(
Expand Down

0 comments on commit 1f03609

Please sign in to comment.