Index: protocol/src/test/java/geniusweb/protocol/CurrentNegoStateTest.java
===================================================================
--- protocol/src/test/java/geniusweb/protocol/CurrentNegoStateTest.java	(revision 52)
+++ 	(revision )
@@ -1,50 +1,0 @@
-package geniusweb.protocol;
-
-import static org.mockito.Mockito.mock;
-
-import java.util.Arrays;
-import java.util.LinkedList;
-import java.util.List;
-
-import geniusweb.actions.Action;
-import geniusweb.actions.PartyId;
-import geniusweb.progress.Progress;
-import geniusweb.progress.ProgressTime;
-import geniusweb.protocol.session.saop.SAOPSettings;
-import geniusweb.protocol.session.saop.SAOPState;
-import tudelft.utilities.junit.GeneralTests;
-
-public class CurrentNegoStateTest extends GeneralTests<CurrentNegoState> {
-	private PartyId party1 = new PartyId("party1");
-	private PartyId party2 = new PartyId("party2");
-	private List<Action> actions1 = new LinkedList<>();
-
-	private List<PartyId> connections = Arrays.asList(party1);
-	private List<PartyId> connections2 = Arrays.asList(party1, party2);
-
-	private Progress progresstime = mock(ProgressTime.class);
-	private SAOPSettings settings = mock(SAOPSettings.class);
-
-	SAOPState saop1 = new SAOPState(actions1, connections2, progresstime,
-			settings, null, null);
-	SAOPState saop2 = new SAOPState(actions1, connections, progresstime,
-			settings, null, null);
-
-	CurrentNegoState state1 = new CurrentNegoState(saop1);
-	CurrentNegoState state1a = new CurrentNegoState(saop1);
-	CurrentNegoState state2 = new CurrentNegoState(saop2);
-
-	@Override
-	public List<List<CurrentNegoState>> getGeneralTestData() {
-		return Arrays.asList(Arrays.asList(state1, state1a),
-				Arrays.asList(state2));
-	}
-
-	@Override
-	public List<String> getGeneralTestStrings() {
-		return Arrays.asList(
-				"CurrentNegoState.*SAOPState.*party1.*party2.*ProgressTime.*SAOPSettings.*",
-				"CurrentNegoState.*SAOPState.*party1.*ProgressTime.*SAOPSettings.*");
-	}
-
-}
Index: protocol/src/test/java/geniusweb/protocol/ProtocolExceptionTest.java
===================================================================
--- protocol/src/test/java/geniusweb/protocol/ProtocolExceptionTest.java	(revision 52)
+++ 	(revision )
@@ -1,54 +1,0 @@
-package geniusweb.protocol;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.util.ObjectBuffer;
-
-import geniusweb.actions.PartyId;
-
-public class ProtocolExceptionTest {
-	private ObjectBuffer jackson = new ObjectBuffer();
-	private Exception exception;
-	private String asString1 = "{\"cause\":null,\"stackTrace\":[],\"party\":\"party1\",\"message\":\"party1:test\",\"suppressed\":[],\"localizedMessage\":\"party1:test\"}";
-
-	@Before
-	public void before() {
-		try {
-			throw new ProtocolException("test", new PartyId("party1"));
-			// int x = 1 / 0;
-		} catch (Exception e) {
-			this.exception = e;
-			System.out.println(e);
-		}
-	}
-
-	@Test
-	public void testSerialize() throws JsonProcessingException {
-
-		ObjectMapper jackson = new ObjectMapper();
-		System.out.println(jackson.writeValueAsString(exception));
-		// disabled check , does not work either in Java8 or in Java16 because
-		// field order seems swapped
-//		assertEquals(asString1, jackson.writeValueAsString(exception));
-
-	}
-
-	// ProtocolExceptions can not be deserialized now
-	@Ignore
-	@Test
-	public void testDeserialize() throws IOException {
-
-		ObjectMapper jackson = new ObjectMapper();
-		Exception read = jackson.readValue(asString1, ProtocolException.class);
-		assertEquals(exception, read);
-	}
-
-}
Index: protocol/src/test/java/geniusweb/protocol/session/ConnectionWithPartiesTest.java
===================================================================
--- protocol/src/test/java/geniusweb/protocol/session/ConnectionWithPartiesTest.java	(revision 52)
+++ protocol/src/test/java/geniusweb/protocol/session/ConnectionWithPartiesTest.java	(revision 1)
@@ -14,29 +14,29 @@
 
 import geniusweb.actions.PartyId;
-import geniusweb.protocol.partyconnection.ProtocolToPartyConnections;
-import geniusweb.protocol.partyconnection.ProtocolToPartyConn;
+import geniusweb.protocol.partyconnection.ConnectionWithParties;
+import geniusweb.protocol.partyconnection.ConnectionWithParty;
 import tudelft.utilities.junit.GeneralTests;
 
 public class ConnectionWithPartiesTest
-		extends GeneralTests<ProtocolToPartyConnections> {
+		extends GeneralTests<ConnectionWithParties> {
 	PartyId party1 = new PartyId("party1");
 	PartyId party2 = new PartyId("party2");
 	PartyId party3 = new PartyId("party3");
 
-	private ProtocolToPartyConn con1 = mock(ProtocolToPartyConn.class);
-	private ProtocolToPartyConn con2 = mock(ProtocolToPartyConn.class);
-	private ProtocolToPartyConn con3 = mock(ProtocolToPartyConn.class);
+	private ConnectionWithParty con1 = mock(ConnectionWithParty.class);
+	private ConnectionWithParty con2 = mock(ConnectionWithParty.class);
+	private ConnectionWithParty con3 = mock(ConnectionWithParty.class);
 
-	private ProtocolToPartyConnections conns1 = new ProtocolToPartyConnections(
+	private ConnectionWithParties conns1 = new ConnectionWithParties(
 			Arrays.asList(con1, con2));
-	private ProtocolToPartyConnections conns1a = new ProtocolToPartyConnections(
+	private ConnectionWithParties conns1a = new ConnectionWithParties(
 			Arrays.asList(con1, con2));
-	private ProtocolToPartyConnections conns2 = new ProtocolToPartyConnections(
+	private ConnectionWithParties conns2 = new ConnectionWithParties(
 			Arrays.asList(con1, con3));
-	private ProtocolToPartyConnections conns3 = new ProtocolToPartyConnections(
+	private ConnectionWithParties conns3 = new ConnectionWithParties(
 			Arrays.asList(con2, con1));
-	private ProtocolToPartyConnections conns4 = new ProtocolToPartyConnections(
+	private ConnectionWithParties conns4 = new ConnectionWithParties(
 			Arrays.asList(con2, con1, con3));
-	private ProtocolToPartyConnections conns5 = new ProtocolToPartyConnections(
+	private ConnectionWithParties conns5 = new ConnectionWithParties(
 			Arrays.asList(con2, con1, con3, con1));
 
@@ -54,5 +54,5 @@
 
 	@Override
-	public List<List<ProtocolToPartyConnections>> getGeneralTestData() {
+	public List<List<ConnectionWithParties>> getGeneralTestData() {
 		return Arrays.asList(Arrays.asList(conns1, conns1a),
 				Arrays.asList(conns2), Arrays.asList(conns3),
@@ -98,5 +98,5 @@
 	@Test
 	public void withPartyTest() {
-		ProtocolToPartyConnections conns = conns3.with(con3);
+		ConnectionWithParties conns = conns3.with(con3);
 		assertEquals(2, conns3.size());
 		assertEquals(3, conns.size());
Index: protocol/src/test/java/geniusweb/protocol/session/DefaultSessionStateTest.java
===================================================================
--- protocol/src/test/java/geniusweb/protocol/session/DefaultSessionStateTest.java	(revision 1)
+++ protocol/src/test/java/geniusweb/protocol/session/DefaultSessionStateTest.java	(revision 1)
@@ -0,0 +1,137 @@
+package geniusweb.protocol.session;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import geniusweb.actions.Action;
+import geniusweb.actions.EndNegotiation;
+import geniusweb.actions.PartyId;
+import geniusweb.deadline.DeadlineTime;
+import geniusweb.issuevalue.Bid;
+import geniusweb.progress.Progress;
+import geniusweb.progress.ProgressTime;
+import geniusweb.protocol.ProtocolException;
+import geniusweb.protocol.partyconnection.ConnectionWithParties;
+import geniusweb.protocol.session.DefaultSessionState;
+import geniusweb.protocol.session.SessionSettings;
+import geniusweb.protocol.session.saop.SAOPSettings;
+import geniusweb.references.PartyRef;
+import geniusweb.references.PartyWithProfile;
+import geniusweb.references.ProfileRef;
+import tudelft.utilities.junit.GeneralTests;
+
+public class DefaultSessionStateTest extends GeneralTests<DefaultSessionState> {
+	private final ObjectMapper jackson = new ObjectMapper();
+	private DefaultSessionState1 state1, state1a, stateA, stateE, stateF;
+	private String state1string = "{\"DefaultSessionState1\":{\"actions\":[],\"progress\":{\"time\":{\"duration\":1000,\"start\":1000}},\"settings\":{\"SAOPSettings\":{\"participants\":[{\"party\":\"party1\",\"profile\":\"profile1\"},{\"party\":\"party2\",\"profile\":\"profile2\"}],\"deadline\":{\"deadlinetime\":{\"durationms\":1000}}}},\"error\":null,\"partyprofiles\":{\"party1\":{\"party\":\"party1\",\"profile\":\"profile1\"}}}}";
+	private ProgressTime progr;
+	private final Date start = new Date(1000l);
+
+	@Before
+	public void before() throws URISyntaxException {
+		List<Action> actions = new LinkedList<>();
+		PartyId party1 = new PartyId("party1");
+		actions.add(new EndNegotiation(party1));
+		ConnectionWithParties conns = new ConnectionWithParties(
+				Collections.EMPTY_LIST);
+		DeadlineTime deadline = new DeadlineTime(1000);
+		progr = new ProgressTime(deadline.getDuration(), start);
+		PartyRef party1ref = new PartyRef("party1");
+		ProfileRef profile1 = new ProfileRef("profile1");
+		PartyRef party2ref = new PartyRef("party2");
+		ProfileRef profile2 = new ProfileRef("profile2");
+		List<PartyWithProfile> participants = Arrays.asList(
+				new PartyWithProfile(party1ref, profile1),
+				new PartyWithProfile(party2ref, profile2));
+		SessionSettings settings = new SAOPSettings(participants, deadline);
+		ProtocolException e = new ProtocolException("test protocol error",
+				party1.getName());
+		HashMap<PartyId, PartyWithProfile> partyprofiles = new HashMap<PartyId, PartyWithProfile>();
+		partyprofiles.put(party1, new PartyWithProfile(party1ref, profile1));
+		state1 = new DefaultSessionState1(Collections.EMPTY_LIST, null, progr,
+				settings, partyprofiles, null);
+		state1a = new DefaultSessionState1(Collections.EMPTY_LIST, null, progr,
+				settings, partyprofiles, null);
+
+		stateA = new DefaultSessionState1(actions, conns, progr, settings,
+				partyprofiles, null);
+
+		stateE = new DefaultSessionState1(Collections.EMPTY_LIST, conns, progr,
+				settings, partyprofiles, e);
+		stateF = new DefaultSessionState1(Collections.EMPTY_LIST, conns, progr,
+				settings, null, e);
+
+	}
+
+	@Override
+	public List<List<DefaultSessionState>> getGeneralTestData() {
+
+		return Arrays.asList(Arrays.asList(state1, state1a),
+				Arrays.asList(stateA), Arrays.asList(stateE),
+				Arrays.asList(stateF));
+	}
+
+	@Override
+	public List<String> getGeneralTestStrings() {
+		return Arrays.asList(
+				"DefaultSessionState1.*\\[\\].*ProgressTime.*1000ms.*SAOPSettings.*party1.*party2.*,null]",
+				"DefaultSessionState1.*\\[.*EndNegotiation.*party1.*\\].*,.*,ProgressTime.*1000ms.*SAOPSettings.*party1.*party2.*,null]",
+				"DefaultSessionState1.*\\[\\],.*,ProgressTime.*1000ms.*,SAOPSettings.*party1.*party2.*,.*ProtocolException: party1:test protocol error.*",
+				"DefaultSessionState1.*\\[\\],.*,ProgressTime.*1000ms.*,SAOPSettings.*party1.*party2.*,.*ProtocolException: party1:test protocol error.*");
+	}
+
+	@Test
+	public void serializeTest() throws JsonProcessingException {
+		System.out.println(jackson.writeValueAsString(state1));
+		assertEquals(state1string, jackson.writeValueAsString(state1));
+	}
+
+	@Test
+	public void deserializeTest() throws IOException {
+		// note, we don't use DefaultSessionState because we can't add the
+		// annotation nor tell jackson dynamically about the test class.
+		DefaultSessionState state = jackson.readValue(state1string,
+				DefaultSessionState1.class);
+		// compare fields, as sessionended is a derived/new inner class
+		assertEquals(progr, state.getProgress());
+	}
+}
+
+/**
+ * We need to implement a few things because we can not instantiate an abstract
+ * class.
+ */
+class DefaultSessionState1 extends DefaultSessionState {
+
+	private DefaultSessionState1() {
+		super();
+	}
+
+	public DefaultSessionState1(List<Action> actions,
+			ConnectionWithParties conns, Progress progr,
+			SessionSettings settings,
+			Map<PartyId, PartyWithProfile> partyprofiles, ProtocolException e) {
+		super(actions, conns, progr, settings, partyprofiles, e);
+	}
+
+	@Override
+	public Bid getAgreement() {
+		return null;
+	}
+
+}
Index: protocol/src/test/java/geniusweb/protocol/session/SessionResultTest.java
===================================================================
--- protocol/src/test/java/geniusweb/protocol/session/SessionResultTest.java	(revision 52)
+++ protocol/src/test/java/geniusweb/protocol/session/SessionResultTest.java	(revision 1)
@@ -7,5 +7,4 @@
 import java.util.Arrays;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -17,12 +16,9 @@
 import com.fasterxml.jackson.databind.ObjectMapper;
 
-import geniusweb.actions.PartyId;
-import geniusweb.inform.Agreements;
 import geniusweb.issuevalue.Bid;
 import geniusweb.issuevalue.DiscreteValue;
 import geniusweb.issuevalue.Value;
-import geniusweb.references.Parameters;
+import geniusweb.protocol.SessionResult;
 import geniusweb.references.PartyRef;
-import geniusweb.references.PartyWithParameters;
 import geniusweb.references.PartyWithProfile;
 import geniusweb.references.ProfileRef;
@@ -34,39 +30,27 @@
 
 	private final String ISSUE1 = "issue1";
+	// private final String errorstring =
+	// "\"error\":{\"java.lang.RuntimeException\":{\"cause\":null,\"stackTrace\":[{\"methodName\":\"<init>\",\"fileName\":\"SessionResultTest.java\",\"lineNumber\":29,\"className\":\"events.SessionResultTest\",\"nativeMethod\":false},{\"methodName\":\"newInstance0\",\"fileName\":\"NativeConstructorAccessorImpl.java\",\"lineNumber\":-2,\"className\":\"sun.reflect.NativeConstructorAccessorImpl\",\"nativeMethod\":true},{\"methodName\":\"newInstance\",\"fileName\":\"NativeConstructorAccessorImpl.java\",\"lineNumber\":62,\"className\":\"sun.reflect.NativeConstructorAccessorImpl\",\"nativeMethod\":false},{\"methodName\":\"newInstance\",\"fileName\":\"DelegatingConstructorAccessorImpl.java\",\"lineNumber\":45,\"className\":\"sun.reflect.DelegatingConstructorAccessorImpl\",\"nativeMethod\":false},{\"methodName\":\"newInstance\",\"fileName\":\"Constructor.java\",\"lineNumber\":423,\"className\":\"java.lang.reflect.Constructor\",\"nativeMethod\":false},{\"methodName\":\"createTest\",\"fileName\":\"BlockJUnit4ClassRunner.java\",\"lineNumber\":217,\"className\":\"org.junit.runners.BlockJUnit4ClassRunner\",\"nativeMethod\":false},{\"methodName\":\"runReflectiveCall\",\"fileName\":\"BlockJUnit4ClassRunner.java\",\"lineNumber\":266,\"className\":\"org.junit.runners.BlockJUnit4ClassRunner$1\",\"nativeMethod\":false},{\"methodName\":\"run\",\"fileName\":\"ReflectiveCallable.java\",\"lineNumber\":12,\"className\":\"org.junit.internal.runners.model.ReflectiveCallable\",\"nativeMethod\":false},{\"methodName\":\"methodBlock\",\"fileName\":\"BlockJUnit4ClassRunner.java\",\"lineNumber\":263,\"className\":\"org.junit.runners.BlockJUnit4ClassRunner\",\"nativeMethod\":false},{\"methodName\":\"runChild\",\"fileName\":\"BlockJUnit4ClassRunner.java\",\"lineNumber\":78,\"className\":\"org.junit.runners.BlockJUnit4ClassRunner\",\"nativeMethod\":false},{\"methodName\":\"runChild\",\"fileName\":\"BlockJUnit4ClassRunner.java\",\"lineNumber\":57,\"className\":\"org.junit.runners.BlockJUnit4ClassRunner\",\"nativeMethod\":false},{\"methodName\":\"run\",\"fileName\":\"ParentRunner.java\",\"lineNumber\":290,\"className\":\"org.junit.runners.ParentRunner$3\",\"nativeMethod\":false},{\"methodName\":\"schedule\",\"fileName\":\"ParentRunner.java\",\"lineNumber\":71,\"className\":\"org.junit.runners.ParentRunner$1\",\"nativeMethod\":false},{\"methodName\":\"runChildren\",\"fileName\":\"ParentRunner.java\",\"lineNumber\":288,\"className\":\"org.junit.runners.ParentRunner\",\"nativeMethod\":false},{\"methodName\":\"access$000\",\"fileName\":\"ParentRunner.java\",\"lineNumber\":58,\"className\":\"org.junit.runners.ParentRunner\",\"nativeMethod\":false},{\"methodName\":\"evaluate\",\"fileName\":\"ParentRunner.java\",\"lineNumber\":268,\"className\":\"org.junit.runners.ParentRunner$2\",\"nativeMethod\":false},{\"methodName\":\"run\",\"fileName\":\"ParentRunner.java\",\"lineNumber\":363,\"className\":\"org.junit.runners.ParentRunner\",\"nativeMethod\":false},{\"methodName\":\"run\",\"fileName\":\"JUnit4TestReference.java\",\"lineNumber\":86,\"className\":\"org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference\",\"nativeMethod\":false},{\"methodName\":\"run\",\"fileName\":\"TestExecution.java\",\"lineNumber\":38,\"className\":\"org.eclipse.jdt.internal.junit.runner.TestExecution\",\"nativeMethod\":false},{\"methodName\":\"runTests\",\"fileName\":\"RemoteTestRunner.java\",\"lineNumber\":538,\"className\":\"org.eclipse.jdt.internal.junit.runner.RemoteTestRunner\",\"nativeMethod\":false},{\"methodName\":\"runTests\",\"fileName\":\"RemoteTestRunner.java\",\"lineNumber\":760,\"className\":\"org.eclipse.jdt.internal.junit.runner.RemoteTestRunner\",\"nativeMethod\":false},{\"methodName\":\"run\",\"fileName\":\"RemoteTestRunner.java\",\"lineNumber\":460,\"className\":\"org.eclipse.jdt.internal.junit.runner.RemoteTestRunner\",\"nativeMethod\":false},{\"methodName\":\"main\",\"fileName\":\"RemoteTestRunner.java\",\"lineNumber\":206,\"className\":\"org.eclipse.jdt.internal.junit.runner.RemoteTestRunner\",\"nativeMethod\":false}],\"message\":\"test\",\"localizedMessage\":\"test\",\"suppressed\":[]}}";
 	private SessionResult result1, result1a, result2, result3, result4;
-	private String jsonstring = "{\"participants\":{\"party2\":{\"party\":{\"partyref\":\"party2\",\"parameters\":{}},\"profile\":\"profile2\"},\"party1\":{\"party\":{\"partyref\":\"party1\",\"parameters\":{}},\"profile\":\"profile1\"}},\"agreements\":{\"party2\":{\"issuevalues\":{\"issue1\":\"a\"}},\"party1\":{\"issuevalues\":{\"issue1\":\"a\"}}},\"penalties\":{\"party2\":0.0,\"party1\":0.0},\"error\":null}";
-	private Map<PartyId, Double> nopenalties = new HashMap<>();
-	private Map<PartyId, Double> penalties = new HashMap<>();
-
-	private PartyId PARTY1 = new PartyId("party1");
-	private PartyId PARTY2 = new PartyId("party2");
-	private PartyId PARTY3 = new PartyId("party3");
+	private String errorstring; // created dynamically: eclipse and maven
+								// generate different stacktrace.
+	private String jsonstring;
 
 	@Before
 	public void before() throws URISyntaxException, JsonProcessingException {
-		penalties.put(PARTY1, 0.1d);
-		penalties.put(PARTY2, 0.2d);
-		nopenalties.put(PARTY1, 0d);
-		nopenalties.put(PARTY2, 0d);
+		errorstring = "\"error\":{\"java.lang.RuntimeException\":"
+				+ jackson.writeValueAsString(error) + "}";
+		System.out.println(errorstring);
+		jsonstring = "{\"participants\":[{\"party\":\"party1\",\"profile\":\"profile1\"},{\"party\":\"party2\",\"profile\":\"profile2\"}],\"agreement\":{\"issuevalues\":{\"issue1\":\"a\"}},"
+				+ errorstring + "}";
 
-		String errorstring = "\"error\":{\"java.lang.RuntimeException\":"
-				+ jackson.writeValueAsString(error) + "}";
-		// System.out.println(errorstring);
-
-		PartyWithParameters party1 = new PartyWithParameters(
-				new PartyRef("party1"), new Parameters());
-		PartyWithParameters party2 = new PartyWithParameters(
-				new PartyRef("party2"), new Parameters());
-
-		PartyWithProfile partyprofile1 = new PartyWithProfile(party1,
-				new ProfileRef("profile1"));
-		PartyWithProfile partyprofile2 = new PartyWithProfile(party2,
-				new ProfileRef("profile2"));
+		PartyWithProfile partyprofile1 = new PartyWithProfile(
+				new PartyRef("party1"), new ProfileRef("profile1"));
+		PartyWithProfile partyprofile2 = new PartyWithProfile(
+				new PartyRef("party2"), new ProfileRef("profile2"));
 
 		Map<String, Value> issuevalues1 = new HashMap<>();
 		issuevalues1.put(ISSUE1, new DiscreteValue("a"));
 		Bid bid1 = new Bid(issuevalues1);
-		Agreements agreement1 = new Agreements().with(new Agreements(bid1,
-				new HashSet<>(Arrays.asList(PARTY1, PARTY2))));
 
 		// different order but that shouldn't matter
@@ -74,24 +58,15 @@
 		issuevalues2.put(ISSUE1, new DiscreteValue("b"));
 		Bid bid2 = new Bid(issuevalues2);
-		Agreements agreement2 = new Agreements().with(new Agreements(bid2,
-				new HashSet<>(Arrays.asList(PARTY1, PARTY3))));
 
-		Map<PartyId, PartyWithProfile> partiesmap = new HashMap<>();
-		partiesmap.put(PARTY1, partyprofile1);
-		partiesmap.put(PARTY2, partyprofile2);
-
-		Map<PartyId, PartyWithProfile> partiesmap2 = new HashMap<>();
-		partiesmap2.put(PARTY1, partyprofile2);
-		partiesmap2.put(PARTY3, partyprofile1);
-
-		result1 = new SessionResult(partiesmap, agreement1, nopenalties, null);
-		result1a = new SessionResult(partiesmap, agreement1, nopenalties, null);
-		result2 = new SessionResult(partiesmap, agreement2, nopenalties, null);
-		result3 = new SessionResult(partiesmap2, agreement1, nopenalties, null);
-		result4 = new SessionResult(partiesmap2, agreement1, penalties, null);
-
-		// IGNORE ERROR for now, it fails somewhere deep in maven suddenly.
-		// result4 = new SessionResult(Arrays.asList(partyprofile1,
-		// partyprofile2), bid1, error);
+		result1 = new SessionResult(Arrays.asList(partyprofile1, partyprofile2),
+				bid1, error);
+		result1a = new SessionResult(
+				Arrays.asList(partyprofile1, partyprofile2), bid1, error);
+		result2 = new SessionResult(Arrays.asList(partyprofile1, partyprofile2),
+				bid2, error);
+		result3 = new SessionResult(Arrays.asList(partyprofile2, partyprofile1),
+				bid2, error);
+		result4 = new SessionResult(Arrays.asList(partyprofile1, partyprofile2),
+				bid1, null);
 	}
 
@@ -106,10 +81,8 @@
 	public List<String> getGeneralTestStrings() {
 		return Arrays.asList(
-				"SessionResult.*party2.*profile2.*,.*party1.*profile1.*Agreements.*Bid.*issue1=\"a\".*0\\.0.*0\\.0.*null.*",
-				"SessionResult.*party2.*profile2.*,.*party1.*profile1.*Agreements.*Bid.*issue1=\"b\".*0\\.0.*0\\.0.*null.*",
-				"SessionResult.*party1.*profile2.*,.*party3.*profile1.*Agreements.*Bid.*issue1=\"a\".*0\\.0.*0\\.0.*null.*",
-				"SessionResult.*party1.*profile2.*,.*party3.*profile1.*Agreements.*Bid.*issue1=\"a\".*party2.*0\\.2.*party1.*0\\.1.*null.*"
-
-		);
+				"SessionResult.*party1.*profile1.*,.*party2.*profile2.*Bid.*issue1=\"a\".*java.lang.RuntimeException.*test.*",
+				"SessionResult.*party1.*profile1.*,.*party2.*profile2.*Bid.*issue1=\"b\".*java.lang.RuntimeException.*test.*",
+				"SessionResult.*party2.*profile2.*,.*party1.*profile1.*Bid.*issue1=\"b\".*java.lang.RuntimeException.*test.*",
+				"SessionResult.*party1.*profile1.*,.*party2.*profile2.*Bid.*issue1=\"a\".*null.*");
 	}
 
Index: protocol/src/test/java/geniusweb/protocol/session/TeamInfoTest.java
===================================================================
--- protocol/src/test/java/geniusweb/protocol/session/TeamInfoTest.java	(revision 52)
+++ 	(revision )
@@ -1,73 +1,0 @@
-package geniusweb.protocol.session;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import geniusweb.references.Parameters;
-import geniusweb.references.PartyRef;
-import geniusweb.references.PartyWithParameters;
-import geniusweb.references.ProfileRef;
-import tudelft.utilities.junit.GeneralTests;
-
-public class TeamInfoTest extends GeneralTests<TeamInfo> {
-
-	private TeamInfo team1 = new TeamInfo(Collections.emptyList());
-	private TeamInfo team1a = new TeamInfo(Collections.emptyList());
-	private PartyRef partyref;
-	private Parameters parameters = new Parameters();;
-	private ProfileRef profileref;
-	private TeamInfo team2, team2a;
-	private String asString1 = "{\"TeamInfo\":{\"parties\":[{\"party\":{\"partyref\":\"party1\",\"parameters\":{}},\"profile\":\"profile1\"}]}}";
-
-	@Before
-	public void before() throws URISyntaxException {
-		partyref = new PartyRef("party1");
-		profileref = new ProfileRef("profile1");
-		team2 = new TeamInfo(new PartyWithParameters(partyref, parameters),
-				profileref);
-		team2a = new TeamInfo(new PartyWithParameters(partyref, parameters),
-				profileref);
-
-	}
-
-	@Override
-	public List<List<TeamInfo>> getGeneralTestData() {
-		return Arrays.asList(Arrays.asList(team1, team1a),
-				Arrays.asList(team2, team2a));
-	}
-
-	@Override
-	public List<String> getGeneralTestStrings() {
-		return Arrays.asList("TeamInfo.\\[\\].",
-				"TeamInfo.\\[PartyWithProfile.*party1.*profile1.*\\].*");
-	}
-
-	@Test
-	public void testSerialize() throws JsonProcessingException {
-
-		ObjectMapper jackson = new ObjectMapper();
-		System.out.println(jackson.writeValueAsString(team2));
-		assertEquals(asString1, jackson.writeValueAsString(team2));
-
-	}
-
-	@Test
-	public void testDeserialize() throws IOException {
-
-		ObjectMapper jackson = new ObjectMapper();
-		TeamInfo read = jackson.readValue(asString1, TeamInfo.class);
-		assertEquals(team2, read);
-	}
-
-}
Index: protocol/src/test/java/geniusweb/protocol/session/saop/SAOPSettingsTest.java
===================================================================
--- protocol/src/test/java/geniusweb/protocol/session/saop/SAOPSettingsTest.java	(revision 52)
+++ protocol/src/test/java/geniusweb/protocol/session/saop/SAOPSettingsTest.java	(revision 1)
@@ -20,8 +20,7 @@
 import geniusweb.deadline.DeadlineTime;
 import geniusweb.protocol.session.SessionSettings;
-import geniusweb.protocol.session.TeamInfo;
-import geniusweb.references.Parameters;
+import geniusweb.protocol.session.saop.SAOPSettings;
 import geniusweb.references.PartyRef;
-import geniusweb.references.PartyWithParameters;
+import geniusweb.references.PartyWithProfile;
 import geniusweb.references.ProfileRef;
 import tudelft.utilities.junit.GeneralTests;
@@ -30,11 +29,11 @@
 public class SAOPSettingsTest extends GeneralTests<SAOPSettings> {
 
-	private TeamInfo partyprof1 = mock(TeamInfo.class);
-	private TeamInfo partyprof2 = mock(TeamInfo.class);
-	private TeamInfo partyprof3 = mock(TeamInfo.class);
-	private List<TeamInfo> participants2 = Arrays.asList(partyprof1,
+	private PartyWithProfile partyprof1 = mock(PartyWithProfile.class);
+	private PartyWithProfile partyprof2 = mock(PartyWithProfile.class);
+	private PartyWithProfile partyprof3 = mock(PartyWithProfile.class);
+	private List<PartyWithProfile> participants2 = Arrays.asList(partyprof1,
 			partyprof2);
-	private List<TeamInfo> participants3 = Arrays.asList(partyprof1, partyprof2,
-			partyprof3);
+	private List<PartyWithProfile> participants3 = Arrays.asList(partyprof1,
+			partyprof2, partyprof3);
 
 	private DeadlineTime deadline = mock(DeadlineTime.class);
@@ -47,5 +46,5 @@
 
 	private SAOPSettings sersettings;
-	private final String serialized = "{\"SAOPSettings\":{\"participants\":[{\"TeamInfo\":{\"parties\":[{\"party\":{\"partyref\":\"http://party1\",\"parameters\":{}},\"profile\":\"http://profile1\"}]}},{\"TeamInfo\":{\"parties\":[{\"party\":{\"partyref\":\"http://party2\",\"parameters\":{}},\"profile\":\"http://profile2\"}]}}],\"deadline\":{\"DeadlineTime\":{\"durationms\":100}}}}";
+	private final String serialized = "{\"SAOPSettings\":{\"participants\":[{\"party\":\"http://party1\",\"profile\":\"http://profile1\"},{\"party\":\"http://party2\",\"profile\":\"http://profile2\"}],\"deadline\":{\"deadlinetime\":{\"durationms\":100}}}}";
 
 	@Before
@@ -55,8 +54,4 @@
 		when(deadline2.toString()).thenReturn("deadline2");
 
-		when(partyprof1.getSize()).thenReturn(1);
-		when(partyprof2.getSize()).thenReturn(1);
-		when(partyprof3.getSize()).thenReturn(1);
-
 		when(partyprof1.toString()).thenReturn("party and profile 1");
 		when(partyprof2.toString()).thenReturn("party and profile 2");
@@ -65,13 +60,13 @@
 		// SERIALIZABLE version with REAL objects. Still no workaround for
 		// this...
-		PartyWithParameters party1 = new PartyWithParameters(
-				new PartyRef("http://party1"), new Parameters());
+		PartyRef party1 = new PartyRef("http://party1");
 		ProfileRef profile1 = new ProfileRef("http://profile1");
-		PartyWithParameters party2 = new PartyWithParameters(
-				new PartyRef("http://party2"), new Parameters());
+		PartyRef party2 = new PartyRef("http://party2");
 		ProfileRef profile2 = new ProfileRef("http://profile2");
-		TeamInfo partywithprof1 = new TeamInfo(party1, profile1);
-		TeamInfo partywithprof2 = new TeamInfo(party2, profile2);
-		List<TeamInfo> participants = Arrays.asList(partywithprof1,
+		PartyWithProfile partywithprof1 = new PartyWithProfile(party1,
+				profile1);
+		PartyWithProfile partywithprof2 = new PartyWithProfile(party2,
+				profile2);
+		List<PartyWithProfile> participants = Arrays.asList(partywithprof1,
 				partywithprof2);
 
@@ -143,5 +138,5 @@
 		SAOPSettings saop = new SAOPSettings(participants2, deadline);
 		SessionSettings saop2 = saop.with(partyprof3);
-		assertEquals(3, saop2.getTeams().size());
+		assertEquals(3, saop2.getParticipants().size());
 	}
 
Index: protocol/src/test/java/geniusweb/protocol/session/saop/SAOPStateTest.java
===================================================================
--- protocol/src/test/java/geniusweb/protocol/session/saop/SAOPStateTest.java	(revision 52)
+++ protocol/src/test/java/geniusweb/protocol/session/saop/SAOPStateTest.java	(revision 1)
@@ -9,6 +9,4 @@
 import static org.mockito.Mockito.when;
 
-import java.io.IOException;
-import java.net.URISyntaxException;
 import java.util.Arrays;
 import java.util.Date;
@@ -18,7 +16,4 @@
 import org.junit.Before;
 import org.junit.Test;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
 
 import geniusweb.actions.Accept;
@@ -27,19 +22,12 @@
 import geniusweb.actions.Offer;
 import geniusweb.actions.PartyId;
-import geniusweb.deadline.Deadline;
-import geniusweb.deadline.DeadlineTime;
 import geniusweb.issuevalue.Bid;
 import geniusweb.progress.Progress;
 import geniusweb.progress.ProgressRounds;
 import geniusweb.progress.ProgressTime;
-import geniusweb.protocol.NegoState;
 import geniusweb.protocol.ProtocolException;
-import geniusweb.protocol.partyconnection.ProtocolToPartyConn;
-import geniusweb.protocol.session.TeamInfo;
-import geniusweb.references.Parameters;
-import geniusweb.references.PartyRef;
-import geniusweb.references.PartyWithParameters;
-import geniusweb.references.PartyWithProfile;
-import geniusweb.references.ProfileRef;
+import geniusweb.protocol.partyconnection.ConnectionWithParties;
+import geniusweb.protocol.partyconnection.ConnectionWithParty;
+import geniusweb.protocol.session.SessionSettings;
 import tudelft.utilities.junit.GeneralTests;
 
@@ -50,21 +38,24 @@
 	private PartyId party2 = new PartyId("party2");
 	private PartyId party3 = new PartyId("party3");
-	private List<Action> actions1 = new LinkedList<>();
+	private List<Action> actions = new LinkedList<>();
 	private Action action = mock(Action.class);
 	private List<Action> actions2 = Arrays.asList(action);
 
-	private ProtocolToPartyConn party1conn = mock(ProtocolToPartyConn.class);
-	private ProtocolToPartyConn party2conn = mock(ProtocolToPartyConn.class);
-	private ProtocolToPartyConn party3conn = mock(ProtocolToPartyConn.class);
-
-	private List<PartyId> connections = Arrays.asList(party1, party2);
-	private List<PartyId> connections2 = Arrays.asList(party1, party3);
-	private List<PartyId> connections3 = Arrays.asList(party1, party2, party3);
+	private ConnectionWithParty party1conn = mock(ConnectionWithParty.class);
+	private ConnectionWithParty party2conn = mock(ConnectionWithParty.class);
+	private ConnectionWithParty party3conn = mock(ConnectionWithParty.class);
+
+	private ConnectionWithParties connections = new ConnectionWithParties(
+			Arrays.asList(party1conn, party2conn));
+	private ConnectionWithParties connections2 = new ConnectionWithParties(
+			Arrays.asList(party1conn, party3conn));
+	private ConnectionWithParties connections3 = new ConnectionWithParties(
+			Arrays.asList(party1conn, party2conn, party3conn));
 
 	private Progress progresstime = mock(ProgressTime.class);
 	private ProgressRounds progressrounds = mock(ProgressRounds.class);
 	private ProgressRounds progressrounds1 = mock(ProgressRounds.class);
-	private SAOPSettings settings = mock(SAOPSettings.class);
-	private SAOPState state, state1, state1a, state2, state3, state4;
+	private SessionSettings settings = mock(SAOPSettings.class);
+	private SAOPState state1, state1a, state2, state3, state4;
 
 	private Bid bid1 = mock(Bid.class);
@@ -76,10 +67,6 @@
 	private EndNegotiation endNegotiation1 = new EndNegotiation(party1);
 
-	private final ObjectMapper jackson = new ObjectMapper();
-
-	private String serialized = "{\"SAOPState\":{\"actions\":[],\"connections\":[\"party1\",\"party2\"],\"progress\":{\"ProgressTime\":{\"duration\":1000000,\"start\":2000000}},\"settings\":{\"SAOPSettings\":{\"participants\":[{\"TeamInfo\":{\"parties\":[{\"party\":{\"partyref\":\"party1ref\",\"parameters\":{}},\"profile\":\"prof1\"}]}}],\"deadline\":{\"DeadlineTime\":{\"durationms\":123000}}}},\"partyprofiles\":{},\"error\":null}}";
-
 	@Before
-	public void before() throws URISyntaxException {
+	public void before() {
 		when(party1conn.getParty()).thenReturn(party1);
 		when(party2conn.getParty()).thenReturn(party2);
@@ -96,26 +83,14 @@
 		when(progressrounds.advance()).thenReturn(progressrounds1);
 
-		state1 = new SAOPState(actions1, connections, progresstime, settings,
-				null, null);
-		state1a = new SAOPState(actions1, connections, progresstime, settings,
+		state1 = new SAOPState(actions, connections, progresstime, settings,
+				null, null);
+		state1a = new SAOPState(actions, connections, progresstime, settings,
 				null, null);
 		state2 = new SAOPState(actions2, connections, progresstime, settings,
 				null, null);
-		state3 = new SAOPState(actions1, connections2, progresstime, settings,
-				null, null);
-		state4 = new SAOPState(actions1, connections, progressrounds, settings,
-				null, null);
-
-		List<PartyId> conns = Arrays.asList(party1, party2);
-		PartyWithParameters pwithp = new PartyWithParameters(
-				new PartyRef("party1ref"), new Parameters());
-		List<PartyWithProfile> teams = Arrays
-				.asList(new PartyWithProfile(pwithp, new ProfileRef("prof1")));
-		List<TeamInfo> participants = Arrays.asList(new TeamInfo(teams));
-		Deadline deadline = new DeadlineTime(123000);
-		SAOPSettings setts = new SAOPSettings(participants, deadline);
-		state = new SAOPState(actions1, conns,
-				new ProgressTime(1000000l, new Date(2000000l)), setts, null,
-				null);
+		state3 = new SAOPState(actions, connections2, progresstime, settings,
+				null, null);
+		state4 = new SAOPState(actions, connections, progressrounds, settings,
+				null, null);
 
 	}
@@ -131,19 +106,19 @@
 	public List<String> getGeneralTestStrings() {
 		return Arrays.asList(
-				"SAOPState.*\\[\\].*party1.*party2.*ProgressTime.*",
-				"SAOPState.*\\[act1\\].*party1.*party2.*ProgressTime.*",
-				"SAOPState.*party1.*party3.*ProgressTime.*",
-				"SAOPState.*party1.*party2.*ProgressRounds.*");
+				"SAOPState.*\\[\\].*ConnectionWithParties.*conn1.*conn2.*ProgressTime.*",
+				"SAOPState.*\\[act1\\].*ConnectionWithParties.*conn1.*conn2.*ProgressTime.*",
+				"SAOPState.*ConnectionWithParties.*conn1.*conn3.*ProgressTime.*",
+				"SAOPState.*ConnectionWithParties.*conn1.*conn2.*ProgressRounds.*");
 	}
 
 	@Test
 	public void constructWith0Connection() {
-		new SAOPState(actions1, Arrays.asList(), progresstime, settings, null,
-				null);
+		new SAOPState(actions, new ConnectionWithParties(Arrays.asList()),
+				progresstime, settings, null, null);
 	}
 
 	@Test
 	public void constructWithNullConnection() {
-		SAOPState state = new SAOPState(actions1, null, progresstime, settings,
+		SAOPState state = new SAOPState(actions, null, progresstime, settings,
 				null, null);
 		assertEquals(0, state.getConnections().size());
@@ -157,6 +132,7 @@
 	@Test
 	public void testNextActor2() {
-		List<PartyId> conns = Arrays.asList(party2, party3);
-		SAOPState state = new SAOPState(actions1, conns, progresstime, settings,
+		ConnectionWithParties conns = new ConnectionWithParties(
+				Arrays.asList(party2conn, party3conn));
+		SAOPState state = new SAOPState(actions, conns, progresstime, settings,
 				null, null);
 		assertEquals(party2, state.getNextActor());
@@ -182,5 +158,5 @@
 	public void isFinalTest() {
 		assertFalse(state1.isFinal(NOW));
-		SAOPState state = new SAOPState(actions1, connections, progresstime,
+		SAOPState state = new SAOPState(actions, connections, progresstime,
 				settings, null, mock(ProtocolException.class));
 		assertTrue(state.isFinal(NOW));
@@ -200,5 +176,5 @@
 		SAOPState state = new SAOPState(actions, connections3, progressrounds,
 				settings, null, null);
-		assertTrue(state.getAgreements().getMap().isEmpty());
+		assertNull(state.getAgreement());
 	}
 
@@ -208,5 +184,5 @@
 		SAOPState state = new SAOPState(actions, connections3, progressrounds,
 				settings, null, null);
-		assertTrue(state.getAgreements().getMap().isEmpty());
+		assertNull(state.getAgreement());
 	}
 
@@ -216,5 +192,5 @@
 		SAOPState state = new SAOPState(actions, connections3, progressrounds,
 				settings, null, null);
-		assertTrue(state.getAgreements().getMap().isEmpty());
+		assertNull(state.getAgreement());
 	}
 
@@ -224,5 +200,5 @@
 		SAOPState state = new SAOPState(actions, connections3, progressrounds,
 				settings, null, null);
-		assertEquals(bid1, state.getAgreements().getMap().get(party1));
+		assertEquals(bid1, state.getAgreement());
 		assertTrue(state.isFinal(NOW));
 	}
@@ -233,5 +209,5 @@
 		SAOPState state = new SAOPState(actions, connections3, progressrounds,
 				settings, null, null);
-		assertTrue(state.getAgreements().getMap().isEmpty());
+		assertEquals(null, state.getAgreement());
 	}
 
@@ -241,16 +217,30 @@
 		SAOPState state = new SAOPState(actions, connections3, progressrounds,
 				settings, null, null);
-		assertTrue(state.getAgreements().getMap().isEmpty());
-	}
-
-	@Test(expected = IllegalArgumentException.class)
+		assertEquals(null, state.getAgreement());
+	}
+
+	@Test
+	public void withWrongActionTest() {
+		// wrong because action has actor null which does not match party1
+		SAOPState state = state1.with(party1, action);
+		assertEquals(1, state.getActions().size());
+		assertEquals(action, state.getActions().get(0));
+		assertTrue(state.isFinal(NOW));
+		assertEquals(
+				"geniusweb.protocol.ProtocolException: party1:act contains wrong credentials: act1",
+				state.getError().toString());
+	}
+
+	@Test
 	public void withActionTest() {
 		when(action.getActor()).thenReturn(party1);
-		state1.with(party1, action);
+		SAOPState state = state1.with(party1, action);
+		assertEquals(1, state.getActions().size());
+		assertEquals(action, state.getActions().get(0));
 	}
 
 	@Test
 	public void withConnectionTest() {
-		SAOPState state = state1.with(party3, (PartyWithProfile) null);
+		SAOPState state = state1.with(party3conn, null);
 		assertEquals(3, state.getConnections().size());
 	}
@@ -261,5 +251,5 @@
 		SAOPState state = new SAOPState(actions, connections3, progressrounds,
 				settings, null, null);
-		assertTrue(state.getAgreements().getMap().isEmpty());
+		assertEquals(null, state.getAgreement());
 		assertEquals(null, state.getError());
 		assertTrue(state.isFinal(NOW));
@@ -269,18 +259,21 @@
 	@Test
 	public void isProtocolErrorFinal() {
-		SAOPState state = new SAOPState(actions1, connections3, progressrounds,
-				settings, null,
-				new ProtocolException("test error", new PartyId("test")));
+		SAOPState state = new SAOPState(actions, connections3, progressrounds,
+				settings, null, new ProtocolException("test error", "test"));
 		assertTrue(state.isFinal(NOW));
 		assertNotNull(state.getError());
 	}
 
-	@Test(expected = IllegalArgumentException.class)
+	@Test
 	public void RefuseImmediateAccept() {
 		Accept nullaccept = new Accept(party1, null);
-		state1.with(party1, nullaccept);
-	}
-
-	@Test(expected = IllegalArgumentException.class)
+		SAOPState state = state1.with(party1, nullaccept);
+		assertTrue(state.isFinal(NOW));
+		assertEquals(
+				"geniusweb.protocol.ProtocolException: party1:Accept without a recent offer",
+				state.getError().toString());
+	}
+
+	@Test
 	public void RefuseNotMyTurn() {
 		List<Action> actions = Arrays.asList(offer1);
@@ -288,8 +281,12 @@
 				settings, null, null);
 
-		state.with(party1, offer1);
-	}
-
-	@Test(expected = IllegalArgumentException.class)
+		state = state.with(party1, offer1);
+		assertTrue(state.isFinal(NOW));
+		assertEquals(
+				"geniusweb.protocol.ProtocolException: party1:actor does not have the turn ",
+				state.getError().toString());
+	}
+
+	@Test
 	public void RefuseNullAccept() {
 		List<Action> actions = Arrays.asList(offer1);
@@ -300,7 +297,9 @@
 		state = state.with(party2, nullaccept);
 		assertTrue(state.isFinal(NOW));
-	}
-
-	@Test(expected = IllegalArgumentException.class)
+		assertTrue(state.getError().toString()
+				.matches(".*party2.*Accepts a bid that was not offered.*"));
+	}
+
+	@Test
 	public void RefuseNullAction() {
 		List<Action> actions = Arrays.asList(offer1);
@@ -308,5 +307,8 @@
 				settings, null, null);
 
-		state = state.with(party2, (Action) null);
+		state = state.with(party2, null);
+		assertEquals(
+				"geniusweb.protocol.ProtocolException: party2:action is null",
+				state.getError().toString());
 	}
 
@@ -321,5 +323,5 @@
 		assertTrue(state.isFinal(NOW));
 		assertNull(state.getError());
-		assertEquals(bid1, state.getAgreements().getMap().get(party1));
+		assertEquals(bid1, state.getAgreement());
 
 	}
@@ -337,23 +339,6 @@
 		assertTrue(state.isFinal(NOW));
 		assertNull(state.getError());
-		assertEquals(bid2, state.getAgreements().getMap().get(party1));
-
-	}
-
-	@Test
-	public void testDeserialize() throws IOException {
-		NegoState obj = jackson.readValue(serialized, NegoState.class);
-		System.out.println(obj);
-		assertEquals(state, obj);
-	}
-
-	@Test
-	public void testSerialize()
-			throws JsonProcessingException, URISyntaxException {
-
-		String string = jackson.writeValueAsString(state);
-		System.out.println(string);
-		assertEquals(serialized, string);
-	}
-
+		assertEquals(bid2, state.getAgreement());
+
+	}
 }
Index: protocol/src/test/java/geniusweb/protocol/session/saop/SAOPTest.java
===================================================================
--- protocol/src/test/java/geniusweb/protocol/session/saop/SAOPTest.java	(revision 52)
+++ protocol/src/test/java/geniusweb/protocol/session/saop/SAOPTest.java	(revision 1)
@@ -3,8 +3,7 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyLong;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.ArgumentMatchers.isA;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
@@ -17,5 +16,4 @@
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
@@ -23,9 +21,9 @@
 import java.util.Map;
 
-import org.junit.Before;
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 
 import geniusweb.actions.Accept;
+import geniusweb.actions.Action;
 import geniusweb.actions.EndNegotiation;
 import geniusweb.actions.Offer;
@@ -35,18 +33,17 @@
 import geniusweb.events.CurrentState;
 import geniusweb.events.ProtocolEvent;
-import geniusweb.inform.ActionDone;
-import geniusweb.inform.Agreements;
-import geniusweb.inform.Finished;
-import geniusweb.inform.Settings;
-import geniusweb.inform.YourTurn;
+import geniusweb.party.inform.Finished;
+import geniusweb.party.inform.Inform;
+import geniusweb.party.inform.Settings;
+import geniusweb.party.inform.YourTurn;
 import geniusweb.progress.Progress;
 import geniusweb.protocol.ProtocolException;
-import geniusweb.protocol.partyconnection.ProtocolToPartyConn;
-import geniusweb.protocol.partyconnection.ProtocolToPartyConnFactory;
-import geniusweb.protocol.partyconnection.ProtocolToPartyConnections;
-import geniusweb.protocol.session.TeamInfo;
-import geniusweb.references.Parameters;
+import geniusweb.protocol.partyconnection.ConnectionWithParties;
+import geniusweb.protocol.partyconnection.ConnectionWithParty;
+import geniusweb.protocol.partyconnection.ConnectionWithPartyFactory;
+import geniusweb.protocol.session.saop.SAOP;
+import geniusweb.protocol.session.saop.SAOPSettings;
+import geniusweb.protocol.session.saop.SAOPState;
 import geniusweb.references.PartyRef;
-import geniusweb.references.PartyWithParameters;
 import geniusweb.references.PartyWithProfile;
 import geniusweb.references.ProfileRef;
@@ -66,5 +63,4 @@
  */
 public class SAOPTest {
-
 	private final SAOPState state = mock(SAOPState.class),
 			connectedstate = mock(SAOPState.class),
@@ -72,6 +68,5 @@
 			finalstate = mock(SAOPState.class);
 
-	private static final long DEADLINE = 1000l;
-	private ProtocolRef SAOPPROTOCOL;
+	private final ProtocolRef SAOP;
 	private static final PartyId PARTY2ID = new PartyId("party2");
 	private static final PartyId PARTY1ID = new PartyId("party1");
@@ -79,65 +74,44 @@
 	private final PartyRef party2ref = mock(PartyRef.class);
 	private final SAOPSettings settings = mock(SAOPSettings.class);
-	private final TeamInfo team1 = mock(TeamInfo.class);
-	private final TeamInfo team2 = mock(TeamInfo.class);
+	private final PartyWithProfile party1 = mock(PartyWithProfile.class);
+	private final PartyWithProfile party2 = mock(PartyWithProfile.class);
 	private SAOP saop;
-	private ProtocolToPartyConnFactory factory;
-	private List<ProtocolToPartyConn> connections;
-	private ProtocolToPartyConn conn1 = mock(ProtocolToPartyConn.class),
-			conn2 = mock(ProtocolToPartyConn.class);
-	private Map<PartyId, TeamInfo> partyprofiles;
+	private ConnectionWithPartyFactory factory;
+	private List connections;
+	private ConnectionWithParty conn1 = mock(ConnectionWithParty.class),
+			conn2 = mock(ConnectionWithParty.class);
+	private Map<PartyId, PartyWithProfile> partyprofiles;
 	private Progress progress = mock(Progress.class);
 	private ProfileRef profile1;
 	private ProfileRef profile2;
-	private ProtocolToPartyConnections connectionswithparties;// = new
-																// ProtocolTmock(
-																// ProtocolToPartyConnections.class);;
+	private ConnectionWithParties connectionswithparties = mock(
+			ConnectionWithParties.class);;
 	@SuppressWarnings("unchecked")
 	private final Listener<ProtocolEvent> testlistener = mock(Listener.class);
-	private final Parameters parameters = new Parameters();
-
-//	private final long NOW = 1000;
-	private final PartyWithParameters partywithparam1 = new PartyWithParameters(
-			party1ref, parameters);
-	private final PartyWithParameters partywithparam2 = new PartyWithParameters(
-			party2ref, parameters);
+
+	private final long NOW = 1000;
 
 	private final Deadline deadlinetime = mock(DeadlineTime.class);
 
-	private Map<PartyId, PartyWithProfile> pwpmap;
-
-	@Before
-	public void before()
+	public SAOPTest()
 			throws URISyntaxException, IOException, NoResourcesNowException {
-		SAOPPROTOCOL = new ProtocolRef("SAOP");
-
-		profile1 = mock(ProfileRef.class);
-		profile2 = mock(ProfileRef.class);
-
-		PartyWithProfile pwp1 = new PartyWithProfile(partywithparam1, profile1);
-		PartyWithProfile pwp2 = new PartyWithProfile(partywithparam2, profile2);
-		when(team1.getParties()).thenReturn(Arrays.asList(pwp1));
-		when(team2.getParties()).thenReturn(Arrays.asList(pwp2));
+		SAOP = new ProtocolRef("SAOP");
+		when(party1.getParty()).thenReturn(party1ref);
+		when(party2.getParty()).thenReturn(party2ref);
 
 		partyprofiles = new HashMap<>();
-		partyprofiles.put(PARTY1ID, team1);
-		partyprofiles.put(PARTY2ID, team2);
-
-		pwpmap = new HashMap<>();
-		pwpmap.put(PARTY1ID, pwp1);
-		pwpmap.put(PARTY2ID, pwp2);
-
-		when(deadlinetime.getDuration()).thenReturn(DEADLINE);
-
-		List<TeamInfo> teams = new ArrayList<>();
-		teams.add(team1);
-		teams.add(team2);
-		when(settings.getTeams()).thenReturn(teams);
-		when(settings.getAllParties()).thenReturn(Arrays.asList(pwp1, pwp2));
+		partyprofiles.put(PARTY1ID, party1);
+		partyprofiles.put(PARTY2ID, party2);
+
+		when(deadlinetime.getDuration()).thenReturn(1000l);
+
+		List<PartyWithProfile> participants = new ArrayList<>();
+		participants.add(party1);
+		participants.add(party2);
+		when(settings.getParticipants()).thenReturn(participants);
 		when(settings.getDeadline()).thenReturn(deadlinetime);
 
-		factory = mock(ProtocolToPartyConnFactory.class);
-		// connections = mock(List.class);
-		connections = Arrays.asList(conn1, conn2);
+		factory = mock(ConnectionWithPartyFactory.class);
+		connections = mock(List.class);
 		when(factory.connect(any(List.class))).thenReturn(connections);
 
@@ -147,30 +121,25 @@
 		when(conn2.getParty()).thenReturn(PARTY2ID);
 
-		mockState(connectedstate, "connected state", true);
-		mockState(state, "running state", true);
-		mockState(finalstate, "final state", true);
+		profile1 = mock(ProfileRef.class);
+		when(party1.getProfile()).thenReturn(profile1);
+		profile2 = mock(ProfileRef.class);
+		when(party2.getProfile()).thenReturn(profile2);
+
+		mockState(connectedstate, "connected state");
+		mockState(state, "initial state");
+		mockState(finalstate, "final state");
 		when(finalstate.isFinal(anyLong())).thenReturn(true);
-		mockState(failstate, "fail state", true);
+		mockState(failstate, "fail state");
 		when(failstate.isFinal(anyLong())).thenReturn(true);
 
-		connectionswithparties = new ProtocolToPartyConnections(
-				Arrays.asList(conn1, conn2));
-
-//		when(connectionswithparties.get(eq(PARTY1ID))).thenReturn(conn1);
-//		when(connectionswithparties.get(eq(PARTY2ID))).thenReturn(conn2);
+		when(connectionswithparties.get(eq(PARTY1ID))).thenReturn(conn1);
+		when(connectionswithparties.get(eq(PARTY2ID))).thenReturn(conn2);
 		// HACK thenReturn twice, so that 2nd call to iterator() returns new
 		// iterator instead of the old one
-//		when(connectionswithparties.iterator())
-//				.thenReturn(Arrays.asList(conn1, conn2).iterator())
-//				.thenReturn(Arrays.asList(conn1, conn2).iterator());
-		Map<PartyId, PartyWithProfile> profilesmap = new HashMap<>();
-		profilesmap.put(PARTY1ID, pwp1);
-		profilesmap.put(PARTY2ID, pwp2);
-		when(state.getPartyProfiles()).thenReturn(profilesmap);
-
-		saop = new SAOP(state, new ReportToLogger("test"),
-				connectionswithparties);
+		when(connectionswithparties.iterator())
+				.thenReturn(Arrays.asList(conn1, conn2).iterator())
+				.thenReturn(Arrays.asList(conn1, conn2).iterator());
+		saop = new SAOP(state, new ReportToLogger("test"));
 		saop.addListener(testlistener);
-
 	}
 
@@ -179,20 +148,13 @@
 	 * 
 	 * @param state  the state to mock (must be already
-	 * @param asText short name for the state, for debugging
-	 * @param bool   true if parties are connected
+	 * @param asText
 	 */
-	private void mockState(SAOPState state, String asText,
-			boolean isConnected) {
+	private void mockState(SAOPState state, String asText) {
 		when(state.getSettings()).thenReturn(settings);
-		if (isConnected) {
-			when(state.getConnections())
-					.thenReturn(Arrays.asList(PARTY1ID, PARTY2ID));
-		} else {
-			when(state.getConnections()).thenReturn(Collections.emptyList());
-		}
-
+		when(state.getConnections()).thenReturn(connectionswithparties);
+		when(state.getPartyProfiles()).thenReturn(partyprofiles);
 		when(state.getProgress()).thenReturn(progress);
-		when(state.with(any(PartyId.class), any(PartyWithProfile.class)))
-				.thenReturn(connectedstate);
+		when(state.with(any(ConnectionWithParty.class),
+				any(PartyWithProfile.class))).thenReturn(connectedstate);
 		when(state.getNextActor()).thenReturn(PARTY1ID);
 		when(state.with(any(PartyId.class), any(EndNegotiation.class)))
@@ -203,6 +165,4 @@
 		when(state.toString()).thenReturn(asText);
 		when(state.with(any(ProtocolException.class))).thenReturn(failstate);
-		when(state.getAgreements()).thenReturn(mock(Agreements.class));
-		when(state.getPartyProfiles()).thenReturn(pwpmap);
 	}
 
@@ -215,5 +175,5 @@
 		when(set.getDeadline()).thenReturn(dl);
 		when(dl.getDuration()).thenReturn(1000l);
-		new SAOP(state1, new ReportToLogger("test"), connectionswithparties);
+		new SAOP(state1, new ReportToLogger("test"));
 		verify(state1, times(0)).with(any(ProtocolException.class));
 		verify(testlistener, times(0)).notifyChange(any(CurrentState.class));
@@ -272,11 +232,11 @@
 				.forClass(Settings.class);
 		verify(conn1).send(actualsettings.capture());
-		assertEquals(new Settings(PARTY1ID, profile1, SAOPPROTOCOL, progress,
-				parameters), actualsettings.getValue());
+		assertEquals(new Settings(PARTY1ID, profile1, SAOP, progress),
+				actualsettings.getValue());
 
 		verify(conn2, times(1)).send(any(Settings.class));
 		verify(conn2).send(actualsettings.capture());
-		assertEquals(new Settings(PARTY2ID, profile2, SAOPPROTOCOL, progress,
-				parameters), actualsettings.getValue());
+		assertEquals(new Settings(PARTY2ID, profile2, SAOP, progress),
+				actualsettings.getValue());
 		verify(state, times(0)).with(any(ProtocolException.class));
 		verify(testlistener, times(0)).notifyChange(any(CurrentState.class));
@@ -286,4 +246,5 @@
 	@Test
 	public void testActionRequestWrongActor() {
+
 		saop.actionRequest(conn2, mock(EndNegotiation.class));
 
@@ -293,7 +254,23 @@
 
 	@Test
-	public void testActionRequest() throws IOException, ProtocolException {
-		saop.nextTurn();
-
+	public void testActionRequest() throws IOException {
+		when(state.getNextActor()).thenReturn(PARTY1ID);
+		when(state.with(any(PartyId.class), any(Action.class)))
+				.thenReturn(state);
+
+		saop.actionRequest(conn1, mock(EndNegotiation.class));
+
+		verify(state, times(0)).with(any(ProtocolException.class));
+		verify(state, times(1)).with(eq(PARTY1ID), any(EndNegotiation.class));
+		verify(connectionswithparties, times(1)).broadcast(any(Inform.class));
+
+		// state.getNextActor() is frozen to PARTY1 by our mocking
+		verify(conn1, times(1)).send(any(YourTurn.class));
+		verify(conn2, times(0)).send(any(YourTurn.class));
+		verify(testlistener, times(0)).notifyChange(any(CurrentState.class));
+	}
+
+	@Test
+	public void testFinalActionRequest() throws IOException {
 		when(state.getNextActor()).thenReturn(PARTY1ID);
 		when(state.with(any(PartyId.class), any(EndNegotiation.class)))
@@ -303,35 +280,10 @@
 
 		verify(state, times(0)).with(any(ProtocolException.class));
-		verify(state, times(1)).with(eq(PARTY1ID), isA((EndNegotiation.class)));
-		// verify broadcast
-		verify(conn1, times(1)).send(isA(ActionDone.class));
-		verify(conn2, times(1)).send(isA(ActionDone.class));
-
-		// state.getNextActor() is frozen to PARTY1 by our mocking
-		verify(conn1, times(1)).send(isA(YourTurn.class));
-		verify(conn2, times(0)).send(isA(YourTurn.class));
-		// listener should be informed about final state.
+		verify(state, times(1)).with(eq(PARTY1ID), any(EndNegotiation.class));
+		verify(connectionswithparties, times(1)).broadcast(any(Finished.class));
 		verify(testlistener, times(1)).notifyChange(any(CurrentState.class));
-	}
-
-	@Test
-	public void testFinalActionRequest() throws IOException, ProtocolException {
-		when(state.getNextActor()).thenReturn(PARTY1ID);
-		when(state.with(any(PartyId.class), any(EndNegotiation.class)))
-				.thenReturn(finalstate);
-		// when(finalstate.getAgreements()).thenReturn(mock(Agreements.class));
-
-		saop.nextTurn(); // ensure we send YourTurn to party1.
-		saop.actionRequest(conn1, mock(EndNegotiation.class));
-
-		verify(state, times(0)).with(any(ProtocolException.class));
-		verify(state, times(1)).with(eq(PARTY1ID), any(EndNegotiation.class));
-		// verify broadcast
-		verify(conn1, times(1)).send(isA(Finished.class));
-		verify(conn2, times(1)).send(isA(Finished.class));
-		verify(testlistener, times(1)).notifyChange(any(CurrentState.class));
-
-		verify(conn1, times(1)).send(isA(YourTurn.class));
-		verify(conn2, times(0)).send(isA(YourTurn.class));
+
+		verify(conn1, times(1)).send(any(YourTurn.class));
+		verify(conn2, times(1)).send(any(YourTurn.class));
 	}
 
@@ -345,7 +297,5 @@
 		doThrow(new IOException("fail sending yourturn")).when(conn1)
 				.send(any(YourTurn.class));
-		// CHECK is the state really final after an exception?
-		when(state.with(any(ProtocolException.class))).thenReturn(finalstate);
-		// when(state.getAgreements()).thenReturn(mock(Agreements.class));
+
 		saop.actionRequest(conn1, mock(Accept.class));
 
@@ -358,5 +308,4 @@
 		doThrow(new IOException("fail sending yourturn")).when(conn1)
 				.send(any(YourTurn.class));
-		// when(failstate.getAgreements()).thenReturn(mock(Agreements.class));
 		// not turn of conn2.
 		saop.actionRequest(conn2, mock(EndNegotiation.class));
@@ -368,7 +317,5 @@
 	@Test
 	public void testActionInFinalState() throws IOException {
-		saop = new SAOP(finalstate, new ReportToLogger("test"),
-				connectionswithparties);
-		// when(finalstate.getAgreements()).thenReturn(mock(Agreements.class));
+		saop = new SAOP(finalstate, new ReportToLogger("test"));
 
 		saop.actionRequest(conn1, mock(Offer.class));
@@ -387,20 +334,3 @@
 		saop.addParticipant(null);
 	}
-
-	@Test
-	public void testDeadlineTimer() throws InterruptedException, IOException {
-		SAOPState unconnectedstate = mock(SAOPState.class);
-		mockState(unconnectedstate, "unconnected state", false);
-		SAOP saopempty = new SAOP(unconnectedstate, new ReportToLogger("test"),
-				new ProtocolToPartyConnections(Collections.emptyList()));
-		saopempty.addListener(testlistener);
-
-		saopempty.start(factory);
-		verify(testlistener, times(0)).notifyChange(any(CurrentState.class));
-		verify(conn1, times(1)).send(isA(YourTurn.class));
-		Thread.sleep(DEADLINE + SAOP.TIME_MARGIN + 100);
-		verify(testlistener, times(1)).notifyChange(any(CurrentState.class));
-		verify(conn1, times(1)).send(isA(Finished.class));
-	}
-
 }
Index: protocol/src/test/java/geniusweb/protocol/session/saop/SaopPartyWithProfileTest.java
===================================================================
--- protocol/src/test/java/geniusweb/protocol/session/saop/SaopPartyWithProfileTest.java	(revision 52)
+++ 	(revision )
@@ -1,107 +1,0 @@
-package geniusweb.protocol.session.saop;
-
-import static org.junit.Assert.assertEquals;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import geniusweb.protocol.session.TeamInfo;
-import geniusweb.references.Parameters;
-import geniusweb.references.PartyRef;
-import geniusweb.references.PartyWithParameters;
-import geniusweb.references.ProfileRef;
-import tudelft.utilities.junit.GeneralTests;
-
-public class SaopPartyWithProfileTest extends GeneralTests<TeamInfo> {
-
-	private PartyRef party1, party1a, party2, party3;
-	private ProfileRef profile1, profile2;
-	private TeamInfo partyprof1, partyprof1a, partyprof2, partyprof3,
-			partyprof4;
-	private final String serialized = "{\"TeamInfo\":{\"parties\":[{\"party\":{\"partyref\":\"ws:party1\",\"parameters\":{}},\"profile\":\"ws:profile1\"}]}}";
-
-	@Before
-	public void before() throws URISyntaxException {
-		party1 = new PartyRef(new URI("ws:party1"));
-		party1a = new PartyRef(new URI("ws:party1"));
-		party2 = new PartyRef(new URI("ws:party2"));
-		party3 = new PartyRef(new URI("http:party3"));
-
-		profile1 = new ProfileRef(new URI("ws:profile1"));
-		profile2 = new ProfileRef(new URI("ws:profile2"));
-
-		Parameters settings1 = new Parameters();
-		Parameters settings2 = new Parameters().with("a", 1);
-
-		PartyWithParameters party1withparams1 = new PartyWithParameters(party1,
-				settings1);
-		PartyWithParameters party1withparams2 = new PartyWithParameters(party1,
-				settings2);
-		PartyWithParameters party2withparams1 = new PartyWithParameters(party2,
-				settings1);
-
-		partyprof1 = new TeamInfo(party1withparams1, profile1);
-		partyprof1a = new TeamInfo(party1withparams1, profile1);
-		partyprof2 = new TeamInfo(party2withparams1, profile1);
-		partyprof3 = new TeamInfo(party1withparams1, profile2);
-		partyprof4 = new TeamInfo(party1withparams2, profile1);
-
-	}
-
-	@Override
-	public List<List<TeamInfo>> getGeneralTestData() {
-		return Arrays.asList(Arrays.asList(partyprof1, partyprof1a),
-				Arrays.asList(partyprof2), Arrays.asList(partyprof3),
-				Arrays.asList(partyprof4));
-	}
-
-	@Override
-	public List<String> getGeneralTestStrings() {
-		return Arrays.asList(
-				"TeamInfo.*PartyWithProfile.PartyRef.ws:party1.,ProfileRef.ws:profile1.*",
-				"TeamInfo.*PartyWithProfile.PartyRef.ws:party2.,ProfileRef.ws:profile1.*",
-				"TeamInfo.*PartyWithProfile.PartyRef.ws:party1.,ProfileRef.ws:profile2.*",
-				"TeamInfo.*PartyWithProfile.PartyRef.ws:party1.\\{a=1\\},ProfileRef.ws:profile1.*");
-	}
-
-	@Test
-	public void smokeTest() throws URISyntaxException {
-	}
-
-	@Test(expected = IllegalArgumentException.class)
-	public void nullTest() throws URISyntaxException {
-		new TeamInfo((PartyWithParameters) null, (ProfileRef) null);
-	}
-
-	@Test
-	public void testSerialize() throws JsonProcessingException {
-		ObjectMapper jackson = new ObjectMapper();
-
-		String json = jackson.writeValueAsString(partyprof1);
-		System.out.println(json);
-		assertEquals(serialized, json);
-	}
-
-	@Test
-	public void testDeserialize()
-			throws JsonParseException, JsonMappingException, IOException {
-		ObjectMapper jackson = new ObjectMapper();
-		// always used as part of bigger class, do not include class name
-		// and therfore can not serialize as TeamOfPartiesAndProfiles
-		TeamInfo p = jackson.readValue(serialized, TeamInfo.class);
-		System.out.println(p);
-		assertEquals(partyprof1, p);
-	}
-
-}
Index: protocol/src/test/java/geniusweb/protocol/tournament/AllPermutationsProtocolTest.java
===================================================================
--- protocol/src/test/java/geniusweb/protocol/tournament/AllPermutationsProtocolTest.java	(revision 1)
+++ protocol/src/test/java/geniusweb/protocol/tournament/AllPermutationsProtocolTest.java	(revision 1)
@@ -0,0 +1,181 @@
+package geniusweb.protocol.tournament;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.math.BigInteger;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+
+import geniusweb.events.ProtocolEvent;
+import geniusweb.issuevalue.Bid;
+import geniusweb.protocol.CurrentNegoState;
+import geniusweb.protocol.NegoState;
+import geniusweb.protocol.SessionResult;
+import geniusweb.protocol.partyconnection.ConnectionWithPartyFactory;
+import geniusweb.protocol.session.SessionProtocol;
+import geniusweb.protocol.session.SessionSettings;
+import geniusweb.protocol.session.SessionState;
+import geniusweb.protocol.tournament.allpermutations.AllPermutationsProtocol;
+import geniusweb.protocol.tournament.allpermutations.AllPermutationsState;
+import geniusweb.references.PartyWithProfile;
+import geniusweb.references.ProtocolRef;
+import tudelft.utilities.listener.Listener;
+import tudelft.utilities.logging.ReportToLogger;
+
+public class AllPermutationsProtocolTest {
+
+	private final AllPermutationsState state = mock(AllPermutationsState.class),
+			newstate = mock(AllPermutationsState.class);
+	private final ReportToLogger log = new ReportToLogger("test");
+	private final AllPermutationsProtocol app = new AllPermutationsProtocol(
+			state, log);
+	private final ConnectionWithPartyFactory factory = mock(
+			ConnectionWithPartyFactory.class);
+	private final SessionSettings settings = mock(SessionSettings.class);
+	private final SessionState finalsessionstate = mock(SessionState.class);
+	private Bid agreement = mock(Bid.class);
+	private final long NOW = 1000;
+
+	@Before
+	public void before() {
+		when(state.getSize()).thenReturn(BigInteger.ZERO);
+		when(finalsessionstate.isFinal(anyLong())).thenReturn(true);
+		when(finalsessionstate.getSettings()).thenReturn(settings);
+		when(finalsessionstate.getAgreement()).thenReturn(agreement);
+		when(state.with(any())).thenReturn(newstate);
+	}
+
+	@Test
+	public void smokeTest() {
+	}
+
+	@Test
+	public void startTestNoSessions() {
+		AllPermutationsProtocol app = new AllPermutationsProtocol(state, log);
+		app.start(factory);
+
+	}
+
+	@Test
+	public void getDescrTest() {
+		assertNotNull(app.getDescription());
+	}
+
+	@Test
+	public void getStateTest() {
+		assertEquals(state, app.getState());
+	}
+
+	@Test
+	public void getRefTest() {
+		assertEquals("APP", app.getRef().getURI().toString());
+	}
+
+	@Test
+	public void runOneSessionTest() throws InterruptedException {
+		MockSessionProtocol sessionprotocol = startSession();
+		sessionprotocol.getListener();
+	}
+
+	@Test
+	public void runOneSessionAndUnhandledEvent() throws InterruptedException {
+		MockSessionProtocol sessionprotocol = startSession();
+		sessionprotocol.getListener().notifyChange(mock(ProtocolEvent.class));
+		verify(state, times(0)).with(any());
+	}
+
+	/**
+	 * Check that a started session correctly handles a session event.
+	 */
+	@Test
+	public void CurrentNegoStateEventTest() throws InterruptedException {
+		MockSessionProtocol sessionprotocol = startSession();
+
+		CurrentNegoState evt = mock(CurrentNegoState.class);
+		when(evt.getState()).thenReturn(finalsessionstate);
+		sessionprotocol.getListener().notifyChange(evt);
+
+		ArgumentCaptor<SessionResult> argument = ArgumentCaptor
+				.forClass(SessionResult.class);
+		verify(state, times(1)).with(argument.capture());
+		assertEquals(agreement, argument.getValue().getAgreement());
+		assertNull(argument.getValue().getError());
+	}
+
+	private MockSessionProtocol startSession() throws InterruptedException {
+		SessionSettings setting = mock(SessionSettings.class);
+		MockSessionProtocol sessionprotocol = new MockSessionProtocol();
+		when(setting.getProtocol(log)).thenReturn(sessionprotocol);
+		when(state.getNextSettings()).thenReturn(setting);
+
+		app.start(factory);
+		Thread.sleep(500); // allow app to start session
+		// this call should return fine, and have listener registered to our
+		// protocol. app now waits for a notification
+		return sessionprotocol;
+	}
+
+}
+
+/**
+ * 
+ * The protocol needs to record the listners, we need a listener to trigger
+ * further protocol actions. Mockito can't handle this, we mneed our own mock...
+ *
+ */
+class MockSessionProtocol implements SessionProtocol {
+	private final List<Listener<ProtocolEvent>> listeners = new LinkedList<>();
+
+	@Override
+	public void start(ConnectionWithPartyFactory connectionfactory) {
+
+	}
+
+	@Override
+	public String getDescription() {
+		return null;
+	}
+
+	@Override
+	public NegoState getState() {
+		return null;
+	}
+
+	@Override
+	public ProtocolRef getRef() {
+		return null;
+	}
+
+	@Override
+	public void addParticipant(PartyWithProfile party) {
+	}
+
+	@Override
+	public void addListener(Listener<ProtocolEvent> l) {
+		listeners.add(l);
+	}
+
+	@Override
+	public void removeListener(Listener<ProtocolEvent> l) {
+	}
+
+	public Listener<ProtocolEvent> getListener() {
+		if (listeners.size() != 1) {
+			throw new IllegalStateException("Not having exactly 1 listener");
+		}
+		return listeners.get(0);
+	}
+
+}
Index: protocol/src/test/java/geniusweb/protocol/tournament/AllPermutationsSettingsTest.java
===================================================================
--- protocol/src/test/java/geniusweb/protocol/tournament/AllPermutationsSettingsTest.java	(revision 1)
+++ protocol/src/test/java/geniusweb/protocol/tournament/AllPermutationsSettingsTest.java	(revision 1)
@@ -0,0 +1,173 @@
+package geniusweb.protocol.tournament;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.net.URISyntaxException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+import geniusweb.deadline.DeadlineTime;
+import geniusweb.protocol.session.saop.SAOPSettings;
+import geniusweb.protocol.tournament.TournamentSettings;
+import geniusweb.protocol.tournament.allpermutations.AllPermutationsSettings;
+import geniusweb.references.PartyRef;
+import geniusweb.references.ProfileRef;
+import tudelft.utilities.junit.GeneralTests;
+import tudelft.utilities.logging.ReportToLogger;
+
+public class AllPermutationsSettingsTest
+		extends GeneralTests<AllPermutationsSettings> {
+
+	private final ObjectMapper jackson = new ObjectMapper();
+
+	private final String serialized = "{\"AllPermutationsSettings\":{"
+			+ "\"parties\":[\"party1\",\"party2\"]," + "\"reuseParties\":false,"
+			+ "\"profiles\":[\"profile1\",\"profile2\",\"profile3\"],"
+			+ "\"partiesPerSession\":2,"
+			+ "\"sessionsettings\":{\"SAOPSettings\":{\"participants\":[],\"deadline\":{\"deadlinetime\":{\"durationms\":10000}}}}}}";
+
+	private AllPermutationsSettings settings, settings1a, settings2, settings3,
+			settings4;
+
+	private SAOPSettings saopsettings;
+
+	private ProfileRef profile1, profile2, profile3;
+
+	private List<PartyRef> parties;
+
+	@Before
+	public void before() throws URISyntaxException {
+		PartyRef partyref1 = new PartyRef("party1");
+		PartyRef partyref2 = new PartyRef("party2");
+		PartyRef partyref3 = new PartyRef("party3");
+
+		parties = Arrays.asList(partyref1, partyref2);
+		DeadlineTime deadline = new DeadlineTime(10000);
+
+		saopsettings = new SAOPSettings(Collections.emptyList(), deadline);
+
+		profile1 = new ProfileRef("profile1");
+		profile2 = new ProfileRef("profile2");
+		profile3 = new ProfileRef("profile3");
+
+		List<ProfileRef> profiles = Arrays.asList(profile1, profile2, profile3);
+
+		settings = new AllPermutationsSettings(parties, false, profiles, 2,
+				saopsettings);
+
+		settings1a = new AllPermutationsSettings(parties, false, profiles, 2,
+				saopsettings);
+
+		settings2 = new AllPermutationsSettings(
+				Arrays.asList(partyref1, partyref2, partyref3), false, profiles,
+				2, saopsettings);
+
+		settings3 = new AllPermutationsSettings(parties, true, profiles, 2,
+				saopsettings);
+
+		settings4 = new AllPermutationsSettings(parties, false,
+				Arrays.asList(profile1, profile2, profile3, profile1), 2,
+				saopsettings);
+
+	}
+
+	@Override
+	public List<List<AllPermutationsSettings>> getGeneralTestData() {
+		return Arrays.asList(Arrays.asList(settings, settings1a),
+				Arrays.asList(settings2), Arrays.asList(settings3),
+				Arrays.asList(settings4));
+	}
+
+	@Override
+	public List<String> getGeneralTestStrings() {
+		return Arrays.asList(
+				"AllPermutationsSettings.*party1.*party2.*,false,.*profile1.*profile2.*profile3.*,2,SAOPSettings.*",
+				"AllPermutationsSettings.*party1.*party2.*party3.*,false,.*profile1.*profile2.*profile3.*,2,SAOPSettings.*",
+				"AllPermutationsSettings.*party1.*party2.*,true,.*profile1.*profile2.*profile3.*,2,SAOPSettings.*",
+				"AllPermutationsSettings.*party1.*party2.*,false,.*profile1.*profile2.*profile3.*profile1.*,2,SAOPSettings.*");
+	}
+
+	@Test
+	public void getProtocolTest() {
+		assertEquals("APP", settings.getProtocol(new ReportToLogger("test"))
+				.getRef().getURI().toString());
+	}
+
+	@Test
+	public void testDeserialize() throws IOException {
+		TournamentSettings obj = jackson.readValue(serialized,
+				TournamentSettings.class);
+		System.out.println(obj);
+		assertEquals(settings, obj);
+	}
+
+	@Test
+	public void testSerialize()
+			throws JsonProcessingException, URISyntaxException {
+
+		String string = jackson.writeValueAsString(settings);
+		System.out.println(string);
+		assertEquals(serialized, string);
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testNullParties() {
+		new AllPermutationsSettings(null, true,
+				Arrays.asList(profile1, profile2, profile3, profile1), 2,
+				saopsettings);
+
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testNoParties() {
+		new AllPermutationsSettings(Collections.emptyList(), true,
+				Arrays.asList(profile1, profile2, profile3, profile1), 2,
+				saopsettings);
+
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testNullProfiles() {
+		new AllPermutationsSettings(parties, true, null, 2, saopsettings);
+
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testInsufficientProfiles() {
+		new AllPermutationsSettings(parties, true,
+				Arrays.asList(profile1, profile2, profile3, profile1), 4,
+				saopsettings);
+
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testNullSessionSettings() {
+		new AllPermutationsSettings(parties, true,
+				Arrays.asList(profile1, profile2, profile3, profile1), 4, null);
+
+	}
+
+	@Test(expected = IllegalArgumentException.class)
+	public void testOnePartyPerSession() {
+		new AllPermutationsSettings(parties, true,
+				Arrays.asList(profile1, profile2, profile3, profile1), 1,
+				saopsettings);
+
+	}
+
+	@Test
+	public void getMaxRuntimeTest() {
+		assertEquals(BigInteger.valueOf(6), settings.permutations().size());
+		assertEquals((Double) (6d * 12), settings.getMaxRunTime());
+	}
+
+}
Index: protocol/src/test/java/geniusweb/protocol/tournament/AllPermutationsStateTest.java
===================================================================
--- protocol/src/test/java/geniusweb/protocol/tournament/AllPermutationsStateTest.java	(revision 1)
+++ protocol/src/test/java/geniusweb/protocol/tournament/AllPermutationsStateTest.java	(revision 1)
@@ -0,0 +1,96 @@
+package geniusweb.protocol.tournament;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+import geniusweb.protocol.SessionResult;
+import geniusweb.protocol.session.SessionSettings;
+import geniusweb.protocol.tournament.allpermutations.AllPermutationsSettings;
+import geniusweb.protocol.tournament.allpermutations.AllPermutationsState;
+import geniusweb.references.PartyWithProfile;
+import tudelft.utilities.immutablelist.ImmutableList;
+
+public class AllPermutationsStateTest {
+
+	private final AllPermutationsSettings toursettings = mock(
+			AllPermutationsSettings.class);;
+	@SuppressWarnings("unchecked")
+	private final List<SessionResult> results = mock(List.class);
+	@SuppressWarnings("unchecked")
+	private final ImmutableList<SessionSettings> settings = mock(
+			ImmutableList.class);
+	private final AllPermutationsState state = new AllPermutationsState(
+			toursettings, settings, results);
+	private final SessionSettings session7settings = mock(
+			SessionSettings.class);
+	private final long NOW = 1000;
+
+	@SuppressWarnings("unchecked")
+	private final List<PartyWithProfile> participants = mock(List.class);
+
+	@Test
+	public void getResultsTest() {
+		assertEquals(results, state.getResults());
+	}
+
+	@Test
+	public void isFinalTestFalse() {
+		when(settings.size()).thenReturn(BigInteger.TEN);
+		when(results.size()).thenReturn(11);
+		assertFalse(state.isFinal(NOW));
+	}
+
+	@Test
+	public void isFinalTestTrue() {
+		when(settings.size()).thenReturn(BigInteger.TEN);
+		when(results.size()).thenReturn(10);
+		assertTrue(state.isFinal(NOW));
+	}
+
+	@Test
+	public void getNextSetting() {
+		prepareNextSettings();
+		assertEquals(session7settings, state.getNextSettings());
+	}
+
+	private void prepareNextSettings() {
+		when(results.size()).thenReturn(7); // result 0..6
+		when(settings.size()).thenReturn(BigInteger.TEN);
+		when(session7settings.getParticipants()).thenReturn(participants);
+		when(settings.get(BigInteger.valueOf(7))).thenReturn(session7settings);
+
+	}
+
+	@Test
+	public void withTest() {
+		prepareNextSettings();
+		ArrayList<SessionResult> results1 = new ArrayList<>();
+		for (int n = 0; n < 7; n++) {
+			results1.add(mock(SessionResult.class));
+		}
+		// use state with "real" results... to allow array copy in with
+		AllPermutationsState state = new AllPermutationsState(toursettings,
+				settings, results1);
+
+		when(settings.size()).thenReturn(BigInteger.TEN);
+		when(settings.get(BigInteger.valueOf(7))).thenReturn(session7settings);
+
+		SessionResult result = mock(SessionResult.class);
+		when(result.getParticipants()).thenReturn(participants);
+		AllPermutationsState state1 = state.with(result);
+
+		assertEquals(null, state1.getError());
+		assertEquals(8, state1.getResults().size());
+		assertEquals(toursettings, state1.getSettings());
+
+	}
+}
Index: protocol/src/test/java/geniusweb/protocol/tournament/TeamTest.java
===================================================================
--- protocol/src/test/java/geniusweb/protocol/tournament/TeamTest.java	(revision 52)
+++ 	(revision )
@@ -1,51 +1,0 @@
-package geniusweb.protocol.tournament;
-
-import static org.junit.Assert.assertEquals;
-
-import java.net.URISyntaxException;
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import geniusweb.references.Parameters;
-import geniusweb.references.PartyRef;
-import geniusweb.references.PartyWithParameters;
-import tudelft.utilities.junit.GeneralTests;
-
-public class TeamTest extends GeneralTests<Team> {
-
-	private Team team1, team1a, team2;
-	private PartyWithParameters pwithp1, pwithp2;
-
-	@Before
-	public void before() throws URISyntaxException {
-		PartyRef partyref1 = new PartyRef("party1");
-		PartyRef partyref2 = new PartyRef("party2");
-		Parameters params1 = new Parameters().with("a", 1);
-		pwithp1 = new PartyWithParameters(partyref1, params1);
-		pwithp2 = new PartyWithParameters(partyref2, params1);
-		team1 = new Team(Arrays.asList(pwithp1));
-		team1a = new Team(Arrays.asList(pwithp1));
-		team2 = new Team(Arrays.asList(pwithp2));
-	}
-
-	@Override
-	public List<List<Team>> getGeneralTestData() {
-		return Arrays.asList(Arrays.asList(team1, team1a),
-				Arrays.asList(team2));
-	}
-
-	@Override
-	public List<String> getGeneralTestStrings() {
-		return Arrays.asList(".PartyRef.party1..a=1..",
-				".PartyRef.party2..a=1..");
-	}
-
-	@Test
-	public void testGet() {
-		assertEquals(Arrays.asList(pwithp1), team1.getParties());
-	}
-
-}
