working on tests
This commit is contained in:
@@ -22,6 +22,7 @@ public class ListMember {
|
||||
public static final int STATE_OWNER = 1;
|
||||
public static final int STATE_SUBSCRIBER = 2;
|
||||
public static final int STATE_AWAITING_CONFIRMATION = 4;
|
||||
public static final int STATE_MODERATOR = 8;
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ListMember.class);
|
||||
private static final String LIST_EMAIL = "list_email";
|
||||
private static final String USER_EMAIL = "user_email";
|
||||
@@ -135,11 +136,23 @@ public class ListMember {
|
||||
return (state & testState) > 0;
|
||||
}
|
||||
|
||||
public boolean isAwaiting(){
|
||||
return hasState(STATE_AWAITING_CONFIRMATION);
|
||||
}
|
||||
|
||||
public boolean isModerator() {
|
||||
return hasState(STATE_OWNER|STATE_MODERATOR);
|
||||
}
|
||||
|
||||
public boolean isOwner(){
|
||||
return hasState(STATE_OWNER);
|
||||
}
|
||||
|
||||
public boolean isSubscriber(){
|
||||
return hasState(STATE_SUBSCRIBER|STATE_MODERATOR|STATE_OWNER);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* return a set of list emails of MailingLists owned by the given user
|
||||
* @param user
|
||||
@@ -197,7 +210,7 @@ public class ListMember {
|
||||
return Map.of(
|
||||
EMAIL,user.email(),
|
||||
NAME,user.name(),
|
||||
STATE,ListMember.stateText(state)
|
||||
STATE,stateText()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -219,14 +232,14 @@ public class ListMember {
|
||||
|
||||
/**
|
||||
* convert state flag to readable text
|
||||
* @param state
|
||||
* @return
|
||||
*/
|
||||
public static String stateText(int state) {
|
||||
public String stateText() {
|
||||
var words = new ArrayList<String>();
|
||||
if ((state & STATE_OWNER) > 0) words.add("owner");
|
||||
if ((state & STATE_SUBSCRIBER) > 0) words.add("subscriber");
|
||||
if ((state & STATE_AWAITING_CONFIRMATION) > 0) words.add("awaiting confirmation");
|
||||
if (isAwaiting()) words.add("awaiting confirmation");
|
||||
if (isModerator()) words.add("moderator");
|
||||
if (isOwner()) words.add("owner");
|
||||
if (isSubscriber()) words.add("subscriber");
|
||||
return String.join(", ",words);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user