-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2571 from bardsoftware/tkt-2514-make-default-colu…
…mns-not-calculated Calculated columns improvements
- Loading branch information
Showing
14 changed files
with
194 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
...ect-tester/test/net/sourceforge/ganttproject/customProperty/CustomPropertyImportTest.java
This file was deleted.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
...oject-tester/test/net/sourceforge/ganttproject/customProperty/CustomPropertyImportTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright 2024 BarD Software s.r.o., Dmitry Barashev. | ||
* | ||
* This file is part of GanttProject, an opensource project management tool. | ||
* | ||
* GanttProject is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* GanttProject is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with GanttProject. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package net.sourceforge.ganttproject.customProperty | ||
|
||
import biz.ganttproject.customproperty.CustomPropertyClass | ||
import biz.ganttproject.customproperty.CustomPropertyEvent | ||
import biz.ganttproject.customproperty.CustomPropertyListener | ||
import net.sourceforge.ganttproject.task.CustomColumnsManager | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
|
||
class CustomPropertyImportTest { | ||
@Test | ||
fun testImportDuplicatedProperties() { | ||
run { | ||
val target = CustomColumnsManager() | ||
target.createDefinition(CustomPropertyClass.TEXT, "col1", null) | ||
target.createDefinition(CustomPropertyClass.TEXT, "col2", null) | ||
|
||
val source = CustomColumnsManager() | ||
source.createDefinition(CustomPropertyClass.TEXT, "col1", null) | ||
source.createDefinition(CustomPropertyClass.TEXT, "col3", null) | ||
|
||
target.importData(source) | ||
val definitions = target.definitions | ||
assertEquals(3, definitions.size) | ||
} | ||
run { | ||
val target = CustomColumnsManager() | ||
target.createDefinition(CustomPropertyClass.TEXT, "col1", null) | ||
target.createDefinition(CustomPropertyClass.TEXT, "col2", null) | ||
|
||
val source = CustomColumnsManager() | ||
source.createDefinition(CustomPropertyClass.DATE, "col1", null) | ||
source.createDefinition(CustomPropertyClass.TEXT, "col3", null) | ||
|
||
target.importData(source) | ||
val definitions = target.definitions | ||
assertEquals(4, definitions.size) | ||
} | ||
} | ||
|
||
@Test | ||
fun `import preserves property id`() { | ||
val target = CustomColumnsManager() | ||
target.createDefinition("col1", CustomPropertyClass.TEXT.iD, "col1", null) | ||
target.createDefinition("col3", CustomPropertyClass.TEXT.iD, "col3", null) | ||
|
||
val source = CustomColumnsManager() | ||
source.createDefinition("col2", CustomPropertyClass.TEXT.iD, "col2", null) | ||
source.createDefinition("col3", CustomPropertyClass.TEXT.iD, "Column3", null) | ||
|
||
target.importData(source) | ||
val definitions = target.definitions | ||
assertEquals(4, definitions.size) | ||
|
||
assertEquals(setOf("col1", "col2", "col3", "tpc0"), definitions.map { it.id }.toSet()) | ||
} | ||
|
||
@Test | ||
fun `import triggers only one event`() { | ||
val target = CustomColumnsManager() | ||
var eventCount = 0 | ||
target.addListener(object: CustomPropertyListener { | ||
override fun customPropertyChange(event: CustomPropertyEvent) { | ||
eventCount++ | ||
} | ||
}) | ||
|
||
val source = CustomColumnsManager() | ||
source.createDefinition(CustomPropertyClass.DATE, "col1", null) | ||
source.createDefinition(CustomPropertyClass.TEXT, "col3", null) | ||
|
||
target.importData(source) | ||
assertEquals(1, eventCount) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.