[1] | 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
|
---|
[78] | 30 | public void createParty() throws InstantiateException, RepositoryException,
|
---|
| 31 | NegotiatorException, IOException {
|
---|
| 32 | PartyRepItem partyRepItem = new PartyRepItem(
|
---|
| 33 | "agents.nastyagent.NullBid");
|
---|
[1] | 34 | DomainRepItem domain = new DomainRepItem(new URL(DOMAIN_REPO));
|
---|
[78] | 35 | ProfileRepItem profileRepItem = new ProfileRepItem(new URL(PARTY1_UTIL),
|
---|
| 36 | domain);
|
---|
[1] | 37 |
|
---|
| 38 | Session session = mock(Session.class);
|
---|
| 39 | Timeline timeline = mock(Timeline.class);
|
---|
| 40 | Deadline deadline = mock(Deadline.class);
|
---|
| 41 | when(session.getTimeline()).thenReturn(timeline);
|
---|
| 42 | when(session.getDeadlines()).thenReturn(deadline);
|
---|
[78] | 43 | SessionsInfo info = new SessionsInfo(null, PersistentDataType.DISABLED,
|
---|
| 44 | true);
|
---|
| 45 | new NegotiationPartyInternal(partyRepItem, profileRepItem, session,
|
---|
| 46 | info, new AgentID("testname"));
|
---|
[1] | 47 |
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | @Test(expected = NullPointerException.class)
|
---|
[78] | 51 | public void createPartyWithNullID() throws InstantiateException,
|
---|
| 52 | RepositoryException, NegotiatorException, IOException {
|
---|
| 53 | PartyRepItem partyRepItem = new PartyRepItem(
|
---|
| 54 | "agents.nastyagent.NullBid");
|
---|
[1] | 55 | DomainRepItem domain = new DomainRepItem(new URL(DOMAIN_REPO));
|
---|
[78] | 56 | ProfileRepItem profileRepItem = new ProfileRepItem(new URL(PARTY1_UTIL),
|
---|
| 57 | domain);
|
---|
[1] | 58 |
|
---|
| 59 | Session session = mock(Session.class);
|
---|
[78] | 60 | SessionsInfo info = new SessionsInfo(null, PersistentDataType.DISABLED,
|
---|
| 61 | true);
|
---|
| 62 | new NegotiationPartyInternal(partyRepItem, profileRepItem, session,
|
---|
| 63 | info, null);
|
---|
[1] | 64 |
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | }
|
---|