source: party/src/test/java/geniusweb/party/DefaultPartyTest.java@ 43

Last change on this file since 43 was 43, checked in by bart, 3 years ago

Added python timedependent parties (conceder, hardliner, etc)

File size: 2.2 KB
RevLine 
[43]1package geniusweb.party;
2
3import static org.junit.Assert.assertNotNull;
4import static org.junit.Assert.assertNull;
5import static org.mockito.Matchers.any;
6import static org.mockito.Mockito.mock;
7import static org.mockito.Mockito.times;
8import static org.mockito.Mockito.verify;
9
10import org.junit.Before;
11import org.junit.Test;
12
13import geniusweb.actions.Action;
14import geniusweb.connection.ConnectionEnd;
15import geniusweb.inform.Inform;
16import tudelft.utilities.listener.Listener;
17
18public class DefaultPartyTest {
19
20 private DefaultParty party;
21
22 @Before
23 public void before() {
24 party = new DefaultParty() {
25
26 @Override
27 public void notifyChange(Inform data) {
28 // TODO Auto-generated method stub
29
30 }
31
32 @Override
33 public String getDescription() {
34 // TODO Auto-generated method stub
35 return null;
36 }
37
38 @Override
39 public Capabilities getCapabilities() {
40 // TODO Auto-generated method stub
41 return null;
42 }
43 };
44
45 }
46
47 @Test
48 public void smoke() {
49 }
50
51 @Test
52 public void getReporter() {
53 assertNotNull(party.getReporter());
54 }
55
56 @SuppressWarnings("unchecked")
57 @Test
58 public void connect() {
59
60 ConnectionEnd<Inform, Action> connection = mock(ConnectionEnd.class);
61 party.connect(connection);
62
63 verify(connection, times(1)).addListener(any(Listener.class));
64 assertNotNull(party.getConnection());
65 }
66
67 @SuppressWarnings("unchecked")
68 @Test
69 public void disconnect() {
70
71 ConnectionEnd<Inform, Action> connection = mock(ConnectionEnd.class);
72 party.connect(connection);
73
74 party.disconnect();
75 verify(connection, times(1)).removeListener(any(Listener.class));
76 assertNull(party.getConnection());
77
78 // check second disconnect is ignored
79 party.disconnect();
80 verify(connection, times(1)).removeListener(any(Listener.class));
81 assertNull(party.getConnection());
82
83 }
84
85 @SuppressWarnings("unchecked")
86 @Test
87 public void terminate() {
88
89 ConnectionEnd<Inform, Action> connection = mock(ConnectionEnd.class);
90 party.connect(connection);
91
92 party.terminate();
93 verify(connection, times(1)).removeListener(any(Listener.class));
94 assertNull(party.getConnection());
95
96 // check second terminate is ignored
97 party.terminate();
98 verify(connection, times(1)).removeListener(any(Listener.class));
99 assertNull(party.getConnection());
100
101 }
102
103}
Note: See TracBrowser for help on using the repository browser.