Fix unit test

This commit is contained in:
J-Jamet
2021-07-07 21:03:11 +02:00
parent f8a2748ede
commit 77dc5943e5
3 changed files with 5 additions and 4 deletions

View File

@@ -7,7 +7,7 @@ import org.junit.Assert
class TemplateAttributeOptionTest: TestCase() {
fun testSerializeOptions() {
val options = HashMap<String, String>().apply {
val options = TemplateAttributeOption().apply {
put("TestA", "TestB")
put("{D", "}C")
put("E,gyu", "15,jk")
@@ -16,8 +16,9 @@ class TemplateAttributeOptionTest: TestCase() {
val strings = TemplateAttributeOption.getStringFromOptions(options)
val optionsAfterSerialization = TemplateAttributeOption.getOptionsFromString(strings)
val otherString = TemplateAttributeOption.getStringFromOptions(optionsAfterSerialization)
Assert.assertEquals("Output not equal to input", options, optionsAfterSerialization)
Assert.assertEquals("Output not equal to input", strings, otherString)
}
}

View File

@@ -124,7 +124,7 @@ class TemplateAttributeOption() : Parcelable {
return mOptions[label]
}
fun add(label: String, value: String) {
fun put(label: String, value: String) {
mOptions[label] = value
}

View File

@@ -158,7 +158,7 @@ class TemplateEngineCompatible(database: DatabaseKDBX): TemplateEngine(database)
val attributeName = label.substring(TEMPLATE_ATTRIBUTE_OPTIONS_PREFIX.length)
val attribute = getOrRetrieveAttributeFromName(attributes, attributeName)
if (value.isNotEmpty()) {
attribute.attribute.options.add(TEMPLATE_ATTRIBUTE_OPTIONS_TEMP, value)
attribute.attribute.options.put(TEMPLATE_ATTRIBUTE_OPTIONS_TEMP, value)
}
entryCopy.removeField(field.name)
} catch (e: Exception) {