diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e9d509c..0eb10d4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ Changelog of Pull Request Notifier for Bitbucket. * Adjusting textarea size in GUI. * Supplying form as JSON to GUI, instead of escaped JSON string. - [c1c0dc0cc2b382b](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/c1c0dc0cc2b382b) Tomas Bjerre *2016-12-26 19:36:32* + [095795704b8e580](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/095795704b8e580) Tomas Bjerre *2016-12-26 20:13:35* Adjustments after merge of @@ -22,6 +22,11 @@ Changelog of Pull Request Notifier for Bitbucket. [649638d30d2d32c](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/649638d30d2d32c) Tomas Bjerre *2016-12-25 21:46:25* +### GitHub [#57](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/57) Trigger button: confirmation dialog + Adding optional confirmation text to buttons + + [b14d86ed8b986ea](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/b14d86ed8b986ea) Tomas Bjerre *2016-12-26 21:10:45* + ### No issue Add interactive forms to buttons diff --git a/src/main/java/se/bjurr/prnfb/presentation/dto/ButtonDTO.java b/src/main/java/se/bjurr/prnfb/presentation/dto/ButtonDTO.java index fd3756ec..77e7bd4e 100644 --- a/src/main/java/se/bjurr/prnfb/presentation/dto/ButtonDTO.java +++ b/src/main/java/se/bjurr/prnfb/presentation/dto/ButtonDTO.java @@ -35,6 +35,15 @@ public class ButtonDTO implements Comparable { private String repositorySlug; private USER_LEVEL userLevel; private UUID uuid; + private String confirmationText; + + public void setConfirmationText(String confirmationText) { + this.confirmationText = confirmationText; + } + + public String getConfirmationText() { + return confirmationText; + } @Override public int compareTo(ButtonDTO o) { @@ -60,9 +69,23 @@ public boolean equals(Object obj) { } else if (!buttonFormList.equals(other.buttonFormList)) { return false; } + if (buttonFormListString == null) { + if (other.buttonFormListString != null) { + return false; + } + } else if (!buttonFormListString.equals(other.buttonFormListString)) { + return false; + } if (confirmation != other.confirmation) { return false; } + if (confirmationText == null) { + if (other.confirmationText != null) { + return false; + } + } else if (!confirmationText.equals(other.confirmationText)) { + return false; + } if (name == null) { if (other.name != null) { return false; @@ -134,7 +157,9 @@ public int hashCode() { final int prime = 31; int result = 1; result = prime * result + (buttonFormList == null ? 0 : buttonFormList.hashCode()); + result = prime * result + (buttonFormListString == null ? 0 : buttonFormListString.hashCode()); result = prime * result + (confirmation == null ? 0 : confirmation.hashCode()); + result = prime * result + (confirmationText == null ? 0 : confirmationText.hashCode()); result = prime * result + (name == null ? 0 : name.hashCode()); result = prime * result + (projectKey == null ? 0 : projectKey.hashCode()); result = prime * result + (repositorySlug == null ? 0 : repositorySlug.hashCode()); @@ -181,8 +206,10 @@ public void setUuid(UUID uuid) { @Override public String toString() { - return "ButtonDTO [buttonFormDtoList=" + return "ButtonDTO [buttonFormList=" + buttonFormList + + ", buttonFormListString=" + + buttonFormListString + ", confirmation=" + confirmation + ", name=" @@ -195,6 +222,8 @@ public String toString() { + userLevel + ", uuid=" + uuid + + ", confirmationText=" + + confirmationText + "]"; } } diff --git a/src/main/java/se/bjurr/prnfb/service/SettingsService.java b/src/main/java/se/bjurr/prnfb/service/SettingsService.java index 9e8b1fa1..155cbe5b 100644 --- a/src/main/java/se/bjurr/prnfb/service/SettingsService.java +++ b/src/main/java/se/bjurr/prnfb/service/SettingsService.java @@ -18,6 +18,18 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.atlassian.bitbucket.pull.PullRequestState; +import com.atlassian.bitbucket.user.SecurityService; +import com.atlassian.bitbucket.util.Operation; +import com.atlassian.sal.api.pluginsettings.PluginSettings; +import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; +import com.atlassian.sal.api.transaction.TransactionCallback; +import com.atlassian.sal.api.transaction.TransactionTemplate; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Optional; +import com.google.common.base.Predicate; +import com.google.gson.Gson; + import se.bjurr.prnfb.listener.PrnfbPullRequestAction; import se.bjurr.prnfb.presentation.dto.ON_OR_OFF; import se.bjurr.prnfb.settings.HasUuid; @@ -33,18 +45,6 @@ import se.bjurr.prnfb.settings.legacy.Header; import se.bjurr.prnfb.settings.legacy.SettingsStorage; -import com.atlassian.bitbucket.pull.PullRequestState; -import com.atlassian.bitbucket.user.SecurityService; -import com.atlassian.bitbucket.util.Operation; -import com.atlassian.sal.api.pluginsettings.PluginSettings; -import com.atlassian.sal.api.pluginsettings.PluginSettingsFactory; -import com.atlassian.sal.api.transaction.TransactionCallback; -import com.atlassian.sal.api.transaction.TransactionTemplate; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; -import com.google.common.base.Predicate; -import com.google.gson.Gson; - public class SettingsService { public static final String STORAGE_KEY = "se.bjurr.prnfb.pull-request-notifier-for-bitbucket-3"; @@ -346,7 +346,14 @@ private PrnfbSettings settingsFromLegacy( } newButtons.add( new PrnfbButton( - UUID.randomUUID(), oldButton.getTitle(), userLevel, ON_OR_OFF.off, null, null, null)); + UUID.randomUUID(), + oldButton.getTitle(), + userLevel, + ON_OR_OFF.off, + null, + null, + "confirmationText", + null)); } List newNotifications = newArrayList(); diff --git a/src/main/java/se/bjurr/prnfb/settings/PrnfbButton.java b/src/main/java/se/bjurr/prnfb/settings/PrnfbButton.java index 778ae14b..5408aef6 100644 --- a/src/main/java/se/bjurr/prnfb/settings/PrnfbButton.java +++ b/src/main/java/se/bjurr/prnfb/settings/PrnfbButton.java @@ -22,6 +22,7 @@ public class PrnfbButton implements HasUuid { private final List buttonFormElementList; private final USER_LEVEL userLevel; private final UUID uuid; + private final String confirmationText; public PrnfbButton( UUID uuid, @@ -30,6 +31,7 @@ public PrnfbButton( ON_OR_OFF confirmation, String projectKey, String repositorySlug, + String confirmationText, List buttonFormElementList) { this.uuid = firstNonNull(uuid, randomUUID()); this.name = name; @@ -37,10 +39,44 @@ public PrnfbButton( this.confirmation = confirmation; this.repositorySlug = emptyToNull(repositorySlug); this.projectKey = emptyToNull(projectKey); + this.confirmationText = emptyToNull(confirmationText); this.buttonFormElementList = firstNonNull(buttonFormElementList, new ArrayList()); } + public String getConfirmationText() { + return confirmationText; + } + + public ON_OR_OFF getConfirmation() { + return this.confirmation; + } + + public String getName() { + return this.name; + } + + public List getButtonFormElementList() { + return buttonFormElementList; + } + + public Optional getProjectKey() { + return fromNullable(this.projectKey); + } + + public Optional getRepositorySlug() { + return fromNullable(this.repositorySlug); + } + + public USER_LEVEL getUserLevel() { + return this.userLevel; + } + + @Override + public UUID getUuid() { + return this.uuid; + } + @Override public boolean equals(Object obj) { if (this == obj) { @@ -63,6 +99,13 @@ public boolean equals(Object obj) { if (confirmation != other.confirmation) { return false; } + if (confirmationText == null) { + if (other.confirmationText != null) { + return false; + } + } else if (!confirmationText.equals(other.confirmationText)) { + return false; + } if (name == null) { if (other.name != null) { return false; @@ -97,35 +140,6 @@ public boolean equals(Object obj) { return true; } - public ON_OR_OFF getConfirmation() { - return this.confirmation; - } - - public String getName() { - return this.name; - } - - public List getButtonFormElementList() { - return buttonFormElementList; - } - - public Optional getProjectKey() { - return fromNullable(this.projectKey); - } - - public Optional getRepositorySlug() { - return fromNullable(this.repositorySlug); - } - - public USER_LEVEL getUserLevel() { - return this.userLevel; - } - - @Override - public UUID getUuid() { - return this.uuid; - } - @Override public int hashCode() { final int prime = 31; @@ -133,6 +147,7 @@ public int hashCode() { result = prime * result + (buttonFormElementList == null ? 0 : buttonFormElementList.hashCode()); result = prime * result + (confirmation == null ? 0 : confirmation.hashCode()); + result = prime * result + (confirmationText == null ? 0 : confirmationText.hashCode()); result = prime * result + (name == null ? 0 : name.hashCode()); result = prime * result + (projectKey == null ? 0 : projectKey.hashCode()); result = prime * result + (repositorySlug == null ? 0 : repositorySlug.hashCode()); @@ -157,6 +172,8 @@ public String toString() { + userLevel + ", uuid=" + uuid + + ", confirmationText=" + + confirmationText + "]"; } } diff --git a/src/main/java/se/bjurr/prnfb/transformer/ButtonTransformer.java b/src/main/java/se/bjurr/prnfb/transformer/ButtonTransformer.java index cfbb972f..1961353a 100644 --- a/src/main/java/se/bjurr/prnfb/transformer/ButtonTransformer.java +++ b/src/main/java/se/bjurr/prnfb/transformer/ButtonTransformer.java @@ -36,6 +36,7 @@ public static ButtonDTO toButtonDto(PrnfbButton from) { to.setProjectKey(from.getProjectKey().orNull()); to.setRepositorySlug(from.getRepositorySlug().orNull()); to.setConfirmation(from.getConfirmation()); + to.setConfirmationText(from.getConfirmationText()); to.setButtonFormList(toButtonFormDtoList(from.getButtonFormElementList())); String buttonFormDtoListString = gson.toJson(to.getButtonFormList()); to.setButtonFormListString(buttonFormDtoListString); @@ -106,6 +107,7 @@ public static PrnfbButton toPrnfbButton(ButtonDTO buttonDto) { buttonDto.getConfirmation(), // buttonDto.getProjectKey().orNull(), // buttonDto.getRepositorySlug().orNull(), // + buttonDto.getConfirmationText(), // buttonFormElement); // } diff --git a/src/main/resources/admin.vm b/src/main/resources/admin.vm index b8703c85..a33adde2 100644 --- a/src/main/resources/admin.vm +++ b/src/main/resources/admin.vm @@ -245,6 +245,12 @@
Whether to show a confirmation dialog.
+
+ + +
If not empty, a confirmation dialog will be shown with this message, before any notification is triggered.
+
+
diff --git a/src/main/resources/pr-triggerbutton.js b/src/main/resources/pr-triggerbutton.js index 4addb207..dea232ad 100644 --- a/src/main/resources/pr-triggerbutton.js +++ b/src/main/resources/pr-triggerbutton.js @@ -116,9 +116,18 @@ define('plugin/prnfb/pr-triggerbutton', [ return $("
").append(radioItems); }; + var confirmationTextTemplate = function(confirmationText) { + if (!confirmationText) { + return ''; + } + + var confirmationDiv = '
' + confirmationText + '
'; + return confirmationDiv; + }; + var formTemplate = function(formDescription) { if (!formDescription || formDescription.length === 0) { - return null; + return ''; } var formItems = []; @@ -244,10 +253,11 @@ define('plugin/prnfb/pr-triggerbutton', [ }); }; - if (item.buttonFormList && item.buttonFormList.length > 0) { + if (item.confirmationText || item.buttonFormList && item.buttonFormList.length > 0) { // Create the form and dialog + var confirmationText = confirmationTextTemplate(item.confirmationText); var form = formTemplate(item.buttonFormList); - var formHtml = $("
").append(form).html(); + var formHtml = $("
").append(confirmationText).append(form).html(); var $dialog = $(dialogTemplate(item.name, formHtml)); $dialog.appendTo($("body")); diff --git a/src/test/java/se/bjurr/prnfb/presentation/ButtonServletTest.java b/src/test/java/se/bjurr/prnfb/presentation/ButtonServletTest.java index 5305442a..1e0dc84e 100644 --- a/src/test/java/se/bjurr/prnfb/presentation/ButtonServletTest.java +++ b/src/test/java/se/bjurr/prnfb/presentation/ButtonServletTest.java @@ -72,9 +72,11 @@ public void before() throws Exception { this.sut = new ButtonServlet(this.buttonsService, this.settingsService, this.userCheckService); this.buttonDto1 = populatedInstanceOf(ButtonDTO.class); + this.buttonDto1.setButtonFormListString(null); this.button1 = toPrnfbButton(this.buttonDto1); this.buttonDto2 = populatedInstanceOf(ButtonDTO.class); + this.buttonDto2.setButtonFormListString(null); this.button2 = toPrnfbButton(this.buttonDto2); rendererWrapper = @@ -106,6 +108,7 @@ private PrnfbButton createPrnfbButton(ButtonDTO button) { button.getConfirmation(), "p1", "r1", + button.getConfirmationText(), new ArrayList<>()); return prnfbButton; } @@ -136,6 +139,11 @@ public void testThatButtonCanBeDeleted() throws Exception { @Test public void testThatButtonCanBeListed() { + this.buttonDto1.setButtonFormListString(null); + this.button1 = toPrnfbButton(this.buttonDto1); + this.buttonDto2.setButtonFormListString(null); + this.button2 = toPrnfbButton(this.buttonDto2); + when(this.settingsService.getButtons()) // .thenReturn(newArrayList(this.button1, this.button2)); allowAll(); @@ -143,6 +151,11 @@ public void testThatButtonCanBeListed() { Response actual = this.sut.get(); @SuppressWarnings("unchecked") Iterable actualList = (Iterable) actual.getEntity(); + Iterator itr = actualList.iterator(); + ButtonDTO first = itr.next(); + first.setButtonFormListString(null); + ButtonDTO second = itr.next(); + second.setButtonFormListString(null); assertThat(actualList) // .containsOnly(this.buttonDto1, this.buttonDto2); } @@ -150,6 +163,7 @@ public void testThatButtonCanBeListed() { @Test public void testThatButtonCanBeListedForAPr() throws Exception { this.buttonDto1 = populatedInstanceOf(ButtonDTO.class); + this.buttonDto1.setButtonFormListString(null); this.buttonDto1.setButtonFormList(this.buttonDto1.getButtonFormList().subList(0, 1)); this.buttonDto1 .getButtonFormList() @@ -161,7 +175,6 @@ public void testThatButtonCanBeListedForAPr() throws Exception { .getButtonFormElementOptionList() .subList(0, 1)); this.button1 = toPrnfbButton(this.buttonDto1); - Integer repositoryId = 2; Long pullRequestId = 3L; when(this.buttonsService.getButtons(repositoryId, pullRequestId)) // @@ -176,6 +189,7 @@ public void testThatButtonCanBeListedForAPr() throws Exception { Iterable actualList = (Iterable) actual.getEntity(); Iterator itr = actualList.iterator(); ButtonDTO buttonDTO1 = itr.next(); + buttonDTO1.setButtonFormListString(null); assertThat(buttonDTO1) // .isEqualTo(this.buttonDto1); } @@ -196,8 +210,11 @@ public void testThatButtonsCanBeListedForAPr() throws Exception { @SuppressWarnings("unchecked") Iterable actualList = (Iterable) actual.getEntity(); - assertThat(actualList) // - .hasSize(2); + Iterator itr = actualList.iterator(); + ButtonDTO first = itr.next(); + first.setButtonFormListString(null); + ButtonDTO second = itr.next(); + second.setButtonFormListString(null); assertThat(actualList) // .containsOnly(this.buttonDto1, this.buttonDto2); } @@ -211,7 +228,10 @@ public void testThatButtonCanBeListedPerProject() throws Exception { Response actual = this.sut.get(this.buttonDto1.getProjectKey().orNull()); @SuppressWarnings("unchecked") Iterable actualList = (Iterable) actual.getEntity(); - + ButtonDTO first = actualList.iterator().next(); + first.setButtonFormListString(null); + assertThat(first) // + .isEqualTo(this.buttonDto1); assertThat(actualList) // .containsOnly(this.buttonDto1); } @@ -222,6 +242,7 @@ public void testThatButtonCanBeListedPerProjectAndRepo() throws Exception { this.buttonDto1.getProjectKey().orNull(), this.buttonDto1.getRepositorySlug().orNull())) // .thenReturn(newArrayList(this.button1)); + this.buttonDto1.setButtonFormListString(null); allowAll(); Response actual = @@ -231,7 +252,7 @@ public void testThatButtonCanBeListedPerProjectAndRepo() throws Exception { Iterable actualList = (Iterable) actual.getEntity(); ButtonDTO firstButtonDto = actualList.iterator().next(); - + firstButtonDto.setButtonFormListString(null); assertThat(actualList) // .hasSize(1); assertThat(firstButtonDto) // diff --git a/src/test/java/se/bjurr/prnfb/service/ButtonsServiceTest.java b/src/test/java/se/bjurr/prnfb/service/ButtonsServiceTest.java index 628aab48..8fed06da 100644 --- a/src/test/java/se/bjurr/prnfb/service/ButtonsServiceTest.java +++ b/src/test/java/se/bjurr/prnfb/service/ButtonsServiceTest.java @@ -22,6 +22,16 @@ import org.junit.Test; import org.mockito.Mock; +import com.atlassian.bitbucket.auth.AuthenticationContext; +import com.atlassian.bitbucket.project.Project; +import com.atlassian.bitbucket.pull.PullRequest; +import com.atlassian.bitbucket.pull.PullRequestRef; +import com.atlassian.bitbucket.pull.PullRequestService; +import com.atlassian.bitbucket.repository.Repository; +import com.atlassian.bitbucket.repository.RepositoryService; +import com.atlassian.bitbucket.server.ApplicationPropertiesService; +import com.google.common.collect.Lists; + import se.bjurr.prnfb.http.ClientKeyStore; import se.bjurr.prnfb.listener.PrnfbPullRequestAction; import se.bjurr.prnfb.listener.PrnfbPullRequestEventListener; @@ -33,16 +43,6 @@ import se.bjurr.prnfb.settings.USER_LEVEL; import se.bjurr.prnfb.settings.ValidationException; -import com.atlassian.bitbucket.auth.AuthenticationContext; -import com.atlassian.bitbucket.project.Project; -import com.atlassian.bitbucket.pull.PullRequest; -import com.atlassian.bitbucket.pull.PullRequestRef; -import com.atlassian.bitbucket.pull.PullRequestService; -import com.atlassian.bitbucket.repository.Repository; -import com.atlassian.bitbucket.repository.RepositoryService; -import com.atlassian.bitbucket.server.ApplicationPropertiesService; -import com.google.common.collect.Lists; - public class ButtonsServiceTest { @Mock private AuthenticationContext authenticationContext; @@ -305,6 +305,7 @@ private void testVisibilityOnRepository( this.confirmation, buttonProjectKey, buttonRepositorySlug, + "confirmationText", null); when(this.repository.getProject()).thenReturn(this.project); when(this.repository.getProject().getKey()) // diff --git a/src/test/java/se/bjurr/prnfb/service/SettingsServiceTest.java b/src/test/java/se/bjurr/prnfb/service/SettingsServiceTest.java index 28335a73..1c366847 100644 --- a/src/test/java/se/bjurr/prnfb/service/SettingsServiceTest.java +++ b/src/test/java/se/bjurr/prnfb/service/SettingsServiceTest.java @@ -19,12 +19,6 @@ import org.junit.Test; import org.mockito.Mock; -import se.bjurr.prnfb.presentation.dto.ON_OR_OFF; -import se.bjurr.prnfb.settings.PrnfbButton; -import se.bjurr.prnfb.settings.PrnfbNotification; -import se.bjurr.prnfb.settings.PrnfbSettings; -import se.bjurr.prnfb.settings.ValidationException; - import com.atlassian.bitbucket.permission.Permission; import com.atlassian.bitbucket.user.EscalatedSecurityContext; import com.atlassian.bitbucket.user.SecurityService; @@ -34,6 +28,12 @@ import com.atlassian.sal.api.transaction.TransactionTemplate; import com.google.gson.Gson; +import se.bjurr.prnfb.presentation.dto.ON_OR_OFF; +import se.bjurr.prnfb.settings.PrnfbButton; +import se.bjurr.prnfb.settings.PrnfbNotification; +import se.bjurr.prnfb.settings.PrnfbSettings; +import se.bjurr.prnfb.settings.ValidationException; + public class SettingsServiceTest { private EscalatedSecurityContext escalatedSecurityContext; private PrnfbNotification notification1; @@ -97,7 +97,9 @@ public T execute(TransactionCallback action) { @Test public void testThatButtonCanBeAddedUpdatedAndDeleted() { - PrnfbButton button1 = new PrnfbButton(null, "title", EVERYONE, ON_OR_OFF.off, "p1", "r1", null); + PrnfbButton button1 = + new PrnfbButton( + null, "title", EVERYONE, ON_OR_OFF.off, "p1", "r1", "confirmationText", null); assertThat(this.sut.getButtons()) // .isEmpty(); @@ -105,13 +107,23 @@ public void testThatButtonCanBeAddedUpdatedAndDeleted() { assertThat(this.sut.getButtons()) // .containsExactly(button1); - PrnfbButton button2 = new PrnfbButton(null, "title", EVERYONE, ON_OR_OFF.off, "p1", "r1", null); + PrnfbButton button2 = + new PrnfbButton( + null, "title", EVERYONE, ON_OR_OFF.off, "p1", "r1", "confirmationText", null); this.sut.addOrUpdateButton(button2); assertThat(this.sut.getButtons()) // .containsExactly(button1, button2); PrnfbButton updated = - new PrnfbButton(button1.getUuid(), "title2", ADMIN, ON_OR_OFF.off, "p1", "r1", null); + new PrnfbButton( + button1.getUuid(), + "title2", + ADMIN, + ON_OR_OFF.off, + "p1", + "r1", + "confirmationText", + null); this.sut.addOrUpdateButton(updated); assertThat(this.sut.getButtons()) // .containsExactly(button2, updated); diff --git a/src/test/java/se/bjurr/prnfb/service/UserCheckServiceTest.java b/src/test/java/se/bjurr/prnfb/service/UserCheckServiceTest.java index 3c014e97..8ac89dcd 100644 --- a/src/test/java/se/bjurr/prnfb/service/UserCheckServiceTest.java +++ b/src/test/java/se/bjurr/prnfb/service/UserCheckServiceTest.java @@ -16,9 +16,6 @@ import org.mockito.Matchers; import org.mockito.Mock; -import se.bjurr.prnfb.presentation.dto.ON_OR_OFF; -import se.bjurr.prnfb.settings.PrnfbButton; - import com.atlassian.bitbucket.permission.Permission; import com.atlassian.bitbucket.permission.PermissionService; import com.atlassian.bitbucket.project.ProjectService; @@ -30,6 +27,9 @@ import com.atlassian.sal.api.user.UserManager; import com.atlassian.sal.api.user.UserProfile; +import se.bjurr.prnfb.presentation.dto.ON_OR_OFF; +import se.bjurr.prnfb.settings.PrnfbButton; + public class UserCheckServiceTest { private final EscalatedSecurityContext escalatedSecurityContext = new EscalatedSecurityContext() { @@ -107,11 +107,14 @@ public void testThatAllowedButtonsCanBeFiltered() { when(this.userManager.isAdmin(this.userKey)) // .thenReturn(false); - PrnfbButton button1 = new PrnfbButton(null, "title1", ADMIN, ON_OR_OFF.off, "p1", "r1", null); + PrnfbButton button1 = + new PrnfbButton(null, "title1", ADMIN, ON_OR_OFF.off, "p1", "r1", "confirmationText", null); PrnfbButton button2 = - new PrnfbButton(null, "title2", EVERYONE, ON_OR_OFF.off, "p1", "r1", null); + new PrnfbButton( + null, "title2", EVERYONE, ON_OR_OFF.off, "p1", "r1", "confirmationText", null); PrnfbButton button3 = - new PrnfbButton(null, "title3", SYSTEM_ADMIN, ON_OR_OFF.off, "p1", "r1", null); + new PrnfbButton( + null, "title3", SYSTEM_ADMIN, ON_OR_OFF.off, "p1", "r1", "confirmationText", null); List buttons = newArrayList(button1, button2, button3); Iterable onlyAllowed = this.sut.filterAllowed(buttons); @@ -132,7 +135,8 @@ public void testThatAllowedCanBeChecked() { when(this.userManager.isSystemAdmin(this.userKey)) // .thenReturn(true); - PrnfbButton candidate = new PrnfbButton(null, "title", ADMIN, ON_OR_OFF.off, "p1", "r1", null); + PrnfbButton candidate = + new PrnfbButton(null, "title", ADMIN, ON_OR_OFF.off, "p1", "r1", "confirmationText", null); assertThat(this.sut.isAllowedUseButton(candidate)) // .isTrue(); diff --git a/src/test/java/se/bjurr/prnfb/transformer/SettingsDataTransformerTest.java b/src/test/java/se/bjurr/prnfb/transformer/SettingsDataTransformerTest.java index 91a9a0d0..54d2f4df 100644 --- a/src/test/java/se/bjurr/prnfb/transformer/SettingsDataTransformerTest.java +++ b/src/test/java/se/bjurr/prnfb/transformer/SettingsDataTransformerTest.java @@ -15,6 +15,7 @@ public class SettingsDataTransformerTest { public void testTransformation() throws ValidationException { ButtonDTO originalDto = populatedInstanceOf(ButtonDTO.class); ButtonDTO retransformedDto = toButtonDto(toPrnfbButton(originalDto)); + retransformedDto.setButtonFormListString(originalDto.getButtonFormListString()); assertThat(retransformedDto) // .isEqualTo(originalDto);