Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
bitfire web engineering
dav4jvm
Commits
86542e01
Commit
86542e01
authored
Nov 14, 2020
by
Ricki Hirner
🐑
Browse files
Add Owner property and some tests
parent
32f2a204
Pipeline
#216081072
passed with stages
in 3 minutes and 1 second
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
93 additions
and
0 deletions
+93
-0
src/main/kotlin/at/bitfire/dav4jvm/PropertyRegistry.kt
src/main/kotlin/at/bitfire/dav4jvm/PropertyRegistry.kt
+1
-0
src/main/kotlin/at/bitfire/dav4jvm/property/HrefListProperty.kt
...in/kotlin/at/bitfire/dav4jvm/property/HrefListProperty.kt
+4
-0
src/main/kotlin/at/bitfire/dav4jvm/property/Owner.kt
src/main/kotlin/at/bitfire/dav4jvm/property/Owner.kt
+30
-0
src/test/kotlin/at/bitfire/dav4jvm/property/CalendarDescriptionTest.kt
...in/at/bitfire/dav4jvm/property/CalendarDescriptionTest.kt
+15
-0
src/test/kotlin/at/bitfire/dav4jvm/property/OwnerTest.kt
src/test/kotlin/at/bitfire/dav4jvm/property/OwnerTest.kt
+23
-0
src/test/kotlin/at/bitfire/dav4jvm/property/PropertyTest.kt
src/test/kotlin/at/bitfire/dav4jvm/property/PropertyTest.kt
+20
-0
No files found.
src/main/kotlin/at/bitfire/dav4jvm/PropertyRegistry.kt
View file @
86542e01
...
...
@@ -44,6 +44,7 @@ object PropertyRegistry {
GetETag
.
Factory
(),
GetLastModified
.
Factory
(),
GroupMembership
.
Factory
(),
Owner
.
Factory
(),
QuotaAvailableBytes
.
Factory
(),
QuotaUsedBytes
.
Factory
(),
ResourceType
.
Factory
(),
...
...
src/main/kotlin/at/bitfire/dav4jvm/property/HrefListProperty.kt
View file @
86542e01
...
...
@@ -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
{
...
...
src/main/kotlin/at/bitfire/dav4jvm/property/Owner.kt
0 → 100644
View file @
86542e01
/*
* 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
View file @
86542e01
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
View file @
86542e01
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
src/test/kotlin/at/bitfire/dav4jvm/property/PropertyTest.kt
0 → 100644
View file @
86542e01
package
at.bitfire.dav4jvm.property
import
at.bitfire.dav4jvm.Property
import
at.bitfire.dav4jvm.XmlUtils
import
java.io.StringReader
open
class
PropertyTest
{
companion
object
{
fun
parseProperty
(
s
:
String
):
List
<
Property
>
{
val
parser
=
XmlUtils
.
newPullParser
()
parser
.
setInput
(
StringReader
(
"<test>$s</test>"
))
parser
.
nextTag
()
// move into <test>
return
Property
.
parse
(
parser
)
}
}
}
\ No newline at end of file
Ricki Hirner
🐑
@rfc2822
mentioned in merge request
!8 (closed)
·
Nov 14, 2020
mentioned in merge request
!8 (closed)
mentioned in merge request !8
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment