Unverified Commit b5e8e839 authored by Gautier de Saint Martin Lacaze's avatar Gautier de Saint Martin Lacaze Committed by GitHub
Browse files

Merge pull request #673 from gitlab4j/pr-662-add-tests

test: Add tests for EmailOnPushService
parents d1556748 2b8bdcf0
......@@ -32,7 +32,7 @@ public class EmailOnPushService extends NotificationService {
@JsonIgnore
public String getRecipients() {
return ((String)getProperty(RECIPIENT_PROP));
return (getProperty(RECIPIENT_PROP));
}
public void setRecipients(String recipients) {
setProperty(RECIPIENT_PROP, recipients);
......@@ -45,7 +45,7 @@ public class EmailOnPushService extends NotificationService {
@JsonIgnore
public Boolean getDisableDiffs() {
return Boolean.valueOf(getProperty(DISABLE_DIFFS_PROP,"false"));
return Boolean.valueOf(getProperty(DISABLE_DIFFS_PROP, false));
}
public void setDisableDiffs(Boolean disableDiffs) {
setProperty(DISABLE_DIFFS_PROP, disableDiffs);
......@@ -54,10 +54,10 @@ public class EmailOnPushService extends NotificationService {
setDisableDiffs(disableDiffs);
return this;
}
@JsonIgnore
public Boolean getSendFromCommitterEmail() {
return Boolean.valueOf(getProperty(SEND_FROM_COMMITTER_EMAIL_PROP,"false"));
return Boolean.valueOf(getProperty(SEND_FROM_COMMITTER_EMAIL_PROP, false));
}
public void setSendFromCommitterEmail(Boolean sendFromCommitterEmail) {
setProperty(SEND_FROM_COMMITTER_EMAIL_PROP, sendFromCommitterEmail);
......@@ -68,16 +68,20 @@ public class EmailOnPushService extends NotificationService {
}
@JsonIgnore
public String getBranchesToBeNotified() {
return ((String)getProperty(BRANCHES_TO_BE_NOTIFIED_PROP));
public BranchesToBeNotified getBranchesToBeNotified() {
String branchesToBeNotified = getProperty(BRANCHES_TO_BE_NOTIFIED_PROP);
if (branchesToBeNotified == null || branchesToBeNotified.isEmpty()) {
return null;
}
return (BranchesToBeNotified.valueOf(branchesToBeNotified.toUpperCase()));
}
public void setBranchesToBeNotified(String branchesToBeNotified) {
setProperty(BRANCHES_TO_BE_NOTIFIED_PROP, branchesToBeNotified);
public void setBranchesToBeNotified(BranchesToBeNotified branchesToBeNotified) {
setProperty(BRANCHES_TO_BE_NOTIFIED_PROP, branchesToBeNotified.toString());
}
public EmailOnPushService withBranchesToBeNotified(String branchesToBeNotified) {
public EmailOnPushService withBranchesToBeNotified(BranchesToBeNotified branchesToBeNotified) {
setBranchesToBeNotified(branchesToBeNotified);
return this;
}
}
......@@ -34,10 +34,12 @@ public abstract class NotificationService {
private Integer id;
private String title;
private String slug;
private Date createdAt;
private Date updatedAt;
private Boolean active;
private Boolean commitEvents;
private Boolean pushEvents;
private Boolean issuesEvents;
private Boolean confidentialIssuesEvents;
......@@ -61,6 +63,14 @@ public abstract class NotificationService {
this.id = id;
}
public String getSlug() {
return slug;
}
public void setSlug(String slug) {
this.slug = slug;
}
public String getTitle() {
return title;
}
......@@ -97,6 +107,19 @@ public abstract class NotificationService {
// The following methods can be used to configure the notification service
// *******************************************************************************
public Boolean getCommitEvents() {
return commitEvents;
}
public void setCommitEvents(Boolean commitEvents) {
this.commitEvents = commitEvents;
}
protected <T> T withCommitEvents(Boolean commitEvents, T derivedInstance) {
this.commitEvents = commitEvents;
return (derivedInstance);
}
public Boolean getPushEvents() {
return pushEvents;
}
......@@ -237,7 +260,7 @@ public abstract class NotificationService {
@JsonIgnore
protected String getProperty(String prop) {
return ((String) getProperty(prop, ""));
return (getProperty(prop, ""));
}
@JsonIgnore
......@@ -270,4 +293,13 @@ public abstract class NotificationService {
public String toString() {
return (JacksonJson.toJsonString(this));
}
public enum BranchesToBeNotified {
ALL, DEFAULT, PROTECTED, DEFAULT_AND_PROTECTED;
@Override
public String toString() {
return (name().toLowerCase());
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment