Loading src/main/kotlin/at/bitfire/dav4jvm/PropertyRegistry.kt +1 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ object PropertyRegistry { GetETag.Factory(), GetLastModified.Factory(), GroupMembership.Factory(), Owner.Factory(), QuotaAvailableBytes.Factory(), QuotaUsedBytes.Factory(), ResourceType.Factory(), Loading src/main/kotlin/at/bitfire/dav4jvm/property/HrefListProperty.kt +4 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading src/main/kotlin/at/bitfire/dav4jvm/property/Owner.kt 0 → 100644 +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 src/test/kotlin/at/bitfire/dav4jvm/property/CalendarDescriptionTest.kt 0 → 100644 +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 src/test/kotlin/at/bitfire/dav4jvm/property/OwnerTest.kt 0 → 100644 +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
src/main/kotlin/at/bitfire/dav4jvm/PropertyRegistry.kt +1 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,7 @@ object PropertyRegistry { GetETag.Factory(), GetLastModified.Factory(), GroupMembership.Factory(), Owner.Factory(), QuotaAvailableBytes.Factory(), QuotaUsedBytes.Factory(), ResourceType.Factory(), Loading
src/main/kotlin/at/bitfire/dav4jvm/property/HrefListProperty.kt +4 −0 Original line number Diff line number Diff line Loading @@ -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 { Loading
src/main/kotlin/at/bitfire/dav4jvm/property/Owner.kt 0 → 100644 +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
src/test/kotlin/at/bitfire/dav4jvm/property/CalendarDescriptionTest.kt 0 → 100644 +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
src/test/kotlin/at/bitfire/dav4jvm/property/OwnerTest.kt 0 → 100644 +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