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 Sep 4, 2023
1 parent d3924f1 commit 1d9f2fa
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,14 @@ package com.nextcloud.android.lib.resources.groupfolders

import com.owncloud.android.AbstractIT
import com.owncloud.android.lib.resources.status.GetCapabilitiesRemoteOperation
import com.owncloud.android.lib.resources.status.OCCapability
import org.junit.Assert.assertEquals
import org.junit.Assume.assumeTrue
import org.junit.Test

class GetGroupfoldersRemoteOperationIT : AbstractIT() {
@Test
fun getGroupfolders() {
val capability = GetCapabilitiesRemoteOperation().execute(client).singleData as OCCapability

val capability = GetCapabilitiesRemoteOperation().execute(nextcloudClient).resultData
assumeTrue(capability.groupfolders.isTrue)

val map = GetGroupfoldersRemoteOperation().execute(nextcloudClient).resultData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ public static File extractAsset(String fileName, Context context) throws IOExcep

@After
public void after() {
// removeOnClient(client);
// removeOnClient(client2);
removeOnClient(client);
removeOnClient(client2);
}

private void removeOnClient(OwnCloudClient client) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,25 @@ public class GetCapabilitiesIT extends AbstractIT {
@Test
public void testGetRemoteCapabilitiesOperation() {
// get capabilities
RemoteOperationResult result = new GetCapabilitiesRemoteOperation().execute(client);
RemoteOperationResult<OCCapability> result = new GetCapabilitiesRemoteOperation().execute(nextcloudClient);
assertTrue(result.isSuccess());
assertTrue(result.getData() != null && result.getData().size() == 1);

OCCapability capability = (OCCapability) result.getData().get(0);
OCCapability capability = result.getResultData();
checkCapability(capability, client.getUserId());
}

@Test
public void testGetRemoteCapabilitiesOperationEtag() {
// get capabilities
RemoteOperationResult result = new GetCapabilitiesRemoteOperation().execute(client);
RemoteOperationResult<OCCapability> result = new GetCapabilitiesRemoteOperation().execute(nextcloudClient);
assertTrue(result.isSuccess());
assertTrue(result.getData() != null && result.getData().size() == 1);

OCCapability capability = (OCCapability) result.getData().get(0);
OCCapability capability = result.getResultData();

RemoteOperationResult resultEtag = new GetCapabilitiesRemoteOperation(capability).execute(client);
RemoteOperationResult<OCCapability> resultEtag = new GetCapabilitiesRemoteOperation(capability).execute(nextcloudClient);
assertTrue(resultEtag.isSuccess());
assertTrue(resultEtag.getData() != null && resultEtag.getData().size() == 1);

OCCapability sameCapability = (OCCapability) resultEtag.getData().get(0);
OCCapability sameCapability = resultEtag.getResultData();

if (capability.getVersion().isNewerOrEqual(OwnCloudVersion.nextcloud_19)) {
assertEquals(capability, sameCapability);
Expand All @@ -89,28 +86,25 @@ public void testGetRemoteCapabilitiesOperationEtag() {
@Test
public void testGetRemoteCapabilitiesOperationWithNextcloudClient() {
// get capabilities
RemoteOperationResult result = new GetCapabilitiesRemoteOperation().execute(nextcloudClient);
RemoteOperationResult<OCCapability> result = new GetCapabilitiesRemoteOperation().execute(nextcloudClient);
assertTrue(result.isSuccess());
assertTrue(result.getData() != null && result.getData().size() == 1);

OCCapability capability = (OCCapability) result.getData().get(0);
OCCapability capability = result.getResultData();
checkCapability(capability, client.getUserId());
}

@Test
public void testGetRemoteCapabilitiesOperationEtagWithNextcloudClient() {
// get capabilities
RemoteOperationResult result = new GetCapabilitiesRemoteOperation().execute(nextcloudClient);
RemoteOperationResult<OCCapability> result = new GetCapabilitiesRemoteOperation().execute(nextcloudClient);
assertTrue(result.isSuccess());
assertTrue(result.getData() != null && result.getData().size() == 1);

OCCapability capability = (OCCapability) result.getData().get(0);
OCCapability capability = result.getResultData();

RemoteOperationResult resultEtag = new GetCapabilitiesRemoteOperation(capability).execute(nextcloudClient);
RemoteOperationResult<OCCapability> resultEtag = new GetCapabilitiesRemoteOperation(capability).execute(nextcloudClient);
assertTrue(resultEtag.isSuccess());
assertTrue(resultEtag.getData() != null && resultEtag.getData().size() == 1);

OCCapability sameCapability = (OCCapability) resultEtag.getData().get(0);
OCCapability sameCapability = resultEtag.getResultData();

if (capability.getVersion().isNewerOrEqual(OwnCloudVersion.nextcloud_19)) {
assertEquals(capability, sameCapability);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ import com.owncloud.android.AbstractIT
import com.owncloud.android.lib.resources.files.ReadFileRemoteOperation
import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation
import com.owncloud.android.lib.resources.files.model.RemoteFile
import junit.framework.Assert.assertEquals
import junit.framework.Assert.assertTrue
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod
import org.junit.Test

class CommentFileRemoteOperationIT : AbstractIT() {
Expand All @@ -44,18 +46,27 @@ class CommentFileRemoteOperationIT : AbstractIT() {
)

val readResult = ReadFileRemoteOperation(remotePath).execute(client)
val remoteFile = readResult.data.get(0) as RemoteFile
val remoteFile = readResult.data[0] as RemoteFile
assertTrue(readResult.isSuccess)

checkComments(0, remoteFile.localId)

assertTrue(
CommentFileRemoteOperation("test", remoteFile.localId)
.execute(client)
.isSuccess
)

assertTrue(
MarkCommentsAsReadRemoteOperation(remoteFile.localId)
.execute(client)
.isSuccess
)
checkComments(1, remoteFile.localId)
}

private fun checkComments(expectedComments: Int, fileId: Long) {
val readComment =
PropFindMethod(client.baseUri.toString() + "/remote.php/dav/comments/files/" + fileId)
client.executeMethod(readComment)
assertTrue(readComment.succeeded())

// offset by 1, as "root" entry always exists if file exists
assertEquals(expectedComments + 1, readComment.responseBodyAsMultiStatus.responses.size)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public class SearchRemoteOperationIT extends AbstractIT {

@BeforeClass
public static void beforeClass() {
capability = (OCCapability) new GetCapabilitiesRemoteOperation(null)
.execute(client)
capability = (OCCapability) new GetCapabilitiesRemoteOperation()
.execute(nextcloudClient)
.getSingleData();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public static DavPropertyNameSet getFilePropSet() {
propSet.add(WebdavEntry.EXTENDED_PROPERTY_SYSTEM_TAGS, ncNamespace);
propSet.add(WebdavEntry.EXTENDED_PROPERTY_METADATA_SIZE, ncNamespace);
propSet.add(WebdavEntry.EXTENDED_PROPERTY_METADATA_GPS, ncNamespace);
propSet.add(WebdavEntry.EXTENDED_PROPERTY_UNREAD_COMMENTS, ocNamespace);

return propSet;
}
Expand Down

0 comments on commit 1d9f2fa

Please sign in to comment.