1 | package negotiator.parties;
|
---|
2 |
|
---|
3 | import static org.mockito.Mockito.mock;
|
---|
4 | import static org.mockito.Mockito.when;
|
---|
5 |
|
---|
6 | import java.io.IOException;
|
---|
7 | import java.net.URL;
|
---|
8 |
|
---|
9 | import org.junit.Test;
|
---|
10 |
|
---|
11 | import genius.core.AgentID;
|
---|
12 | import genius.core.Deadline;
|
---|
13 | import genius.core.exceptions.InstantiateException;
|
---|
14 | import genius.core.exceptions.NegotiatorException;
|
---|
15 | import genius.core.parties.NegotiationPartyInternal;
|
---|
16 | import genius.core.parties.SessionsInfo;
|
---|
17 | import genius.core.persistent.PersistentDataType;
|
---|
18 | import genius.core.repository.DomainRepItem;
|
---|
19 | import genius.core.repository.PartyRepItem;
|
---|
20 | import genius.core.repository.ProfileRepItem;
|
---|
21 | import genius.core.session.RepositoryException;
|
---|
22 | import genius.core.session.Session;
|
---|
23 | import genius.core.timeline.Timeline;
|
---|
24 |
|
---|
25 | public class NegotiationPartyInternalTest {
|
---|
26 | private static final String PARTY1_UTIL = "file:src/test/resources/partydomain/party1_utility.xml";
|
---|
27 | private static final String DOMAIN_REPO = "file:src/test/resources/partydomain/party_domain.xml";
|
---|
28 |
|
---|
29 | @Test
|
---|
30 | public void createParty() throws InstantiateException, RepositoryException, NegotiatorException, IOException {
|
---|
31 | PartyRepItem partyRepItem = new PartyRepItem("agents.nastyagent.NullBid");
|
---|
32 | DomainRepItem domain = new DomainRepItem(new URL(DOMAIN_REPO));
|
---|
33 | ProfileRepItem profileRepItem = new ProfileRepItem(
|
---|
34 | new URL(PARTY1_UTIL), domain);
|
---|
35 |
|
---|
36 | Session session = mock(Session.class);
|
---|
37 | Timeline timeline = mock(Timeline.class);
|
---|
38 | Deadline deadline = mock(Deadline.class);
|
---|
39 | when(session.getTimeline()).thenReturn(timeline);
|
---|
40 | when(session.getDeadlines()).thenReturn(deadline);
|
---|
41 | SessionsInfo info = new SessionsInfo(null, PersistentDataType.DISABLED, true);
|
---|
42 | new NegotiationPartyInternal(partyRepItem, profileRepItem, session, info, new AgentID("testname"), null);
|
---|
43 |
|
---|
44 | }
|
---|
45 |
|
---|
46 | @Test(expected = NullPointerException.class)
|
---|
47 | public void createPartyWithNullID()
|
---|
48 | throws InstantiateException, RepositoryException, NegotiatorException, IOException {
|
---|
49 | PartyRepItem partyRepItem = new PartyRepItem("agents.nastyagent.NullBid");
|
---|
50 | DomainRepItem domain = new DomainRepItem(new URL(DOMAIN_REPO));
|
---|
51 | ProfileRepItem profileRepItem = new ProfileRepItem(
|
---|
52 | new URL(PARTY1_UTIL), domain);
|
---|
53 |
|
---|
54 | Session session = mock(Session.class);
|
---|
55 | SessionsInfo info = new SessionsInfo(null, PersistentDataType.DISABLED, true);
|
---|
56 | new NegotiationPartyInternal(partyRepItem, profileRepItem, session, info, null, null);
|
---|
57 |
|
---|
58 | }
|
---|
59 |
|
---|
60 | }
|
---|