Stephan Richter
3 years ago
17 changed files with 613 additions and 145 deletions
@ -1,16 +0,0 @@ |
|||||||
<configuration scan="true" scanPeriod="30 seconds" debug="true"> |
|
||||||
<!-- scan="true" enables automatic updates if config file changes, see http://logback.qos.ch/manual/configuration.html --> |
|
||||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> |
|
||||||
<encoder> |
|
||||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5}: %msg%n |
|
||||||
</pattern> |
|
||||||
</encoder> |
|
||||||
</appender> |
|
||||||
|
|
||||||
<root level="WARN"> |
|
||||||
<appender-ref ref="STDOUT" /> |
|
||||||
</root> |
|
||||||
|
|
||||||
<logger name="de.srsoftware" level="DEBUG" /> |
|
||||||
|
|
||||||
</configuration> |
|
@ -0,0 +1,144 @@ |
|||||||
|
package de.srsoftware.widerhall.data; |
||||||
|
|
||||||
|
import junit.framework.TestCase; |
||||||
|
|
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
import static de.srsoftware.widerhall.Constants.*; |
||||||
|
|
||||||
|
public class ListMemberTest extends TestCase { |
||||||
|
|
||||||
|
/*public void testConfirm() { |
||||||
|
NEEDS MOCK |
||||||
|
}*/ |
||||||
|
|
||||||
|
/*public void testCreate() { |
||||||
|
NEEDS MOCK |
||||||
|
}*/ |
||||||
|
|
||||||
|
/*public void testCreateTable() { |
||||||
|
NEEDS MOCK |
||||||
|
}*/ |
||||||
|
|
||||||
|
/*public void testFrom() { |
||||||
|
NEEDS MOCK |
||||||
|
}*/ |
||||||
|
|
||||||
|
public void testHasState() { |
||||||
|
int state = 32 | 8 | 2; |
||||||
|
ListMember lm = new ListMember(null,null,state,null); |
||||||
|
assertFalse(lm.hasState(1)); |
||||||
|
assertTrue(lm.hasState(2)); |
||||||
|
assertFalse(lm.hasState(4)); |
||||||
|
assertTrue(lm.hasState(8)); |
||||||
|
assertFalse(lm.hasState(16)); |
||||||
|
assertTrue(lm.hasState(32)); |
||||||
|
|
||||||
|
assertTrue(lm.hasState(1|2)); |
||||||
|
assertFalse(lm.hasState(1|4)); |
||||||
|
assertTrue(lm.hasState(1|8)); |
||||||
|
assertFalse(lm.hasState(1|16)); |
||||||
|
assertTrue(lm.hasState(1|32)); |
||||||
|
|
||||||
|
assertTrue(lm.hasState(2|4)); |
||||||
|
assertTrue(lm.hasState(2|8)); |
||||||
|
assertTrue(lm.hasState(2|16)); |
||||||
|
assertTrue(lm.hasState(2|32)); |
||||||
|
|
||||||
|
assertTrue(lm.hasState(4|8)); |
||||||
|
assertFalse(lm.hasState(4|16)); |
||||||
|
assertTrue(lm.hasState(4|32)); |
||||||
|
|
||||||
|
assertTrue(lm.hasState(8|16)); |
||||||
|
assertTrue(lm.hasState(8|32)); |
||||||
|
|
||||||
|
assertTrue(lm.hasState(16|32)); |
||||||
|
|
||||||
|
assertTrue(lm.hasState(1|2|4)); |
||||||
|
assertTrue(lm.hasState(1|2|8)); |
||||||
|
assertTrue(lm.hasState(1|2|16)); |
||||||
|
assertTrue(lm.hasState(1|2|32)); |
||||||
|
assertTrue(lm.hasState(1|4|8)); |
||||||
|
assertFalse(lm.hasState(1|4|16)); |
||||||
|
assertTrue(lm.hasState(1|4|32)); |
||||||
|
assertTrue(lm.hasState(1|8|16)); |
||||||
|
assertTrue(lm.hasState(1|8|32)); |
||||||
|
assertTrue(lm.hasState(1|16|32)); |
||||||
|
|
||||||
|
assertTrue(lm.hasState(2|4|8)); |
||||||
|
assertTrue(lm.hasState(2|4|16)); |
||||||
|
assertTrue(lm.hasState(2|4|32)); |
||||||
|
assertTrue(lm.hasState(2|8|16)); |
||||||
|
assertTrue(lm.hasState(2|8|32)); |
||||||
|
assertTrue(lm.hasState(2|16|32)); |
||||||
|
|
||||||
|
assertTrue(lm.hasState(4|8|16)); |
||||||
|
assertTrue(lm.hasState(4|8|32)); |
||||||
|
assertTrue(lm.hasState(4|16|32)); |
||||||
|
assertTrue(lm.hasState(8|16|32)); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public void testIsOwner() { |
||||||
|
var guest = new ListMember(null,null,ListMember.STATE_SUBSCRIBER,null); |
||||||
|
var owner = new ListMember(null,null,ListMember.STATE_OWNER,null); |
||||||
|
var mod = new ListMember(null,null,ListMember.STATE_MODERATOR,null); |
||||||
|
assertFalse(guest.isOwner()); |
||||||
|
assertTrue(owner.isOwner()); |
||||||
|
assertFalse(mod.isOwner()); |
||||||
|
} |
||||||
|
|
||||||
|
public void testIsModerator() { |
||||||
|
var guest = new ListMember(null,null,ListMember.STATE_SUBSCRIBER,null); |
||||||
|
var owner = new ListMember(null,null,ListMember.STATE_OWNER,null); |
||||||
|
var mod = new ListMember(null,null,ListMember.STATE_MODERATOR,null); |
||||||
|
assertFalse(guest.isModerator()); |
||||||
|
assertTrue(owner.isModerator()); |
||||||
|
assertTrue(mod.isModerator()); |
||||||
|
} |
||||||
|
|
||||||
|
/*public void testListsOwnedBy() { |
||||||
|
NEEDS MOCK |
||||||
|
}*/ |
||||||
|
|
||||||
|
/*public void testLoad() { |
||||||
|
NEEDS MOCK |
||||||
|
}*/ |
||||||
|
|
||||||
|
/*public void testOf() { |
||||||
|
NEEDS MOCK |
||||||
|
}*/ |
||||||
|
|
||||||
|
public void testSafeMap() { |
||||||
|
var user = new User("email","name","salt","hash",0); |
||||||
|
var lm = new ListMember(null,user,ListMember.STATE_AWAITING_CONFIRMATION,"token"); |
||||||
|
assertEquals(Map.of(EMAIL,"email",NAME,"name",STATE,"awaiting confirmation"),lm.safeMap()); |
||||||
|
} |
||||||
|
|
||||||
|
public void testStateText() { |
||||||
|
var guest = new ListMember(null,null,ListMember.STATE_SUBSCRIBER,null); |
||||||
|
var owner = new ListMember(null,null,ListMember.STATE_OWNER,null); |
||||||
|
var mod = new ListMember(null,null,ListMember.STATE_MODERATOR,null); |
||||||
|
var await = new ListMember(null,null,ListMember.STATE_AWAITING_CONFIRMATION,null); |
||||||
|
|
||||||
|
assertEquals("subscriber",guest.stateText()); |
||||||
|
assertEquals("moderator, owner, subscriber",owner.stateText()); |
||||||
|
assertEquals("moderator, subscriber",mod.stateText()); |
||||||
|
assertEquals("awaiting confirmation",await.stateText()); |
||||||
|
} |
||||||
|
|
||||||
|
public void testToken() { |
||||||
|
var lm = new ListMember(null,null,0,"bam"); |
||||||
|
assertEquals("bam",lm.token()); |
||||||
|
} |
||||||
|
|
||||||
|
/*public void testUnsubscribe() { |
||||||
|
NEEDS MOCK |
||||||
|
}*/ |
||||||
|
|
||||||
|
public void testUser() { |
||||||
|
var user = new User("email","name","salt","hash",0); |
||||||
|
var lm = new ListMember(null,user,ListMember.STATE_AWAITING_CONFIRMATION,"token"); |
||||||
|
assertEquals(user,lm.user()); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue