Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 86542e01 authored by Ricki Hirner's avatar Ricki Hirner
Browse files

Add Owner property and some tests

parent 32f2a204
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ object PropertyRegistry {
            GetETag.Factory(),
            GetLastModified.Factory(),
            GroupMembership.Factory(),
            Owner.Factory(),
            QuotaAvailableBytes.Factory(),
            QuotaUsedBytes.Factory(),
            ResourceType.Factory(),
+4 −0
Original line number Diff line number Diff line
@@ -17,9 +17,13 @@ abstract class HrefListProperty: Property {

    val hrefs = LinkedList<String>()

    val href
        get() = hrefs.firstOrNull()

    override fun toString() =  "href=[" + hrefs.joinToString(", ") + "]"



    abstract class Factory: PropertyFactory {

        fun create(parser: XmlPullParser, list: HrefListProperty): HrefListProperty {
+30 −0
Original line number Diff line number Diff line
/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package at.bitfire.dav4jvm.property

import at.bitfire.dav4jvm.Property
import at.bitfire.dav4jvm.XmlUtils
import org.xmlpull.v1.XmlPullParser

class Owner: HrefListProperty() {

    companion object {
        @JvmField
        val NAME = Property.Name(XmlUtils.NS_WEBDAV, "owner")
    }


    class Factory : HrefListProperty.Factory() {

        override fun getName() = NAME

        override fun create(parser: XmlPullParser) =
                create(parser, Owner())

    }

}
 No newline at end of file
+15 −0
Original line number Diff line number Diff line
package at.bitfire.dav4jvm.property

import org.junit.Assert.assertEquals
import org.junit.Test

class CalendarDescriptionTest: PropertyTest() {

    @Test
    fun testSource() {
        val results = parseProperty("<calendar-description xmlns=\"urn:ietf:params:xml:ns:caldav\">My Calendar</calendar-description>")
        val result = results.first() as CalendarDescription
        assertEquals("My Calendar", result.description)
    }

}
 No newline at end of file
+23 −0
Original line number Diff line number Diff line
package at.bitfire.dav4jvm.property

import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test

class OwnerTest: PropertyTest() {

    @Test
    fun testOwner_WithoutHref() {
        val results = parseProperty("<owner xmlns=\"DAV:\">https://example.com</owner>")
        val owner = results.first() as Owner
        assertNull(owner.href)
    }

    @Test
    fun testOwner_OneHref() {
        val results = parseProperty("<owner xmlns=\"DAV:\"><href>https://example.com</href></owner>")
        val owner = results.first() as Owner
        assertEquals("https://example.com", owner.href)
    }

}
 No newline at end of file
Loading