From 1d9f2fa06c4bf0dc3cb8d24280ff4aa0144a02f0 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Mon, 4 Sep 2023 07:41:38 +0200 Subject: [PATCH] wip Signed-off-by: tobiasKaminsky --- .../GetGroupfoldersRemoteOperationIT.kt | 4 +-- .../java/com/owncloud/android/AbstractIT.java | 4 +-- .../owncloud/android/GetCapabilitiesIT.java | 30 ++++++++----------- .../comments/CommentFileRemoteOperationIT.kt | 23 ++++++++++---- .../files/SearchRemoteOperationIT.java | 4 +-- .../lib/common/network/WebdavUtils.java | 1 + 6 files changed, 35 insertions(+), 31 deletions(-) diff --git a/library/src/androidTest/java/com/nextcloud/android/lib/resources/groupfolders/GetGroupfoldersRemoteOperationIT.kt b/library/src/androidTest/java/com/nextcloud/android/lib/resources/groupfolders/GetGroupfoldersRemoteOperationIT.kt index 3ae092d29..c690c07d3 100644 --- a/library/src/androidTest/java/com/nextcloud/android/lib/resources/groupfolders/GetGroupfoldersRemoteOperationIT.kt +++ b/library/src/androidTest/java/com/nextcloud/android/lib/resources/groupfolders/GetGroupfoldersRemoteOperationIT.kt @@ -29,7 +29,6 @@ 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 @@ -37,8 +36,7 @@ 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 diff --git a/library/src/androidTest/java/com/owncloud/android/AbstractIT.java b/library/src/androidTest/java/com/owncloud/android/AbstractIT.java index f8c2d6141..83a4869d9 100644 --- a/library/src/androidTest/java/com/owncloud/android/AbstractIT.java +++ b/library/src/androidTest/java/com/owncloud/android/AbstractIT.java @@ -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) { diff --git a/library/src/androidTest/java/com/owncloud/android/GetCapabilitiesIT.java b/library/src/androidTest/java/com/owncloud/android/GetCapabilitiesIT.java index 7e47325dc..3b0103c5c 100644 --- a/library/src/androidTest/java/com/owncloud/android/GetCapabilitiesIT.java +++ b/library/src/androidTest/java/com/owncloud/android/GetCapabilitiesIT.java @@ -51,28 +51,25 @@ public class GetCapabilitiesIT extends AbstractIT { @Test public void testGetRemoteCapabilitiesOperation() { // get capabilities - RemoteOperationResult result = new GetCapabilitiesRemoteOperation().execute(client); + RemoteOperationResult 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 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 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); @@ -89,28 +86,25 @@ public void testGetRemoteCapabilitiesOperationEtag() { @Test public void testGetRemoteCapabilitiesOperationWithNextcloudClient() { // get capabilities - RemoteOperationResult result = new GetCapabilitiesRemoteOperation().execute(nextcloudClient); + RemoteOperationResult 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 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 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); diff --git a/library/src/androidTest/java/com/owncloud/android/lib/resources/comments/CommentFileRemoteOperationIT.kt b/library/src/androidTest/java/com/owncloud/android/lib/resources/comments/CommentFileRemoteOperationIT.kt index bd53d4688..4647c3277 100644 --- a/library/src/androidTest/java/com/owncloud/android/lib/resources/comments/CommentFileRemoteOperationIT.kt +++ b/library/src/androidTest/java/com/owncloud/android/lib/resources/comments/CommentFileRemoteOperationIT.kt @@ -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() { @@ -44,7 +46,10 @@ 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) @@ -52,10 +57,16 @@ class CommentFileRemoteOperationIT : AbstractIT() { .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) } } diff --git a/library/src/androidTest/java/com/owncloud/android/lib/resources/files/SearchRemoteOperationIT.java b/library/src/androidTest/java/com/owncloud/android/lib/resources/files/SearchRemoteOperationIT.java index 480931e20..ca1d1b84a 100644 --- a/library/src/androidTest/java/com/owncloud/android/lib/resources/files/SearchRemoteOperationIT.java +++ b/library/src/androidTest/java/com/owncloud/android/lib/resources/files/SearchRemoteOperationIT.java @@ -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(); } diff --git a/library/src/main/java/com/owncloud/android/lib/common/network/WebdavUtils.java b/library/src/main/java/com/owncloud/android/lib/common/network/WebdavUtils.java index 5fe8d0769..90ba2edce 100644 --- a/library/src/main/java/com/owncloud/android/lib/common/network/WebdavUtils.java +++ b/library/src/main/java/com/owncloud/android/lib/common/network/WebdavUtils.java @@ -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; }