diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 22b70dc..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -CommitPrefixIdeaPluginWithGradle \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 61a9130..fb7f4a8 100644 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 38167d7..2483849 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,7 @@ - + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index bd6f2df..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/build.gradle b/build.gradle index b0aa8ba..0946bf4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,26 +1,47 @@ plugins { + id 'java' id 'org.jetbrains.intellij' version '0.7.2' - id 'org.jetbrains.kotlin.jvm' version '1.4.31' + id 'org.jetbrains.kotlin.jvm' version '1.5.31' } group 'dmitriy.molchanov' -version '1.3' +version '1.4' repositories { mavenCentral() } +java { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 +} + dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib" + implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.6.0' } // See https://github.com/JetBrains/gradle-intellij-plugin/ intellij { - version '2020.3.3' + version '2020.3.2' plugins = ['Git4Idea'] } patchPluginXml { changeNotes """ - Add change notes here.
- most HTML tags may be used""" + 1.4
+ + """ +} +test { + useJUnitPlatform() +} + +runPluginVerifier { + ideVersions = ["IC-2021.2"] +} + +patchPluginXml { + untilBuild null } \ No newline at end of file diff --git a/src/main/kotlin/dmitriy/molchanov/GitMessageTagCheckerProvider.kt b/src/main/kotlin/dmitriy/molchanov/GitMessageTagCheckerProvider.kt index acc0564..ba2f7a4 100644 --- a/src/main/kotlin/dmitriy/molchanov/GitMessageTagCheckerProvider.kt +++ b/src/main/kotlin/dmitriy/molchanov/GitMessageTagCheckerProvider.kt @@ -4,6 +4,7 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.vcs.changes.LocalChangeList import com.intellij.openapi.vcs.changes.ui.CommitMessageProvider import dmitriy.molchanov.data.Repository +import dmitriy.molchanov.model.Rule import git4idea.repo.GitRepository import git4idea.repo.GitRepositoryManager @@ -14,14 +15,23 @@ class GitMessageTagCheckerProvider : CommitMessageProvider { val gitRepositoryManager = GitRepositoryManager.getInstance(project) val currentRepository = gitRepositoryManager.repositories.firstOrNull() val branchName = currentRepository?.currentBranch?.name ?: return lastComment - val regex = getRegexForRepository(currentRepository) ?: return lastComment + val rule = getRuleForRepository(currentRepository) + val regex = rule?.regexPrefix?.let(::Regex) ?: return lastComment val match = regex.find(branchName) return match?.value - ?.let { taskPrefix -> getConcatenatedMessage(lastComment, taskPrefix, regex) } + ?.let { taskPrefix -> + getConcatenatedMessage( + lastComment = lastComment, + taskPrefix = taskPrefix, + startWith = rule.startWith, + endWith = rule.endWith, + isUpperCase = rule.isUpperCase + ) + } ?: lastComment } - private fun getRegexForRepository(repository: GitRepository): Regex? { + private fun getRuleForRepository(repository: GitRepository): Rule? { val remoteUrl = repository .info.remotes.firstOrNull() ?.firstUrl @@ -29,15 +39,24 @@ class GitMessageTagCheckerProvider : CommitMessageProvider { return Repository.instance .getRules() .firstOrNull { it.gitRepo.trim() == remoteUrl.trim() } - ?.regexPrefix - ?.let(::Regex) } - private fun getConcatenatedMessage(lastComment: String?, taskPrefix: String, regex: Regex): String { - if (lastComment.isNullOrEmpty()) return "$taskPrefix " - val currentPrefix = regex.find(lastComment)?.value - return currentPrefix - ?.let { lastComment.replace(currentPrefix, taskPrefix) } - ?: "$taskPrefix $lastComment" + private fun getConcatenatedMessage( + lastComment: String?, + taskPrefix: String, + startWith: String, + endWith: String, + isUpperCase: Boolean? + ): String { + val registeredPrefix = when (isUpperCase) { + false -> taskPrefix.lowercase() + true -> taskPrefix.uppercase() + else -> taskPrefix + } + val fullPrefix = "$startWith$registeredPrefix$endWith" + return when { + lastComment?.contains(fullPrefix) == true -> lastComment + else -> fullPrefix + } } } \ No newline at end of file diff --git a/src/main/kotlin/dmitriy/molchanov/Strings.kt b/src/main/kotlin/dmitriy/molchanov/Strings.kt index 43544a0..b695835 100644 --- a/src/main/kotlin/dmitriy/molchanov/Strings.kt +++ b/src/main/kotlin/dmitriy/molchanov/Strings.kt @@ -2,13 +2,17 @@ package dmitriy.molchanov object Strings { const val EMPTY = "" - const val DISABLE_CLEAR_INITIAL_OPTION = "For the CommitMessage plugin to work, you must disable the \"Clear initial commit message\" option Disable " + const val DISABLE_CLEAR_INITIAL_OPTION = + "For the CommitMessage plugin to work, you must disable the \"Clear initial commit message\" option Disable " const val SUCCESS_DISABLE = "Option has been disabled" const val FILL_FIELDS = "Fill in the fields" const val ADD_RULE = "Add rule" const val GIT_REPO = "Git repo:" const val REGEX_PREFIX = "Regex prefix:" const val CHECK_BRANCH = "Check branch:" + const val REGISTER = "Register:" + const val START_WITH = "Start with:" + const val END_WITH = "End with:" const val GIT_REPO_WARNING = "Git repo is empty" const val REGEX_PREFIX_WARNING = "Regex prefix is empty" const val CHECK_BRANCH_WARNING = "Check string is empty" @@ -20,4 +24,9 @@ object Strings { const val LIKE_THIS_PLUGIN = "Like this plugin? Please " const val STAR_ON_GITHUB = "star on github." const val GITHUB_URL = "https://github.com/MolchanovDmitry/CommitPrefixIdeaPlugin" + const val RESULT = "Result:" + const val COMMIT_MESSAGE = "your commit message.\n" + const val REGISTER_NONE = "None" + const val REGISTER_LOWER_CASE = "Lower case" + const val REGISTER_UPPER_CASE = "Upper case" } \ No newline at end of file diff --git a/src/main/kotlin/dmitriy/molchanov/data/Repository.kt b/src/main/kotlin/dmitriy/molchanov/data/Repository.kt index 12a287d..6b8e774 100644 --- a/src/main/kotlin/dmitriy/molchanov/data/Repository.kt +++ b/src/main/kotlin/dmitriy/molchanov/data/Repository.kt @@ -1,11 +1,12 @@ package dmitriy.molchanov.data +import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.components.PersistentStateComponent -import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.components.State import com.intellij.openapi.components.Storage import dmitriy.molchanov.model.Rule + @State(name = "RuleServiceData", storages = [Storage("ruleServiceData.xml")]) class Repository : PersistentStateComponent { @@ -21,12 +22,8 @@ class Repository : PersistentStateComponent { fun removeRule(rule: Rule) { rules - .firstOrNull { it.gitRepo == rule.gitRepo } - ?.let(rules::remove) - } - - fun removeRule(rules: List) { - rules.forEach(::removeRule) + .firstOrNull { it.gitRepo == rule.gitRepo } + ?.let(rules::remove) } override fun getState(): Repository { @@ -36,13 +33,13 @@ class Repository : PersistentStateComponent { override fun loadState(stateLoadedFromPersistence: Repository) { stateLoadedFromPersistence.serializedRules - ?.let { Serializer.deserialize(it) } - ?.let { rules = it } + ?.let { Serializer.deserialize(it) } + ?.let { rules = it } } companion object { var rules: ArrayList = ArrayList() val instance: Repository - get() = ServiceManager.getService(Repository::class.java) + get() = ApplicationManager.getApplication().getService(Repository::class.java) } } \ No newline at end of file diff --git a/src/main/kotlin/dmitriy/molchanov/domain/Presenter.kt b/src/main/kotlin/dmitriy/molchanov/domain/Presenter.kt index fae8f94..50b08ff 100644 --- a/src/main/kotlin/dmitriy/molchanov/domain/Presenter.kt +++ b/src/main/kotlin/dmitriy/molchanov/domain/Presenter.kt @@ -13,12 +13,13 @@ class Presenter : SettingsDialog.OnSettingsDialogListener { private val repository = Repository.instance private val repositoryManagers = ProjectManager.getInstance().openProjects .map(GitRepositoryManager::getInstance) - private lateinit var settingsDialog: SettingsDialog + private val settingsDialog by lazy { + SettingsDialog(this).apply { + addRules(repository.getRules()) + } + } fun showMain() { - val rules = repository.getRules() - settingsDialog = SettingsDialog(this) - settingsDialog.addRules(rules) settingsDialog.show() } @@ -30,13 +31,16 @@ class Presenter : SettingsDialog.OnSettingsDialogListener { } override fun onRemoveClick() { - val rules = settingsDialog.getSelectedRules() - repository.removeRule(rules) + val selectedReps = settingsDialog.getSelectedReps() + repository.getRules() + .filter { rule -> selectedReps.contains(rule.gitRepo) } + .forEach(repository::removeRule) updateSettingsDialogTable() } override fun onEditClick() { - val rule = settingsDialog.getSelectedRules().firstOrNull() ?: return + val selectedRep = settingsDialog.getSelectedReps().firstOrNull() ?: return + val rule = repository.getRules().firstOrNull { it.gitRepo == selectedRep } ?: return showAddRuleDialog(rule) { newRule -> repository.removeRule(rule) repository.addRule(newRule) @@ -74,7 +78,7 @@ class Presenter : SettingsDialog.OnSettingsDialogListener { repositoryManagers.forEach { gitRepManager -> gitRepManager.repositories .mapNotNull { gitRep -> gitRep.info.remotes.firstOrNull()?.firstUrl } - .forEach { url -> gitRepUrls.add(url) } + .forEach(gitRepUrls::add) } return gitRepUrls } diff --git a/src/main/kotlin/dmitriy/molchanov/model/Rule.kt b/src/main/kotlin/dmitriy/molchanov/model/Rule.kt index ee9f7c5..cd7f19d 100644 --- a/src/main/kotlin/dmitriy/molchanov/model/Rule.kt +++ b/src/main/kotlin/dmitriy/molchanov/model/Rule.kt @@ -3,23 +3,48 @@ package dmitriy.molchanov.model import dmitriy.molchanov.Strings import java.io.Serializable +/** + * Правило для сохранения. + * + * @property gitRepo репозиторий, для которого актуально правило + * @property regexPrefix регулярное выражение + * @property checkString строка для проверки + * @property startWith строка, которая будет подставляться в начало нашего префикса + * @property endWith строка, которая будет подставляться в конец нашего префикса + * @property isUpperCase перевести префикс в: + * true -> верхний регистр, false - нижний регистр, null -> не переводить. + */ class Rule : Serializable { var gitRepo: String var regexPrefix: String var checkString: String + var startWith: String + var endWith: String + var isUpperCase: Boolean? @Suppress("unused") //serialization fix constructor() { gitRepo = Strings.EMPTY regexPrefix = Strings.EMPTY checkString = Strings.EMPTY + startWith = Strings.EMPTY + endWith = Strings.EMPTY + isUpperCase = null } - constructor(gitRepo: String, - regexPrefix: String, - checkString: String) { + constructor( + gitRepo: String, + regexPrefix: String, + checkString: String, + startWith: String, + endWith: String, + isUpperCase: Boolean? + ) { this.gitRepo = gitRepo this.regexPrefix = regexPrefix this.checkString = checkString + this.startWith = startWith + this.endWith = endWith + this.isUpperCase = isUpperCase } } \ No newline at end of file diff --git a/src/main/kotlin/dmitriy/molchanov/ui/add/AddRuleDialog.kt b/src/main/kotlin/dmitriy/molchanov/ui/add/AddRuleDialog.kt index 81600fa..144f405 100644 --- a/src/main/kotlin/dmitriy/molchanov/ui/add/AddRuleDialog.kt +++ b/src/main/kotlin/dmitriy/molchanov/ui/add/AddRuleDialog.kt @@ -8,6 +8,7 @@ import java.awt.event.KeyEvent import java.awt.event.KeyListener import javax.swing.* + /** * Дилог сохранения/редактирования правила * @@ -22,14 +23,45 @@ class AddRuleDialog( ) : DialogWrapper(true) { val rule: Rule? - get() = selectedGitRep?.let { Rule(it, prefixEdit.text, checkStringEdit.text) } + get() = selectedGitRep?.let { + Rule( + gitRepo = it, + regexPrefix = prefixEdit.text, + checkString = checkStringEdit.text, + startWith = startWithEdit.text, + endWith = endWithEdit.text, + isUpperCase = shouldRuleBuUpperCase() + ) + } private val selectedGitRep: String? get() = gitRepBox.selectedItem?.toString() - private val gitRepBox = ComboBox(gitRepUrls.toTypedArray()) - private val prefixEdit = JTextField(TEXT_COLUMNS) + private val prefixEdit = JTextField(TEXT_COLUMNS).apply { + editablePrefix?.regexPrefix?.let(::setText) + } private val checkStringEdit = JTextField(TEXT_COLUMNS) + private val startWithEdit = JTextField(TEXT_COLUMNS).apply { + editablePrefix?.startWith?.let(::setText) + } + private val endWithEdit = JTextField(TEXT_COLUMNS).apply { + editablePrefix?.endWith?.let(::setText) + } private val statusLabel = JLabel(Strings.FILL_FIELDS) + private val resultTitle = JLabel(Strings.RESULT) + private val resultTextField = JTextArea(Strings.COMMIT_MESSAGE).apply { + addFocusListener(DisabledEditFocusListener(this)) + } + + private val gitRepBox = ComboBox(gitRepUrls.toTypedArray()).apply { + isEditable = true + addActionListener { updateCheckString() } + editablePrefix?.gitRepo?.let(::setToolTipText) + } + private val registerBox = + ComboBox(arrayOf(Strings.REGISTER_NONE, Strings.REGISTER_LOWER_CASE, Strings.REGISTER_UPPER_CASE)).apply { + selectedItem = editablePrefix?.isUpperCase?.registerString() ?: Strings.REGISTER_NONE + addActionListener { updateDialogStatus() } + } private val keyListener = object : KeyListener { override fun keyTyped(p0: KeyEvent?) {} @@ -39,69 +71,86 @@ class AddRuleDialog( init { init() - gitRepBox.isEditable = true - gitRepBox.addActionListener { updateCheckString() } title = Strings.ADD_RULE - editablePrefix?.gitRepo?.let(gitRepBox::setToolTipText) - editablePrefix?.regexPrefix?.let(prefixEdit::setText) editablePrefix?.checkString - ?.let(checkStringEdit::setText) - ?: updateCheckString() + ?.let(checkStringEdit::setText) + ?: updateCheckString() updateDialogStatus() } override fun createCenterPanel(): JComponent { // Создание панели для размещение компонентов val root = BoxLayoutUtils.createVerticalPanel() + val getRepLabel = JLabel(Strings.GIT_REPO) val prefixLabel = JLabel(Strings.REGEX_PREFIX) + val registerLabel = JLabel(Strings.REGISTER) + val startWithLabel = JLabel(Strings.START_WITH) + val endWithLabel = JLabel(Strings.END_WITH) val checkStringLabel = JLabel(Strings.CHECK_BRANCH) + val gitRepGroup = getViewGroup(getRepLabel, gitRepBox) val prefixGroup = getViewGroup(prefixLabel, prefixEdit) - val statusGroup = getCheckText(statusLabel) val checkStringGroup = getViewGroup(checkStringLabel, checkStringEdit) + val startWithGroup = getViewGroup(startWithLabel, startWithEdit) + val endWithGroup = getViewGroup(endWithLabel, endWithEdit) + val statusGroup = getCheckText(statusLabel) + + val registerGroup = getViewGroup(registerLabel, registerBox) + + val messageGroup = getViewGroup(startWithGroup, endWithGroup) + // Определение размеров надписей к текстовым полям - GuiUtils.makeSameSize(arrayOf(getRepLabel, prefixLabel, checkStringLabel)) + GuiUtils.makeSameSize(arrayOf(getRepLabel, prefixLabel, checkStringLabel, registerLabel, startWithLabel)) root.add(gitRepGroup) root.add(prefixGroup) root.add(checkStringGroup) + root.add(registerGroup) + root.add(messageGroup) root.add(statusGroup) + root.add(getCheckText(resultTitle)) + root.add(resultTextField) return root } /** Берем текущую ветку из выбранного репозитория и вставляем в [checkStringEdit] */ private fun updateCheckString() { selectedGitRep - ?.let(getCurBranchByUrl) - ?.let(checkStringEdit::setText) + ?.let(getCurBranchByUrl) + ?.let(checkStringEdit::setText) } private fun updateDialogStatus() { - val dialogStatus = getDialogStatus() + val dialogStatusToPrefix = getDialogStatusToCorePrefix() + val dialogStatus = dialogStatusToPrefix.first + val prefix = dialogStatusToPrefix.second + statusLabel.text = dialogStatus.message okAction.isEnabled = dialogStatus.shouldOkButtonActive + + resultTextField.text = (prefix?.formatByParams() ?: "") + Strings.COMMIT_MESSAGE } /** Получить строку вида "текст _ поле для ввода" */ - private fun getViewGroup(label: JLabel, component: JComponent): JPanel = - BoxLayoutUtils.createHorizontalPanel().apply { - component.addKeyListener(keyListener) - add(label) - add(Box.createHorizontalStrut(HORIZONTAL_STRUT)) - add(component) - } + private fun getViewGroup(component: JComponent, componentWithListener: JComponent): JPanel = + BoxLayoutUtils.createHorizontalPanel().apply { + componentWithListener.addKeyListener(keyListener) + add(component) + add(Box.createHorizontalStrut(HORIZONTAL_STRUT)) + add(componentWithListener) + } private fun getCheckText(statusLabel: JLabel): JPanel = - BoxLayoutUtils.createHorizontalPanel().apply { - add(statusLabel) - } + BoxLayoutUtils.createHorizontalPanel().apply { + add(statusLabel) + } /** * Получить статус заполнения формы */ - private fun getDialogStatus(): DialogStatus { + private fun getDialogStatusToCorePrefix(): Pair { var message = Strings.EMPTY if (selectedGitRep.isNullOrEmpty()) message += "${Strings.GIT_REPO_WARNING}, " if (prefixEdit.text.isNullOrEmpty()) message += "${Strings.REGEX_PREFIX_WARNING}, " @@ -109,8 +158,9 @@ class AddRuleDialog( if (message.isNotEmpty()) { val showedMessage = message.substring(0, message.length - 2) return DialogStatus( - message = "$showedMessage", - shouldOkButtonActive = false) + message = "$showedMessage", + shouldOkButtonActive = false + ) to null } val regex = Regex(prefixEdit.text) val checkStr = checkStringEdit.text @@ -120,16 +170,47 @@ class AddRuleDialog( val matchText = checkStr.substring(first, lastMatch) val endText = checkStr.substring(lastMatch) return DialogStatus( - message = "" + - "$startText" + - "$matchText" + - "$endText" + - "", - shouldOkButtonActive = true) + message = "" + + "Match check: $startText" + + "${matchText}" + + "$endText" + + "", + shouldOkButtonActive = true + ) to matchText } return DialogStatus( - message = "${Strings.NO_MATCHES_FOUND}", - shouldOkButtonActive = false) + message = "${Strings.NO_MATCHES_FOUND}", + shouldOkButtonActive = false + ) to null + } + + private fun String.formatByParams(): String { + val prefix = startWithEdit.text + val suffix = endWithEdit.text + val registeredValue = when(shouldRuleBuUpperCase()){ + true -> uppercase() + false -> lowercase() + else -> this + } + return "$prefix$registeredValue$suffix" + } + + /** + * Возвращает показатель регистра для правила. + * @return true перевести в верхний регистр. + * @return false перевести в нижний регистр. + * @return null не переводить. + */ + private fun shouldRuleBuUpperCase() = when (registerBox.selectedItem?.toString()) { + Strings.REGISTER_UPPER_CASE -> true + Strings.REGISTER_LOWER_CASE -> false + else -> null + } + + private fun Boolean?.registerString() = when (this) { + true -> Strings.REGISTER_UPPER_CASE + false -> Strings.REGISTER_LOWER_CASE + else -> Strings.REGISTER_NONE } private class DialogStatus(val message: String, val shouldOkButtonActive: Boolean) diff --git a/src/main/kotlin/dmitriy/molchanov/ui/add/BoxLayoutUtils.kt b/src/main/kotlin/dmitriy/molchanov/ui/add/BoxLayoutUtils.kt index 163f53b..4294888 100644 --- a/src/main/kotlin/dmitriy/molchanov/ui/add/BoxLayoutUtils.kt +++ b/src/main/kotlin/dmitriy/molchanov/ui/add/BoxLayoutUtils.kt @@ -19,6 +19,6 @@ object BoxLayoutUtils { /** Создание панели с горизонтальным расположением */ fun createHorizontalPanel() = JPanel().apply { - layout = BoxLayout(this, BoxLayout.X_AXIS) + layout = BoxLayout(this, BoxLayout.LINE_AXIS) } } \ No newline at end of file diff --git a/src/main/kotlin/dmitriy/molchanov/ui/add/DisabledEditFocusListener.kt b/src/main/kotlin/dmitriy/molchanov/ui/add/DisabledEditFocusListener.kt new file mode 100644 index 0000000..257196d --- /dev/null +++ b/src/main/kotlin/dmitriy/molchanov/ui/add/DisabledEditFocusListener.kt @@ -0,0 +1,22 @@ +package dmitriy.molchanov.ui.add + +import java.awt.event.FocusEvent +import java.awt.event.FocusListener +import java.lang.ref.WeakReference +import javax.swing.JTextArea + +/** + * Слушатель фокуса, не позволяющий редактировать [JTextArea] + */ +class DisabledEditFocusListener(textArea: JTextArea): FocusListener { + + private val weakTextArea = WeakReference(textArea) + + override fun focusGained(e: FocusEvent) { + weakTextArea.get()?.isEditable = false + } + + override fun focusLost(e: FocusEvent?) { + weakTextArea.get()?.isEditable = true + } +} \ No newline at end of file diff --git a/src/main/kotlin/dmitriy/molchanov/ui/main/SettingsDialog.kt b/src/main/kotlin/dmitriy/molchanov/ui/main/SettingsDialog.kt index b347647..12f5732 100644 --- a/src/main/kotlin/dmitriy/molchanov/ui/main/SettingsDialog.kt +++ b/src/main/kotlin/dmitriy/molchanov/ui/main/SettingsDialog.kt @@ -56,13 +56,10 @@ class SettingsDialog( } } - fun getSelectedRules() = table.selectedRows + fun getSelectedReps() = table.selectedRows .map { - val repo = tableModel.getValueAt(it, REP_INDEX) as String - val regexPrefix = tableModel.getValueAt(it, REGEX_INDEX) as String - val checkString = tableModel.getValueAt(it, CHECK_INDEX) as String - Rule(repo, regexPrefix, checkString) - }.toList() + tableModel.getValueAt(it, REP_INDEX) as String + } override fun createCenterPanel(): JComponent { val root = JPanel(VerticalLayout()) @@ -137,7 +134,5 @@ class SettingsDialog( private companion object { const val ICON_SIZE = 25 const val REP_INDEX = 0 - const val REGEX_INDEX = 1 - const val CHECK_INDEX = 2 } } \ No newline at end of file diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 7dfebc5..14355f3 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -17,9 +17,11 @@ 1.3
+ + 1.4
    -
  • Migrate to gradle
  • +
  • Added the ability to add additional text around the result regex value.
  • +
  • Added the ability change text register.
1.2
    diff --git a/src/test/kotlin/dmitriy/molchanov/SerializerTest.kt b/src/test/kotlin/dmitriy/molchanov/SerializerTest.kt index d675fa8..d2da7ba 100644 --- a/src/test/kotlin/dmitriy/molchanov/SerializerTest.kt +++ b/src/test/kotlin/dmitriy/molchanov/SerializerTest.kt @@ -2,7 +2,8 @@ package dmitriy.molchanov import dmitriy.molchanov.data.Serializer import dmitriy.molchanov.model.Rule -import org.junit.Assert.* +import org.junit.Assert.assertArrayEquals +import org.junit.Assert.assertEquals import org.junit.Test class SerializerTest { @@ -19,9 +20,23 @@ class SerializerTest { } @Test - fun serializeRule(){ - val rule = Rule("11", "22", "33") - val rule2 = Rule("aa", "bb", "cc") + fun serializeRule() { + val rule = Rule( + gitRepo = "11", + regexPrefix = "22", + checkString = "33", + startWith = "[", + endWith = "]", + isUpperCase = true + ) + val rule2 = Rule( + gitRepo = "aa", + regexPrefix = "bb", + checkString = "cc", + startWith = "[", + endWith = "]", + isUpperCase = false + ) val list = arrayListOf(rule, rule2) val ser = Serializer.serialize(list) val des = Serializer.deserialize>(ser!!) as ArrayList @@ -29,9 +44,15 @@ class SerializerTest { assertEquals(rule.gitRepo, des[0].gitRepo) assertEquals(rule.checkString, des[0].checkString) assertEquals(rule.regexPrefix, des[0].regexPrefix) + assertEquals(rule.startWith, des[0].startWith) + assertEquals(rule.endWith, des[0].endWith) + assertEquals(rule.isUpperCase, des[0].isUpperCase) assertEquals(rule2.gitRepo, des[1].gitRepo) assertEquals(rule2.checkString, des[1].checkString) assertEquals(rule2.regexPrefix, des[1].regexPrefix) + assertEquals(rule2.endWith, des[1].endWith) + assertEquals(rule2.isUpperCase, des[1].isUpperCase) + assertEquals(rule.startWith, des[1].startWith) } } \ No newline at end of file