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 { ...@@ -32,7 +32,7 @@ public class EmailOnPushService extends NotificationService {
@JsonIgnore @JsonIgnore
public String getRecipients() { public String getRecipients() {
return ((String)getProperty(RECIPIENT_PROP)); return (getProperty(RECIPIENT_PROP));
} }
public void setRecipients(String recipients) { public void setRecipients(String recipients) {
setProperty(RECIPIENT_PROP, recipients); setProperty(RECIPIENT_PROP, recipients);
...@@ -45,7 +45,7 @@ public class EmailOnPushService extends NotificationService { ...@@ -45,7 +45,7 @@ public class EmailOnPushService extends NotificationService {
@JsonIgnore @JsonIgnore
public Boolean getDisableDiffs() { public Boolean getDisableDiffs() {
return Boolean.valueOf(getProperty(DISABLE_DIFFS_PROP,"false")); return Boolean.valueOf(getProperty(DISABLE_DIFFS_PROP, false));
} }
public void setDisableDiffs(Boolean disableDiffs) { public void setDisableDiffs(Boolean disableDiffs) {
setProperty(DISABLE_DIFFS_PROP, disableDiffs); setProperty(DISABLE_DIFFS_PROP, disableDiffs);
...@@ -54,10 +54,10 @@ public class EmailOnPushService extends NotificationService { ...@@ -54,10 +54,10 @@ public class EmailOnPushService extends NotificationService {
setDisableDiffs(disableDiffs); setDisableDiffs(disableDiffs);
return this; return this;
} }
@JsonIgnore @JsonIgnore
public Boolean getSendFromCommitterEmail() { 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) { public void setSendFromCommitterEmail(Boolean sendFromCommitterEmail) {
setProperty(SEND_FROM_COMMITTER_EMAIL_PROP, sendFromCommitterEmail); setProperty(SEND_FROM_COMMITTER_EMAIL_PROP, sendFromCommitterEmail);
...@@ -68,16 +68,20 @@ public class EmailOnPushService extends NotificationService { ...@@ -68,16 +68,20 @@ public class EmailOnPushService extends NotificationService {
} }
@JsonIgnore @JsonIgnore
public String getBranchesToBeNotified() { public BranchesToBeNotified getBranchesToBeNotified() {
return ((String)getProperty(BRANCHES_TO_BE_NOTIFIED_PROP)); 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) { public void setBranchesToBeNotified(BranchesToBeNotified branchesToBeNotified) {
setProperty(BRANCHES_TO_BE_NOTIFIED_PROP, branchesToBeNotified); setProperty(BRANCHES_TO_BE_NOTIFIED_PROP, branchesToBeNotified.toString());
} }
public EmailOnPushService withBranchesToBeNotified(String branchesToBeNotified) { public EmailOnPushService withBranchesToBeNotified(BranchesToBeNotified branchesToBeNotified) {
setBranchesToBeNotified(branchesToBeNotified); setBranchesToBeNotified(branchesToBeNotified);
return this; return this;
} }
} }
...@@ -34,10 +34,12 @@ public abstract class NotificationService { ...@@ -34,10 +34,12 @@ public abstract class NotificationService {
private Integer id; private Integer id;
private String title; private String title;
private String slug;
private Date createdAt; private Date createdAt;
private Date updatedAt; private Date updatedAt;
private Boolean active; private Boolean active;
private Boolean commitEvents;
private Boolean pushEvents; private Boolean pushEvents;
private Boolean issuesEvents; private Boolean issuesEvents;
private Boolean confidentialIssuesEvents; private Boolean confidentialIssuesEvents;
...@@ -61,6 +63,14 @@ public abstract class NotificationService { ...@@ -61,6 +63,14 @@ public abstract class NotificationService {
this.id = id; this.id = id;
} }
public String getSlug() {
return slug;
}
public void setSlug(String slug) {
this.slug = slug;
}
public String getTitle() { public String getTitle() {
return title; return title;
} }
...@@ -97,6 +107,19 @@ public abstract class NotificationService { ...@@ -97,6 +107,19 @@ public abstract class NotificationService {
// The following methods can be used to configure the notification service // 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() { public Boolean getPushEvents() {
return pushEvents; return pushEvents;
} }
...@@ -237,7 +260,7 @@ public abstract class NotificationService { ...@@ -237,7 +260,7 @@ public abstract class NotificationService {
@JsonIgnore @JsonIgnore
protected String getProperty(String prop) { protected String getProperty(String prop) {
return ((String) getProperty(prop, "")); return (getProperty(prop, ""));
} }
@JsonIgnore @JsonIgnore
...@@ -270,4 +293,13 @@ public abstract class NotificationService { ...@@ -270,4 +293,13 @@ public abstract class NotificationService {
public String toString() { public String toString() {
return (JacksonJson.toJsonString(this)); 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